From: Robert D. <rob...@gm...> - 2024-04-06 17:26:53
|
On Sat, Apr 6, 2024 at 9:46 AM Pierre CAMPET <pie...@ac...> wrote: > > Thanks for the help > > when i try your solution i get > > plot2d: expression g > should depend only on x, or be an expression of 2 variables > > the values of g(0), g(0.19) and g(1) are correct. Pierre, thanks for your interest in Maxima. I'm not entirely certain, but I believe the behavior you observe is the consequence of a subtle distinction between "=" and "equal" in Maxima. Try changing the first condition in your function E from if x = b then ... to if equal(x, b) then ... Do you get the expected plot with that change? There are other ways to represent the stair step function. Here is a different formulation -- E(f, x, n, a, b) := if x < a or x > b then 0 else block([d, k], d: (b - a)/n, k: floor((x - a)/d), f(k*d)); and then as before with g(x) := E(f, x, 10, 0, 1); I find that plot2d ([f, g], [x, 0, 1]); shows the expected plot. Does that work for you? best Robert |