From: Stavros M. <mac...@gm...> - 2024-07-16 22:15:43
|
There are several problems here: - *makelist* does not work with *simp:false* because it relies on simplification to calculate the index values. This is what allows it to evaluate, for example, *makelist(i,i,2.0b0,9/2) *(where ordinary Lisp arithmetic doesn't work) or for that matter *makelist(i,i,x+2,x+4) *(which is a bit weird, but...). - *block([simp:false],?meval(ex))* won't simplify *during* the evaluation, but it will when it returns the value from *block*. For example: *block([simp:false],print(2+2)) *prints 2+2 but returns 4. - You seem to expect *Dx: x+10; makelist(Dx,x,1,3)* to return *[11,12,13]*. But that would require *Dx* to be evaluated twice. The *Dx* there is evaluated exactly the same way as *block([x:3], Dx) => x-1*. If you're willing to read Lisp formatting, a simple way to trace your evaluation is *:lisp (trace meval) *. This can get very voluminous of course. On Sun, Jul 14, 2024 at 1:54 PM Eduardo Ochs <edu...@gm...> wrote: > Hi list, > > I am still confused about by original problem, but now I have better > questions... and the main one is open-ended: there are many cases in > which I don't understand how Maxima executes things, and I would like > to have tools to "single step these cases by hand". There is an > example below, and it's evident that my current tools are not very > good - can you send suggestions? > > /* A reduced version of my original problem > */ > mklist0(xs, expr) := buildq([xs, expr], makelist(expr, splice(xs)))$ > mklist (xs, expr) ::= mklist0(xs, expr)$ > aroundx0 (expr) ::= mklist0([x,2,4], expr)$ > > [x0,y0] : [3, 2]; > [Dx,Dy] : [x-x0, y-y0]; > aroundx0(Dx); /* Bad: [x - 3, x - 3, x - 3] */ > aroundx0('Dx); /* Bad: [Dx, Dx, Dx] */ > aroundx0(ev(Dx)); /* Good: [- 1, 0, 1] */ > > /* Some tools - see the link below */ > /* simp:false$ */ > simp:true$ > dosimp(ex) := block([simp:true], expand(ex,0,0))$ > doeval(ex) := block([simp:false], ?meval(ex))$ > fulleval(ex) := block([simp:true], ?meval(ex))$ > macroexp1(ex) := apply('macroexpand1, [ex])$ > > /* An attempt to "single-step an example by hand": > */ > o0 : '(aroundx0(ev(Dx))); /* aroundx0(ev(Dx)) */ > o1 : macroexp1(o0); /* makelist(ev(Dx), x, 2, 4) */ > o2 : 'Dx; /* Dx */ > o3 : doeval(o2); /* x - 3 */ > o4 : block([x:2], ''o3); /* - 1 */ > o5 : block([x:3], ''o3); /* 0 */ > o6 : block([x:4], ''o3); /* 1 */ > o7 : [o4, o5, o6]; /* [- 1, 0, 1] */ > o8 : apply('ev, [o1]); /* [- 1, 0, 1] */ > o8 : doeval(o1); /* err: ...must evaluate to a number */ > o8 : fulleval(o1); /* [- 1, 0, 1] */ > > Thanks in advance! > Eduardo Ochs > http://anggtwu.net/eev-maxima.html > > > P.S.: some of the "tools" are from Stavros, from: > https://sourceforge.net/p/maxima/mailman/message/37417447/ > |