I have used Mathematica to calculate tunneling for quantum harmonic oscillator. The code is simple:

ψ[n_, x_] := 1/Sqrt[Sqrt[Pi] 2^n n!] Exp[-x^2/2] HermiteH[n, x];
t512 = {};
For[i = 0, i <= 512, i++, 
  tim = Timing[
    N[2*Integrate[ψ[i, x]^2, {x, Sqrt[2 i + 1], Infinity}]]]; 
  Print[tim[[1]]]; Print[i];
  AppendTo[t512, tim[[2]]]];

So, essentially, we are calculating symbolically integrals of squares of the Hermite polynomials multiplied by a Gaussian. To my surprise timings (in seconds) show quasi-periodic minima:

Timings of integrals in seconds. Polynomials of order 2n, n=0,...,512

What can be the reason?

  • $\begingroup$ Your code doesn't work (just gives a bunch of error messages), and it's not clear how you got the graph you obtained. Please fix it and post a working example that produces the graph that you obtained. $\endgroup$ – DumpsterDoofus Jan 17 '15 at 22:13
  • $\begingroup$ I edited it to try fixing the issue; if this is incorrect, feel free to revert the edit. $\endgroup$ – DumpsterDoofus Jan 17 '15 at 22:21
  • $\begingroup$ Thanks for for fixing my code, which I messed up when trying to make it short. And thanks for your observation about these square roots once in a while being integers. It did not occur to me. $\endgroup$ – arkajad Jan 19 '15 at 9:45
  • $\begingroup$ Probably the calculation of values of high order polynomials at integer points is faster. $\endgroup$ – arkajad Jan 19 '15 at 10:07

Try this:

Flatten@Position[Sqrt[2 Range[512] + 1], _Integer, 1]

resulting in

{4, 12, 24, 40, 60, 84, 112, 144, 180, 220, 264, 312, 364, 420, 480}

You'll notice that the quasi-periodic oscillations are centered at the numbers in the list above. This is due to the fact that $\sqrt{2i+1}\in\mathbb{Z}$ for those values of $i$, and presumably Integrate's symbolic method for definite integration goes quicker at integer bounds.

As to why that Integrate executes faster at integers, I have no idea; Mathematica's symbolic integration methods are really complicated and I don't understand them, but perhaps someone else will have an answer for that.

|improve this answer|||||
  • $\begingroup$ I wouldn't be surprised if most of Mathematica's symbolic techniques are faster on integers....Mine are.:) $\endgroup$ – Michael E2 Jan 18 '15 at 3:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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