2 Graphs - 2 Intervals - 1 Window



On 12/13/06, Stavros Macrakis <macrakis at alum.mit.edu> wrote:

> If the function returns a symbol rather than a number, plot will not
> plot any points.  For example:
>
>      f(x):= if x<0 then sin(x) else if x>1 then cos(x) else 'foo;
>      plot2d('(f(x)),[x,-1,2]);

The current version of the plotting code will try hard to see
if there is something plottable where 'foo is returned.
So if x<0 then ... else 'foo; has the expected effect but it
takes a long time to get there.

f(x) := if x < 0 then sin(x) else if x>1 then cos(x);
plot2d ('(f(x)), [x, - 1, 2]);

i.e. no trailing else (equivalently, "... else false") yields the
same graph with many fewer function evaluations --
the false return value causes the plotter to give up sooner.

That is the behavior of Maxima 5.10; dunno what any previous
version does in this case -- the plotting code has been
evolving at a steady pace.

claudius at euteneuers.de wrote:

> I tested 0 instead of %i. => Same result.
> Maxima plots %i like 0. I tested
> > (%i1) Cos(x) := if x > -3 and x < 2 then cos(x)$
> but your're right: plot2d doesn't like it.

I'm pretty sure that is the behavior of Maxima before 5.10.
Claudius, you might consider updating your installation.
Maxima 5.11 will be released soon.

The plotting code is something of a mess from the
user's point of view, and it's really too bad about that.
There are proposals on the table for revising the
user-visible behavior of plot2d/plot3d; we might give that
stuff higher priority.

FWIW
Robert