plotting



On 10/12/07, Wiel Aerts <wiel.aerts at xs4all.nl> wrote:

> I defined a function as follows:
>
> cheby(n) := block([term : 0], for i thru n
>               do if primep(i) then term : log(i) + term, return(term));
>
> Then I want to make some plot:
> plot2d(cheby, [x,2,10]);
> everything OK.
>
> If I write the statement as follows I got:
>
> (%i5) plot2d(cheby(x),[x,2,10]);
> Maxima was unable to evaluate the predicate:
> 1 > x
> #0: cheby(n=x)
>  -- an error.  To debug this try debugmode(true);

When plot2d is called, its arguments are evaluated.
(That is the case with most Maxima functions. For some
functions, arguments are not evaluated.)
Attempting to evaluate cheby(x) causes an error because
"for i thru n" is evaluated and that fails when n is the symbol x,
not a number.

There are various ways to postpone evaluation of cheby in plot2d.
Probably the easiest thing is just to omit the argument, e.g plot2d(cheby, ...).
You could also write plot2d('(cheby(x)), ...) or plot2d('cheby(x), ...).

Hope this helps

Robert Dodier