About
What is Math sketchbook?
Math sketchbook is a programming IDE for math.
It provides real-time evaluation and solutions to expressions and equations.
This tool is primarily designed for programmers, with extra attention to linear algebra, which is useful in game development.
It's not a symbolic math engine, it only performs numerical calculations. This is enough in most cases.
How can Math sketchbook help me?
Assistance
Unlike Wolfram|Alpha, Math sketchbook doesn't attempt to fully solve the problem at hand, instead it assists the user in solving it.
The benefit of this approach is the flexibility that it provides. This assistance works in equations and equation systems, which other tools cannot solve; and it also works in more custom situations (like reorganizing an expression), that other tools don't cover.
The entered equations are solved numerically (even quite complex ones) and the solutions are used to verify every transformation or simplification of the equation, helping to highlight any mistakes.
Constant values may be entered for variables used in an expression. This can be later used to verify transformations made to the expression, similar to equations.
I've made an example to show this.
Sketches
In case you need to do quick calculations, try out a new formula, while coding for example, Math sketchbook can be quite convenient to perform these calculations.
Transferring mathematical expressions between the source code and this app is straightforward. Standard syntax for mathematical expressions is employed.
Math sketchbook is also quite convenient when calculations have to be done repeatedly with different values, because it supports defining and reusing constants.
Features
Code editor
Mathematical expressions and equations can be edited like any source code. This allows entering several expressions at once.
The entered expressions are persistent: they remain there after reloading the page.
Errors and warnings are presented in the same manner as they typically appear in programming IDEs.
The code editor integrated into this website is Code Mirror. It has a lot of customizations, including the widgets that display the results of each calculation.
Evaluation engine
The evaluation engine is running on a web worker, so it doesn't interrupt the UI.
Changes to the document are evaluated incrementally to speed up the calculations.
The custom evaluation engine implements:
- parsing syntax
- splitting the document into independent chunks
- evaluating expressions
- generating meaningful errors/warnings
- verifying results
Solving equations
The custom evaluation engine does not handle the solution of equations and equation systems. This task is performed by a third-party library called Nerdamer.
It provides numerical solutions to equations. It is not restricted to solving a few simple equation types. It will evaluate anything as long as its algorithm converges on a result (which can handle quite a lot).
One limitation is that generally it won't find multiple solutions. Nerdamer does support multiple solutions for quadratic equations, but this hasn't been exposed on the interface.
Tech stack
Math sketchbook is an SPA (single page application). Pages are pre-rendered at build time to provide meta tags for both SEO and for social media. This also speeds up the initial load times, but not significantly.
I used the following tools to create this web app:
- React
- Typescript
- Vite
- SCSS (no framework for CSS)
- Code Mirror: the code editor
- Nerdamer: math lib to solve equations