MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Real roots of polynomials

  • To: mathgroup at
  • Subject: [mg24729] Re: [mg24688] Real roots of polynomials
  • From: "Ersek, Ted R" <ErsekTR at>
  • Date: Wed, 9 Aug 2000 02:31:29 -0400 (EDT)
  • Sender: owner-wri-mathgroup at

Jack Goldberg wanted an efficient way to find all real roots of a
polynomial.  The built-in functions Roots and NRoots can do nothing but find
roots of polynomials.  I hope the developers made these functions work as
efficiently as possible. As expected NRooots runs much faster.  You only
need to do is a little programming to discard the roots with a non-zero
complex part. I give you functions below that work like Roots and NRoots but
only return the real roots. The definition below only works for polynomials
in one variable.

You could if you want give RealRoots all the same options as the built-in
Roots function.


  Select[Roots[lhs*rhs, var, Cubics->False,Quartics->False],

  Select[NRoots[lhs*rhs, var], (Im[Last[#]]*  0.0)&]

RealRoots[2 x^4-3 x^3+x-5*0,x]

x == Root[-5 + #1 - 3*#1^3 + 2*#1^4 & , 1] || 
x == Root[-5 + #1 - 3*#1^3 + 2*#1^4 & , 2]

NRealRoots[2 x^4-3 x^3+x-5*0,x]

x == -1.05796 || x == 1.78349

Ted Ersek

Mathematica tips, tricks have moved to

  • Prev by Date: Re: Real roots of polynomials
  • Next by Date: Re: Mathematica won't solve simple diff. eqn.--Correction
  • Previous by thread: Re: Real roots of polynomials
  • Next by thread: Re: Can I solve PDE in Mathematica?