I want to create a function (in wxMaxima) that evaluates an expression and returns x- and y-values. Inputs are
- expr - the expression
- var - the variable that the expression should be evaluated for
- a - start of the interval
- b - end of the interval
- n - number of steps
Currently it lookes like this:
funvalues(expr,var,a,b,n) := block(
[d,t,f],
d:(b-a)/(n-1),
t:makelist(i,i,a,b,d),
f:makelist(expr,var,t),
[t,f,expr,var,d]
);
Using it should look like this:
(%i313) funvalues(x^2,x,0,5,6);
(%o313) [[0,1,2,3,4,5],[0,1,4,9,16,25],x^2,x,1]
instead this happens:
(%i313) funvalues(x^2,x,0,5,6);
(%o313) [[0,1,2,3,4,5],[x^2,x^2,x^2,x^2,x^2,x^2],x^2,x,1]
It seems like handing over the variable to the second makelist-command does not work properly. I tried tinkering around with some evflags, but I do not know them good enough to say that it can't be solved that way.
Writing everything directly to makelist works:
(%i362) kill(x,expr,var,t,f)$
t: makelist(i,i,0,5,1);
f: makelist(x^2,x,t);
(t) [0,1,2,3,4,5]
(f) [0,1,4,9,16,25]
I am sure I could work around this somehow but obviously I lack some understanding of how Maxima works.
Thanks in advance :)