Skip to content

det, transpose, trace and an entry of a name for a matrix #2427

Description

@Rafael-SOWNet

#2180 computes det, transpose and the rest from a matrix that is written out. So det(A) of a name is refused, and transpose(A) * B can't be written. trace(A) parses as the product trace * A, and A[k, l] doesn't parse. #2422 compiles matrix arguments, but nothing can take their determinant, their trace or an entry.

Proposal:

  • Nodes det(A), transpose(A), trace(A) and A[k, l]. Indices count from 1, as in a_ij, Mathematica, Maple and MATLAB. The C# indexer keeps counting from 0.
  • Each operation is carried out once A is a matrix, by substitution, simplification, evaluation and compilation over T[,].
  • A non-square matrix has no determinant or trace, and an index out of range names no entry. Both stay unevaluated.

Until #1237, nothing else knows that A is a matrix. So:

  • a product with a transpose in it must not be reordered: transpose(A) * A - A * transpose(A) is not 0;
  • a name next to a written matrix must not be multiplied into its entries: det(A * [[2, 0], [0, 3]]) is not 6 * A^2.

Follows #2147, which decided that a written matrix is computed when parsed and left names open, and #2422.

Activity

  1. added this to the 2.7.0 milestone on Nov 13, 2026
  2. Rafael-SOWNet commented on Nov 13, 2026

    @Rafael-SOWNet
    MemberAuthor

    Decided for 2.7.0:

    • Indices count from 1 in an expression. A[1, 1] is the first entry, as in a_ij, Mathematica, Maple, Maxima, MATLAB and Julia. SymPy counts from 0 only because Python does.
    • The C# indexer still counts from 0. Matrix's matrix[k] and matrix[x, y] have done so since 2021, as C# does, so M[k, l] in an expression is matrix[k - 1, l - 1] in code. The syntax page says so.
    • Indexing an expression is new. On master, "[[1, 2], [3, 4]][2, 1]" and "A[1, 1]" both throw UnhandledParseException.

    The branch is ready. A full check and a chain run before the PR opens, after #2422 merges.

  3. moved this from Todo to In Progress in AngouriMathon Nov 13, 2026
  4. added 2 commits that reference this issue on Nov 13, 2026
    2a3eef8
    a1b0149
  5. moved this from In Progress to Done in AngouriMathon Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions