Repository navigation
det, transpose, dot, cross and resultant are functions in an expression - #2180
Merged
Rafael-SOWNet merged 3 commits intoOct 28, 2026
Merged
Rafael-SOWNet merged 3 commits into
Rafael-SOWNet merged 3 commits into
Conversation
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 Report❌ Patch coverage is
Additional details and impacted files@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Rafael-SOWNet
force-pushed
the
det-dot-cross-transpose-and-resultant-in-an-expression
branch
from
October 28, 2026 12:10
ccae548 to
e99f19f
Compare
…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
deleted the
det-dot-cross-transpose-and-resultant-in-an-expression
branch
October 28, 2026 19:21
This was referenced Nov 13, 2026
Rafael-SOWNet
added a commit
that referenced
this pull request
Nov 13, 2026
…argument det(A) of a symbol was refused at parsing, transpose(x) too, trace(A) was the product trace * A, and A[i, j] did not parse. Each of the four is now a node over what it is applied to, carried out once that is a matrix: by Substitute, Simplify, Evaled and a compiled delegate taking T[,]. Of a matrix written out each is still computed as it is parsed, as det and transpose were, so nothing #2180 answered moves but transpose(x). - Determinantf, Transposef, Tracef and MatrixEntryf, with printing that parses back, LaTeX (\det, ^{\mathrm{T}}, \operatorname{tr}, a subscript), SymPy, substitution, sorting, serialization, and MathS.Matrices.Determinant, Transpose, Trace and Entry. - An entry counts its row and column from 1, as a_ij does: [[1, 2], [3, 4]][2, 1] is 3. The brackets follow an atom directly, which did not parse before. - A non-square matrix has no determinant and no trace, and an index out of range or not whole names no entry: the node is left as it is, never a number. Written out, each is refused at parsing, as det of a non-square matrix was. A number, a statement or a set is no matrix and is refused. - det(transpose(A)) is det(A), trace(transpose(A)) is trace(A), transpose(transpose(A)) is A and transpose(A)[k, l] is A[l, k]. - The transpose, the trace and an entry are differentiated through the matrix; the determinant keeps its derivative node, Jacobi's formula needing the adjugate. - Compiled: the transpose, Bareiss' fraction-free determinant with the largest pivot where the elements have a size (exact over long and int), the trace, and the entry with its indices checked whole and in range when called. Shapes written into the expression are checked at Compile. - A product with a transpose in it is a product of matrices, and Simplify read it as commutative: transpose(A) * A - A * transpose(A) simplified to 0, and transpose(A) * B printed as B * transpose(A). Such a product is set aside as a name of its own while the rest is simplified, and put back with each factor simplified in place; the canonical sort and the print order leave it as written. - A name beside a written matrix may stand for a matrix, and simplification reads it as a number: det(A [[2, 0], [0, 3]]) was 6 A^2 at parsing, and a compiled delegate computed that. Such an argument is not carried out, at parsing, in evaluation or by Simplify, until the name is a matrix; det([[x, 1], [2, x]]), whose names are entries, is x^2 - 2 as before. Measured: the new MatrixOperationNodesTest compares every value with one computed from the entries, at real, negative and non-real matrices, 2x2 and 3x3, and every compiled value with evaluation, including a matrix argument beside a written matrix, which the base commit's SimplifiedAroundMatrixArguments leaves to these nodes. The 2.6.0 values in BREAKING-CHANGES.md are measured on the 2.6.0 package. Closes #2427. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rafael-SOWNet
added a commit
that referenced
this pull request
Nov 13, 2026
…argument det(A) of a symbol was refused at parsing, transpose(x) too, trace(A) was the product trace * A, and A[i, j] did not parse. Each of the four is now a node over what it is applied to, carried out once that is a matrix: by Substitute, Simplify, Evaled and a compiled delegate taking T[,]. Of a matrix written out each is still computed as it is parsed, as det and transpose were, so nothing #2180 answered moves but transpose(x). - Determinantf, Transposef, Tracef and MatrixEntryf, with printing that parses back, LaTeX (\det, ^{\mathrm{T}}, \operatorname{tr}, a subscript), SymPy, substitution, sorting, serialization, and MathS.Matrices.Determinant, Transpose, Trace and Entry. - An entry counts its row and column from 1, as a_ij does: [[1, 2], [3, 4]][2, 1] is 3. The brackets follow an atom directly, which did not parse before. - A non-square matrix has no determinant and no trace, and an index out of range or not whole names no entry: the node is left as it is, never a number. Written out, each is refused at parsing, as det of a non-square matrix was. A number, a statement or a set is no matrix and is refused. - det(transpose(A)) is det(A), trace(transpose(A)) is trace(A), transpose(transpose(A)) is A and transpose(A)[k, l] is A[l, k]. - The transpose, the trace and an entry are differentiated through the matrix; the determinant keeps its derivative node, Jacobi's formula needing the adjugate. - Compiled: the transpose, Bareiss' fraction-free determinant with the largest pivot where the elements have a size (exact over long and int), the trace, and the entry with its indices checked whole and in range when called. Shapes written into the expression are checked at Compile. - A product with a transpose in it is a product of matrices, and Simplify read it as commutative: transpose(A) * A - A * transpose(A) simplified to 0, and transpose(A) * B printed as B * transpose(A). Such a product is set aside as a name of its own while the rest is simplified, and put back with each factor simplified in place; the canonical sort and the print order leave it as written. - A name beside a written matrix may stand for a matrix, and simplification reads it as a number: det(A [[2, 0], [0, 3]]) was 6 A^2 at parsing, and a compiled delegate computed that. Such an argument is not carried out, at parsing, in evaluation or by Simplify, until the name is a matrix; det([[x, 1], [2, x]]), whose names are entries, is x^2 - 2 as before. Measured: the new MatrixOperationNodesTest compares every value with one computed from the entries, at real, negative and non-real matrices, 2x2 and 3x3, and every compiled value with evaluation, including a matrix argument beside a written matrix, which the base commit's SimplifiedAroundMatrixArguments leaves to these nodes. The 2.6.0 values in BREAKING-CHANGES.md are measured on the 2.6.0 package. Closes #2427. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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)andcross(a)were read as products, anddot, a two-vectorcrossandresultantdid not parse.Each is now a function, computed from its arguments when it is parsed, since there is no node for any of them:
det(M)Matrix.Determinanttranspose(M)Matrix.T, which]Twrites only straight after a bracketdot(a, b)dotand Mathematica'sDotcross(a, b)cross(a)cross([x, y])being[-y, x], as Mathematica'sCrossof one vectorresultant(p, q, x)MathS.Polynomials.ResultantThe book's two plane products are then
cross(a), which it writes[a], anddot(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 throwsInvalidArgumentParseExceptionnaming the function:det(A)of a symbol, a non-square determinant, vectors of different lengths, a two-vectorcrossin the plane, aresultantof something that is not a polynomial. The result is as unsimplified as it would be written out by hand:dot([1, 2], [3, 4])is1 * 3 + 2 * 4.det([[1, 2], [3, 4]])det * [[1, 2], [3, 4]]-2transpose([1, 2])transpose * [1, 2][[1, 2]], the rowtranspose(x)transpose * xInvalidArgumentParseExceptioncross([a, b])cross * [a, b][-b, a]dot([1, 2], [3, 4])UnhandledParseException1 * 3 + 2 * 4resultant(x^2 - 1, x - a, x)UnhandledParseExceptiona ^ 2 - 1The
detrow of #2136's breaking entry, which is not released yet, is taken out of it, sincedetis 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.mddescribes 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 madeMatrix.Determinantreachable 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 wassin(x) ^ 2 + -cos(x) * -cos(x)and issin(x) ^ 2 - cos(x) * -cos(x). The native smoke test now parses adetthat takes the expansion, and adotof across; 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.
McpUnitTestschecks thatangourimath://syntaxnames every function the grammar accepts, and failed for these in the first run. Its check now also acceptsInvalidArgumentParseException, whichdet(x)throws becausexis not a matrix, as it already accepted an argument count refused.Measured
BREAKING-CHANGES.md, then 17233 passed; with the second commit 17234 passed, 0 failed; McpUnitTests 349, TerminalUnitTests 69 and InteractiveWrapperUnitTests 19 passed.ParseEasy0.0% andParseHard−0.2% in allocation, with four more tokens in the lexer.Closes #2147.
🤖 Generated with Claude Code
https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura