From db67f4cb84abdfbacc2bd1ebab5a16c152955ae2 Mon Sep 17 00:00:00 2001 From: jos Date: Sun, 22 Jan 2017 13:42:19 +0100 Subject: [PATCH] Removed method `Node.simplify()` (use function `simplify` instead) --- docs/expressions/expression_trees.md | 5 ----- lib/expression/node/Node.js | 14 -------------- lib/function/algebra/simplify.js | 4 ++-- test/function/algebra/derivative.test.js | 4 ++-- test/function/algebra/simplify.test.js | 2 +- 5 files changed, 5 insertions(+), 24 deletions(-) diff --git a/docs/expressions/expression_trees.md b/docs/expressions/expression_trees.md index f0dfe579e..1be3392e2 100644 --- a/docs/expressions/expression_trees.md +++ b/docs/expressions/expression_trees.md @@ -140,11 +140,6 @@ All nodes have the following methods: Information about the options in [Customization](customization.md#custom-latex-and-string-output). -- `simplify([rules: Array]): Node` - - Simplify the expression tree. Optionally, a custom set with rules can be - passed. See function `math.simplify` for more details. - - `toTex(options: object): string` Get a [LaTeX](http://en.wikipedia.org/wiki/LaTeX) representation of the diff --git a/lib/expression/node/Node.js b/lib/expression/node/Node.js index be88a5280..bfdf04e34 100644 --- a/lib/expression/node/Node.js +++ b/lib/expression/node/Node.js @@ -72,20 +72,6 @@ function factory (type, config, load, typed, math) { return factory(defs); }; - /** - * Simplify the expression tree. - * @param {Array<{l:string, r: string} | string | function>} [rules] - * Optional list with custom rules - * @return {Node} - * Returns the simplified expression tree. - */ - Node.prototype.simplify = function (rules) { - if (typeof rules !== 'undefined') { - return math.simplify(this, rules); - } - return math.simplify(this); - }; - /** * Compile the node to javascript code * @param {Object} defs Object which can be used to define functions diff --git a/lib/function/algebra/simplify.js b/lib/function/algebra/simplify.js index 78570d4ac..9ab45fc69 100644 --- a/lib/function/algebra/simplify.js +++ b/lib/function/algebra/simplify.js @@ -66,11 +66,11 @@ function factory (type, config, load, typed) { */ var simplify = typed('simplify', { 'string': function (expr) { - return parse(expr).simplify(simplify.rules); + return simplify(parse(expr), simplify.rules); }, 'string, Array': function (expr, rules) { - return parse(expr).simplify(rules); + return simplify(parse(expr), rules); }, 'Node': function (expr) { diff --git a/test/function/algebra/derivative.test.js b/test/function/algebra/derivative.test.js index 4cd666aa6..ed5262546 100644 --- a/test/function/algebra/derivative.test.js +++ b/test/function/algebra/derivative.test.js @@ -175,14 +175,14 @@ describe('derivative', function() { var res = math.eval('derivative("x^2", "x")'); assert.ok(res && res.isNode) - assert.equal(res.simplify().toString(), '2 * x'); + assert.equal(res.toString(), '2 * x'); }); it('should evaluate a derivative containing nodes', function() { var res = math.eval('derivative(parse("x^2"), parse("x"))'); assert.ok(res && res.isNode) - assert.equal(res.simplify().toString(), '2 * x'); + assert.equal(res.toString(), '2 * x'); }); }); diff --git a/test/function/algebra/simplify.test.js b/test/function/algebra/simplify.test.js index ad490d449..881ce89b3 100644 --- a/test/function/algebra/simplify.test.js +++ b/test/function/algebra/simplify.test.js @@ -65,7 +65,7 @@ describe('simplify', function() { }); it('should compute and simplify derivatives', function() { - var res = math.eval('simplify(derivative("5x*3x", "x"))'); + var res = math.eval('derivative("5x*3x", "x")'); assert.ok(res && res.isNode) assert.equal(res.toString(), '30 * x'); });