Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I defined a one-dimensional momentum operator $\hat{p}=-i\hbar\frac{\partial}{\partial{x}}$ in Mathematica

p = -I * h * D[#, x]&

and I want to get the kinetic energy operator $\hat{T}=\hat{p}^2/2m=-\frac{\hbar^2}{2m}\frac{\partial^2}{\partial x^2}$ from it, so

T = p^2/(2m)

but it gives the wrong result

What can I do about it? Do I have to derive the operators by hand?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

You can't just squre an operator since no multiplication of functions (operators) are defined in Mathematica. You have to write something like

T = (p@p@#)/(2 m) &

or

T = p[p[#]]/(2 m) &
share|improve this answer

Here is a more generalized method for what you want to do:

Let's define our momentum operator as you did above:

P := -I * h * D[#, x]&

Then we can define the nth power operator in a more general way as:

T[n_] := Nest[P, #, n] &

So for example the Kinetic energy operator (which is P^2 / (2 m)) will be:

T[2] / (2 m)

And we can use it on some function f as follows

(1/ (2 m))T[2]@(E^(I k x))

Which gives:

Mathematica graphics

as expected.

Now if we want P^3 we just use T[3] etc.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.