# How to make a list of the roots of a polynomial equation without the x ==" s in each entry? [duplicate]

        List @@ Roots[x τ (-1 + τ^2) (-1 +
\!$$\*SubsuperscriptBox[\(b$$, $$1$$, $$2$$]\)) (-1 + τ^2
\!$$\*SubsuperscriptBox[\(b$$, $$1$$, $$2$$]\)) (Subscript[b, 1] -
Subscript[c, 1]) (τ^2 Subscript[b, 1] - Subscript[c,
1]) (-1 +
Subscript[b, 1] Subscript[c, 1]) (-1 + τ^2 Subscript[b, 1]
Subscript[c, 1]) (x τ - Subscript[c,
2]) (τ^2 Subscript[b, 1] - x Subscript[c, 2]) (-1 +
x τ Subscript[c, 2]) (-x + τ^2 Subscript[b, 1]
Subscript[c, 2]) (x τ - Subscript[c,
3]) (τ^2 Subscript[b, 1] - x Subscript[c, 3]) (-1 +
x τ Subscript[c, 3]) (-x + τ^2 Subscript[b, 1]
Subscript[c, 3]) == 0, x]


gives

    {x == 0, x == Subscript[c, 2]/τ,
x == (τ^2 Subscript[b, 1])/Subscript[c, 2],
x == 1/(τ Subscript[c, 2]),
x == τ^2 Subscript[b, 1] Subscript[c, 2],
x == Subscript[c, 3]/τ,
x == (τ^2 Subscript[b, 1])/Subscript[c, 3],
x == 1/(τ Subscript[c, 3]),
x == τ^2 Subscript[b, 1] Subscript[c, 3]}.


I would like to have a list of the roots without the x== in each entry. How can I remove this?

• Calling your list lst use e.g. lst[[All, 2]]. Commented Jul 18, 2013 at 20:01
• Thanks! That exactly answered my question. Commented Jul 18, 2013 at 20:03

I think Artes will not elaborate and since questions should have answers posted as such, I will volunteer to try to write one.

Let's call your result lst. In Mathematica all things, however rendered, are functions wrapped in functions. Those equality signs? Actually a function called Equal.

To extract some part of an output it helps to know exactly how the expression we're dealing with looks and for this purpose we have FullForm.

lst // FullForm


Gives

List[Equal[x,0],Equal[x,Times[Power[\[Tau],-1],Subscript[c,2]]],Equal[x,Times[Power[\[Tau],2],Subscript[b,1],Power[Subscript[c,2],-1]]],Equal[x,Times[Power[\[Tau],-1],Power[Subscript[c,2],-1]]],Equal[x,Times[Power[\[Tau],2],Subscript[b,1],Subscript[c,2]]],Equal[x,Times[Power[\[Tau],-1],Subscript[c,3]]],Equal[x,Times[Power[\[Tau],2],Subscript[b,1],Power[Subscript[c,3],-1]]],Equal[x,Times[Power[\[Tau],-1],Power[Subscript[c,3],-1]]],Equal[x,Times[Power[\[Tau],2],Subscript[b,1],Subscript[c,3]]]]


Artes retrieved all elements on the first level and the second element on the second level using Part (lst[[All, 2]]). We can easily see from the FullForm that this is possible. Your list is just a list of Equal elements and the relevant part is the second argument to those list elements.

Most of all, peaking at the expression with FullForm often makes it very easy to find patterns that match what you want to extract, you could do

lst /. Equal[__, x__] -> x


and you would get the same thing.