Skip to content
This repository has been archived by the owner on May 23, 2019. It is now read-only.

Releases: nicolewhite/algebra.js

algebra.js 0.2.4

21 Oct 15:12
Compare
Choose a tag to compare

Bug Fixes

  • Solving quadratics with irrational solutions when a > 1 was yielding incorrect results. Fixed in a84cb43.
  • Coefficients on variables with degree > 1 were being incorrectly raised to said degree. Fixed in 3b492c3.

algebra.js 0.2.2

22 Aug 19:38
Compare
Choose a tag to compare

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

21 Aug 16:54
Compare
Choose a tag to compare

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

20 Aug 21:26
Compare
Choose a tag to compare

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.

sum

var exp = new Expression("x").add("y").add(3); // x + y + 3

var sum = Expression.summation("x", 3, 6); // 4y + 30