Mini CAS in Haskell with symbolic calculus, numeric integration, and an interactive web interface.
1.3K
A small Computer Algebra System written in Haskell.
This project parses mathematical expressions, simplifies them, differentiates them symbolically, computes symbolic and numeric integrals, evaluates expressions safely, and visualizes the results through a minimal web interface.
It was built for the Logical & Functional Programming course, but designed as a real, self-contained system rather than a throwaway assignment.
All actual computation is done locally by the Haskell engine.
The LLM is only used to explain results, never to compute them.
The system is built around a single expression type, which keeps everything predictable and easy to follow.
Main components:
Expr – symbolic expression typeParse – hand-written recursive-descent parserSimplify – deterministic simplification rulesDifferentiate – symbolic differentiation engineIntegrate – symbolic antiderivatives and numeric integrationEval – safe numeric evaluationPretty – LaTeX-style pretty printingLLM – optional explanation layer (no computation)Main – web server, visualization, and glue logicEach module has a single responsibility and operates directly on the expression tree.
The application runs as a small web service. You can:
The interface is intentionally minimal and focuses on clarity rather than visual complexity.
The project includes a small, tightly constrained LLM module that generates short explanations of results in plain English.
Important constraints:
This keeps the system deterministic while still providing a readable explanation when desired(you need a CEREBAS API key for it).
A prebuilt multi-architecture Docker image is available.
docker run --rm -p 3000:3000 irfanuruchi/integral-calculator:latest
Then open:
http://localhost:3000
The image supports both linux/amd64 and linux/arm64, so the same command works on Windows, Linux, and macOS (including Apple Silicon).
latestv10.1.0To enable the optional LLM explanations:
docker run --rm -p 3000:3000 \
-e CEREBRAS_API_KEY=your_key_here \
irfanuruchi/integral-calculator:latest
If the key is not set, the application still runs normally.
cabal build
cabal run
The server will start on port 3000.
The goal of this project was not to build a large CAS, but to understand how such systems work internally.
Writing the parser, simplifier, and calculus rules by hand made the behavior predictable and transparent. Keeping everything centered around one expression type made symbolic transformations feel natural and easy to reason about.
The system is intentionally compact, but it covers the core ideas behind symbolic computation, numeric integration, and functional program structure.
This started as a course assignment, but it was treated as an opportunity to build something closer to a real tool — small enough to understand end-to-end, but complete enough to be genuinely useful.
The result is a minimal CAS that demonstrates how symbolic math, numeric methods, functional programming, and a lightweight web interface can fit together cleanly.
Content type
Image
Digest
sha256:33956109f…
Size
38.2 MB
Last updated
3 months ago
docker pull irfanuruchi/integral-calculator