question using subst



Hello Luis,

> eq1:a=b$
> eq2:c=d$
> 
> then
> 
> subst([eq1,eq2],a*c);
> 
> yields  b d, as expected.
> 
> However if I try
> k:2$
> subst(makelist(concat(eq,i),i,1,k),a*c);
> 
> this ends with an error:
> 
> Improper argument to SUBST:
> [eq1, eq2]

Maxima evaluates the argument makelist(concat(eq,i),i,1,k)
to [eq1, eq2], but that is not evaluated any further.

To cause [eq1, eq2] to evaluate to [a=b, c=d], 
you can write

  subst (''(makelist (concat(eq, i), i, 1, k)), a*c);

The quote-quote '' (two single quotes, not a double quote)
causes an extra evaluation. Or you can try

  foo: makelist (concat(eq, i), i, 1, k);
  foo: ev (foo);
  subst (foo, a*c);

In general Maxima doesn't try to evaluate expressions
as much as possible. This policy makes it easier to
predict the result of evaluation. Sometimes, however,
you need to encourage Maxima try a little harder.

For what it's worth,
Robert Dodier

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com