Skip to content

muhammadalmaskhan/ncpy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ncpy

PyPI Version License Downloads Python Versions GitHub Stars Last Commit Open Issues

ncpy Numerical Computing in Python.

ncpy is a compact, educational Python library that implements common numerical methods for quick prototyping and expermentations.
Built on NumPy and (optionally) SciPy, it offers easy-to-use functions for:

  • Root finding
  • Interpolation
  • Curve fitting / Approximation
  • Numerical integration
  • Numerical differentiation
  • Solving linear systems
  • Best Approximations

Why use ncpy?

One package, many methods : no need to import multiple libraries
Lightweight & beginner-friendly : great for teaching & learning numerical methods
Educational : functions are implemented clearly for understanding algorithms
Fast enough : powered by NumPy for efficiency


✨ Features Overview

Category Methods
Root-finding Bisection, Newton–Raphson, Secant, Fixed-point iteration
Interpolation Lagrange, Newton divided differences, Linear, Cubic spline, Neville’s method
Approximation Polynomial least squares, Exponential fit, Logarithmic fit
Integration Trapezoidal, Simpson 1/3, Simpson 3/8, Romberg, Gaussian quadrature
Differentiation Forward, Backward, Central differences, Richardson extrapolation, Numerical gradient
Linear Systems Gaussian elimination, Gauss–Jordan, LU decomposition, Jacobi, Gauss–Seidel, Conjugate Gradient
Best Approximations Least Squares, Gram–Schmidt Orthonormalization

Examples


  • Root finding - Newton Raphson
from ncpy import newton_raphson

f = lambda x: x**2 - 2
df = lambda x: 2*x

root = newton_raphson(f, df, x0=1.0)
print("Root:", root)  # ~1.4142
  • Interpolation — Lagrange
from ncpy import lagrange_interpolation

x_points = [0, 1, 2]
y_points = [1, 3, 2]
print(lagrange_interpolation(x_points, y_points, 1.5))
  • Numerical Integration — Simpson's 1/3 Rule
from ncpy import simpson13
import math

area = simpson13(math.sin, 0, math.pi, n=100)
print(area)  # ~2.0

📦 Installation

pip install ncpy

📍 Visitors

```

About

Compact educational Python library for numerical methods

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages