Function symbolicEqual #
Attempts to determine if two expressions are symbolically equal, i.e.
one is the result of valid algebraic manipulations on the other.
Currently, this simply checks if the difference of the two expressions
simplifies down to 0. So there are two important caveats:
- whether two expressions are symbolically equal depends on the
manipulations allowed. Therefore, this function takes an optional
third argument, which are the options that control the behavior
as documented for the
simplify() function.
- it is in general intractable to find the minimal simplification of
an arbitrarily complicated expression. So while a
true value
of symbolicEqual ensures that the two expressions can be manipulated
to match each other, a false value does not absolutely rule this out.
Syntax #
math.symbolicEqual(expr1, expr2)
math.symbolicEqual(expr1, expr2, options)
Parameters #
| Parameter |
Type |
Description |
expr1 |
Node | string |
The first expression to compare |
expr2 |
Node | string |
The second expression to compare |
options |
Object |
Optional option object, passed to simplify |
Returns #
| Type |
Description |
| boolean |
Returns true if a valid manipulation making the expressions equal is found. |
Throws #
Type | Description
—- | ———–
Examples #
math.symbolicEqual('x*y', 'y*x') // Returns true
math.symbolicEqual('x*y', 'y*x', {context: {multiply: {commutative: false}}}) // Returns false
math.symbolicEqual('x/y', '(y*x^(-1))^(-1)') // Returns true
math.symbolicEqual('abs(x)','x') // Returns false
math.symbolicEqual('abs(x)','x', {context: math.simplify.positiveContext}) // Returns true
See also #
simplify,
evaluate
History #
| Version |
Comment |
| v10.3 |
Created |