On 11/17/06, Andrej Vodopivec <andrej.vodopivec at gmail.com> wrote:
> (%i1) f(x) := if x<=2 then x-3 else x^2;
> (%o1) f(x):=if x<=2 then x-3 else x^2
> (%i2) plot2d([[parametric,t,'(f(t)),[t,-1,2]],[parametric,t,'(f(t)),[t,2
> +0.000001,5]]],[x,-1,5]);
>
> The difference is the you quote f(t) in plot2d.
Agreed with Andrej here -- a couple of other solutions.
(1) Just put the name of the function in the plot expression
(i.e. don't indicate the argument). E.g.
f(x) := if x<=2 then x-3 else x^2;
plot2d ([[parametric, t, f, [t, -1, 2]], [parametric, t, f, [t, 2 +
0.000001, 5]]], [x, -1, 5]);
(2) Maxima 5.10.0 comes with an add-on package boolsimp which
implements unevaluated conditionals. This makes working with
functions defined piecewise more natural. E.g.
load (boolsimp);
f(x) := if x<=2 then x-3 else x^2;
plot2d ([[parametric, t, f(t), [t, -1, 2]], [parametric, t, f(t), [t,
2 + 0.000001, 5]]], [x, -1, 5]);
so your original plot2d expression works.
HTH
Robert Dodier