Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Mathematica How to distinguish exact roots using Solve?

  1. Jan 2, 2017 #1
    Can someone help me distinguish when Solve[polynomial==0,x] returns exact solutions as opposed to solutions in terms of Roots? For example, if I code:

    myroots = x /. Solve[1/2 + 1/5 x + 9/10 x^2 + 2/3 x^3 - 1/5 x^4 + 3/11 x^5 == 0, x]

    this cannot be solved in terms of radicals so Solve returns Root objects:

    {Root[165+66 #1+297 #1^2+220 #1^3-66 #1^4+90 #1^5&,1],
    Root[165+66 #1+297 #1^2+220 #1^3-66 #1^4+90 #1^5&,2],
    Root[165+66 #1+297 #1^2+220 #1^3-66 #1^4+90 #1^5&,3],
    Root[165+66 #1+297 #1^2+220 #1^3-66 #1^4+90 #1^5&,4],
    Root[165+66 #1+297 #1^2+220 #1^3-66 #1^4+90 #1^5&,5]}

    but
    myroots = x /. Solve[1/2 + 1/5 x + 9/10 x^2 + 2/3 x^3 - 1/5 x^4 == 0, x]

    returns exact solutions in terms of radicals. I can't figure out how to distinguish the two as in:

    If[solve returns exact solutions,
    do this;
    ,
    else if Roots are returned do this
    ]

    Can someone help me do this?
     
  2. jcsd
  3. Jan 2, 2017 #2

    Dale

    Staff: Mentor

    A Root is an exact numeric quantity. You can use N on it to get an approximate value to any degree of precision needed. You can also use ToRadicals on it if needed.
     
  4. Jan 4, 2017 #3

    Ben Niehoff

    User Avatar
    Science Advisor
    Gold Member

    You should read the help files on pattern matching. The pattern which matches a Root object is "_Root". Or you can use Head, which returns the head of an expression:

    Code (Text):
    If[Head[expr]===Root, ...]
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted



Similar Discussions: How to distinguish exact roots using Solve?
Loading...