From: Jaime V. <vi...@fe...> - 2024-04-06 16:00:05
|
Try this: g(x):=E(f,x,10,0,1)$ plot2d([f,g], [x,0,1]); Plot2d expects an expression of one variable or the name of a function with only input parameter. Notice that neither E(f,x,10,0,1)] nor g(x) return an expression with the variable x and E is not the name of a function with a single input parameter but g is. Regards, Jaime On 06/04/24 16:32, Pierre CAMPET wrote: > > Hello > > > I'd like to draw a stair function to illustrate what we called in > france "Méthode des rectangles" : > > I try this : > > f(x):=1/(1+x); > E(f,x,n,a,b):=block( > if x=b then return(f(b)) > else > for i:1 thru n do if (x < a+i*(b-a)/n) then return(f(a+(i-1)/n)) > ); > E(f,0.19,10,0,1); > E(f,1,10,0,1); > E(f,0,10,0,1); > > But > > wxplot2d([f(x),E(f,x,10,0,1)], [x,0,1])$ > > give me an error : COERCE-FLOAT-FUN: no such Lisp or Maxima function: done > > any idea to produce the function may be with no evaluation on each x ? > > |