Skip to content

det, transpose, dot, cross and resultant are functions in an expression - #2180

Merged
Rafael-SOWNet merged 3 commits into
masterfrom
det-dot-cross-transpose-and-resultant-in-an-expression
Oct 28, 2026
Merged

Rafael-SOWNet merged 3 commits into
masterfrom
det-dot-cross-transpose-and-resultant-in-an-expression

Conversation

@Rafael-SOWNet

@Rafael-SOWNet Rafael-SOWNet commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Modenov's Problems in Geometry computes areas, collinearity, concurrency and elimination with determinants, vector products and resultants. None of them could be written in an expression: det(M) was refused by name (#2136), transpose(x) and cross(a) were read as products, and dot, a two-vector cross and resultant did not parse.

Each is now a function, computed from its arguments when it is parsed, since there is no node for any of them:

Function Computed by
det(M) Matrix.Determinant
transpose(M) Matrix.T, which ]T writes only straight after a bracket
dot(a, b) the sum of the products of the components, neither side conjugated, as SymPy's dot and Mathematica's Dot
cross(a, b) the vector product in three dimensions
cross(a) a vector of the plane turned through a right angle anticlockwise, cross([x, y]) being [-y, x], as Mathematica's Cross of one vector
resultant(p, q, x) MathS.Polynomials.Resultant

The book's two plane products are then cross(a), which it writes [a], and dot(cross(a), b), its pseudo-scalar product (a, b) = a_1 b_2 - a_2 b_1. Neither needs a name of its own.

An argument has to be a matrix or a vector written out, or one once its operations are carried out: det(2 * [[1, 2], [3, 4]]) is -8. Anything else throws InvalidArgumentParseException naming the function: det(A) of a symbol, a non-square determinant, vectors of different lengths, a two-vector cross in the plane, a resultant of something that is not a polynomial. The result is as unsimplified as it would be written out by hand: dot([1, 2], [3, 4]) is 1 * 3 + 2 * 4.

Input Was (2.6.0) Now
det([[1, 2], [3, 4]]) det * [[1, 2], [3, 4]] -2
transpose([1, 2]) transpose * [1, 2] [[1, 2]], the row
transpose(x) transpose * x throws InvalidArgumentParseException
cross([a, b]) cross * [a, b] [-b, a]
dot([1, 2], [3, 4]) throws UnhandledParseException 1 * 3 + 2 * 4
resultant(x^2 - 1, x - a, x) throws UnhandledParseException a ^ 2 - 1

The det row of #2136's breaking entry, which is not released yet, is taken out of it, since det is no longer refused. The parser is regenerated with the vendored ANTLR 4.13.1, and the post-processor leaves no generated class public. Docs/Usage/Syntax.md describes the functions.

The determinant expands itself where the elimination declines. The first CI run failed to publish natively, on the C++ wrapper and in Trimming & NativeAOT: det(M) in the parser made Matrix.Determinant reachable from every native build. Where the fraction-free elimination cannot read the entries as polynomials, that falls back to GenericTensor's Laplace expansion, which compiles an expression tree (IL3050). The second commit writes the same expansion along the first row over the entries. It needs no lock on GenericTensor's shared scratch matrix, and it agrees with GenericTensor's on 60 generated matrices of roots, sines, logarithms and symbols, compared by value. The value is unchanged and the printed form can differ, which its own breaking entry records: [[sin(x), cos(x)], [-cos(x), sin(x)]]'s determinant was sin(x) ^ 2 + -cos(x) * -cos(x) and is sin(x) ^ 2 - cos(x) * -cos(x). The native smoke test now parses a det that takes the expansion, and a dot of a cross; published locally with NativeAOT it passes 47 of 47, and the C++ wrapper's native publish reports no warning.

The MCP server's syntax document names the five. McpUnitTests checks that angourimath://syntax names every function the grammar accepts, and failed for these in the first run. Its check now also accepts InvalidArgumentParseException, which det(x) throws because x is not a matrix, as it already accepted an argument count refused.

Measured

  • Suite: 17204 passed, 0 failed, 13 skipped on the branch as first pushed; rebased onto A trigonometric identity is decided over the sines and cosines of its base angles #2179's merge (766e34b) for one conflict in BREAKING-CHANGES.md, then 17233 passed; with the second commit 17234 passed, 0 failed; McpUnitTests 349, TerminalUnitTests 69 and InteractiveWrapperUnitTests 19 passed.
  • Intbench chain against master 257f88b: identical on every family, 0 moves.
  • Performance gate: passed on all 19 gated benchmarks; ParseEasy 0.0% and ParseHard −0.2% in allocation, with four more tokens in the lexer.

