KAS
A lightweight JavaScript CAS for comparing expressions and equations. It is used throughout Khan Academy's interactive exercises.
This library is forked from https://github.com/Khan/KAS to address some minor issues
What can it do?
It can parse plain text math, LaTeX, or a mix of both:
var expr = KASexpr;expr;// "3*x*42/42*sin(y)^(2)"
It can evaluate expressions:
var expr = KASexpr;expr;// 5
It can compare expressions and equations:
var expr1 = KASexpr;var expr2 = KASexpr;KASequal;// true var eq1 = KASexpr;var eq2 = KASexpr;KASequal;// true
It can perform basic transforms that always simplify an expression:
var expr = KASexpr;expr;// "2+3*x+y" var expr = KASexpr;expr;// "x^(2*y)"
It can perform non-simplifying transforms on an expression:
var expr = KASexpr;expr;// "a*b*(c+d)*e^(f)"expr;// "a*b*e^(f)*c+a*b*e^(f)*d"expr;// "a*b*e^(f)*(c+d)"
It can combine the above abilities to perform powerful simplification:
var expr = KASexpr;expr;// "(n*x^(5))^(5)*(n^(-2)*x^(2))^(-1*-3)"expr;// "n^(-1)*x^(31)" var expr = KASexpr;expr;// "(15*n*p+-25*m*p)*(15*p^(2)+-5*p)^(-1)+(20*m*p+10*p^(2))*(15*p^(2)+-5*p)^(-1)"expr;// "(-1+3*p)^(-1)*(3*n+-1*m+2*p)"
How to build the library
npm install
npm run build
How to build the parser
First, make any changes in src/parser-generator.js
npm install
npm run build:parser