Tricky Integral $\int_{0}^{\pi/2} \left[\frac{\sec^2 \theta}{2}\cdot \exp(\frac{\sec^2 \theta}{2})\right]^{-1} d\theta$ - Brain Slayer Given the integral
$$
\int_{0}^{\pi/2}
\left[\frac{\sec^{2}\left(\theta\right)}{2}
\exp\left(\frac{\sec^{2}\left(\theta\right)}{2}\right)\right]^{\,-1} \mathrm{d}\theta
$$
How am supposed to evaluate it within few minutes $?$. Is there a quick trick solve the integral $?$.
Should you wish to see my attempt at doing so, then you should know that my solution is analyzed the author's one, because I could not solve it without seeing clues. So, I would like to get some ideas from; I think that I fail to solve this guy because I could not see something...
 A: $$I=2\int_{0}^{\pi/2} \cos^2 x e^{-\frac{1}{2}sec^2 x} dx$$
Let $\tan x=t$, then
$$I= 2e^{-1/2}\int_{0}^{\infty} \frac{e^{-t^2/2}}{(1+t^2)^2} dt=
=2e^{-1/2}\int_{0}^{\infty} e^{-t^2/2} \int_{0}^{\infty} z e^{-z(1+t^2)} dz.$$
$$\implies I=2e^{-1/2} \int_{0}^{\infty} ze^{-z}\int_{0}^{\infty} e^{-(1/2+z)t^2}dt=\sqrt{2\pi}e^{-1/2}\int_{0}^{\infty} \frac{z e^{-z}}{\sqrt{1+2z}} dz$$
Let $1+2z=u^2$ then
$$I=\frac{\sqrt{2\pi}}{2} e^{-1/2}\int_{1}^{\infty} (u^2-1)~ e^{-(u^2-1)/2} du=\frac{\sqrt{2\pi}}{2} \int_{1}^{\infty} (u^2-1)e^{-u^2/2}du=\sqrt{\frac{\pi}{2e}}.$$
A: I would be surprised if one can solve this integral within a few minutes without any prior knowledge. But there are some ideas that helps tackle this integral.
1. Write
$$ I = \int_{0}^{\frac{\pi}{2}} (2\cos^2\theta) e^{-\frac{1}{2}\sec^2\theta} \, \mathrm{d}\theta. $$
If you see an exponential function of something other than linear or quadratic polynomials inside the integral sign, then that integral is highly unlikely to be tackled directly except for some lucky cases. So, if we believe that this integral can be computed in a closed form, then we may first try to make the exponent simpler. Here, let us make the substitution $x = \tan\theta$. Then
$$ I = 2 \int_{0}^{\infty} \frac{1}{(x^2+1)^2} e^{-\frac{1}{2}(x^2+1)} \, \mathrm{d}x. $$
2. If we write $y = x^2 + 1$ for simplicity, we now that the integrand takes the form $\frac{1}{y^2} e^{-y/2}$. Both the factor $\frac{1}{y^2}$ and the exponential $e^{-y/2}$ suggest that we might possibly use the trick:
$$ \frac{1}{y^2} = \int_{0}^{\infty} s e^{-ys} \, \mathrm{d}s. $$
Plugging this to the integral $I$ above and interchanging the order of integration, we indeed confirm that the integral now assumes a much familiar form:
$$ I
= 2 \int_{0}^{\infty} \int_{0}^{\infty} s e^{-(x^2+1)(s+\frac{1}{2})} \, \mathrm{d}x\mathrm{d}s
= \sqrt{\pi} \int_{0}^{\infty} \frac{s}{(s+\frac{1}{2})^{1/2}} e^{-(s+\frac{1}{2})} \, \mathrm{d}s. $$
Although we can push this direction further to find the value of $I$, we will stop at here as it is already covered in another answer.
This trick can be thought as a generalization of integration by parts. As such, it serves as a versatile tool for computing many other tricky integrals. Here is another example of this sort:

Exercise. Using the above trick, show that
$$ \int_{0}^{\infty} \frac{\sin^2 x}{x^2} \, \mathrm{d}x = \frac{\pi}{2}. $$
(Hint: $\int_{0}^{\infty} e^{-sx} \sin^2 x \, \mathrm{d}x = \frac{2}{s(s^2+4)}$ for $s > 0$.)

