ODE Cash Karp 5th Order VI
- 已更新2025-07-30
- 閱讀時間為 5 分鐘
Solves ordinary differential equations with initial conditions using the Cash Karp method.

Inputs/Outputs
X (name of variables)
—
X is an array of strings of variables.
time start
—
time start is the start point of the ODE. The default is 0.
time end
—
time end is the end point of the time interval under investigation. The default is 1.0.
h (step rate)
—
h is the step rate at the beginning of the algorithm. The Cash Karp algorithm works with an adaptive step rate. The default is 0.1.
X0
—
X0 is the vector of the start condition x[10], …, x[n0]. There is a one-to-one relation between the components of X0 and X.
accuracy
—
accuracy controls the accuracy of the solutions. The default is 0.0, which specifies the maximum deviation of the calculated solution from the actual solution.
time
—
time is the string denoting the time variable. The default variable is t.
F(X,t) (right sides of the ODE
as functions of X and t)
—
F(X,t) is a 1D array of strings representing the right sides of the differential equations. The formulas can contain any number of valid variables.
Times
—
Times is a 1D array representing the time steps. The ODE Cash Karp method yields arbitrarily chosen time steps between time start and time end.
X Values (solution)
—
X Values is a 2D array of the solution vector x[10], …, x[n]. The top index runs over the time steps, as specified in the Times array, and the bottom index runs over the elements of x[10], …, x[n].
ticks
—
ticks is the time in milliseconds for the whole calculation.
error
—
error returns any error or warning from the VI. Errors are produced by using the wrong inputs X, X0, and F(X,t). You can wire error to the Error Cluster From Error Code VI to convert the error code or warning into an error cluster. |
The Cash Karp method works with an adaptive step rate and is computationally more efficient than the Euler method and the Runge Kutta method. The Cash Karp method is an embedded Runge Kutta formula and is based on a fifth-order strategy (with six steps).
and
with
tn + 1 = tn + hThe a2, …, a6; b21, …, b65; c1, …, c6; and c1*, …, c6* are fixed real numbers. This choice determines the quality of the method.
You can determine the actual step size hnew with the help of the accuracy value, the old step size h, the difference Δ = |X(tn + 1) – X*(tn + 1)|, and the following equation.
The following illustration shows the solution of the following system of ordinary differential equations in a 3D representation.
The previous equations and boundary conditions are entered on the front panel as:
- time start: 0.00
- time end: 40.00
- X0: [0.6, 0.6, 0.6]
- F(X,t): [10*(y-x), x*(28-z) - y, x*y - (8/3)*z]
- X: [x,y,z]
Examples
Refer to the following example files included with LabVIEW.
- labview\examples\Mathematics\Differential Equations - ODE\Planar Three Body Problem.vi
X (name of variables)
—
time start
—
X0
—
time
—
Times
—
X Values (solution)
—
ticks
—
error
—