Methodology

How the calculations run, why we picked the formulas we did, and how the AI explanations are produced. Updated June 2026.

Where the math happens

Every calculator on this site runs locally in your browser. There is no API call, no server roundtrip, and no data sent anywhere when you click "Calculate". The calculator engine is a single JavaScript file (calculator-engine.js) that lives in your browser cache after the first page load. This matters for three reasons: results come back in milliseconds, your inputs never leave your device for ordinary calculations, and the calculator continues to work even if our servers are down.

The exception is "AI Solve", which is a separate button. AI Solve does call our server, which then calls an upstream LLM provider. We discuss that path further down.

Why we use these specific formulas

For many geometry problems there are multiple correct formulas — but they differ in numerical behavior near edge cases. We pick the more stable variant even when it is longer. Three examples:

  • Heron's formula (area from three sides). The textbook form A = √(s(s-a)(s-b)(s-c)) where s = (a+b+c)/2 works fine for well-formed triangles but loses precision when the triangle is nearly degenerate (a + b ≈ c). We use Kahan's stable rearrangement 16A² = (a + (b+c))(c - (a-b))(c + (a-b))(a + (b-c)), evaluated in descending side-length order. The two formulas agree to 4 decimal places on textbook inputs and disagree by orders of magnitude near the degenerate boundary.
  • Law of Cosines vs Law of Sines for angle recovery. When solving SSS (three sides), the Law of Cosines gives a unique angle for each vertex via cos C = (a² + b² − c²) / (2ab). We use this in preference to recovering angles via the Law of Sines, because the Law of Sines is multivalued — the arcsin step has two solutions in (0°, 180°) and you have to manually pick the right branch. SSS via Law of Cosines is single-valued and stable.
  • SSA ambiguous case. When you give us two sides and an angle opposite one of them (the SSA pattern), the answer may be zero, one, or two valid triangles depending on the relationship between the side lengths and the given angle. We do not pretend this away — the Triangle Solver returns the primary acute solution and, when a second obtuse solution exists, attaches an "ambiguous_note" result showing both. The branch logic and worked example are on the Triangle Solver page.

Numerical precision

All calculations use IEEE 754 double-precision floating point (the standard JavaScript Number type, providing about 15-17 significant decimal digits). Where a result is sensitive to rounding — for example, the inverse trigonometric functions near ±1 — we clamp the input to the valid domain before evaluation. The helper gcAcos(x) evaluates Math.acos(Math.max(-1, Math.min(1, x))) so that a value of 1.0000000001 produced by accumulated floating-point error returns 0° rather than NaN.

Results are shown to 4 decimal places by default, but the underlying calculation retains full double precision. We do not truncate intermediate values during the calculation chain.

The 22-case validation suite

Before every release we run an automated test suite of 22 cases drawn from textbook references. Sample entries include:

  • Heron's formula on a 3-4-5 right triangle (expected area = 6.0000)
  • SSA ambiguous case at a = 6, b = 8, A = 35° (expected primary angle B ≈ 49.886°)
  • Pythagorean theorem with mixed real and integer inputs
  • Sphere volume and surface area at r = 1 (expected 4π/3 and 4π)
  • Regular polygon interior angle sum and individual interior angle at n = 12

Each case has a tolerance (typically 0.001) that the implementation must meet. Failures block the release. Administrators can view the live suite at ?gc_calc_self_test=1 on any page.

How AI Solve works

The "AI Solve" button is a separate code path from the calculator. When you click it, the inputs you typed are sent — along with a system prompt that instructs the model to explain the solution step-by-step in the style of a textbook — to one of the following LLM providers:

  • Anthropic Claude — for proof-style problems (congruence, similarity, geometric reasoning)
  • OpenAI GPT — for general geometry computation explanations
  • DeepSeek v4 — for visual / photo-input problems via DeepSeek-VL

The routing is set per-calculator type — each calculator config declares an ai_purpose field (one of general / proof / reasoning / vision) and the AI handler picks the best-fit provider. If the configured provider is unavailable, we fall back to the next provider with the same capability.

The numeric answer above the AI explanation is always the deterministic output of our calculator engine — it is not generated by the LLM. The LLM's job is to explain that number, not to recompute it. If the LLM's text appears to reach a different number, trust the calculator. See our Editorial Policy for our corrections process.

Limitations and what we do not compute

Geometry Calculator covers two-dimensional and three-dimensional Euclidean geometry, plane analytic geometry, and standard trigonometry. We do not currently support:

  • Non-Euclidean geometry (hyperbolic, elliptic, projective)
  • Differential geometry (curvature, tangent spaces, geodesics on curved surfaces)
  • Algebraic geometry (varieties, schemes, intersection theory)
  • Topology beyond the basic shape-classification level

Some advanced calculators on the site touch the boundary of these areas (for example, parametric curves on the coordinate plane). We mark those as Advanced (P2 priority) in the calculator listing and recommend you cross-validate results against a CAS tool like Mathematica or SymPy for production work.