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...
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:
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: