Releases: nicolewhite/algebra.js
algebra.js 0.2.4
algebra.js 0.2.2
Bug Fixes
Expression Simplification
Expression simplification was failing in certain scenarios where there were multiple like-terms. This was fixed in 96b0e46.
Parser
Negative Numbers
The parser no longer throws when there are negative numbers, e.g.
var eq = algebra.parse("x^2 + 4 = -4");
Adjacent Parentheses
The parser now interprets anything adjacent to a parenthesis as multiplication, e.g.
var exp = algebra.parse("5(x + 2)");
exp.toString(); // 5x + 10
var exp = algebra.parse("(x + 2)(x + 2)");
exp.toString(); // x^2 + 4x + 4
algebra.js 0.2.1
Bug Fixes
Expression.simplify
was failing when the expression consisted only of unsimplified constants. Previously, it would only simplify down to two constants:
exp = new Expression("x").add(3); // x + 3
exp = exp.pow(2, false); // xx + 3x + 3x + 3 * 3
exp = exp.eval({x: 2}, false); // 2 * 2 + 3 * 2 + 3 * 2 + 3 * 3
exp = exp.simplify(); // 6 + 19
Now it simplifies down to the single constant:
exp = exp.simplify(); // 25
algebra.js 0.2.0
Bug Fixes
Single-variable equations with an infinite number of solutions were returning undefined
when solved. They now return Fraction(1, 1)
.
var exp = new Expression("x").add(2); // x + 2
var eq = new Equation(exp, exp); // x + 2 = x + 2
var ans = eq.solveFor("x"); // 1
New Features
Parser
You can now build expressions and equations from strings.
var exp = algebra.parse("x^2 + 4 * x + 4");
var eq = algebra.parse("x^2 + 4 * x + 4 = 0");
Expression Simplification
You can now pass a simplify
argument to all Expression operations.
var exp = new Expression("x").add(2); // x + 2
exp = exp.multiply(5, false); // 5x + 5 * 2
exp = exp.simplify(); // 5x + 10
exp = exp.add(5, false); // 5x + 10 + 5
exp = exp.divide(5, false); // 5/5x + 10/5 + 5/5
exp = exp.simplify(); // x + 3
exp = exp.pow(2, false); // xx + 3x + 3x + 3 * 3
exp = exp.eval({x: 2}, false); // 2 * 2 + 3 * 2 + 3 * 2 + 3 * 3
Summation
A summation
method has been added to the Expression class. It allows you to sum over a range for a specific variable.
var exp = new Expression("x").add("y").add(3); // x + y + 3
var sum = Expression.summation("x", 3, 6); // 4y + 30