# [Maxima] variable evaluation

Stavros Macrakis macrakis at alum.mit.edu
Tue Apr 3 09:19:36 CDT 2007

```On 4/3/07, Zoho Vignochi <zoho.vignochi at gmail.com> wrote:
> Sorry, I only posted a snippet of code, the entire script is here:

The line a[i,i-j]: solve(...,a[i,i-j]) seems to reflect a
misunderstanding about the return value of "solve".  Univariate solve
returns a list of *equations*, not of values, e.g.

solve( x=1 , x) => [x=1]
solve( x^2=1, x) => [x=1,x=-1]

If they are consistent linear equations, and so you are certain there
is exactly one value returned, the value would be
part(solve(...),1,2).  I don't recommend this sort of error-prone
shortcut in production code, but try it out to see if it does what you
want.

I am not sure I understand your full intent, but try replacing the
last part with:

( a[i,i-j]: part( solve(
(coeff(collectterms(expand(A),c),c,2*(i-j)+1)), a[i,i-j] ), 1,2)   ),
K[i]: part(  solve(coeff(collectterms(expand(A),c),c,1),K[i] ),1,2) )

Is that what you had in mind?

In the future, I would recommend that before using new routines in
functions you write, you read the documentation carefully and try them
out by hand on some simpler examples.  This is one of the advantages
of an interactive system like Maxima.

-s
```