- #1
Poirot
- 94
- 3
I am trying to numerically solve the recurrence relation for:
$$ T[n]=\frac{sm}{2\hbar^2i k_n}(T[n-1]+T[n+1]) \\
k_n=(\frac{2m(E-\hbar \omega n)}{\hbar^2})^{1/2}$$
My code is:
Taking all the constants to be 1, except E which I have plugged to be zero, to ensure non negative root.
I think I need my seed values to be $$T_{-2}$$ and $$T_{2} (=1)$$ so it's at the end of the boundary but I keep getting the error that the recursion depth of 1024 has been exceeded and I've tried "Block" and set it as high as possible without crashing the kernel to no avail. If I plug $$T_{-2}=T_{-1}=1$$ I actually get an answer but if I use interpolating to see what this looks like it's blowing up exponentially (I'm taking the Abs of it as complex). I was told to look for convergence but to me, this seems like divergence, which may be due to not being able to set the end points.
How can I actually plug end points into get a reasonable answer?
Thanks in advance, and apologies for my lack of coding ability, I'm very new to Mathematica.
$$ T[n]=\frac{sm}{2\hbar^2i k_n}(T[n-1]+T[n+1]) \\
k_n=(\frac{2m(E-\hbar \omega n)}{\hbar^2})^{1/2}$$
My code is:
Code:
RecurrenceTable[{Tn[
n] == (s*
m/(2*\[HBar]^2*
I*(2*m*(En - \[HBar]*\[Omega]*n)/\[HBar]^2)^(1/2)))*(Tn[
n - 1] + Tn[n + 1]), Tn[-2] == 1, Tn[2] == 1}, Tn, {n, -2, 2}]
I think I need my seed values to be $$T_{-2}$$ and $$T_{2} (=1)$$ so it's at the end of the boundary but I keep getting the error that the recursion depth of 1024 has been exceeded and I've tried "Block" and set it as high as possible without crashing the kernel to no avail. If I plug $$T_{-2}=T_{-1}=1$$ I actually get an answer but if I use interpolating to see what this looks like it's blowing up exponentially (I'm taking the Abs of it as complex). I was told to look for convergence but to me, this seems like divergence, which may be due to not being able to set the end points.
How can I actually plug end points into get a reasonable answer?
Thanks in advance, and apologies for my lack of coding ability, I'm very new to Mathematica.