Basic implementation 4th order Runge Kutta method for ODE's

A robust, modern implementation of the Fourth-Order Runge-Kutta (RK4) method in Python. This repository provides a highly optimized backend powered by NumPy and SymPy that can solve an arbitrary number of $N$-order ordinary differential equations (ODEs), alongside an interactive Tkinter GUI with embedded Matplotlib graphs.
numpy.ndarray for superior performance and compact logic.2 * t - 3 * y[0]); the core uses SymPy to parse, strictly validate, and efficiently compile them to native Numpy expressions.unittest suites.git clone https://github.com/JCLArriaga5/Runge-Kutta4.git
cd Runge-Kutta4
pip install -r requirements.txt
sudo apt-get install python3-tk
You can easily import and utilize the RK4 class in your own scripts.
import numpy as np
from rk4odes.rk4 import RK4
# Example 1: First-Order System
rk_1 = RK4('2 * t - 3 * y + 1')
result_1 = rk_1.solve(ti=1.0, yi=5.0, t=1.5, h=0.01)
print("1st Order Result:", result_1)
# Example 2: Second-Order System (Harmonic Oscillator y'' = -y)
# Decomposed as: y0' = y1, y1' = -y0
rk_2 = RK4(['y[1]', '-y[0]'])
result_2 = rk_2.solve(ti=0.0, yi=[0.0, 1.0], t=np.pi/2, h=0.01)
print("2nd Order Result:", result_2)
Launch the graphical app to solve and visualize systems without writing code.
cd rk4odes/GUI
python3 GUI.py

Note: The GUI supports passing multi-line equations in its text area and comma-separated initial values, allowing you to plot multiple interlocked differential curves at once.
The project includes built-in unit tests verifying numerical accuracy and error handling. You can run them via:
python3 -m unittest discover -s tests -v
This project is licensed under the MIT License - see the LICENSE file for details.