0

I am having a hard time with a huge script. I use Solve function to solve my algebraic equation with parameters of the 4 th order. The result is really messy. Is that possible to assign the roots to variables automatically? Now I use Standartform function, copy and paste each root separately in a new cell, in order to write the result in a new variables.

If it is not clear what I want, suppose we have an equation we want to solve:

In[841]:= StandardForm[Solve[a*x^2 + b*x + c == 0, x]]

Out[841]//StandardForm= {{x -> (-b - Sqrt[b^2 - 4 a c])/(
2 a)}, {x -> (-b + Sqrt[b^2 - 4 a c])/(2 a)}}

In order to work with 2 roots, I have to write two new lines, and copy\paste the result from Out[841]. I want both roots to be written in 2 new variables automatically, so I can work with these variables immidiately.

After doing a quick search through a documentation of Solve, I didn't find the answer.

Thanks,

Mikhail Genkin
  • 607
  • 1
  • 4
  • 11
  • 1
    Look here. And you can always assign the output of Solve to a variable sols, say, and then do x /. First@sols. – march Sep 17 '15 at 22:55
  • 1
    Caution: StandardForm, MatrixForm, NumberForm, (basically all the *Forms) make something pretty to look at AND at the same time make it inconvenient or impossible to then do any further calculations with that. This is a mistake that new users and the obsessive desktop publishers make over and over. If you do myvar=Solve[...] and then Print[StandardForm[myvar]] then you can usually avoid this problem. – Bill Sep 17 '15 at 23:03
  • oh, I see, thanks. Should I close the problem? – Mikhail Genkin Sep 17 '15 at 23:09

0 Answers0