maths.numerical_analysis.runge_kutta_fehlberg_45 ================================================ .. py:module:: maths.numerical_analysis.runge_kutta_fehlberg_45 .. autoapi-nested-parse:: Use the Runge-Kutta-Fehlberg method to solve Ordinary Differential Equations. Functions --------- .. autoapisummary:: maths.numerical_analysis.runge_kutta_fehlberg_45.runge_kutta_fehlberg_45 Module Contents --------------- .. py:function:: runge_kutta_fehlberg_45(func: collections.abc.Callable, x_initial: float, y_initial: float, step_size: float, x_final: float) -> numpy.ndarray Solve an Ordinary Differential Equations using Runge-Kutta-Fehlberg Method (rkf45) of order 5. https://en.wikipedia.org/wiki/Runge%E2%80%93Kutta%E2%80%93Fehlberg_method args: func: An ordinary differential equation (ODE) as function of x and y. x_initial: The initial value of x. y_initial: The initial value of y. step_size: The increment value of x. x_final: The final value of x. Returns: Solution of y at each nodal point # exact value of y[1] is tan(0.2) = 0.2027100937470787 >>> def f(x, y): ... return 1 + y**2 >>> y = runge_kutta_fehlberg_45(f, 0, 0, 0.2, 1) >>> float(y[1]) 0.2027100937470787 >>> def f(x,y): ... return x >>> y = runge_kutta_fehlberg_45(f, -1, 0, 0.2, 0) >>> float(y[1]) -0.18000000000000002 >>> y = runge_kutta_fehlberg_45(5, 0, 0, 0.1, 1) Traceback (most recent call last): ... TypeError: 'int' object is not callable >>> def f(x, y): ... return x + y >>> y = runge_kutta_fehlberg_45(f, 0, 0, 0.2, -1) Traceback (most recent call last): ... ValueError: The final value of x must be greater than initial value of x. >>> def f(x, y): ... return x >>> y = runge_kutta_fehlberg_45(f, -1, 0, -0.2, 0) Traceback (most recent call last): ... ValueError: Step size must be positive.