Practical mathematics for Free Pascal.
Scientific, statistical, financial, engineering, and machine-learning tools—with no third-party runtime dependencies.
- Broad: 12 focused domains, from matrices and probability to geometry and ARIMA.
- Native: written for FPC 3.2.2+ in
objfpcmode. - Lightweight: use only the units you need; no third-party runtime dependencies.
- Ready to explore: searchable reference docs, runnable examples, and a release-qualified automated suite.
Note
1.9.3 is the current release; 1.2.0 was the first public release. The project follows semantic versioning; read the release notes and changelog when upgrading.
Open the 1.9.3 release page
or download the source directly as
.tar.gz
or .zip.
You can also clone the repository:
git clone https://github.com/ikelaiah/mathlib-fp.git
cd mathlib-fpSave this as my_program.pas:
program hello_mathlib;
{$mode objfpc}{$H+}
uses
ProbabilityLib.Distributions;
begin
Writeln('P(Z <= 1.96) = ', TProbabilityKit.NormalCDF(1.96, 0, 1):0:6);
end.Expected output:
P(Z <= 1.96) = 0.975002
Compile it with src/ on the unit search path:
mkdir -p lib
fpc -Fusrc -FUlib my_program.pas
./my_programUsing Lazarus? Add src/ under Project Options → Compiler Options → Paths → Other Unit Files, or install the mathlib-fp package from packages/lazarus/mathlib_fp.lpk.
| Domain (unit family) | Highlights |
|---|---|
| MathBase | Shared types, constants, precision, local RNG state, bounded expressions, and numerical interchange |
| AlgebraLib | Compatibility matrices, typed dense storage/solvers, and structured/sparse/matrix-free solvers |
| FinanceLib | TVM, bonds, NPV/IRR, options, risk metrics |
| StatsLib | Descriptive/streaming statistics, paired distributions, inference, regression diagnostics, and bootstrap |
| EngineeringLib | Fluids, thermodynamics, batch/block DSP, and unit conversion |
| NumericsLib | Roots, interpolation, fitting, differentiation, adaptive integration and ODEs |
| ProbabilityLib | Continuous and discrete distributions |
| CombinatoricsLib | Counting, sequences, number theory, permutations |
| OptimizationLib | Diagnostic scalar/multivariate/constrained optimisation, two-phase LP, dense convex QP and SOCP |
| TimeSeriesLib | Smoothing, decomposition, ARIMA, anomaly detection, and scalar/multivariate Kalman filtering |
| MLLib | Leakage-safe preprocessing, regression/classification, typed clustering/PCA/LDA/forests, and exact neighbours |
| GeometryLib | 2-D/3-D geometry, vector arithmetic, and scale-safe norms |
All public units live in src/; the domains can be used independently unless
their documentation says otherwise. See the
terminology and API naming inventory for the
difference between domains, units, and Kit classes.
The examples/ directory contains 24 commented walkthroughs with
at least one runnable program for every domain. Newcomers can follow the
beginner guide, choose a short task from the
beginner recipes, or follow the
example index and suggested learning path. Compile one in
seconds:
cd examples
mkdir -p lib
fpc -Fu../src -FUlib 00_getting_started.pas
./00_getting_startedOn Windows, run the generated .exe instead. Start with the
versioned web documentation or the
repository documentation index for offline use. The release
page also provides the generated offline HTML archive and its SHA-256 checksum.
To compile all examples into example-bin/ from the repository root, run
sh ./build-examples.sh or .\build-examples.ps1. See the
example guide for compiler-path
options.
Bug reports and pull requests are welcome. For first-use friction, use the focused 1.9 feedback route. See CONTRIBUTING.md to get started, or run the full test suite locally:
cd tests
mkdir -p lib
fpc -Fu../src -FUlib TestRunner.lpr
./TestRunner -a --format=plainMaintainers preparing a distribution should follow the release checklist. The project roadmap describes the quality-first path toward a comprehensive native Free Pascal numerical package.
MIT © the mathlib-fp contributors.
Originally extracted from tidykit-fp.