formula.cfored.com · docs · cbmas-orb-formulas v0.1

Solver Toolkit

Tools for solving formulas and equations — symbolic, numeric, step-by-step, and graphical — and how each class is used to independently verify the formulas in this library. The library's discipline is that no implementation certifies itself: every export is pinned to a canonical value or cross-checked by at least one tool from this page. Formula details live in the searchable index.

01 — TOOL MAP · WHICH SOLVER FOR WHICH JOB

Four solver classes, one selection rule

Exact answer wanted → symbolic. Number wanted from a formula with no closed form → numeric. Learning or auditing the derivation → step-by-step. Building intuition about roots, intersections, and shape → graphing.

ClassToolsSolvesReaches its limit when
Symbolic (CAS)SymPy · WolframAlpha · pen-input CAS apps (Derive-style handwriting canvases)Exact antiderivatives, closed-form roots, algebraic simplification, ODEsNo elementary closed form exists — most real pricing integrals
NumericSciPy · NumPy · MATLAB / OctaveQuadrature, root-finding, optimization, linear systems — to machine precisionYou need the form of the answer, not its value
Step-by-step webeMathHelp Integral Calculator · WolframAlpha Pro steps · SymbolabWorked derivations with each rule named — audit-grade paper trailExpressions exceed textbook size; no programmatic reuse
GraphingDesmos · GeoGebraRoots as x-intercepts, equilibria as intersections, sensitivity by sliderYou need more than ~3 significant figures
02 — SYMBOLIC · EXACT FORMS FIRST

SymPy, WolframAlpha, pen-input CAS

A CAS answers with a formula, not a float. Use it to confirm the algebra this library hard-codes — breakeven identities, parity relations, closed-form Greeks — before trusting any numeric agreement.

# Gate 5 breakeven: solve EV(p) = p·RR − (1−p) = 0 exactly
>>> from sympy import symbols, solve, Rational
>>> p, rr = symbols("p rr", positive=True)
>>> solve(p*rr - (1 - p), p)
[1/(rr + 1)]                      ← breakeven_win_rate, exact
>>> solve(p*Rational(3,2) - (1-p) - Rational(1,4), p)
[1/2]                             ← EV floor 0.25R at R:R 1.5 ⇒ p* = 50%
Pen-input canvases (Derive-style apps) put a CAS behind handwriting recognition — fastest for whiteboard-speed checks of a derivative or a rearrangement, but the recognized expression must be re-read before the answer is trusted: a mis-read exponent solves the wrong equation confidently.
03 — NUMERIC · SCIPY AS THE WORKHORSE

quad · brentq · fsolve · linprog

When the closed form runs out, SciPy turns the formula into a number to machine precision. The library itself keeps SciPy as an optional extra — NumPy core stays dependency-light; SciPy powers the CVaR LP solver and the verification bench.

# Verify Black-Scholes 10.4506 (Hull) by brute-force quadrature
>>> from scipy.integrate import quad; from numpy import exp, log, sqrt, pi
>>> S,K,r,T,s = 100,100,.05,1,.20
>>> f = lambda z: exp(-z*z/2)/sqrt(2*pi) * \
...     max(S*exp((r-s*s/2)*T + s*sqrt(T)*z) - K, 0)
>>> exp(-r*T) * quad(f, -10, 10)[0]
10.450583572534535                ← black_scholes_call gives 10.450583572186:
                                     agreement to 9 decimals (quad tolerance)

# Root-find the same Gate 5 boundary numerically
>>> from scipy.optimize import brentq
>>> brentq(lambda p: p*2.5 - 1 - 0.25, 0, 1)
0.5                               ← agrees with the CAS and the library
Three independent answers or it isn't verified. Formula (library) · quadrature (SciPy) · canon (Hull). When all three agree to tolerance, the export is pinned in CI — that is how the 10.4506 test in this repo was built.
04 — STEP-BY-STEP · THE AUDIT TRAIL

Integral calculators with steps shown

Web solvers like eMathHelp's Integral Calculator return not just the answer but each rule applied — substitution, parts, table lookup. That is a derivation audit trail: the same posture as this stack's gate audits, where the verdict must be reproducible line by line.

∫ cos(x²) dx                       ← the calculator's own example
  = √(π/2) · C(√(2/π)·x) + K      Fresnel C — no elementary form

The example is chosen well: it looks innocent and has no elementary antiderivative. A step-by-step solver proves that honestly (it names the Fresnel special function) where a naive symbolic attempt just stalls — the tool tells you which class of answer exists before you spend time hunting for one that doesn't.

Steps are for auditing, not for production. Anything that feeds the pipeline is re-implemented in the library with a pinned test; a screenshot of a solver's steps is documentation, never a dependency.
05 — GRAPHING · SEE THE ROOT BEFORE SOLVING IT

Desmos and GeoGebra

Plot the two sides of an equation and the solution is the intersection; plot f and the roots are the x-intercepts. For this library's decision math, Desmos is the fastest way to see the gate geometry before trusting any solver's number.

# Paste into Desmos — Gate 5 in two curves:
f(p) = p·(1 + 1.5) − 1             EV at R:R = 1.5
y = 0.25                           the EV floor
→ intersection at p = 0.5          the charter worked number

# Supply–demand equilibrium (derivatives §26):
Q = 400 − 2P                       demand
Q = −100 + 2P                      supply
→ intersection at P* = 125, Q* = 150
Sliders are sensitivity analysis. Put R:R on a slider and watch the breakeven intersection slide along 1/(1+RR) — the fastest intuition pump for why the EV gate tightens as targets shrink.
06 — HOW THIS LIBRARY USES THE TOOLKIT

Every export answers to an outside solver

Library exportVerified againstPinned value / identity
black_scholes_callHull canon + SciPy quadrature10.4506 at S=K=100, r=5%, σ=20%, T=1
breakeven_win_rateSymPy exact solve · Desmos intersectionπ* = 1/(1+R:R); 40% at 1.5R
ev_gate_checkbrentq root of the floor equationp* = 0.50 at floor 0.25R, R:R 1.5
cvar_lp_solve_robustSciPy linprog (the optional extra itself)Rockafellar–Uryasev LP formulation
crr_priceLattice → Black-Scholes convergencewithin 0.01 of 10.4506 at 1000 steps
linear_equilibriumDesmos/GeoGebra intersectionP* = 125, Q* = 150 on the Figure-2 lines
fokker_planck_stepAnalytic moments of the diffusionmass ≡ 1; mean drifts μ·t; variance grows σ²·t
Gate 5 in productionParity suite (library as third oracle beside MATLAB)verdict parity through the old rounding boundary
Selection rule, stated once. Reach for the CAS to know what the answer is, SciPy to know it to machine precision, a step-by-step solver to audit how, and Desmos to see why. Anything that survives all four earns a pinned CI test — and after that, the test is the tool.