plotting piecewise functions



Let me point out one more thing: the following opens a can of worms!

> --- Plot2d quotes its first argument ---
> 
> It would be possible for plot2d to only evaluate the expression at the
> plotted x's (make it an mfexpr).  But then instead of:
> 
>    (C1) x^3-1$
>    (C2) plot2d(c1,[x,-1,1])$
>    (C3) plot2d([c1,diff(c1,x)],[x,-1,1])$
>    (C4) polarplot(expr,var):=
>  
> plot2d([parametric,expr*cos(var),expr*sin(var)],[var,0,2*%pi])$
> 
> you would have to do
> 
>    (C2) plot2d(''c1,[x,-1,1])$
>    (C3) plot2d(''([c1,diff(c1,x)]),[x,-1,1])$    /* Parentheses are
> needed */
>    (C4) polarplot(expr,var)::=                   /* Define as macro */
>           buildq([expr:expr,var:var],
>  
> '(plot2d([parametric,expr*cos(var),expr*sin(var)],[var,0,2*%pi]))
>             );
> 

Guess the output from Maxima:
(C1) sss:'(if x<0 then 0 else 1)$
(C2) plot2d(sss,[x,-1,1]);
(C3) sss(x):=sin(x);
(C4) plot2d(sss,[x,-1,1]);

So, what would (D4) be? (Correct answer: stepwise function plot!)

> Plotting a named expression is, I think, a very common case, especially
> for new users and elementary users; we should "make simple things
> simple, and hard things possible".
> 
> I think it is as easy to tell people to use '(...) in one case as
> ''(...) in the other.  Functions that quote their arguments (fexprs in
> Lisp, mfexprs in Maxima) are *always* trouble to work with because you
> can't compose them straightforwardly.

The example above shows that the treatment of named expressions needs 
more attantion. I would suggest 'quote 1st argument and expand named 
expressions internally' strategy for plot2d. It combines the best from 
all notations present. If my opinion counts, of course...
--
Andrei Zorine