Newbie problems with plot2d



> lognormal(x) := (1/x)*exp(-(log(x/x0))^2/(2*sig^2));
> tfmi(t) := first(quad_qagi(lognormal(s)*exp(-s*t), s, 10^-16, inf));
> x0:2; sig:2; amp:0.1;
> tfmi(0.1); /* OK */
> tfmi(1.0); /* OK */
> numberp(tfmi(0.1)); /* true */
> plot2d(tfmi(t),[t,0.1,1]); /* fails */

Try:

plot2d(tfmi,[t,0.1,1]);
plot2d('(tfmi(t)), [t,0.1,1]);

Explanation: tfmi is the name of a function, while
tfmi(t) is an expression. If you pass the expression,
then you want it to be unsimplified (because t is
meant to be a numeric input).

> array(tvec, 20);
> array(yvec, 20);
> for i:0 step 1 thru 19 do
> block(
>    tvec[i]: 0.1*i,
>    yvec[i]: tfmi(tvec[i])
>    );
> display(tvec[3],yvec[3]); /* OK */
> plot2d([discrete,tvec,yvec]);  /* fails */

or:

tlist : makelist(0.1*i,i,0,19);
ylist : map(tfmi,tlist);
plot2d([discrete,ylist,tlist]);

Explanation: arrays and lists are different beasts and
plot2d expects lists not arrays (see the examples in the
online help).

-- 
Leo Butler                 l_butler at users.sourceforge.net
SDF Public Access UNIX System -   http://sdf.lonestar.org