Ask Your Question

Defining differential operator that acts like curl

asked 2014-12-30 07:45:21 -0500

Marios Papachristou gravatar image

updated 2014-12-30 08:19:19 -0500


As a newbie in using SAGE (experience with Python and Numpy), I was wondering how to define a differential operator that acts like curl (or $\nabla \times \vec F$). The curl for a vector field $\vec F=(F_x,F_y, F_z)$is defined as a determinant $\mathrm{det} (\nabla,\vec F) $. I want to define such operators that act on $F_x, F_y, F_z$ without calculating the determinant a priori. In other words if I was to multiply $\frac {\partial }{\partial x}$ with $F_y$, I would expect to get $\frac{\partial F_y}{\partial x}$ EDIT:

class DiffOpp(SageObject):

    def __init__(self, dep_var):
        self.dep_var = dep_var

    def __mul__(self, f):
        return diff(f, self.dep_var)
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2014-12-30 09:27:01 -0500

calc314 gravatar image

The previous question here links to a worksheet which gives the following code:

var ('x y z')
def divergence(F):
    assert(len(F) == 3)
    return diff(F[0],x) + diff(F[1],y) + diff(F[2],z) 
def curl(F):
    assert(len(F) == 3)
    return vector([diff(F[2],y)-diff(F[1],z), diff(F[0],z)-diff(F[2],x), diff(F[1],x)-diff(F[0],y)])

There is also a ticket here on this issue that has a link to some code as well.

edit flag offensive delete link more


  1. However $\nabla \cdot \vec F$ work in n-dimensions since it's a dot product
  2. I do not want to just calculate the derivative but I want the differential operator to act as a multiplier

For example the hamiltonian operator $\hat H = \frac {\hbar}{-2m} \nabla^2 + V $ can act on a wavefunction $\psi$ as $$\hat H | \psi \rangle = - \frac{\hbar}{2m} \nabla^2 \psi + V \psi$$

Marios Papachristou gravatar imageMarios Papachristou ( 2015-01-01 14:16:51 -0500 )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


Asked: 2014-12-30 07:45:21 -0500

Seen: 212 times

Last updated: Dec 30 '14