Skip to content

Math tools, phase 9: MathEngine adapter for reference tests, series to infinity [no-new-version] - #65

Merged
simonebortolin merged 27 commits into
mainfrom
ccr-f0e25fb4-eczbl3-mathengine
Nov 15, 2026
Merged

simonebortolin merged 27 commits into
mainfrom
ccr-f0e25fb4-eczbl3-mathengine

Conversation

@simonebortolin

Copy link
Copy Markdown
Owner

Pull request #55 was merged into the branch of the graphs in space after that branch had already gone to main, so the adapter never reached main. This brings it there, with the work done on the branch since. Only samples/ and tests/ change: nothing of the packages.

The adapter of the engine of Microsoft Mathematics

samples/SharpEquations.MathTools.MathEngine/ is an optional ICasEngine over mathenginen.dll, to compare its results with AngouriMath in the reference tests. The library is never in the repository: it is looked for in MATHENGINEN_PATH, else in the program files. Windows only; MathEngineTests are skipped elsewhere.

Series to infinity

AngouriMath leaves a sum to infinity as it is. Series (samples/SharpEquations.MathTools.Core/Cas/) sums the ones whose term is a quotient of polynomials of the index, plain or with the sign of (−1)ᵏ:

  • partial fractions over the roots that are fractions, summed by the digamma function at fractions (theorem of Gauss) and by ζ(j, x) for repeated roots (Bernoulli numbers, derivatives of the cotangent);
  • a factor of degree 2 without such roots, by the residues of π cot πz: 1/(k^2+1);
  • a term that does not go to zero fast enough sums to ∞ or −∞;
  • what has no closed form (ζ(3) for 1/k^3) stays as it is.

Polynomial, RationalFunction and Fraction (SeriesAlgebra.cs) are the exact arithmetic it needs, in plain C# over BigInteger.

Tests

  • SeriesTests: 42 cases.
  • cas.json: the case of 1/k^2 is no longer pending, and 13 series are added.
  • MathEngineTests skips the series the engine of Microsoft gives back as they are.
  • On Linux: 599 passed, 179 skipped (the cases of MathEngine and the pending ones), 0 failed. The cases of MathEngine run on Windows only, with the library installed.

After this is merged, the branch ccr-f0e25fb4-eczbl3-3d has nothing left that main lacks and can be deleted.


Generated by Claude Code

claude and others added 27 commits November 12, 2026 22:13
…ight-click menu

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyVio8afJsGwHW9i5v5HDs
(cherry picked from commit 8b0b84f)
The runners now default to the .NET 11 SDK: its analyzer reports CA1860 on
Vars.Any(), and the wasm-tools workload it installs does not build net10.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyVio8afJsGwHW9i5v5HDs
(cherry picked from commit 76f710e)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyVio8afJsGwHW9i5v5HDs
(cherry picked from commit 196f85d)
The caption shows the equation forms as formulas. A check box makes a
letter one parameter for every graph, its sliders moving together. Copy
image puts the graphs on the clipboard; the graph's context menu copies
it or resets the view, and dragging pans with the left button only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyVio8afJsGwHW9i5v5HDs
(cherry picked from commit d67b73d)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyVio8afJsGwHW9i5v5HDs
(cherry picked from commit 71caa2c)
…w-version]

- Formulas carry a GraphPreset (the equation drawn, parameters at their
  starting values): a Graph button on their card draws them on the graphs page
- A "Curves" subject, the normal distribution, damped oscillation, projectile
- Graph parameters may be Greek letters (θ, ω, γ, μ, σ)
- Units: force and power, tablespoon and teaspoon, NIST factors
- UnicodeMath: a script whose argument ends in a fraction is parenthesized,
  so x^(2/3) reads back as written

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyVio8afJsGwHW9i5v5HDs
(cherry picked from commit 3789a8b)
…trimmed WebAssembly build can read it [no-new-version]

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyVio8afJsGwHW9i5v5HDs
(cherry picked from commit 085d96f)
…version]

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyVio8afJsGwHW9i5v5HDs
(cherry picked from commit 9b7653a)
…ion]

A 3D page between the graphs and the worksheet: surfaces z=f(x,y) and
curves x,y,z of t drawn in a box the camera turns around, a slider for
each parameter. Graph3DView draws with OpenGL through Silk.NET where
Avalonia gives a context, and with the painter's algorithm on Skia
elsewhere (in the browser, or where the context fails).

- Core: SurfacePlot, the equation of a graph in space and its parameters
- Graphing: Scene3D (meshes and curves in the cube, poles clipped),
  OrbitCamera, Painter3D
- the remove buttons use ×, which the bundled font has: ✕ showed as a
  box in the browser

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyVio8afJsGwHW9i5v5HDs
(cherry picked from commit 813cb1c)
…menu, shared parameters, formula caption

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyVio8afJsGwHW9i5v5HDs
(cherry picked from commit ce2ae2e)
…nce tests [no-new-version]

