SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.analysis.function.polynomial.root
Class Cubic

java.lang.Object
  extended by com.numericalmethod.suanshu.analysis.function.polynomial.root.Cubic
All Implemented Interfaces:
Solver

public class Cubic
extends java.lang.Object
implements Solver

This is a cubic equation solver.

Solve

ax3 + bx2 + cx + d = 0
using cubic root-finding formula, which is based on Cardano's method.

See Also:

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.numericalmethod.suanshu.analysis.function.polynomial.root.Solver
Solver.RootFindingException, Solver.Type
 
Constructor Summary
Cubic()
           
 
Method Summary
 NumberList solve(Polynomial polynomial)
          Solve ax3 + bx2 + cx + d = 0
 Solver.Type type()
          Get the type of the solver.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Cubic

public Cubic()
Method Detail

type

public Solver.Type type()
Description copied from interface: Solver
Get the type of the solver.

Specified by:
type in interface Solver
Returns:
the solver type

solve

public NumberList solve(Polynomial polynomial)
Solve
ax3 + bx2 + cx + d = 0

Specified by:
solve in interface Solver
Parameters:
polynomial - the cubic polynomial to solve
Returns:
a list of all roots in Number
Throws:
java.lang.IllegalArgumentException - if the polynomial degree is not 3

SuanShu, a Java numerical and statistical library

Copyright © 2011 Numerical Method Inc. Ltd. All Rights Reserved.