# Defining differential operator that acts like curl

Hello,

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 close merge delete

Sort by » oldest newest most voted

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,x) + diff(F,y) + diff(F,z)
def curl(F):
assert(len(F) == 3)
return vector([diff(F,y)-diff(F,z), diff(F,z)-diff(F,x), diff(F,x)-diff(F,y)])


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

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$$