leesugil / symbolic

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

commutativity, associativity #6

Closed leesugil closed 5 months ago

leesugil commented 5 months ago

f = a x^2 + b x^1 + c x^0 x = 2 y = 3 g = y f ==> 3 a 4 + 3 b 2 + 3 c 1

i want the outcome to be ==> 12 a + 6 b + 3 * c

leesugil commented 5 months ago

related issue

Screenshot 2024-02-01 at 12 43 44 PM
leesugil commented 5 months ago

isolating to calcExpr, it seems to work fine (to the current version's standard) with parsing:

Screenshot 2024-02-01 at 12 47 37 PM
leesugil commented 5 months ago

symbols: "f" = "a x^2 + b x^1 + c x^0" "g" = "y f" "h" = "g z" "i" = "-1 h" "j" = "i * -1" "x" = "2" "y" = "3" "z" = "7"

Screenshot 2024-02-01 at 12 58 05 PM
leesugil commented 5 months ago

this is when i nullified x, y, z again. seems like calcExpr problem?

Screenshot 2024-02-01 at 1 01 41 PM
leesugil commented 5 months ago

update direction: assume an expression is distributed. like -2 b a 3 / c 2 d 6

  1. each term between +, - are a product of and /. for parts with , using commutativity, sort their order in lexicon order. put numbers in front always. like -6 a b / 12 c d

  2. then do the number calculation to yield -0.5 a b / c * d

memo: decide how to handle a / b / d? the current module reads it as a / (b / d)

leesugil commented 5 months ago

resolved