NumInt is a Python tool to approximate definite integrals using standard numerical methods: Left-hand, Right-hand, Midpoint, Trapezoid, and Simpson. It supports both interactive input and CLI commands.
- Approximate definite integrals with 5 standard numerical methods.
- Compute absolute error compared to the exact integral (when possible).
- Supports constants like
piande. - Interactive prompts or CLI arguments.
Clone the repository:
git clone https://github.com/Drain-Man/NumInt.git
cd NumIntInstall dependencies:
pip install -r requirements.txtInteractive Mode: Run the program and follow the prompts:
python main.pyYou will be asked for:
- Function
f(x)(e.g.,sin(x)+x^2) - Lower and upper bounds
- Number of subintervals
- Approximation method
CLI Mode:
python main.py --function "sin(x)" --lower 0 --upper pi --n 100 --method simpsonParameters:
--function: Function to integrate (supports^for exponentiation)--lower: Lower bound of interval--upper: Upper bound of interval--n: number of subintervals--method: Approximation method (left,right,center,trapezoid,simpson)--version: Show program version and exit
NumInt parses functions using SymPy, allowing many standard mathematical expressions.
Examples:
sin(x)
cos(x)
x^2 + 3*x
exp(x)
sqrt(x)
Logarithms follow SymPy syntax:
log(x) # natural logarithm (ln)
log(x, 10) # base-10 logarithm
NumInt also supports:
ln(x)
which is treated as an alias for log(x).
Constants supported:
pi
e
Pre-built Windows Executable: Windows users can run NumInt without installing Python
-
Download the Windows executable from the Releases section: https://github.com/Drain-Man/NumInt/releases
-
Run from the command line with CLI arguments:
...\NumInt.exe --function "x^2" --lower 0 --upper 1 --n 10 --method trapezoid- Run the
.exewithout CLI Arguments to use in interactive mode. Note: This Version is v1.0. Future releases may include updated binaries.
Building the Windows Executable Yourself:
If you prefer to build the .exe locally (e.g. for a newer version):
# Install PyInstaller if not installed
pip install pyinstaller
# From the project root
pyinstaller --onefile --name NumInt --icon Resources\NumInt.ico main.pyThe .exe will appear in the dist/ folder.
Interactive Example:
Enter a function f(x): sin(x)
Enter the lower boundary of the interval: 0
Enter the upper boundary of the interval: pi
Enter the number of subintervals: 8
Enter the type of approximation
1: Left
2: Right
3: Center
4: Trapezoid
5: Simpson
(Enter number or name): simpson
Simpson approximation: 2.00026917
Exact value: 2
Absolute error: 2.692e-04
If you want to run NumInt.exe from any folder without typing the full path:
- Move
NumInt.exeto a permanent location (e.g.C:\Program Files\NumInt\) - Open Environment Variables with
sysdm.cpl-> Advanced -> Environment Variables. - Under "User variables" or "System variables", edit the
Pathvariable and add the folder containingNumInt.exe. - Ok -> Ok -> Ok
- Open a new Command Prompt and test:
NumInt.exe --versionAll notable changes to this project are documented in CHANGELOG.md.
- SymPy – Python library for symbolic mathematics. https://www.sympy.org/