Skip to content

Show a matrix power A^^n as A^⟨n⟩ (#1005) - #2605

Open
gunterkoenigsmann wants to merge 3 commits into
mainfrom
claude/matrix-power-angle-brackets
Open

gunterkoenigsmann wants to merge 3 commits into
mainfrom
claude/matrix-power-angle-brackets

Conversation

@gunterkoenigsmann

@gunterkoenigsmann gunterkoenigsmann commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Requested by Gunter · project thread

Closes #1005.

Why

In Maxima, A^n of a matrix is the elementwise power and A^^n is the matrix power. wxMaxima drew both as a plain exponent, so A^^-1 (the inverse) and A^-1 (the matrix of reciprocals) looked the same. wxMathML.lisp already sent mat="true", but only copy-as-text used it. Drawing, LaTeX, MathML and RTF all dropped it, and ToXML() never wrote it back, so saving and reloading a .wxmx turned a matrix power into an ordinary one.

What

  • 2D: the exponent is drawn between ⟨ ⟩ (U+27E8/27E9, in the exponent's font size), like Maxima's own A^<n>. Hovering over it shows a tooltip explaining the difference.
  • Linear (broken) form: reads A^^n.
  • LaTeX: A^{\langle n\rangle}, which is what Maxima's tex() writes.
  • MathML / OMML (RTF): keep the brackets.
  • Matlab: A^n, since ^ already is Matlab's matrix power.
  • .wxmx / XML clipboard: mat="true" is now saved. Cell::Copy() keeps the flag too; it used to lose it.
  • Indexed base a[1]^^2 (SubSupCell): gets the same treatment. wxxml-mexpt-array also didn't flag the mqapply case.

Tests

New test_MatrixPower covers:

  • bracket placement and widths
  • the tooltip
  • the linear form
  • every export format
  • XML round trip and Copy() for both cell types
  • that ordinary powers are unchanged

Unit tests pass locally (under xvfb). I also checked live in Xvfb with a real Maxima: B^^n; B^2; B^^(n+1); B^^-1; a[1]^^2; render as B^⟨n⟩, B², B^⟨n+1⟩, B^⟨-1⟩ and a₁^⟨2⟩.

The ExptCellGeometry.svg diagram notes the brackets. NEWS.md is updated, and I hand-added the one new msgid to the POT.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VdqsMALeBYMSmTayVuE3eJ

In Maxima A^n of a matrix is the elementwise power and A^^n the matrix
power, but wxMaxima drew both as a plain exponent. The flag wxMathML.lisp
already sent (mat="true") only reached copy as text; drawing, LaTeX,
MathML and RTF dropped it, and ToXML() didn't write it, so a saved
.wxmx turned a matrix power into an ordinary one.

The exponent of a matrix power is now drawn between angle brackets, as
Maxima's own 2D display does, with a tooltip explaining the difference.
The linear (broken) form reads A^^n. LaTeX export writes
A^{\langle n\rangle} like Maxima's tex(); MathML and OMML keep the
brackets; Matlab export writes A^n, Matlab's matrix power. Also covered:
an indexed base (a[1]^^2, SubSupCell), which wxMathML.lisp didn't flag
for an mqapply base, and Cell::Copy(), which lost the flag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VdqsMALeBYMSmTayVuE3eJ
@gunterkoenigsmann gunterkoenigsmann self-assigned this Oct 30, 2026
A fraction or a nested power in the exponent got small glyph brackets in
its middle. Cell::DrawAngleBracketsAround() now draws brackets spanning
the exponent's height as lines when it is taller than the glyphs.

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

This branch has not been deployed

No deployments
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.

Exponent of dot product should be displayed in angle brackets

2 participants