0

I am new to maxima.

Wanted to know how to extract the solution for solve? Example:

(%i1) soln: solve([x^2 - 9 =0], [x]);
(soln) [x=-3,x=3]

How to extract the values -3 and 3 and assign them to some variables. I know that if the solution had been

(soln) [-3,3]

then I could have used soln[1] and soln[2] to get the values -3 and 3 respectively.

I hope I am able to express my doubt. Any help would be appreciated.

ASarkar
  • 469
  • 5
  • 16
  • Possible duplicate of [How to assign the output of solve in maxima to a variable?](https://stackoverflow.com/questions/9765715/how-to-assign-the-output-of-solve-in-maxima-to-a-variable) – Surenthar Pitchai Nov 29 '18 at 05:55

1 Answers1

1

Thanks to @SurentharP for the link to the solution. I searched SO but missed the answer that the link provides. For the above problem the solution is as follows:

soln: solve([x^2-9=0], [x]);
xvals : map(rhs, soln);

In this case xvals will store the values -3 and 3. The issue is solved.

ASarkar
  • 469
  • 5
  • 16