Basic · Scientific · 2D graph · 3D surface — all modes, zero deps
0
This is a four-mode calculator that runs entirely in the browser: basic arithmetic, scientific functions, 2D function graphing (up to six simultaneous equations), and 3D surface plotting with mouse-drag rotation. No dependencies, no server — the expression evaluator, canvas renderer, and 3D mesh are all hand-rolled TypeScript.
The 2D graphing mode is Desmos-like: type a function of x, see it plotted, pan and zoom with the mouse. The 3D mode takes functions of two variables (z = f(x,y)) and renders them as colored wireframe meshes — useful for visualizing optimization landscapes, wave functions, and any math that lives in three dimensions.
Basic / Scientific mode — type an expression and press Enter or click Equals. The evaluator handles precedence, parentheses, and all standard functions. Scientific mode adds trig, inverse trig, logarithms, and factorials.
2D graphing mode:
y = f(x). The y = prefix is implied — just enter the right-hand side (e.g., sin(x), x^2 - 3).3D surface mode:
sin(sqrt(x^2 + y^2)), x^2 - y^2).Expression evaluator — all modes share a hand-written recursive descent parser. It handles operator precedence, nested parentheses, and function calls via new Function() in a sandboxed context with no network access.
2D graphing — each equation is sampled at 800 points across the visible x range. The sampler detects discontinuities (NaN returns, or function value jumps exceeding 2× the canvas height in graph units) and lifts the pen, avoiding false lines drawn across vertical asymptotes. This is why 1/x doesn’t show a vertical line at x=0.
3D surface — a quad mesh is generated at n × n grid points over the x/y range, where n is the resolution setting. Each quad is split into two triangles, z-colored using a blue–green–yellow–red heatmap gradient mapped to the normalized z range. Rendering uses the Painter’s algorithm (back-to-front sort) for depth-correct occlusion — no WebGL required.
Expression syntax supported across all modes:
| Symbol | Meaning |
|---|---|
+ - * / | Basic arithmetic |
^ | Exponentiation (e.g. x^2) |
sin(x) cos(x) tan(x) | Trigonometric (radians) |
asin(x) acos(x) atan(x) | Inverse trig |
log(x) | Base-10 logarithm |
ln(x) | Natural logarithm |
sqrt(x) | Square root |
abs(x) | Absolute value |
exp(x) | e^x |
pi e | Constants |
Mathematical visualization is one of the most underused debugging techniques in software engineering. Before implementing a mathematical function — a smoothing curve, a decay schedule, a price model — plot it. See if the shape matches your intuition. Catch domain errors (negative inputs to square roots, division by zero) before they appear as NaN values in production.
Use cases where 2D graphing saves debugging time:
base^attempt) to verify it doesn’t explode on high retry counts3D graphing is uniquely useful for understanding optimization landscapes. Plotting a loss function z = (x-2)^2 + (y-1)^2 shows the bowl shape that gradient descent navigates. x^2 - y^2 (a saddle point) makes the saddle-point problem in non-convex optimization instantly visual. sin(x)*cos(y) shows why periodic functions have multiple local minima.
Parametric thinking — even without explicit parametric mode, you can plot related equations simultaneously. Plot x^2, x^2 - 1, x^2 + 1 to visualize vertical translation. Plot sin(x) and sin(2x) to see frequency doubling. The six-equation limit is enough for most comparison tasks.
sin(x * pi / 180). This is stated in the limitations but worth remembering — sin(90) returns -0.85, not 1.0.1/(x-2) to see how the discontinuity detection works. The graph correctly lifts the pen at x=2 rather than drawing a spurious vertical line.abs(x) to plot piecewise-linear functions: abs(x - 2) + abs(x + 1) is a valid piecewise linear plot. Useful for visualizing L1 regularization terms.new Function() — standard browser JavaScript sandbox. No network access is possible from within it.x * pi / 180 to convert degree input.For informational purposes only. Not financial, medical, or legal advice. You are solely responsible for how you use these tools.