google / mathsteps

Step by step math solutions for everyone
https://socratic.org
Apache License 2.0
2.12k stars 276 forks source link

Absolute value of unknowns (in equations) #49

Open evykassirer opened 7 years ago

evykassirer commented 7 years ago

This is blocked on #128 (new parser) because we need to support multiple equations.

e.g. |x| + 3 = 4 can solve for x by separating it into x + 3 = 4 and -x + 3 = 4

to support these, we'd also have to support multiple equations (related issue: #48)

hmaurer commented 7 years ago

Mmh that's quite interesting in terms of pedagogy. I haven't really thought about it but at first it seems we could have a sort-of tree structure for equations with "AND" and "OR" nodes, and operate on that tree in steps in the same way you currently operate on expression trees.

For example, starting from a single root node |x| + 3 = 4, we would transform it to an "OR" node with left branch x + 3 = 4 and right branch -x + 3 = 4.

You could also imagine a slightly more complex example. Say we start with the system

|x| = 3
x >= 0

The initial tree structure would be

AND(|x| = 3, x >= 0)

The first step would deal with the absolute value and we would get

AND(
  OR(x = 3, -x = 3),
  x >= 0
)

then we could distribute the conjunction over the disjunction to get

OR(
  AND(x = 3, x >= 0),
  AND(-x = 3, x >= 0),
)

We would then eliminate the right branch of the "OR" node because -x = 3 and x >= 0 are not satisfiable, and somehow contract x = 3 and x >= 0 (since they contain redundant information) to the single equation x = 3.

In a short example like this it seems it would work and be easy to follow, but in this specific case the reasoning "x >= 0 so I can just remove the absolute value" would also be correct (and shorter).

What do you think?

evykassirer commented 7 years ago

I hadn't thought about it much yet, but that sounds quite reasonable! Since this will be a pretty big decision, I think it's worth doing research into what other CAS do as well.