[Maxima] how to write in a block(?) a very long "block" of statements

Robert Dodier robert.dodier at gmail.com
Wed May 30 09:44:40 CDT 2007

```On 5/30/07, Viktor Nagy <viktor.nagy at gmail.com> wrote:

> (
> lambda2:1,
> w1opt : ev(substshares(substval(substbd(solve(diff(pis11,
> w[1])+diff(pis31, w[1]), w[1])))), lambda=1-lambda2),
> w2opt : ev(substshares(substval(substbd(solve(diff(pis22,
> w[2])+diff(pis32, w[2]), w[2])))), lambda=lambda2),
> pi31eq : ev(ev(substshares(pis31), w1opt), lambda=1-lambda2),
> pi32eq : ev(ev(substshares(pis32), w2opt), lambda=lambda2),
> T1opt : substval(substbd(pi31eq-pi32eq+T2)),
> T2opt : substshares(substval(substbd(pi32eq-pi31eq+T1))));
> -----------
>
> My problem is that lambda is not evaluated in any of these expressions, even
> if it is evaluated in the original formulation.

You've encountered the subtleties of evaluation, one of the twin
arcana major of Maxima (the other being simplification).

Maxima tries only once to evaluate an expression. You might
expect Maxima to re-evaluate until the expression does not
change, but that is not Maxima's policy.

In the assignments for w1opt and w2opt, try writing
FOO : substshares (...);
ev (FOO, lambda = 1 - lambda2);
ev (substshares (...), lambda = 1 - lambda2);
i.e. computing the expression, then calling ev to change lambda.
I think that modifies the evaluation just enough to get the expected result.
You'll want to do that for each of the four calls to ev in the block.

lambda is a special symbol in Maxima; it designates an
unnamed function. I don't know if that's going to cause
trouble here. You could change it to %lambda or something
to distinguish it.

Seems like an interesting example -- thanks for showing it to us.

HTH
Robert Dodier
```