0
|
5461 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
GROUPS:

# Some problem with for loop not giving results

Posted 9 years ago
 nm = 100; Reap[For[v2 = -10., v2 < -9, v2 = v2 + 1/10., v[x_] := I*x^3 + I*v2*x^2; c[m_, n_] := 1./Sqrt[2^(m + n)*Factorial[m]*Factorial[n]*Pi]; x1[m_, n_] := (1/Sqrt[2.])*(Sqrt[n + 1]*KroneckerDelta[m, n + 1] + Sqrt[n]*KroneckerDelta[m, n - 1]); g[m_, n_] := c[m, n]*Integrate[ Exp[-x^2]*HermiteH[m, x]*x^3*HermiteH[n, x], {x, -Infinity, Infinity}]; p2[m_, n_] := .5*(2*n + 1)*KroneckerDelta[m, n] - .5*Sqrt[n*(n - 1)]* KroneckerDelta[m, n - 2] - .5*Sqrt[(n + 1)*(n + 2)]* KroneckerDelta[m, n + 2]; x3[m_, n_] := (1/ Sqrt[8.])*(Sqrt[(n + 1.)*(n + 2)*(n + 3)]* KroneckerDelta[m, n + 3.] + Sqrt[n*(n - 1)*(n - 2)]* KroneckerDelta[m, n - 3] + (3*(n + 1)*Sqrt[n + 1])* KroneckerDelta[m, n + 1] + 3*n*Sqrt[n]*KroneckerDelta[m, n - 1]); h[m_, n_] := p2[m, n] + I*x3[m, n] + I*v2*x[m, n]; mat = Table[h[m, n], {m, 0, nm}, {n, 0, nm}]; Eigenvalues[mat]; a = Sort[Re[Select[Eigenvalues[mat], Abs[Im[#]] < 10^-5 &]]]; j = Length[a]; b = a[[1 ;; 7]]; Sow[Join[{v2, Part[b, 1]}]]]][[2, 1]] 
2 Replies
Sort By:
Posted 9 years ago
Posted 9 years ago
 suggest you use Table instead of For and define the functions first before calling Table.
Community posts can be styled and formatted using the Markdown syntax.