Skip to content

Commit

Permalink
Updated docs of simplify, extended algebra examples
Browse files Browse the repository at this point in the history
  • Loading branch information
josdejong committed Aug 6, 2017
1 parent fd87f83 commit 4fc0c4b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/algebra.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var math = require('../index');
console.log('simplify expressions');
console.log(math.simplify('3 + 2 / 4').toString()); // '7 / 2'
console.log(math.simplify('2x + 3x').toString()); // '5 * x'
console.log(math.simplify('2 * 3 * x', {x: 4}).toString()); // '24'
console.log(math.simplify('x^2 + x + 3 + x^2').toString()); // '2 * x ^ 2 + x + 3'
console.log(math.simplify('x * y * -x / (x ^ 2)').toString()); // '-y'

Expand Down
3 changes: 3 additions & 0 deletions lib/function/algebra/simplify.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,13 @@ function factory (type, config, load, typed, math) {
*
* simplify(expr)
* simplify(expr, rules)
* simplify(expr, rules, scope)
* simplify(expr, scope)
*
* Examples:
*
* math.simplify('2 * 1 * x ^ (2 - 1)'); // Node {2 * x}
* math.simplify('2 * 3 * x', {x: 4}); // Node {24}
* var f = math.parse('2 * 1 * x ^ (2 - 1)');
* math.simplify(f); // Node {2 * x}
*
Expand Down

0 comments on commit 4fc0c4b

Please sign in to comment.