mirror of
https://github.com/josdejong/mathjs.git
synced 2026-01-25 15:07:57 +00:00
Removed method Node.simplify() (use function simplify instead)
This commit is contained in:
parent
08ed2b4160
commit
db67f4cb84
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@ -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');
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user