Simple Vector analysis

30 views
Skip to first unread message

Alexander Heger

unread,
Apr 17, 2023, 10:43:07 AM4/17/23
to sympy
I am trying to do some simple vector algebra/analysis, but am not sure how to start getting useful results with SymPy.

Here an example:

from sympy.tensor.tensor import TensorIndexType, TensorHead
from sympy.tensor.toperators import PartialDerivative
from sympy import symbols
from sympy.tensor.tensor import TensorSymmetry
sym2 = TensorSymmetry.fully_symmetric(2)
L = TensorIndexType("L")
A = TensorHead("A", [L,L], sym2)
x = TensorHead("x", [L])
i, j, k = symbols("i j k")
PartialDerivative(A(-i,-j)*x(i)*x(j), x(j))

The result is 

PartialDerivative(A(-L_0, -L_1)*x(L_0)*x(L_1), x(j))

Assuming A is constant, how can make SymPy to evaluate this to the expression below?

2 * A(-j, -L_1)*x(L_0)



Reply all
Reply to author
Forward
0 new messages