rk4odes/rk4.py
def solve(self, ti, yi, ui, t, h=0.001):
        """
        Solution of the second-order ordinary differential equation

        Parameters
        ----------
        ti : Value of the initial t
        yi : Value of the initial y
        ui : Value of the initial y'
        t : Value that you want to evaluate in the diff system
        h : Integration step

        Returns
        -------
        yi : Value of y for the t desired
        ui : Value of y' for the t desired
        """

        for _ in np.arange(ti, t, h):
            m1 = self.g(ui)
            k1 = self.f(ti, yi, ui)

            m2 = self.g(ui + k1 * h / 2)
            k2 = self.f(ti + h / 2, yi + m1 * h / 2, ui + k1 * h / 2)

            m3 = self.g(ui + k2 * h / 2)
            k3 = self.f(ti + h / 2, yi + m2 * h / 2, ui + k2 * h / 2)

            m4 = self.g(ui + k3 * h)
            k4 = self.f(ti + h, yi + m3 * h, ui + k3 * h)

            yi += (h / 6) * (m1 + 2 * (m2 + m3) + m4)
            self.ys.append(yi)

            ui += (h / 6) * (k1 + 2 * (k2 + k3) + k4)
            self.us.append(ui)

            ti += h
            self.ts.append(ti)

        return yi, ui

        Solution of the second-order ordinary differential equation

        Parameters
        ----------
        ti : Value of the initial t
        yi : Value of the initial y
        ui : Value of the initial y'
        t : Value that you want to evaluate in the diff system
        h : Integration step

        Returns
        -------
        yi : Value of y for the t desired
        ui : Value of y' for the t desired
        
Solution of the second-order ordinary differential equation
Parameters



Returns

yi : Value of y for the t desired
ui : Value of y' for the t desired
Solution of the second - order ordinary differential equation Parameters Returns yi : Value of y for the t desired ui : Value of y ' for the t desired
def solve(self, ti, yi, ui, t, h=0.001):
        for _ in np.arange(ti, t, h):
            m1 = self.g(ui)
            k1 = self.f(ti, yi, ui)
            m2 = self.g(ui + k1 * h / 2)
            k2 = self.f(ti + h / 2, yi + m1 * h / 2, ui + k1 * h / 2)
            m3 = self.g(ui + k2 * h / 2)
            k3 = self.f(ti + h / 2, yi + m2 * h / 2, ui + k2 * h / 2)
            m4 = self.g(ui + k3 * h)
            k4 = self.f(ti + h, yi + m3 * h, ui + k3 * h)
            yi += (h / 6) * (m1 + 2 * (m2 + m3) + m4)
            self.ys.append(yi)
            ui += (h / 6) * (k1 + 2 * (k2 + k3) + k4)
            self.us.append(ui)
            ti += h
            self.ts.append(ti)
        return yi, ui
def solve ( self , ti , yi , ui , t , h = 0.001 ) : for _ in np . arange ( ti , t , h ) : m1 = self . g ( ui ) k1 = self . f ( ti , yi , ui ) m2 = self . g ( ui + k1 * h / 2 ) k2 = self . f ( ti + h / 2 , yi + m1 * h / 2 , ui + k1 * h / 2 ) m3 = self . g ( ui + k2 * h / 2 ) k3 = self . f ( ti + h / 2 , yi + m2 * h / 2 , ui + k2 * h / 2 ) m4 = self . g ( ui + k3 * h ) k4 = self . f ( ti + h , yi + m3 * h , ui + k3 * h ) yi += ( h / 6 ) * ( m1 + 2 * ( m2 + m3 ) + m4 ) self . ys . append ( yi ) ui += ( h / 6 ) * ( k1 + 2 * ( k2 + k3 ) + k4 ) self . us . append ( ui ) ti += h self . ts . append ( ti ) return yi , ui
Solution of the second-order ordinary differential equation
Parameters
Solution of the second - order ordinary differential equation Parameters
"""
        Solution of the second-order ordinary differential equation

        Parameters
        ----------
        ti : Value of the initial t
        yi : Value of the initial y
        ui : Value of the initial y'
        t : Value that you want to evaluate in the diff system
        h : Integration step

        Returns
        -------
        yi : Value of y for the t desired
        ui : Value of y' for the t desired
        """
self
ti
yi
ui
t
h