Implement symbols for CAS computations #3061
Replies: 11 comments
-
Thanks for your input Michal. So far we already have |
Beta Was this translation helpful? Give feedback.
-
Well, let x = new math.SymbolNode('x');
let y = new math.SymbolNode('y');
math.evaluate('det( [[ 1, x ],[ y, 0 ]] )', {x, y});
// "Unexpected type of argument in function multiplyScalar (expected: number or Complex or BigNumber or Fraction or Unit or string or boolean, actual: Node, index: 0)" I know Of course the implementation of symbols should leverage the existing functionality. After looking into the Algebra chapter of the docs, I think that allowing arithmetical operations on So should I go ahead and try implementing arithmetics on |
Beta Was this translation helpful? Give feedback.
-
I understand what you mean. The I'm not sure though if that is what you are really looking for. The example you give:
is solving an equation. It may be enough to implement a function Implementing a function |
Beta Was this translation helpful? Give feedback.
-
Thanks for your comment, I'll start working on this in a week! Just to clarify: I didn't mean solving an equation, I really meant computing the determinant with the symbol |
Beta Was this translation helpful? Give feedback.
-
That sounds good :). I don't yet have a clear idea on what you're going to implement exactly and whether that's something generic that we can put in mathjs. "the determinant with the symbol x in the upper right corner and the symbol y in the left bottom corner" sounds very specific to me? |
Beta Was this translation helpful? Give feedback.
-
I started fiddling with the implementation, but I got stuck very early. I wanted to add this overload for the 'Node, any': function(x, y) {
return new OperatorNode('+', 'add', [clone(x), clone(y)])
}, However, when I try to add In a reply to your previous comment: Determinants are used very often in antisymetrization problems, which are quite wide-spread across several disciplines (see Jacobian, Hessian, Wronskian, Slater, Vandermonde determinants), so imho it's one of the operations you'd want to perform on symbols quite often. But I'll make an actual showcase once I have a working prototype :) |
Beta Was this translation helpful? Give feedback.
-
Did you add |
Beta Was this translation helpful? Give feedback.
-
Yes, that's exactly what I did. And this alone was enough to stop the project from |
Beta Was this translation helpful? Give feedback.
-
@m93a I created a small proof of concept of being able to use function |
Beta Was this translation helpful? Give feedback.
-
This is a very valuable idea, and has spurred multiple POCs (including one I did myself), but still is rather more of a Discussion than an issue. Hence, moving. |
Beta Was this translation helpful? Give feedback.
-
Advanced CAS systems let users define their own symbols and perform symbolic operations with them. Example in Sympy. Since all math.js functions can operate on complex numbers (that means they have to call
add
andmul
methods instead of JavaScript+
and*
operators), it should be really straightforward to implement something like(EDIT: already implemented asSymbolicExpression
Node
) which behaves like a number but remembers the symbols involved.Example usage:
Beta Was this translation helpful? Give feedback.
All reactions