3. Alternatively, we may ask if we can "cancel out" $\frac{1}{y^2}$ factor, since the integral will be much easier to compute if this factor were not there. This idea can be realized by invoking the Feynman's trick: Let
$$ f(s) := 2 \int_{0}^{\infty} \frac{1}{(x^2+1)^2} e^{-s(x^2+1)} \, \mathrm{d}x. $$
Then $I = f(1/2)$, and using the gaussian integral we check that
$$ f(\infty) = f'(\infty) = 0, \qquad f''(\alpha) = 2 \int_{0}^{\infty} e^{-s(x^2+1)} \, \mathrm{d}x = \sqrt{\frac{\pi}{s}} \, e^{-s}. $$
Then applying the "initial" condition $f'(\infty) = 0$ to $\int \sqrt{\frac{\pi}{s}} \, e^{-s} \, \mathrm{d}s = \pi \operatorname{erf}(\sqrt{s}) + C$ gives
$$ f'(s) = \pi (\operatorname{erf}(\sqrt{s}) - 1). $$
Similarly as before, using
\begin{align*}
\int \pi (\operatorname{erf}(\sqrt{s}) - 1) \, \mathrm{d}s
&= \pi s (\operatorname{erf}(\sqrt{s}) - 1) - \int \sqrt{\pi s} e^{-s} \, \mathrm{d}s \\
&= \pi s (\operatorname{erf}(\sqrt{s}) - 1) + \sqrt{\pi s} e^{-s} - \int \frac{\sqrt{\pi}}{2\sqrt{s}} e^{-s} \, \mathrm{d}s \\
&= \pi s (\operatorname{erf}(\sqrt{s}) - 1) + \sqrt{\pi s} e^{-s} - \frac{\pi}{2} \operatorname{erf}(\sqrt{s}) + C
\end{align*}
and applying the "initial" condition $f(\infty) = 0$,
$$ f(s) = \pi \bigl( s - \tfrac{1}{2} \bigr) (\operatorname{erf}(\sqrt{s}) - 1) + \sqrt{\pi s} e^{-s}. $$
Plugging $s = \frac{1}{2}$ gives the desired answer.
This is another versatile tool for computing many tricky integral. The key idea is to perturb the integrand by introducing an auxiliary parameter, and performing some calculus to the resulting integral regarded as a function of that parameter.
In the following example, both the idea in part 2 and Feynman's trick is utilized:

Exercise. For $a > 0$, consider the integral
$$ f(a) = \int_{0}^{\infty}\int_{0}^{\infty} a \cos(ax)\sin(ay)e^{-a xy} \, \mathrm{d}x\mathrm{d}y. $$
Computing this in two ways to show that
$$ f(a) = \int_{0}^{\infty} \frac{\cos(ax)}{x^2 + 1} \, \mathrm{d}x = \int_{0}^{\infty} \frac{y \sin(ay)}{y^2 + 1} \, \mathrm{d}y. $$
Using this, check that $f'(a) = -f(a)$ and $f(0) = \frac{\pi}{2}$. The unique solution of this equation for $a \geq 0$ is $f(a) = \frac{\pi}{2}e^{-a}$, hence it determines the value of the above integral.

A: Note
$$I= \int_{0}^{\pi/2} \left(\frac12{\sec^2 \theta}\>e^{\frac{\sec^2 \theta}{2}}\right)^{-1} d\theta
= J\left(\frac12\right)
$$
where
$$J(a)=2 \int_{0}^{\pi/2} \frac{e^{-a\sec^2\theta}}{\sec^2\theta}d\theta, \>\>\>\>\>\>\>J’(a)= -2\int_{0}^{\pi/2} e^{-a\sec^2\theta}d\theta, \\
J’’(a)=2\int_{0}^{\pi/2} e^{-a\sec^2\theta}\sec^2\theta d\theta
= 2\int_{0}^{\pi/2} e^{-a(1+\tan^2\theta)}d(\tan\theta)=\frac{\sqrt\pi e^{-a}}{\sqrt a}
$$
and $J(\infty)=J’(\infty)=0$. Then
\begin{align}
I &=J\left(\frac12\right)=-\int_{\frac12}^\infty J’(a)da\\
&=\int_{\frac12}^\infty\left( \int_a^\infty J’’(s)ds \right)\>da
=\int_{\frac12}^\infty\left(\int_{\frac12}^s J’’(s) da\right) \> ds\\
&=\int_{\frac12}^\infty (s-\frac12) J’’(s) ds
=\int_{\frac12}^\infty (s-\frac12)\frac{\sqrt\pi e^{-s}}{\sqrt s}ds\\
& =-\sqrt\pi \int_{\frac12}^\infty d(\sqrt s e^{-s} ) 
=\sqrt{\frac{\pi}{2e}}
\end{align}