An optional ICasEngine over mathenginen.dll (Windows only, from the user's
installation or MATHENGINEN_PATH, never in the repository): the linear input,
the commands, the error codes and the values of a result are written and read
by MathEngineText and tested everywhere; the reference cases run through the
engine only where it is installed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyVio8afJsGwHW9i5v5HDs
(cherry picked from commit a06d65c)
The library keeps every context in one global table that is not guarded
against threads, uses thread-local storage and calls CoInitialize on the
calling thread. Parallel tests and Task.Run made it crash with an access
violation in SetParsingOptions. All native calls of every engine now run,
one at a time, on a single STA thread, as in Microsoft Mathematics.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyVio8afJsGwHW9i5v5HDs
(cherry picked from commit 70d2a39)
…ults, decode MathML entities

- Solve as Microsoft Mathematics does: each equation parsed in the linear format and
  serialized as a formula, then SymbolicSolve[List[...]] parsed as a formula and executed
  through an equation request with the variable list.
- Results are read from the linear text (invisible brackets, implicit products,
  inverse-function powers, ±, √, π, ⅈ) by AngouriMath, falling back to the MathML.
- Named MathML entities (&InvisibleTimes;, &ImaginaryI;, ...) are decoded before parsing.
- The input is read in the test's angle unit and the engine always runs in radians.
- Linear input: negatives without (-1)*, floor, ceiling, sign, arcsec, arccsc,
  combination, sum, product, definite integral, infinity.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyVio8afJsGwHW9i5v5HDs
(cherry picked from commit eeacd33)
…ication, series, tuples, conditions and duplicates

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyVio8afJsGwHW9i5v5HDs
(cherry picked from commit 15a8e5b)
…ong real ones with complex fallback, variable names only when asked

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyVio8afJsGwHW9i5v5HDs
(cherry picked from commit b30984f)
…solve among the reals when the complex field fails

- ReadLinear keeps x=1 and y=1 apart, reads |x| as abs(x), and arc only before a call
- Solve retries among the real numbers on an error or a family with a parameter
- an explicit letter is passed to the request, else the request without it
- the trigonometric combination the engine does not do is skipped for it

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyVio8afJsGwHW9i5v5HDs
(cherry picked from commit 81750dd)
…read negative powers as quotients

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyVio8afJsGwHW9i5v5HDs
(cherry picked from commit c17c78d)
…esult is in polar form

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyVio8afJsGwHW9i5v5HDs
(cherry picked from commit 339d619)
…MathNet.Symbolics

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyVio8afJsGwHW9i5v5HDs
…ion]

A 3D page between the graphs and the worksheet: surfaces z=f(x,y) and
curves x,y,z of t drawn in a box the camera turns around, a slider for
each parameter. Graph3DView draws with OpenGL through Silk.NET where
Avalonia gives a context, and with the painter's algorithm on Skia
elsewhere (in the browser, or where the context fails).

- Core: SurfacePlot, the equation of a graph in space and its parameters
- Graphing: Scene3D (meshes and curves in the cube, poles clipped),
  OrbitCamera, Painter3D
- the remove buttons use ×, which the bundled font has: ✕ showed as a
  box in the browser

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyVio8afJsGwHW9i5v5HDs
(cherry picked from commit 813cb1c)
…menu, shared parameters, formula caption

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyVio8afJsGwHW9i5v5HDs
(cherry picked from commit ce2ae2e)
…iMath

Series.Close replaces each sum to infinity that AngouriMath leaves as it is
with its value: c/k^p by zeta (even p by the Bernoulli numbers, p = 1 has no
end), c(-1)^k/k^p by eta, c(-1)^k/(2k+1)^p by the Dirichlet beta (odd p, by
the Euler numbers), c/((k-a)(k-b)) by telescoping, and a sum of such terms
term by term. The form is found from the values of the term, its constant
exactly at the first k; a later start takes the first terms away. The
reference case of 1/k^2 is no longer pending.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyVio8afJsGwHW9i5v5HDs
…fractions

The table of forms found from the values of the term gives way to an exact
reading of it: a quotient of polynomials of the index with fractions as
coefficients, plain or with the sign of (-1)^k. It is split in partial
fractions over the roots that are fractions, and summed by the digamma
function at fractions (theorem of Gauss: pi, logarithms, square roots), by
zeta(j, x) for the repeated roots (Bernoulli numbers, and the derivatives of
the cotangent for x with 1-x), and by the residues of pi cot(pi z) for a
factor of degree 2 without such roots: 1/(k^2+1), 1/((3k+1)(3k+2)),
(-1)^k/(3k+1), 1/(k^2(k+1)). A term that does not go to zero fast enough
sums to infinity; zeta(3) and the like stay as they are.

Polynomial, RationalFunction and Fraction are the exact arithmetic it needs.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyVio8afJsGwHW9i5v5HDs
Thirteen sums with a closed form: zeta and eta at even numbers, telescoping
ones, the series of Leibniz and its cube, digamma at thirds, and 1/(k^2+1).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyVio8afJsGwHW9i5v5HDs
…ives back as they are

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The pull requests of the graphs in space and of the views in MVVM are in main:
what is left here is the adapter of the engine of Microsoft Mathematics and
the series to infinity.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyVio8afJsGwHW9i5v5HDs
@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Pre-release removed now that this PR is closed.

@simonebortolin
simonebortolin merged commit 41bd1c6 into main Nov 15, 2026
28 checks passed
@simonebortolin
simonebortolin deleted the ccr-f0e25fb4-eczbl3-mathengine branch November 15, 2026 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants