lines 71-160 of file: xrst/algorithm.xrst {xrst_begin an_ode} {xrst_spell kutta llll runge } An ODE Solution ############### ODE *** .. math:: \begin{array}{llll} y_i '(t) & = & x_0 & \mbox{for} \; i = 0 \\ y_i '(t) & = & \sum_{j=1}^i x_j y_{i-1} (t) & \mbox{for} \; i > 0 \\ \end{array} Parameter Vector ================ We refer to :math:`x` as the parameter vector in the ode. Initial Value ************* .. math:: y_i (0) = 0 \; \mbox{for all} \; i Solution ******** This initial value problem has the following analytic solution (which can be used to check function values and derivatives): .. math:: \begin{array}{llll} y_0 (t) & = & x_0 t \\ y_1 (t) & = & x_0 x_1 t^2 / 2 ! \\ y_2 (t) & = & x_0 x_1 x_2 t^3 / 3 ! \end{array} .. math :: y_i (t) = \frac{t^{i+1}}{(i+1)!} \prod_{j=0}^i x_j \; \; \mbox{for all} \; i Algorithm ********* The :ref:`rk4_step-name` method is used to approximate the solution for :math:`y(t)` at :math:`t = 2` . Note that this approximation has no truncation error for :math:`i < 4` . option ****** This algorithm uses the ``n_arg`` and ``n_other`` options; see below: n_arg ===== This is the size of the vectors *x* and *y* above . There is an assert checking that *n_arg* > 0. n_other ======= This is the number of :ref:`Runge-Kutta steps` used to approximate the solution of the ODE :math:`y(t)` . There is an assert checking that *n_other* > 0. {xrst_toc_hidden xrst/rk4_step.xrst } Implementation ============== :ref:`rk4_step-name` , :ref:`cpp_an_ode-name` , :ref:`py_an_ode-name` . Derivative ********** The partial of :math:`y_i (t)` with respect to :math:`x_j` is .. math:: \frac{ \partial y_i (t) }{ \partial x_j } = \begin{cases} y_i (t) / x_j & \text{if} \; j \leq i \\ 0 & \text{otherwise} \end{cases} {xrst_end an_ode}