Ask Your Question

Revision history [back]

One way to obtain the desired graph would be to define a function real_log which would map x to log(x) if x is positive, and return "not a number" if x is not positive.

sage: nan = float(NaN)
sage: real_log = lambda x: log(x) if x > 0 else nan
sage: y = lambda x: abs(real_log(x))
sage: G = plot(y, (-5, 5))
verbose 0 (3763: plot.py, generate_plot_points) WARNING: When plotting, failed to evaluate function at 100 points.
verbose 0 (3763: plot.py, generate_plot_points) Last error message: 'Unable to compute f(-0.047921289673)'
sage: G.show(aspect_ratio=1, axes=True, gridlines=True, ymin=-1, ymax=6)
Launched png viewer for Graphics object consisting of 1 graphics primitive