|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.opensourcephysics.numerics.Root
public class Root
Class Root defines various root finding algorithms. This class cannot be subclassed or instantiated because all methods are static.
Method Summary | |
---|---|
static double |
bisection(Function f,
double x1,
double x2,
double tol)
Implements the bisection method for finding the root of a function. |
static double[][] |
cubic(double a,
double b,
double c,
double d)
Solves for the roots of the cubic equation ax3+bx2+cx+d=0. |
static double[][] |
getJacobian(VectorFunction feqs,
int n,
double[] xx,
double tol)
Computes the Jacobian using a finite difference approximation. |
static double |
newton(Function f,
double x,
double tol)
Implements Newton's method for finding the root of a function. |
static double |
newton(Function f,
Function df,
double x,
double tol)
Implements Newton's method for finding the root of a function. |
static double |
newtonBisection(Function f,
double xleft,
double xright,
double tol,
int icmax)
Implements Newton's method for finding the root but switches to the bisection method if the the estimate is not between xleft and xright. |
static double |
newtonMultivar(VectorFunction feqs,
double[] xx,
int max,
double tol)
|
static double[][] |
polynomial(double[] c)
Solves for the roots of the polynomial with the given coefficients c: c[0] + c[1] * x + c[2] * x^2 + .... |
static double[][] |
quadratic(double a,
double b,
double c)
Solves for the complex roots of the quadratic equation ax2+bx+c=0. |
static double[] |
quadraticReal(double a,
double b,
double c)
Solves for the real roots of the quadratic equation ax2+bx+c=0. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static double[] quadraticReal(double a, double b, double c)
a
- double quadratic term coefficientb
- double linear term coefficientc
- double constant term
public static double[][] quadratic(double a, double b, double c)
a
- double quadratic term coefficientb
- double linear term coefficientc
- double constant term
public static double[][] cubic(double a, double b, double c, double d)
a
- double cubic term coefficientb
- double quadratic term coefficientc
- double linear term coefficientd
- double constant term
public static double[][] polynomial(double[] c)
double[]
- c coefficients
public static double newton(Function f, double x, double tol)
f
- Function the functionx
- double guess the roottol
- double computation tolerance
public static double newton(Function f, Function df, double x, double tol)
f
- Function the functiondf
- Function the derivative of the functionx
- double guess the roottol
- double computation tolerance
public static double bisection(Function f, double x1, double x2, double tol)
f
- Function the functionx1
- double lowerx2
- double uppertol
- double computation tolerance
public static double newtonBisection(Function f, double xleft, double xright, double tol, int icmax)
xleft
- doublexright
- doubletol
- double toleranceicmax
- int number of trials
public static double newtonMultivar(VectorFunction feqs, double[] xx, int max, double tol)
public static double[][] getJacobian(VectorFunction feqs, int n, double[] xx, double tol)
feqs
- VectorFunction - the function containing n equationsn
- int - number of equationsxx
- double[] - the variable array at which the Jacobian is calculatedtol
- double - the small change to find the derivatives
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |