Skip to content

Repository files navigation

mathlib-fp — numerical computing for Free Pascal

mathlib-fp

Practical mathematics for Free Pascal.
Scientific, statistical, financial, engineering, and machine-learning tools—with no third-party runtime dependencies.

Free Pascal 3.2.2+ Lazarus 4.8+ Version 1.9.3 CI status MIT license

✨ Why mathlib-fp?

  • Broad: 12 focused domains, from matrices and probability to geometry and ARIMA.
  • Native: written for FPC 3.2.2+ in objfpc mode.
  • 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.

🚀 Quick start

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-fp

Save 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_program

Using Lazarus? Add src/ under Project Options → Compiler Options → Paths → Other Unit Files, or install the mathlib-fp package from packages/lazarus/mathlib_fp.lpk.

🧰 What's included

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.

🧪 Try an example

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_started

On 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.

🤝 Contributing

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=plain

Maintainers preparing a distribution should follow the release checklist. The project roadmap describes the quality-first path toward a comprehensive native Free Pascal numerical package.

📄 License

MIT © the mathlib-fp contributors.

Originally extracted from tidykit-fp.

About

A focused Free Pascal math library collection for scientific, engineering, statistical, financial, optimization, time-series, machine-learning, and geometry work. The source has no third-party runtime dependencies.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

5 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages