fix: pick up math-expressions fix for lost matrix entries of -1 - #1729
Merged
Merged
Conversation
Subtracting a matrix with an entry of -1, as in
<math simplify>$A + $B - $C</math>
either gave a wrong entry or failed with an internal error. Distributing
the minus sign over the entries produced the product (-1)(-1), which
simplified to an empty product rather than to 1, so the entry dropped out
of the sum. Tuples and vectors were affected the same way.
Fixed upstream in math-expressions 2.0.0-alpha96.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01563D3v3KXwuRLmni12AuvU
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.
Bumps
math-expressionsfrom2.0.0-alpha95to2.0.0-alpha96, which fixes wrong answers and a hard failure in matrix, vector, and tuple arithmetic.The bug
The
(2,2)entry came out as-8instead of-7. With different numbers — an<answer>checking a student's matrix, say — the same document instead failed withTypeError: Cannot read properties of undefined (reading '0')and rendered nothing.Both come from one defect in the simplifier. Distributing the minus sign over
C's entries turns the-1entry into the product(-1)(-1); the pass that merges numeric factors omitted a coefficient of1from its result, which for a product of nothing but numbers left an empty multiplication that later evaluated toundefined. The entry then vanished from its sum. Which symptom the reader saw depended on how the remaining addends sorted around the missing one: a negative partial sum silently dropped it, a positive one dereferenced it and threw.Ordinary scalar arithmetic never hit this, since numbers are evaluated before the pass runs. Only products built afterwards — those from distributing a scalar over a matrix, vector, or tuple — could reach it, so entries of
-1in a subtracted matrix were the common trigger.Fixed upstream in Doenet/math-expressions#89, released as
2.0.0-alpha96.Verification
Both documents now give
[[-1, 8], [-5, -7]]and[[9, 2], [-7, -4]], with$ans.matrix[2][2]reading-7.matrix,matrixinput,math, and thelinearAlgebrasuites pass against the new version.🤖 Generated with Claude Code