lines 6-83 of file: python/cmpad/runge_kutta.py {xrst_begin_parent py_runge_kutta} {xrst_spell dy int ns tf yf yi yt } Python Fourth Order Runge Kutta Method ###################################### Prototype ********* {xrst_literal , # BEGIN DEF, # END DEF # BEGIN RETURN, # END RETURN } Purpose ******* This routine returns an approximate solution for :math:`y( t^f )` where :math:`y(0) = y^i` and :math:`y' (t) = f(y)` . like_numpy ********** This is a :ref:`like_numpy-name` class. It is used to vectorize the :ref:`rk4_step-name` algorithm. fun *** This is a :ref:`py_fun_obj-name` . The syntax *dy* = *fun* ( *yt* ) , were *yt* is :math:`y(t)` , sets *dy* equal to the derivative :math:`y'(t)` . yi ** is the value of :math:`y(t)` at :math:`t = 0` . This is a vector like object with elements of type ``float`` or *Scalar* . tf ** is the value of *t* at which we wish to evaluate :math:`y(t)` . This is an object of type ``float`` or *Scalar* . ns ** is the number of :ref:`Runge-Kutta steps` to use. The more steps the smaller the step size and the more accurate the solution. This is an ``int`` . yf ** The return value *yf* has the same size as *yi* and is the approximation for :math:`y(t)` at *t* = *tf* . This is a vector like object with elements of type ``float`` or *Scalar* . {xrst_toc_hidden after python/xam/runge_kutta.py } Source Code *********** :ref:`runge_kutta.py-name` Example ******* :ref:`xam_runge_kutta.py-name` contains an example and test of ``py_runge_kutta`` . {xrst_end py_runge_kutta}