Created
August 18, 2015 20:31
-
-
Save lorenzoongithub/c9b38a90a45e898a3ca1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// algebraic equations | |
// in javascript | |
// http://algebra.js.org/ | |
// | |
load('http://algebra.js.org/javascripts/algebra.min.js'); | |
var Expression = algebra.Expression; | |
var Equation = algebra.Equation; | |
var Fraction = algebra.Fraction; | |
expr = new Expression("x"); | |
expr = expr.subtract(3); | |
expr = expr.add("x"); | |
if (expr.toString() != '2x - 3') throw ''; | |
eq = new Equation(expr, 4); | |
if (eq.toString() != '2x - 3 = 4') throw ''; | |
var x = eq.solveFor("x"); | |
if (x.toString() != '7/2') throw ''; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment