Calcigral
Simple integral calculator in Haskell
What is Calcigral
Calcigral is a simple command-line utility for approximating the value of definite integrals with one variable over a real line.
Features
- Three approximation strategies:
Rectangle
,Trapezoid
,Paraboloid
- Can approximate up to any absolute error
- Supports $-\infty$, $+\infty$ approximation bounds
- Function input: any haskell function using
Prelude
- Command-line interface
Examples
Simple
Evaluate $I = \int \limits_0^1 \sin(x) dx = 1 - \cos 1 \approx 0.45969…$
$ calcigral 0 1 sin
Strategy: Rectangle
IntegralResult {value = 0.459997112932708, steps = 15}
===
Strategy: Trapezoid
IntegralResult {value = 0.45954804321221476, steps = 62}
===
Strategy: Paraboloid
IntegralResult {value = 0.45970774492731087, steps = 18}
===
Note: Default max absolute error is 1e-3
Infinite bounds
Evaluate $I = \int \limits_{-\infty}^{\infty} e^{-x^2} dx = \sqrt \pi \approx 1.77245385…$
$ calcigral MinusInfinity PlusInfinity '\x -> exp (-x * x)' 0.001 1000 -s Paraboloid
Strategy: Paraboloid
IntegralResult {value = 1.7724624243349956, steps = 276}
===
Diverging
Evaluate $I = \int \limits_{0}^{1} \frac{1}{x} dx = \ln 1 - \ln 0 \rightarrow \infty$
$ calcigral 0 1 '\x -> 1 / x' -s Rectangle
Strategy: Rectangle
Diverging
===
Goals of this project
This utility is a educational project for the JetBrains Functional Programming course (Fall 2022) at Constructor University. Hence, the goals of this project are educational.
License
This project is BSD-3-Clause licensed