You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm thinking about implementing a simple module for quantum mechanics similar to that of Sympy. The most important features would be:
kets – abstract vectors, they aren't arrays of numbers but instead symbols with specific multiplication rules
operators – abstraction of matrices, again instead of multi-dimensional arrays, they are just symbols, multiplying A * B * ket(n) is equivalent to applying operator B to the ket n and then applying operator A to the result
bras – duals of kets, multiplying bra(m) * ket(n) is equivalent to dot product of vectors
These three types of objects have to obey specific multiplication rules, and multiplication isn't commutative for them.
In Sympy these are implemented this way: each new object is defined by a class that extends the core Expression class. The classes redefine the base class's multiply method. This way they can define custom multiplication rules without modifying the core library.
If I understand it correctly, math.js doesn't have multiply method on expressions, but instead I can define a new non-commutative multiplication that extends the core Operator class and mark it as non-commutative. Is that right?
Or is there a better way to approach this?
This is what the workflow could look like:
import{Operator}from"math/quantum"letH=newOperator('H',{hermitian: true});letE3=H.eigenket(3);letscope={ H,E3}math.evaluate('dagger(H * E3) * H * E3',scope)// <E3| H⁺ H |E3> = 3 * 3 <E3|E3> = 9
EDIT: Maybe somewhat related to #467. EDIT 2: Obviously I'll need symbols first #1732.
The text was updated successfully, but these errors were encountered:
The symbolic computation that mathjs has so far uses nodes like SymbolNode and OperatorNode, the same as generated by the parser when parsing an expression (math.parse('...')).
I'm thinking about implementing a simple module for quantum mechanics similar to that of Sympy. The most important features would be:
A * B * ket(n)
is equivalent to applying operator B to the ketn
and then applying operator A to the resultbra(m) * ket(n)
is equivalent to dot product of vectorsThese three types of objects have to obey specific multiplication rules, and multiplication isn't commutative for them.
In Sympy these are implemented this way: each new object is defined by a class that extends the core
Expression
class. The classes redefine the base class'smultiply
method. This way they can define custom multiplication rules without modifying the core library.If I understand it correctly,
math.js
doesn't havemultiply
method on expressions, but instead I can define a new non-commutative multiplication that extends the coreOperator
class and mark it as non-commutative. Is that right?Or is there a better way to approach this?
This is what the workflow could look like:
EDIT: Maybe somewhat related to #467.
EDIT 2: Obviously I'll need symbols first #1732.
The text was updated successfully, but these errors were encountered: