1
$\begingroup$

So I am trying to find the absolute value of the roots of a polynomial in Mathematica. I am quite new to this software and I am having a hard time how to figure out the absolute value of the roots of a polynomial. Here's what I have done.

  • I defined a polynomial say P[degree_,z_]:= (*something*)
  • Now I use: Solve[P[5,z]==0] This gives me the exact roots of the polynomial, but if I use Abs[Solve[P[5,z]==0]], this doesn't return the absolute values of the roots. Any help is highly appreciated.
$\endgroup$
1
  • $\begingroup$ Perhaps z /. Solve[p[z] == 0, z] // Abs // N $\endgroup$
    – Cesareo
    Jun 26 at 8:13
1
$\begingroup$

Since Solve[P[degree,z]] returns a set of rules, so we need to modify it a little.

Let us define data= Solve[P[degree,z]==0,z] , then use Table[z/.data[[i]],{i,1,degree}] this table gives us the value of the roots corresponding to the $i$th position. Now this is a number and we can apply mathematical operations here.

Using Table[Abs[z/.data[[i]]],{i,1,degree}] will return the absolute values of the roots.

Extra observation: If the polynomial have very complicated roots and mathematica returns them in not so simple form we can use NSolve as long as we are only concerned about the absolute value of roots.

$\endgroup$
1
  • 2
    $\begingroup$ Or to leave solution (roots) as rules, roots /. (z -> root_) :> (z -> Abs[root]) $\endgroup$
    – Bob Hanlon
    Jun 26 at 14:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.