• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nicolewhite / algebra.js / 87
95%

Build:
DEFAULT BRANCH: master
Ran 22 Aug 2015 04:00PM UTC
Jobs 1
Files 8
Run time 0s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

pending completion
87

push

travis-ci

nicolewhite
Fix bug in Expression.simplify

The original implementation of Expression._combineLikeTerms was written
when Expressions were always simplified. In some cases where like-terms
show up multiple times and are scattered, terms would be missed because
I was splicing on the array that was being iterated through (which is
probably bad in general). It’s been rewritten to keep track of which
terms have already been encountered.

E.g., this used to fail:

var exp = algebra.parse("x + y + 3");
var unsimplified = exp.pow(3, false);
unsimplified.toString();

// xxx + xyy + yxx + yxy + yyx + yyy + xxy + xyx + 3yx + 3xy + 3xy +
3yy + 3xx + 3xx + 3yy + 3yx + 3yy + 3yx + 3xx + 3xy + 3 * 3x + 3 * 3y +
3 * 3x + 3 * 3y + 3 * 3x + 3 * 3y + 3 * 3 * 3

var simplified = unsimplified.simplify();
simplified.toString();
// x^3 + y^3 + 2x^2y + y^2x + x^2y + 2y^2x + 6y^2 + 9x^2 + 3y^2 + 3xy +
15yx + 27x + 18y + 9y + 27

Notice the 2x^2y and x^2y terms are not combined when they should be.

This now works correctly:

var simplified = unsimplified.simplify();
simplified.toString();
// x^3 + y^3 + 3x^2y + 3y^2x + 9x^2 + 9y^2 + 18xy + 27x + 27y + 27

1009 of 1027 relevant lines covered (98.25%)

799.45 hits per line

Jobs
ID Job ID Ran Files Coverage
1 87.1 22 Aug 2015 04:00PM UTC 0
98.25
Travis Job 87.1
Source Files on build 87
Detailed source file information is not available for this build.
  • Back to Repo
  • Travis Build #87
  • 96b0e467 on github
  • Prev Build on master (#86)
  • Next Build on master (#88)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc