Class RungeKuttaFehlberg
- java.lang.Object
-
- dev.nm.analysis.differentialequation.ode.ivp.solver.rungekutta.RungeKuttaFehlberg
-
- All Implemented Interfaces:
ODESolver
public class RungeKuttaFehlberg extends Object implements ODESolver
The Runge-Kutta-Fehlberg method is a version of the classic Runge-Kutta method, which additionally uses step-size control and hence allows specification of a local truncation error bound. In particular, the algorithm estimates the error by comparing the results of the 5th and the 4th order Runge-Kutta solutions. This step requires six evaluations of the input method. To be conservative, a safety factor γ is included in the step size update formula, to make the new step size somewhat smaller than that predicted to yield the local error exactly equal to the error upper bound. In this implementation, the step size is updated by this formula: \[ h_1 = \gamma \left( \frac{\max\left\{ \left \| y \right \|, 1 \right\} \epsilon}{\left \| E \right \|} \right)^{1/5} h_0, \] where \(\gamma\) is the safety factor, \(y\) and \(E\) are the current abscissa and error respectively, \(\epsilon\) is the lower bound of the local truncation error, until the error criterion \[ \left \| E \right \| \le \max\left\{ \left \| y \right \|, 1 \right\} \epsilon \] is met.- See Also:
- Wikipedia: Runge-Kutta-Fehlberg method
-
-
Field Summary
Fields Modifier and Type Field Description static double
DEFAULT_SAFETY_FACTOR
Default value for the safety factor γ.
-
Constructor Summary
Constructors Constructor Description RungeKuttaFehlberg(double epsilon, double minStepSize)
Create a new instance of the Runge-Kutta-Fehlberg method for the given parameters, with the default safety factor value.RungeKuttaFehlberg(double epsilon, double minStepSize, double gamma)
Create a new instance of the Runge-Kutta-Fehlberg method with the given safety factor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ODESolution
solve(ODE1stOrder ode)
Solve the given ODE using Runge-Kutta-Fehlberg method.
-
-
-
Field Detail
-
DEFAULT_SAFETY_FACTOR
public static final double DEFAULT_SAFETY_FACTOR
Default value for the safety factor γ.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
RungeKuttaFehlberg
public RungeKuttaFehlberg(double epsilon, double minStepSize)
Create a new instance of the Runge-Kutta-Fehlberg method for the given parameters, with the default safety factor value.- Parameters:
epsilon
- the upper bound on the local truncation errorminStepSize
- the lower bound on step size
-
RungeKuttaFehlberg
public RungeKuttaFehlberg(double epsilon, double minStepSize, double gamma)
Create a new instance of the Runge-Kutta-Fehlberg method with the given safety factor.- Parameters:
epsilon
- the upper bound on the local truncation errorminStepSize
- the lower bound on step sizegamma
- the safety factor (0 < γ ≤ 1)
-
-
Method Detail
-
solve
public ODESolution solve(ODE1stOrder ode)
Solve the given ODE using Runge-Kutta-Fehlberg method. The result will range from α to β, where the steps taken depends on the execution of the algorithm, which in turn depends on the accuracy of the respective step sizes. If the error criterion cannot be satisfied using step sizes greater than or equal tohMin
, anUnsatisfiableErrorCriterionException
will be thrown. In this case, eitherhMin
has to be decreased orepsilon
has to be increased.
-
-