[Maxima] Defining Functions in Maxima

Robert Dodier robert.dodier at gmail.com
Mon May 21 20:46:13 CDT 2012


On 2012-05-20, Barton Willis <willisb at unk.edu> wrote:

> Something like the following should work:
>
> (%i18) g(x) := (x : mod(x+1,2)-1,  if x < -1/4 then 2 else if x < 0 then -1 else if x < 1/4 then 1 else -2)$
>
> (%i19) wxplot2d('(g(x)),[x,-1,4]);

I'm happy to report that the following all yield the same picture:

(%i2) plot2d(g, [u, -1, 5]);
(%i3) plot2d(g(x), [x, -1, 5]);
(%i4) plot2d('(g(x)), [x, -1, 5]);
(%i5) plot2d('g(x), [x, -1, 5]);

with g defined above.

That is, the various ways of quoting or not quoting the function to be
plotted (each of which may seem more obvious to different people) all
have the same result.

That's using plot2d -- I don't know whether wxplot2d works the same (I
hope so).

best

Robert Dodier



More information about the Maxima mailing list