Changes since the initial architecture was documented. Covers the residue theorem module, complex plane visualizations, UI redesign, and integration improvements.
Evaluates improper integrals of rational functions P(x)/Q(x) over (-inf, inf) using complex contour integration. This is the first step into complex analysis territory.
residue_theorem.rb definite_integral.rb
When a residue theorem integration runs, four plots are rendered in both the results panel and the expression tree panel:
Results panel: 4 in a row at 270px each. Tree panel: 2x2 grid at 150px each, matching tree height.
complex_plot.js
All operation forms (derivative, integrate, evaluate, gradient, differential, definite integral, residue) now auto-detect variables from the formula and present them as color-coded clickable chips instead of text inputs.
Each detected variable gets its own styled input field with matching color. No more "x 2.0 y 3.0" text format.
Definite integral and residue forms show a live number-line bar. Drag the handles to change bounds; values update in real-time. Supports infinity endpoints.
Input bar, formula display, trees, and results stay together. All example groups moved to the bottom of the page.
Four themes: Default (dark glass), Academic (cool slate-indigo), Artistic (warm amber-rose), Wild (neon green-magenta). Persists via localStorage.
Each step category gets a unique math symbol (xn for power, u-arrow for substitution, theta for trig, etc). Reduced padding and margins. Simplification steps are extra-compact.
New: integrate_mixed_pf handles denominators that factor into linear terms times an irreducible quadratic. Uses numerical point-evaluation to set up a linear system, Gaussian elimination to solve for coefficients, then integrates each part separately (ln terms for linear factors, ln+arctan for the quadratic).
Example: (x^2+1)/(x^3+3x) = (x^2+1)/(x(x^2+3))
Decomposes as 1/(3x) + (2x)/(3(x^2+3)), integrates to (1/3)ln|x| + (1/3)ln(x^2+3).
Previously returned "integral" (unsolvable). Now fully handles the general case.
rational_integration.rb
Gradient and differential form endpoints now simplify each component after computation. Previously, raw derivative output like 2*x^(2-1) + y^2*((0*ln(y) + 2*0/y)) was returned as-is. Now it simplifies to 2*x and 2*y.
New dropdown in the header with three modes:
Simplification steps are now shown in the solution steps panel with a ≈ symbol.
| Symbol | Category | Color |
|---|---|---|
∫∂ | Integration by Parts | Blue |
xn | Power Rule | Amber |
+- | Sum/Difference | Green |
∘ | Product/Chain Rule | Blue |
c | Constant | Purple |
ex | Exponential | Emerald |
∿ | Trigonometric | Cyan |
u-arrow | U-Substitution | Amber |
P/Q | Partial Fractions | Pink |
theta | Trig Identity | Teal |
sqrt | Radical/Trig Sub | Fuchsia |
div | Polynomial Division | Sky |
≈ | Simplification | Slate |
✓ | Final Result | Purple |
P and Q in partial fraction steps are now color-coded: P in red, Q in green, with quotient in blue and remainder in amber.
The client-side convertToLatex function was rewritten to handle nested parentheses correctly. The old regex /exp\(([^)]+)\)/ broke on exp(cos(x)) because [^)]+ stops at the first close paren. The new version uses a proper balanced-paren scanner, fixing all nested function rendering.
All script tags use ?v=N version parameters, incremented on each deployment, to prevent browser caching issues. This solved the initial bug where complex_plot.js wasn't loading despite being deployed.
Early version used div.innerHTML += '...' after drawing to a canvas, which serializes the canvas to HTML (losing all pixel data) then re-parses it. Fixed by using createElement + appendChild for labels.
Continued in: History Part 3: The Correctness Audit, Independent Verification & the Modern UI →
Symbolic Math Engine — Built with Ruby — Back to Engine — History Part 1 — History Part 3