-7

I have a polynomial,for example 3x4- 5x + 4.

Assume that I have an array A = { 3, 0, 0, -5, 4 } with the polynomial's coefficients.

How can I use the array A to find the roots of the polynomial?

Is there any function or library to download to do it?

[Note: Original question was about a quadratic: 3x2- 5x + 4.]

I found this: http://commons.apache.org/proper/commons-math/apidocs/org/apache/commons/math3/analysis/solvers/LaguerreSolver.html

How can I get the roots of the polynomial and store them in a an array B?...

Konstantinos_S
  • 65
  • 2
  • 10

3 Answers3

2

For ax2 + bx + c = 0 the solutions are

x = (-b + (b2 - 4ac)1/2) / 2a

and

x = (-b - (b2 - 4ac)1/2) / 2a

By the way, there are analytical solutions up to and including the 4th degree.

Bathsheba
  • 231,907
  • 34
  • 361
  • 483
0

Mathematical Java libraries:

colt, Apache's Mahout, JScience

to list just a three of them. But you probably don't need a library to solve such a trivial equation.

alex
  • 10,900
  • 15
  • 70
  • 100
0

Try the efficient java matrix library

They have a sample code in the same link.

Mkl Rjv
  • 6,815
  • 5
  • 29
  • 47