Khan/khan-exercises — pull request #114426 by Merbs (2013-11-13 10:42:11+00:00)
Title: KAS learns differentiation!

Most of the proposed changes are within KAS (Khan Algebra System?), adding the functionality to differentiate. To that end, a couple helper functions (sameAs, contains, copy, ... ) were defined.

In addition, KAS's parse function got a sister parseArray, who takes in something like `["+",4.5,["sin",["*","x","y","z"]],["^","e",3]]` and makes it into KAS's internal `Add(Float(4.5), Trig("sin", Mul(Var("x"), Var("y"), Var("z"))), Pow(Const("e"), Int(3)))`, which can then be printed, tex'd, differentiated, etc. The function was inspired by the utils polynomials/calculus/expressions format, and a generateMultivariateFunction() was added to calculus.js in that fashion. To see it in use, I made the exercise exact_equations.

At the bequest of Alex's (@alopatin) comments (and my own aesthetic sanity), the simplify function got a makeover. Among the changes are adding reciprocal trig functions (e.g. `1/cos(x)` to `sec(x)`), combining unequal trig exponents, and adding a super-simplify flag (via an options object that is now passed almost everywhere). Notably it has (at least one) breaking change, in that `ln(xy), |xy| and z^(x+y)` are no longer expanded by default. But that was by changing a true to a false, and can be changed back. Another noticeable change is that `1-x` no longer shows up as `1-1x`, which seemed to be a bug rather than a feature. And expressions are ordered [vars, powers, logs, trigs, expressions].

Specifically for the exact_equations exercise, the answers-types.js 'expression' type got data-placeholder and data-empty functionality. And KAS got a couple additional functions (allAddTermsWith, ...), which can be localized within the exercise if they have no general use.

Also adds testing to local-only/kas.js from the Khan/KAS project with additional tests for the new differentiate function.

Several other small fixes are proposed. More details are in the commits. Most of the deletions are changes made in Khan/KAS that were not yet merged into local-only/kas.js. I would have rebase'd them all together, but the commits make more sense separately (also this is the rebase'd version).

Any comments or suggestions for the exact_equations exercise would be appreciated.