Ask Your Question
1

How do I use sage to check differential vector identities? Do I need to create an operator?

asked 2021-07-29 22:18:10 +0100

Willians gravatar image

updated 2021-07-29 22:30:53 +0100

Hi!
I would like to check some differential vector identities. Any suggestion to achieve this goal would be welcomed.


Example of a case I already worked out: $\vec{\nabla} (fg) = (\vec{\nabla}f) g + f (\vec{\nabla} g)$.

Code (I coudn't manage to put it on a single box, sorry):

from sage.manifolds.operators import *
E.<x,y,z> = EuclideanSpace()
f = function('f')(x,y,z)
g = function('g')(x,y,z)
sff = E.scalar_field(sff, name = 'sff')
sfg = E.scalar_field(sfg, name = 'sfg')
sffg = E.scalar_field(sffg, name = 'sffg')
grad(sffg) == grad(sff) * sfg + sff * grad(sfg)

Out: True


Example of what I want to check: $ \vec{\nabla} (\vec{A}\centerdot \vec{B}) = \vec{A}\times(\vec{\nabla} \times \vec{B}) + \vec{B} \times (\vec{\nabla} \times \vec{A}) + (\vec{A} \centerdot \vec{\nabla}) \vec{B} + (\vec{B} \centerdot \vec{\nabla}) \vec{A}. $ I don't know how to came to differential operators of the form $(\vec{A} \centerdot \vec{\nabla})$.

I tried (kind of hopelessly) newOperator=A.dot(grad()) without success.

How could I put sage to check identities like this one?

Thank you in advance.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-07-30 03:39:47 +0100

eric_g gravatar image

You can define the following Python function:

def dotnabla(A, B):
    nabla = E.metric().connection()
    return nabla(B).contract(A)

which evaluates $(\vec{A}\cdot\vec{\nabla})\vec{B}$ as the contraction $A^j\nabla_j B^i$.

edit flag offensive delete link more

Comments

Thank you a lot, Eric! This is what I was searching for.

Willians gravatar imageWillians ( 2021-07-30 14:40:29 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2021-07-29 22:18:10 +0100

Seen: 249 times

Last updated: Jul 30 '21