lines 9-80 of file: cpp/include/cmpad/algo/runge_kutta.hpp {xrst_begin_parent runge_kutta} {xrst_spell dy ns tf yf yi yt obj } A C++ Fourth Order Runge Kutta Solver ##################################### Syntax ****** | |tab| ``# include `` | |tab| *yf* = ``cmpad::runge_kutta`` ( *fun* , *yi* , *tf*, *ns* ) Prototype ********* {xrst_literal // BEGIN PROTOTYPE // END PROTOTYPE } Purpose ******* This routine returns an approximate solution for :math:`y( t^f )` where :math:`y(0) = y^i` and :math:`y' (t) = f(y)` . Vector ****** The vectors *yi* and *yf* have this fun_obj :ref:`cpp_fun_obj@vector_type` . fun *** The syntax *dy* = *fun* ( *yt* ) , were *yt* is :math:`y(t)` , sets *dy* equal to the derivative :math:`y'(t)` . Both *yt* and *dy* are represented as *Vector* objects. yi ** is the value of :math:`y(t)` at :math:`t = 0` . tf ** is the value of *t* at which we wish to evaluate :math:`y(t)` . 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. yf ** The return value *yf* has the same size as *yi* and is the approximation for :math:`y(t)` at *t* = *tf* . {xrst_toc_table after cpp/xam/runge_kutta.cpp } Example ******* :ref:`xam_runge_kutta.cpp-name` contains an example and test of ``runge_kutta`` . {xrst_end runge_kutta}