Canonical rules for fraction numerators
See original GitHub issueHi all! I’m super interested in MathJSON, and I’m trying to set up MathLive/Compute in a personal project.
I was working on comparing linear equations with simplify/evaluate/canonical and found that I couldn’t get a consistent representation for (-7/4)x+10
const answerbox="\\frac{-7x}{4}+10"
const answer = [ "Add", [ "Multiply", [ "Divide", -7, 4 ], "x" ], 10]
match(
ce.evaluate(ce.parse(answerbox)),
ce.evaluate(answer)
)
);
Is this a case where I need to use additional rewrite rules to coerce this into a unique ‘canonical’ form for comparison, or is this within the scope of the canonical
function?
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (7 by maintainers)
Top Results From Across the Web
Continued fraction - Wikipedia
In mathematics, a continued fraction is an expression obtained through an iterative process ... It is generally assumed that the numerator of all...
Read more >Fraction Rules: Algebraic rules for working with fractions.
Fraction rules are a set of algebraic rules for working with fractions. A fraction has a numerator and a denominator. A fraction represents...
Read more >How to set up fractions III - canonical forms via the Euclidean ...
In order to deal with fractions smoothly, young students need to learn about canonical forms for fractions --where the numerators and ...
Read more >A simple canonical representation of rational numbers
We describe the relation between this representation of numbers and the representation as fractions of non-zero natural numbers. The usual operations of.
Read more >How to Add Fractions with Different Denominators - dummies
Start out by multiplying the numerator of the first fraction by the denominators of all the other fractions. · Do the same with...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Here is the relevant sympy documentation. Typing the following into the sympy live shell (bottom right of the documentation page) does demonstrate that behavior:
Of course if that turns out to be more trouble than it’s worth, that’s an entirely valid reason for not including it.
It feels a bit weird to me to not have division in the canonical form (admittedly, an earlier version of the Compute Engine did just that). That also makes some simplification rules more difficult to write since instead of detecting patterns of the form
a/b
you now have to pick upa*c*d
wherec
(ord
) is of the formb^-1
.Can you tell me more about Sympy’s expectations in that regard? Do you have a pointer in the documentation that discusses this and perhaps a rationale for it?
On a broader note, I intend in an upcoming revision, to have clearer lines between ‘formatting’ (i.e. putting into a canonical form) and ‘simplifying’. Formatting will not account for any calculations (i.e. multiply by 1), but will focus on sorting arguments of commutative functions, and reducing associative, idempotent and involutory functions. Simplify on the other hand will apply more rules, including ones depending on the numerical values of the arguments, and other ‘assumptions’ about arguments (for example whether an argument is a positive real, or a complex number, etc…