# Homework Help: Calculating energy for particle in finite box.

1. Mar 8, 2010

### knut-o

[solved] Calculating energy for particle in finite box.

1. The problem statement, all variables and given/known data
I am going to look at a particle in a finite boxpotential where V(x)=-V0 for -a<x=<a
And they are bound, in other words -V0<E<0. This is a transcendtale equation that need to be solved graphicly/numericly.
I am aware of two solutions, one of odd, and one of even.

2. Relevant equations
To make calculation easier, the task defines $$k=\frac{\sqrt{2m|E|}}{\hbar}, l=\frac{\sqrt{2m(V_0+E)}}{\hbar}=\frac{\sqrt{2m(V-|E|)}}{\hbar}$$
Also told that solution for the equation is $$ltan(la)=k$$ (even) and $$lcot(la)=-k (odd)$$
Rewriting these to, for odd: $$zcot(z)=-\sqrt{z_0 ^2-z}$$ and for even: $$ztan(z)=\sqrt{z_0 ^2-z^2}$$ where z=l*a and $$z_0 ^2=\frac{2mV0a^2}{\hbar ^2}$$

Now, I am tolk to solve these numericly for V0=10eV and a=1nm, and m as electronic mass:

3. The attempt at a solution
Since it's a numerical task, I am writing it in matlab, but getting some horrible answers.
Since I am told to express the energi to the end I use the relevant units for my program (this could be the issue, but my graph is just a straight line).
So here is my program (agian, it's written in MATlab, but the pseudocode should be easy to recognize for other languages):

figure(1) %For even functions:
V0=10; %eV
a=1; nm
z=0:.0.1:5*pi/2; %This one aswell, but the tan/cot-functions make this a sensible choise?
m=511000; %eV/c^2
h=6.582*10^(-16); eVs
k=sqrt(2*m*abs(E))/h;
l=sqrt(2*m*(V0+E))/h;
z0=(a^2/h^2)*2*m*V0;

y11=z.*tan(z); %Gives the array for left side of the equation
y12=sqrt(z0^2-z.^2); % Should give array for right side of equation
plot(z,y11,'-r') %Plots it into figure 1 with a red line
hold 'on'
plot(z,y12) %Plots it into same figure with a blue (default) line.

The problem I end up with, is that it's in the size order of 1037, so plotting it on same graph as something with size order of about 1-10 is just silly. So I am wondering where the program fails. It should be quite easy to calcute, considering z is just an array running from 0 to (a number) and z0 is a constant, but I end up with a straight line for the right side, which according to my book (David J. Griffits, Introduction to Quantum Mechanics, figure 2.18: page 80) says it two quite defined graphs, which is also where I got my z-array from, but the plot he is using ($$tan(z)=\sqrt{\frac{z0}{z} ^2-1}$$) gives distinct points where they cross, whereas mine deosn't look anything like it.

I am only suppoosed to find the first one (where they cross) and then calcutate E, but what formula do I use for that? Do I put it into $$z=l\cdot a=\frac{\sqrt{2m(V0+E)}}{\hbar}a\Rightarrow E=\frac{(\frac{z\hbar}{a})^2}{2m}-V0$$?
And then how do I express it in eV without having to calculate it to Joule first, then divide by the value of charge of an electron?

Halp.

Edit: I've done some breakthrough when it comes to the task, turns out, the z0 constant is easy to calculate, so I am very curious, and stressing about what I should use for z, amd what about the E? Should I make a loop that is just slooow?

Edit2: No need to respond, I solved it all by myself now :) .

Last edited: Mar 8, 2010