Back to Projects

Package of Solution of ODE

Github Repository

Project Abstract

We have developed a comprehensive Python package for solving Ordinary Differential Equations (ODEs) using various numerical methods. This package efficiently handles both first-order and second-order ODEs, implementing methods such as Euler’s Method, Modified Euler’s Method (Heun’s Method), Runge-Kutta Methods (RK2, RK4), Taylor Series Method, Milne’s Predictor-Corrector Method, Adams-Bashforth Predictor-Corrector Method, and Runge-Kutta for Second-Order ODEs. Designed for students, researchers, and professionals in Applied Mathematics, Engineering, and Computational Science, it provides high accuracy and performance in solving differential equations. The package is ideal for mathematical modeling, engineering simulations, and computational science applications, where analytical solutions are impractical.

Project Supervisor

Dr. R.P. Singh and Dr. Harshita Madduri ( Assistant Professor, Department of Mathematics NIT Kurukshetra )

Project Collaborator

Mamta Saini (M.Sc. Mathematics NIT Kurukshetra, ML and DA expert)

ODE Solver Python Package

Numerical Methods for Solving Ordinary Differential Equations (ODEs) in Python

This repository contains Python implementations of various numerical methods for solving first-order and second-order ordinary differential equations (ODEs).

1st Order ODE Methods

Euler's Method

$$ y_{n+1} = y_n + h f(x_n, y_n) $$
def euler(f):
          ...  # Implementation of Euler's method
      

Modified Euler's Method (Heun's Method)

$$ y^* = y_n + h f(x_n, y_n) $$ $$ y_{n+1} = y_n + \frac{h}{2} [ f(x_n, y_n) + f(x_{n+1}, y^*) ] $$
def modified_euler(f):
          ...  # Implementation of Modified Euler's method
      

Runge-Kutta 2nd Order Method (RK2)

$$ k_1 = h f(x_n, y_n) $$ $$ k_2 = h f(x_n + h, y_n + k_1) $$ $$ y_{n+1} = y_n + \frac{1}{2} (k_1 + k_2) $$
def rk2(f):
          ...  # Implementation of RK2 method
      

Runge-Kutta 4th Order Method (RK4)

$$ k_1 = h f(x_n, y_n) $$ $$ k_2 = h f(x_n + \frac{h}{2}, y_n + \frac{k_1}{2}) $$ $$ k_3 = h f(x_n + \frac{h}{2}, y_n + \frac{k_2}{2}) $$ $$ k_4 = h f(x_n + h, y_n + k_3) $$ $$ y_{n+1} = y_n + \frac{1}{6} (k_1 + 2k_2 + 2k_3 + k_4) $$
def rk4(f):
          ...  # Implementation of RK4 method
      

How to Use This Package

Step 1: Clone the Repository

$ git clone https://github.com/manojms3063/ODE-solver-python-package
      $ cd ODE-solver-python-package
      

Step 2: Install Dependencies

$ pip install numpy sympy

Step 3: Run Examples

import numpy as np
      import sympy as smp
      from (folder name where you have saved all 3 files) import euler, rk4, ...
      
      def f(x, y):
          return x + y
      
      rk4(f)
      

Creating a Python Package

To create your own Python package:

from setuptools import setup, find_packages
      
      setup(
          name='numerical_ode_methods',
          version='1.0',
          packages=find_packages(),
          install_requires=['numpy', 'sympy'],
      )

Publishing to PyPI

$ python setup.py sdist bdist_wheel
      $ twine upload dist/*
      
Back to Projects