Usage Notes¶
Ordinary Differential Equations¶
An ordinary differential equation is an equation involving one or more dependent variables \(y_i\), an independent variable t, and derivatives of the \(y_i\) with respect to t.
In the initial-value problem (IVP), the initial or starting values of the dependent variables \(y_i\) at a known value \(t = t_0\) are given. Values of \(y_i(t)\) for \(t > t_0\) or \(t < t_0\) are required.
The functions odeRungeKutta and odeAdamsKrogh solve the IVP for ODEs of the form
with \(y_i(t = t_0)\) specified. Here \(f_i\) is a user-supplied function that must be evaluated at any set of values \((t, y_1, ..., y_N)\), \(i = 1, ..., N\).
This problem statement is abbreviated by writing it as a system of first-order ODEs, \(y(t) = [y_1(t), ..., y_N(t)]^T\), \(f(t, y) = [f_1(t, y), ..., f_N(t, y)]^T\), so that the problem becomes \(y' = f(t, y)\) with initial values \(y(t_0)\).
The system \(\tfrac{dy}{dt} = y' = f(t,y)\) is said to be stiff if some of the eigenvalues of the Jacobian matrix \(\left\{ \partial y'_i / \partial y_j \right\}\) are large and negative. An alternate definition is based on the disparate integration times using a non-stiff solver compared to an implicit integration solver. Frequently differential equations modeling the behavior of physical systems are stiff, such as chemical reactions proceeding to equilibrium where subspecies effectively complete their reactions in different epochs. An alternate model concerns discharging capacitors such that different parts of the system have widely varying decay rates (or time constants).
Users typically identify stiff systems by the fact that numerical differential equation solvers such as odeRungeKutta are inefficient, or else completely fail. Special methods are often required. The most common inefficiency is that a large number of evaluations of f(t, y) (and hence an excessive amount of computer time) are required to satisfy the accuracy and stability requirements of the software. In such cases, use the IMSL function odeAdamsKrogh. For more discussion about stiff systems, see Gear (1971, Chapter 11) or Shampine and Gear (1979).
The function:doc:/math/differential/odeAdamsKrogh solves systems of ordinary differential equations of order one, order two, or mixed order one and two.
Differential-algebraic Equations¶
Frequently, it is not possible or not convenient to express the model of a dynamical system as a set of ODEs. Rather, an implicit equation is available in the form
The \(g_i\) are user-supplied functions. The system is abbreviated as
\(g\left(t, y, y' \right) = \left[ g_1\left(t, y, y' \right), \ldots, g_N\left(t, y, y' \right) \right]^T = 0\)
With initial value \(y(t_0)\). Any system of ODEs can be trivially written as a differential-algebraic system by defining
The function differentialAlgebraicEqs solves differential-algebraic systems of index 1 or index 0. For a definition of index of a differential-algebraic system, see (Brenan et al. 1989). Also, see Gear and Petzold (1984) for an outline of the computing methods used.
Partial Differential Equations¶
There is a section Introduction to pde1dMg in this chapter for pde1dMg with greater details. This software is a variable grid-variable order integrator. It solves a problem
with boundary conditions
The function modifiedMethodOfLines solves the IVP problem for systems of the form
subject to the boundary conditions
and subject to the initial conditions \(u_i \left( x,t = t_0 \right) = g_i(x)\) ,for \(i = 1, ..., N\). Here, \(f_i\), \(g_i\), \(\alpha_j^{(i)}\), and \(\beta_j^{(i)}\) are user-supplied, \(j = 1, 2\).
The function feynmanKac solves a single equation on a finite interval \(\left[x_{\text{min}}, x_{\text{max}}\right]\) . This equation often arises in applications from financial engineering and that is the primary focus of the document examples. The equation, initial conditions and Feynman-Kac boundary values are given by
The solution is approximated by a piece-wise series of Hermite quintic polynomials on a grid of the interval \(\left[x_{\text{min}}, x_{\text{max}}\right]\) that yields a twice differentiable solution. To assist in the evaluation of the approximate solution and its derivatives there is the function feynmanKacEvaluate.
The function fastPoisson2d solves Laplace’s, Poisson’s, or Helmholtz’s equation in two dimensions. This function uses a fast Poisson method to solve a PDE of the form
over a rectangle, subject to boundary conditions on each of the four sides. The scalar constant c and the function f are user specified.