Get one of the solutions as Variable Value in Maxima

454 Views Asked by At

I want to create random variables for a way more complex program to read.

Some example code is:

a:random(20);
b:random(100);
[c]:solve(a = 2 * x + b, [x]);
tex(a);
tex(b);
tex(c);

however, the last line prints x=5 instead of 5.

is it somehow possible to get the value of the solutin in maxima?

1

There are 1 best solutions below

0
On BEST ANSWER

The explanation is that solve returns a list of equations such as x = 5, not just values such as 5.

Of course the values are the right-hand sides of the equations. So you can do e.g.:

[c] : map(rhs,solve(a = 2 * x + b, [x]));