leesugil / symbolic

Symbolic calculator for arithmetic operations with fractions
GNU General Public License v3.0
1 stars 0 forks source link

commutativity #11

Closed leesugil closed 5 months ago

leesugil commented 5 months ago

1 + x -1 != x

leesugil commented 5 months ago

will make _commExpr(p, op) where op == " + ". (also for _commExpr(p, " ") and _commExpr(p, " + "), will sort letter variables in lexicon order?? if we re-parse an expr after _commExpr(p, " "), we'll single-out purely character terms. then we can sort the variables there, maybe?)

leesugil commented 5 months ago

need to make a design choice.

Screenshot 2024-02-02 at 11 37 12 AM

if i prefer x + -1 to x - 1, pros) commutativity is easier cons) variables get registered as like -x as oppose to -1 x? ==> check the code similar application to will turn a simple abc / def into abc^(def)?

leesugil commented 5 months ago

to support the pros, instead of converting -x into -1 x when parsing, can we keep it as -x but register a symbol -x to mean -1 x during addSymb?

leesugil commented 5 months ago

on the second thought, it might not be that simple as updateExpr runs ahead of commExpr anyway which replaces -x by -1 * x anyway.

one workaround is to treat x - y as -y + x if and only if y is a pure number. this applies to x / y as y^-1 * x iff y is a pure number.

leesugil commented 5 months ago

resolved