Help › Functions
Differential equations
rkfixed Rkadapt rkadapt Bulstoer bulstoer Adams Stiffb stiffb Stiffr stiffr AdamsBDF BDF Radau
rkfixed(y, x1, x2, npoints, D) As in Mathcad
The solution of a system of differential equations by fourth-order Runge–Kutta, in equal steps from x1 to x2.
y is the vector of starting values at x1 (a one-element vector for a single equation). D(x, y) is a function you define that gives the vector of derivatives, one for each starting value. The y it receives is always a vector, so write y[0, shown y₀, for the first value. npoints is the number of steps, a positive whole number.
The answer is a matrix with npoints+1 rows: the x values in the first column, then one column for each of the y values. x2 can be below x1 to solve backwards. The step is fixed, so a larger npoints is more accurate. For steps chosen to meet an accuracy, see Rkadapt.
Units
MathMath accepts units here: x with one unit and each y with its own, and D must then give each value in y's units per x's.
Refused
- A D that gives a different number of values than there are starting values.
- A D whose values have the wrong units.
- A number of points that isn't a positive whole number.
w≔(1)
D(x,y)≔(−y0)
Y≔rkfixed(w,0,1,4,D)
Y4,0=1
Y4,1=0.368
Rkadapt(y, x1, x2, npoints, D) As in Mathcad
The solution of a system of differential equations by an adaptive Runge–Kutta method, given at equal steps from x1 to x2.
Arguments and answer are as for rkfixed: a matrix of npoints+1 rows, x first. Inside, it takes whatever smaller steps keep the error low, then reports at the equal points, so the answer is more accurate than rkfixed for the same npoints.
It differs from rkadapt in the output: Rkadapt gives the points you ask for, rkadapt gives the points the solver itself chose.
Units
As for rkfixed.
Refused
- As for
rkfixed. - Equations too stiff to solve in a reasonable number of steps. Try
Radau or Stiffr.
w≔(1)
D(x,y)≔(−y0)
Y≔Rkadapt(w,0,1,4,D)
Y4,1=0.368
rkadapt(y, x1, x2, acc, D, kmax, save) As in Mathcad
The solution of a system of differential equations by an adaptive Runge–Kutta method, at the points the solver chose.
It differs from Rkadapt in its output and arguments. Instead of equal steps, the answer has the start, then a row whenever x has moved by more than save since the last row kept, up to kmax rows, and always the end x2. A save of 0 keeps every step. acc is the accuracy wanted, a number above 0 such as 10⁻⁶.
The method is the same as Rkadapt's; only the points reported differ. The answer is a matrix with x in the first column, then one for each y.
Units
As for rkfixed.
Refused
- An accuracy that isn't a plain number above 0.
- A kmax that isn't a positive whole number.
- As for
rkfixed.
w≔(1)
D(x,y)≔(−y0)
Y≔rkadapt(w,0,1,10−8,D,3,0)
Y2,0=1
Y2,1=0.368
Bulstoer(y, x1, x2, npoints, D) As in Mathcad
The solution of a system of differential equations, given at equal steps from x1 to x2, for smooth equations.
Arguments and answer are as for Rkadapt: a matrix of npoints+1 rows, x first. Mathcad's Bulirsch–Stoer method suits smooth solutions; in MathMath it shares the adaptive Runge–Kutta solver Rkadapt uses, so the two agree.
It differs from bulstoer in the output: Bulstoer reports at equal points, bulstoer at the solver's own.
Units
As for rkfixed.
Refused
w≔(1)
D(x,y)≔(−y0)
Y≔Bulstoer(w,0,1,4,D)
Y4,1=0.368
bulstoer(y, x1, x2, acc, D, kmax, save) As in Mathcad
As Bulstoer, but at the points the solver chose, to an accuracy you give.
The arguments after D are as for rkadapt: acc, the accuracy; kmax, the most rows; and save, the least spacing in x between rows kept. The end x2 is always the last row.
The method is the same as Bulstoer's; only the points reported differ.
Units
As for rkfixed.
Refused
w≔(1)
D(x,y)≔(−y0)
Y≔bulstoer(w,0,1,10−8,D,3,0)
Y2,0=1
Y2,1=0.368
Adams(y, x1, x2, npoints, D, [tol]) As in Mathcad
The solution of a system of differential equations, given at equal steps from x1 to x2, for smooth equations, to an optional tolerance.
Arguments and answer are as for Rkadapt, with an optional last argument: the tolerance, a number above 0 (10⁻⁹ if omitted). In MathMath it shares the adaptive Runge–Kutta solver of Rkadapt.
For stiff equations see AdamsBDF and Radau.
Units
As for rkfixed.
Refused
- A tolerance that isn't a plain number above 0.
- As for
rkfixed.
w≔(1)
D(x,y)≔(−y0)
Y≔Adams(w,0,1,4,D,10−10)
Y4,1=0.368
Stiffb(y, x1, x2, npoints, D, J) As in Mathcad
The solution of a stiff system of differential equations, given at equal steps from x1 to x2, using the Jacobian J.
Arguments are as for rkfixed, with one more: J(x, y), a function you define that gives an n×(n+1) matrix. Its first column holds ∂D/∂x, and the n columns after it ∂Dᵢ/∂yⱼ. A system is stiff when the plain solvers need very small steps to stay stable.
In MathMath Stiffb and Stiffr use the same stiff solver, so they give the same answers, though Mathcad's differ in method. The lowercase stiffb gives the solver's own points instead of equal ones.
Units
As for rkfixed.
Refused
- A J that isn't n×(n+1).
- As for
rkfixed.
w≔(1)
D(x,y)≔(−y0)
J(x,y)≔(0−1)
Y≔Stiffb(w,0,1,4,D,J)
Y4,1=0.368
stiffb(y, x1, x2, acc, D, J, kmax, save) As in Mathcad
As Stiffb, but at the points the solver chose, to an accuracy you give.
J is as for Stiffb, an n×(n+1) matrix. acc, kmax and save are as for rkadapt: the accuracy, the most rows, and the least spacing in x between rows kept. The end x2 is always the last row.
The solver is the same as Stiffb's, and the same as stiffr's in MathMath.
Units
As for rkfixed.
Refused
w≔(1)
D(x,y)≔(−y0)
J(x,y)≔(0−1)
Y≔stiffb(w,0,1,10−8,D,J,3,0)
Y2,0=1
Y2,1=0.368
Stiffr(y, x1, x2, npoints, D, J) As in Mathcad
The solution of a stiff system of differential equations, given at equal steps from x1 to x2, using the Jacobian J.
Arguments and answer are as for Stiffb. Mathcad's Stiffr is a Rosenbrock method; in MathMath it and Stiffb use the same solver, so they give the same answers. The lowercase stiffr gives the solver's own points instead.
Units
As for rkfixed.
Refused
w≔(1)
D(x,y)≔(−y0)
J(x,y)≔(0−1)
Y≔Stiffr(w,0,1,4,D,J)
Y4,1=0.368
stiffr(y, x1, x2, acc, D, J, kmax, save) As in Mathcad
As Stiffr, but at the points the solver chose, to an accuracy you give.
Arguments are as for stiffb. The solver is the same as Stiffr's; only the points reported differ.
Units
As for rkfixed.
Refused
w≔(1)
D(x,y)≔(−y0)
J(x,y)≔(0−1)
Y≔stiffr(w,0,1,10−8,D,J,3,0)
Y2,0=1
Y2,1=0.368
AdamsBDF(y, x1, x2, npoints, D, [J], [tol]) As in Mathcad
The solution of a system of differential equations, given at equal steps from x1 to x2, switching between methods to suit stiff or smooth stretches.
Arguments and answer are as for rkfixed. After D come two optional arguments, in this order: a Jacobian J(x, y), an n×n matrix of ∂Dᵢ/∂yⱼ (without the ∂D/∂x column Stiffb takes), and a tolerance. Without J it is found numerically. The default tolerance is 10⁻⁹.
In MathMath it uses the same stiff solver as BDF and Radau.
Units
As for rkfixed.
Refused
- A J that isn't n×n.
- An optional argument that isn't a function or a number.
- As for
rkfixed.
w≔(1)
D(x,y)≔(−y0)
Y≔AdamsBDF(w,0,1,4,D)
Y4,1=0.368
BDF(y, x1, x2, npoints, D, [J], [tol]) As in Mathcad
The solution of a stiff system of differential equations, given at equal steps from x1 to x2, by a backward differentiation method.
Arguments are as for AdamsBDF: optionally an n×n Jacobian J(x, y) and then a tolerance. Without J it is found numerically. In MathMath it uses the same solver as AdamsBDF and Radau. Radau also takes a mass matrix.
Units
As for rkfixed.
Refused
w≔(1)
D(x,y)≔(−y0)
Y≔BDF(w,0,1,4,D)
Y4,1=0.368
Radau(y, x1, x2, npoints, D, [J], [M], [tol]) As in Mathcad
The solution of a stiff system of differential equations, given at equal steps from x1 to x2, optionally with a mass matrix.
Arguments are as for BDF, with a third optional argument: a constant, invertible n×n mass matrix M, which solves M·y′ = D(x, y). The optional arguments go in the order J, M, tol and are told apart by kind: a function is J, a matrix is M, a number is the tolerance. When M is given, J is not used.
Units
As for rkfixed.
Refused
- A singular mass matrix: a system with no solution for y′ isn't supported.
- A mass matrix that isn't n×n.
- As for
AdamsBDF.
w≔(1)
D(x,y)≔(−y0)
Y≔Radau(w,0,1,4,D)
Y4,1=0.368