|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.opensourcephysics.numerics.Polynomial
public class Polynomial
Polynomial implements a mathematical polynomial: c[0] + c[1] * x + c[2] * x^2 + .... This class is based on code published in Object-Oriented Implementation of Numerical Methods by Didier H. Besset. The code has been adapted to the OSP framework by Wolfgang Christian.
Field Summary | |
---|---|
protected double[] |
coefficients
Polynomial coefficients. |
Constructor Summary | |
---|---|
Polynomial(double[] coef)
Constructs a polynomial with the given coefficients. |
|
Polynomial(java.lang.String[] coef)
Constructs a polynomial with the given coefficients. |
Method Summary | |
---|---|
Polynomial |
add(double r)
|
Polynomial |
add(Polynomial p)
Adds the given polynomial to this polynomial. |
double |
coefficient(int n)
Gets the coefficient value at the desired position |
Polynomial |
deflate(double r)
Deflates the polynomial by removing the root. |
int |
degree()
Gets the degree of this polynomial function. |
Polynomial |
derivative()
Gets the derivative of this polynomial. |
Polynomial |
divide(double r)
Divides this polynomial by a constant. |
Polynomial |
divide(Polynomial p)
Divides this polynomial by another polynomial. |
Polynomial[] |
divideWithRemainder(Polynomial p)
Divides this polynomial by another polynomial. |
static double |
evalPolynomial(double x,
double[] coeff)
Evaluates a polynomial using the given coefficients. |
double |
evaluate(double x)
Evaluates the polynomial for the specified variable value. |
double[] |
getCoefficients()
Gets a clone of the polynomial coefficients c: c[0] + c[1] * x + c[2] * x^2 + .... |
Polynomial |
integral()
Integrates this polynomial. |
Polynomial |
integral(double value)
Integrates this polynomial having the specified value for x = 0. |
Polynomial |
multiply(double r)
Multiplies this polynomial by a constant. |
Polynomial |
multiply(Polynomial p)
Multiplies this polynomial by another polynomial. |
double[][] |
roots()
Gets the complex roots of this polynomial. |
double[] |
rootsReal()
Gets the real roots of this polynomial. |
Polynomial |
subtract(double r)
Subtracts a constant from this polynomial. |
Polynomial |
subtract(Polynomial p)
Subtracts another polynomial from this polynomial. |
java.lang.String |
toString()
Converts this polynomial to a String. |
double[] |
valueAndDerivative(double x)
Returns the value and the derivative of this polynomial for the specified variable value in an array of two elements |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected double[] coefficients
Constructor Detail |
---|
public Polynomial(double[] coef)
coef
- polynomial coefficients.public Polynomial(java.lang.String[] coef)
coef
- polynomial coefficients.Method Detail |
---|
public double[] getCoefficients()
public static double evalPolynomial(double x, double[] coeff)
x
- coeff
- the polynomial coefficients.public Polynomial add(double r)
r
- double number added to the polynomial.
public Polynomial add(Polynomial p)
p
- Polynomial
public double coefficient(int n)
n
- int the position of the coefficient to be returned
public Polynomial deflate(double r)
r
- double a root of the polynomial (no check made).
public int degree()
public Polynomial derivative()
public Polynomial divide(double r)
r
- double
public Polynomial divide(Polynomial p)
p
- Polynomial
public Polynomial[] divideWithRemainder(Polynomial p)
p
- polynomial
public Polynomial integral()
public Polynomial integral(double value)
value
- double value of the integral at x=0
public Polynomial multiply(double r)
r
- double
public Polynomial multiply(Polynomial p)
p
- Polynomial
public double[][] roots()
public double[] rootsReal()
public Polynomial subtract(double r)
r
- the constant
public Polynomial subtract(Polynomial p)
p
- Polynomial
public java.lang.String toString()
toString
in class java.lang.Object
public double evaluate(double x)
evaluate
in interface Function
x
- double value at which the polynomial is evaluated
public double[] valueAndDerivative(double x)
x
- double value at which the polynomial is evaluated
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |