Inverse Nasty Integral Intrigued by the original question on a nasty integral, one wonders what functions $f(x)$ exist such that 

$$\int_0^\infty f(x)\; dx=\frac {\pi}2$$

Something to do with the area of a half-circle with unit radius perhaps?
Edited To Add 
It should be specified that $f(x)$ should not contain $\pi$, and is preferably a rational function. 
The intention of posting the question was to take a different approach to the the original nasty integral by first considering the answer and then working backwards, sort of a heuristic approach.
This has yielded an excellent answer posted by @achillehui below, which also addresses the original nasty integral question in a very simple way. 
 A: If $f$ is a function such as $\int_0^\infty f(x)\,dx=l$ is finite, then:


*

*If $l\neq 0$ you can simply consider the function $g=\frac{\pi}{2l}f$.

*If $l=0$ you can take any function $g$ such as $\int_0^\infty g(x)\,dx=\frac{\pi}{2}$ (for example $g(x)=\frac{1}{1+x^2}$) and then consider the function $h=f+g$.
There can be many arbitrary functions which integral over $[0,+\infty)$ exist such as $f(x)= \frac{1}{\sqrt{x}}$ if $x\in [0,1]$ and $f(x)=\frac{1}{x^2}$ if $x\in [1,+\infty)$.
A: Another perspective was given by Glaisher in the late 19th century. Suppose $f(x)$ is an even function whose integral over the real line exists. The series expansion of $f(x)$ around $x = 0$ is given as:
$$f(x) = \sum_{n=0}^{\infty}(-1)^n c_n x^{2n}$$
We can formally write $c_n$ as $E^{n}c_0$, where $E$ is the operator that when applied to $c_n$ will yield $c_{n+1}$. We can then formally express $f(x)$ as:
$$f(x) = \sum_{n=0}^{\infty}(-1)^n E^{n}c_0 x^{2n} = \frac{c_0}{1+E x^2}$$
Now, if $E$ were a positive real number we could write down:
$$\int_{0}^{\infty}f(x)dx = \frac{\pi}{2} E^{-\frac{1}{2}}c_0$$
Glaisher assumed that this is still valid for $E$ defined as above, we wrote down the identity:
$$\int_{0}^{\infty}f(x)dx = \frac{\pi}{2} c_{-\frac{1}{2}}$$
The question is then how to make sense of $c_{-\frac{1}{2}}$. In cases where $c_n$ can be expressed using factorials, one can replace these by gamma functions; Glaisher noted that this prescription always yields the correct answer for all the examples he was able to check. A proof that this indeed works was given later by Hardy, who gave a proof of Ramanujan's master theorem which generalizes Glaisher's theorem.
A: Using Glasser's Master theorem, it is very easy to cook up very nasty looking
integral which evaluates to $\frac{\pi}{2}$. 
For example, start from the integral
$$\int_{-\infty}^\infty \frac{1}{u^2+1} du = \pi\tag{*1}$$
If one replace the $u$ in integrand by $\displaystyle\;x - \frac{1}{x} - \frac{1}{x+1} - \frac{1}{x+2}$, one obtain
$$\int_{-\infty}^\infty \frac{1}{\left(x - \frac{1}{x} - \frac{1}{x+1} - \frac{1}{x+2}\right)^2 + 1} dx = \pi$$
Expand the integrand and extract the even part, you get something to challenge your friends:
$$\int_0^\infty 
\frac{
x^{14}-15x^{12}+82x^{10}-190x^8+184x^6-60x^4+16x^2
}{x^{16}-20x^{14}+156x^{12}-616x^{10}+1388x^8-1792x^6+1152x^4-224x^2+16
}\; dx = \frac{\pi}{2}$$
Notes
The statement about Glasser's Master theorem in above link is slightly off. The coefficient $|\alpha|$ in front of $x$ there need to be $1$. Otherwise, there will be an extra scaling factor on RHS of the identity. When in doubt, please consult the original paper by Glasser, 

Glasser, M. L. "A Remarkable Property of Definite Integrals." Math. Comput. 40, 561-563, 1983. 

and an online copy of that paper can be found here.
Update
About the nasty integral that trigger all this. 
If we replace the $u$ in integrand of $(*1)$ by $t - \frac{1}{t} - \frac{1}{t+1}$, change variable to $x = \frac{1}{t}$ on both intervals $[0,\infty)$ and $(-\infty, 0]$ and combine the result. We get
$$ \int_{-\infty}^\infty
\frac{1}{\left(\frac{1}{x}-x-\frac{x}{x+1}\right)^2+1} \frac{dx}{x^2}
= \int_{-\infty}^\infty \frac{1}{\left(t-\frac{1}{t}-\frac{1}{t+1}\right)^2+1} dt = \pi
$$
With help of a CAS, the integrand in leftmost integral can be expanded to
$$\frac{1}{\left(\left(\frac{1}{x}-x-\frac{x}{x+1}\right)^2+1\right)x^2} =
f(x) \stackrel{def}{=}
\frac{(x+1)^2}{x^6+4x^5+3x^4 - 4x^3 - 2x^2 + 2x + 1}$$
In terms of  $f$, we have
$$\int_{-\infty}^\infty f(x) dx = \pi \quad\implies\quad
\int_0^{\infty} \frac{f(x) + f(-x)}{2} dx = \frac{\pi}{2}\tag{*2}$$
With help of a CAS again, one find
$$\frac{f(x) + f(-x)}{2} = \frac{x^8-4x^6+9x^4-5x^2+1}{x^{12}-10x^{10}+37x^8-42x^6+26x^4-8x^2+1}$$
The rightmost integral of $(*2)$ is nothing but the nasty integral in the link.
