Integral $\int_0^{\infty}\frac{e^{-a x^2(x^2-\pi^2)}\cos(2\pi a x^3)}{\cosh x}dx$

EDIT @Random Variable found an error in sign in the exponent of the integrand. This is corrected, and does not affect the result. Many thanks to RV for carefully reading through.

To evaluate this integral, consider the following integral in the complex plane:

$$\oint_C \frac{dz}{\sinh{z}} e^{-a (z^2+\pi^2/4)^2}$$

where $C=C_1+C_2+C_3+C_4+C_5+C_6$ as illustrated below:

enter image description here

$$\int_{C_1} \frac{dz}{\sinh{z}} e^{-a (z^2+\pi^2/4)^2} = \int_{i \pi/2}^{R+i \pi/2} \frac{dx}{\sinh{x}} e^{-a (x^2+\pi^2/4)^2}$$ $$\int_{C_2} \frac{dz}{\sinh{z}} e^{-a (z^2+\pi^2/4)^2} = i\int_{\pi/2}^{-\pi/2} \frac{dy}{\sinh{(R+iy)}} e^{-a [(R+i y)^2+\pi^2/4]^2} $$ $$\int_{C_3} \frac{dz}{\sinh{z}} e^{-a (z^2+\pi^2/4)^2} = \int_{R-i \pi/2}^{-i \pi/2} \frac{dx}{\sinh{x}} e^{-a (x^2+\pi^2/4)^2}$$ $$\int_{C_4} \frac{dz}{\sinh{z}} e^{-a (z^2+\pi^2/4)^2} = \int_{-\pi/2}^{-\epsilon} \frac{dy}{\sin{y}} e^{-a (y^2-\pi^2/4)^2} $$ $$\int_{C_5} \frac{dz}{\sinh{z}} e^{-a (z^2+\pi^2/4)^2} = i \epsilon\int_{-\pi/2}^{\pi/2} \frac{d\phi \, e^{i \phi}}{\sinh{(\epsilon e^{i \phi}})} e^{-a [\epsilon^2 e^{i 2 \phi}+\pi^2/4]^2} $$ $$\int_{C_6} \frac{dz}{\sinh{z}} e^{-a (z^2+\pi^2/4)^2} = \int_{\epsilon}^{\pi/2} \frac{dy}{\sin{y}} e^{-a (y^2-\pi^2/4)^2} $$

We intend to take $R \to \infty$ and $\epsilon \to 0$. In this case, it should be clear that the integral over $C_2$ will vanish in the former limit. Also, the integrals over $C_4$ and $C_6$ cancel each other out as the sum is an integral over an odd integrand over a symmetric interval.

We are then left with the integrals over $C_1$, $C_3$, and $C_5$. The sum of the first two integrals, over $C_1$ and $C_3$, is

$$\underbrace{\int_{i \pi/2}^{\infty+i \pi/2} \frac{dz}{\sinh{z}} e^{-a (z^2+\pi^2/4)^2}}_{z=x+i \pi/2} + \underbrace{\int_{\infty-i \pi/2}^{-i \pi/2} \frac{dz}{\sinh{z}} e^{-a (z^2+\pi^2/4)^2}}_{z=x-i \pi/2} = \\ -i \int_0^{\infty} \frac{dx}{\cosh{x}} e^{-a x^2 (x+i \pi)^2} + i \int_{\infty}^0 \frac{dx}{\cosh{x}} e^{-a x^2 (x-i \pi)^2}$$

which is

$$-i \int_0^{\infty} \frac{dx}{\cosh{x}} e^{-a x^2 (x^2-\pi^2)} \left [ e^{i 2 \pi a x^3} + e^{-i 2 \pi a x^3}\right] = -i 2 \int_0^{\infty} \frac{dx}{\cosh{x}} e^{-a x^2 (x^2-\pi^2)} \cos{2 \pi a x^3} $$

The integral over $C_5$ is, in the limit as $\epsilon \to 0$, is

$$i \epsilon\int_{-\pi/2}^{\pi/2} \frac{d\phi \, e^{i \phi}}{\sinh{(\epsilon e^{i \phi}})} e^{-a [\epsilon^2 e^{i 2 \phi}+\pi^2/4]^2} \approx i \epsilon\int_{-\pi/2}^{\pi/2} \frac{d\phi \, e^{i \phi}}{\epsilon e^{i \phi}} e^{-a (\pi^2/4)^2} = i \pi e^{-a \pi^4/16}$$

By Cauchy's Theorem, the sum of the integrals over these contours is zero. Thus we get

$$-i 2 \int_0^{\infty} \frac{dx}{\cosh{x}} e^{-a x^2 (x^2-\pi^2)} \cos{2 \pi a x^3} + i \pi e^{-a \pi^4/16}=0$$

The result follows.

ADDENDUM

Apparently I made one edit too many and it was pointed out that the solution, clean as it is now, has become a deux ex machina. Fair enough: I will put back the motivation behind the sleight of hand.

Basically, when I looked at the integral, it screamed "complete the square in the exponentials." So, I rewrote the integral as the real part of

$$\int_0^{\infty} \frac{dx}{\cosh{x}} e^{-a x^2 (x+i \pi)^2}$$

The problem is that, while tempting to make a substitution like $u=x (x+i \pi)$, you end up having to follow a curve in the complex plane. Better, I thought, to work with something more symmetric if I am going to work in the complex plane anyway. Thus I let $x=y-i \pi/2$ so that the above integral becomes

$$-i \int_{i \pi/2}^{\infty+i \pi/2} \frac{dy}{\sinh{y}} e^{-a (y^2+\pi^2/4)^2}$$

And to me it became clear that the contour $C$ above would be useful once I did this. The rest is, well, above.