Closes #2147.

🤖 Generated with Claude Code

https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura

Modenov's Problems in Geometry computes areas, collinearity, concurrency and elimination
with determinants, vector products and resultants, and none of them could be written in an
expression: det(M) was refused by name, transpose(x) and cross(a) were read as products, and
dot, a two-vector cross and resultant did not parse.

Each is computed from its arguments when it is parsed, since there is no node for any of
them: det through Matrix.Determinant, transpose through Matrix.T, resultant through
MathS.Polynomials.Resultant, and dot and cross from the components. dot conjugates neither
side, as SymPy's dot and Mathematica's Dot do not. cross of two vectors is the vector product
in three dimensions, and cross of one vector in the plane is that vector turned through a
right angle anticlockwise, as Mathematica's Cross of one vector is, so dot(cross(a), b) is the
book's pseudo-scalar product. An argument has to be a matrix or a vector written out, or one
once its operations are carried out; anything else throws InvalidArgumentParseException
naming the function.

Closes #2147.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
@codecov

codecov Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.51877% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.44%. Comparing base (766e34b) to head (9d0251c).

Files with missing lines Patch % Lines
...ources/AngouriMath/Core/Antlr/AngouriMathParser.cs 98.78% 4 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2180      +/-   ##
==========================================
+ Coverage   86.42%   86.44%   +0.02%     
==========================================
  Files         296      296              
  Lines       65221    65332     +111     
  Branches    19165    19180      +15     
==========================================
+ Hits        56366    56475     +109     
- Misses       4804     4805       +1     
- Partials     4051     4052       +1     
Flag Coverage Δ
cpp 37.77% <ø> (ø)
csharp 87.01% <99.51%> (+0.01%) ⬆️
fsharp 32.97% <ø> (ø)
interactive 40.72% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
Sources/AngouriMath/Core/Antlr/AngouriMathLexer.cs 99.00% <100.00%> (+0.02%) ⬆️
Sources/AngouriMath/Core/Antlr/ParsingHelpers.cs 90.16% <100.00%> (+20.16%) ⬆️
...rces/AngouriMath/Core/Entity/Omni/Entity.Matrix.cs 83.60% <100.00%> (+0.48%) ⬆️
Sources/AngouriMath/Functions/GenTensorGuard.cs 100.00% <ø> (ø)
...ources/AngouriMath/Core/Antlr/AngouriMathParser.cs 86.51% <98.78%> (+0.19%) ⬆️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Rafael-SOWNet Rafael-SOWNet moved this from Todo to In review in AngouriMath Oct 28, 2026
@Rafael-SOWNet
Rafael-SOWNet force-pushed the det-dot-cross-transpose-and-resultant-in-an-expression branch from ccae548 to e99f19f Compare October 28, 2026 12:10
Rafael-SOWNet and others added 2 commits October 28, 2026 12:29
…library itself

Where the fraction-free elimination cannot read the entries as polynomials,
Matrix.Determinant took GenericTensor's Laplace expansion, which compiles an expression tree:
ILC reports IL3050 on it, and det(M) in the parser made it reachable from every native build,
so the C++ wrapper's and the Trimming & NativeAOT jobs failed to publish. The expansion along
the first row is now written over the entries. It is the same expansion, needs no lock on
GenericTensor's shared scratch matrix, and agrees with GenericTensor's on 60 generated
matrices of roots, sines, logarithms and symbols, compared by value. The native smoke test
parses a det that takes it, and a dot of a cross.

Part of #2147.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
… resultant

McpUnitTests checks that angourimath://syntax names every function the grammar accepts.
det(x), transpose(x) and cross(x) are now refused with InvalidArgumentParseException, since x
is not a matrix, which that test reads as a function of something else, as it reads a count
refusal. The refusal's example is the function's own: cross([1, 2, 3], [4, 5, 6]) rather than
a matrix.

Part of #2147.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
@Rafael-SOWNet
Rafael-SOWNet merged commit 00d857b into master Oct 28, 2026
36 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in AngouriMath Oct 28, 2026
@Rafael-SOWNet
Rafael-SOWNet deleted the det-dot-cross-transpose-and-resultant-in-an-expression branch October 28, 2026 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

det, dot, cross, transpose and resultant as functions in an expression

1 participant