Skip to content

Repository files navigation

centl

A calculator first, a language when needed.

CENTL is a calculator-first numerical language. Write mathematics directly, interactively or in scripts, without programming ceremony. It is exact by default, explicit about approximation, and never prints an unjustified digit.

You should not need to become a programmer to calculate or abandon mathematical rigor to program.

CENTL 0.10.0 adds exact finite sequences and first-order recurrences, verified exact roots for real quadratics, a more capable calculator input experience, durable cross-process history, local runtime diagnostics, stack-safe exact rendering, and deterministic hardening and performance gates.

Principles

  • Typing an expression produces an answer immediately.
  • A script is simply a saved sequence of calculator expressions and definitions.
  • Ordinary mathematics requires no imports, boilerplate, entry points, or type declarations.
  • Integers, decimals, and fractions are exact by default.
  • Approximation and rounding are always visible and intentional.
  • Advanced capabilities appear gradually without changing the basic language.
  • Error messages explain the mathematics, not compiler internals.

Try it

Install a native Linux or macOS release without a compiler toolchain:

curl -fsSLO https://raw.githubusercontent.com/chasebryan/centl/main/install
less install
sh install
centl 'solve(x^2 - 5*x + 6 = 0, x)'

On Windows PowerShell:

Invoke-WebRequest https://raw.githubusercontent.com/chasebryan/centl/main/install.ps1 -OutFile install.ps1
Get-Content .\install.ps1
Unblock-File .\install.ps1
.\install.ps1
centl 'solve(x^2 - 5*x + 6 = 0, x)'

From a source checkout with the development toolchain installed:

make test
./centl '0.1 + 0.2'
./centl 'diff(x^3 + 2*x + 1, x)'
./centl 'integrate(3*x^2 + 2*x + 1, x)'
./centl 'integrate(x^2, x = 0, 1)'
./centl 'factor(x^2 - 1)'
./centl 'solve(x^2 - 5*x + 6 = 0, x)'
./centl 'solve(x^2 = 2, x)'
./centl 'sum(k^2, k = 1, 100)'
./centl 'sequence(k^2, k = 1, 5)'
./centl 'recurrence(1, a = a*n, n = 0, 5)'
./centl 'distance(0, 0, 3, 4)'
./centl 'approx(sin(pi / 6), 20)'
3/10
3 * x^2 + 2
x^3 + x^2 + x
1/3
(x - 1) * (x + 1)
x in {2, 3}
x in {-sqrt(2), sqrt(2)}
338350
[1, 4, 9, 16, 25]
[1, 1, 2, 6, 24, 120]
5
≈ [0.49999999999999999999, 0.50000000000000000001]

Run ./centl for the calculator, ./centl --syntax for every implemented form, ./centl --file path for a script, ./centl --serve for persistent JSON Lines, or ./centl --mcp as a local AI tool. Mathematical output is colored when written to a terminal; use --color=always, --no-color, or NO_COLOR to control it.

Calculator sessions and scripts remember immutable definitions written as r = 3 or f(x) = x^2 + 1.

In an interactive terminal, incomplete statements continue at a ....> prompt. Tab completes built-in and session-defined names, Up/Down browse the bounded history saved across calculator processes, and :history or :clear-history inspect or durably clear it. Standard-input and --file scripts use the same multiline statement rules. Human syntax errors identify the source line and column and show a caret at the failing byte.

History is stored as private, versioned state at $XDG_STATE_HOME/centl/history.json on Unix, falling back to $HOME/.local/state/centl/history.json, and at %LOCALAPPDATA%\centl\history.json on Windows. It is capped at 1,000 entries and 1 MiB, and concurrent calculator processes merge additions under a lock before an atomic replacement. Use --no-history, set CENTL_NO_HISTORY, or set CENTL_HISTORY=off to retain Up/Down history only for the current process. The syntax guide documents paths, privacy, concurrency, limits, and the disk-format policy.

Developer quickstart

New to OCaml, F*, or rigorous numerics? Follow the complete manual contributor onboarding. See CONTRIBUTING.md for system prerequisites, the pinned F* setup, and the reproducible opam bootstrap. Once those are installed:

scripts/bootstrap-opam
eval "$(opam env --switch=centl)"
make test

Design

CENTL is in early development. See the architecture, near-term product design path, complete syntax sheet, numerical contract, calculus syntax, algebra syntax, mathematical functions, exact finite iteration and sequences, installation and binary releases, verification boundary, performance contract, machine protocol, MCP adapter, and roadmap. Release history is summarized in the changelog.

License

SPDX-License-Identifier: AGPL-3.0-or-later

Releases

Contributors

Languages