Is it possible to have $\int_0^\infty f(x)\,dx$ convergent and $|f|=1$ everywhere? I came across a problem that asked if it is posible for a function to be Riemann integrable function in $[0,+\infty)$ but also $|f(x)|\geq 1$ for all $x\geq 0$. 
At first I thought it was imposible, but I realized that only holds for continuous functions, because they would have to be either positive or negative, and then they would have to go to 0 at infinity. 
I have an idea of what the function would have to be like, with alternating signs, but whose integral converges, but I haven't been able to find any, so I'm starting to think it is imposible. 
I would like some help finding this function, or disproving it, as I don't know many tools for working with functions without a constant sign.
 A: Let $a_0=0,$ $a_n = \sum_{k=1}^{n}1/k, n\ge 1.$ Then $0=a_0<a_1<a_2 < \cdots $ and $a_n\to \infty.$ Define
$$f=\sum_{n=1}^{\infty}(-1)^{n}\chi_{[a_{n-1},a_n)}.$$
Then $|f|=1$ everywhere and $\int_0^\infty f(x)\,dx = -1+1/2-1/3+1/4-\cdots,$ which converges by the alternating series test.
A: 
I came across a problem that asked if it is posible for a function to be Riemann integrable function in $[0,+\infty)$ but also $|f(x)|\geq 1$ for all $x\geq 0$. 

Yes, although the integral will be improper. For each $n \in \mathbb{Z}_{\geq 1}$, divide the interval $[n-1, n]$ into $2^n$ subintervals $I_{k,n} \stackrel{\text{def}}{=}\left[n-1+\frac{k-1}{2^n}, n-1+\frac{k}{2^n}\right]$ for each $1 \leq k \leq 2^n$. Define $f_n:[n-1, n] \to \mathbb{R}$ by $f_n(x) = 1$ if $x \in I_{k,n}$ for $k$ odd, and $f_n(x) = -1$ if $x \in I_{k,n}$ for $k$ even. It is clear that $\int_{n-1}^{n} f_n = 0$. 
Now extend this to $[0, \infty)$ in the natural way by defining $f:[0, \infty) \to \mathbb{R}$ such that $f(x) = f_n(x)$ for all $x \in [n-1, n]$. A careful argument shows that for any $x \in \mathbb{R}$, $\left|\int_{0}^{x} f\right| \leq 2^{-\lceil x \rceil}$, and hence $\left|\int_{0}^{\infty} f\right| = 0$
One can use a similar argument to find a function $g$ such that $\lim_{x \to \infty} |g(x)| = \infty$, but $\int_{\mathbb{R}^{+}} g = 0$. 
A: Here is a more elementary example:
Let $\phi$ be a $1$-periodic function such that $\phi(x)=-1$ for $x \in [0,{1 \over 2})$ and $\phi(x) = 1$ for $x \in [{1 \over 2},1)$.
Note that for an integer $n$ and $x \in [0,1]$, we have $|\int_n^{n+x} \phi(2^kt)dt| \le {1 \over 2^{k+1}}$.
Define $f(x) = \sum_{n=0}^\infty 1_{[n,n+1)} \phi(2^nx)$.
Then $|f(x)| = 1$ for all $x\ge 0$ and
$\int_0^\infty f(x)dx = 0$ (the improper integral).
A: The Fresnel integral:
$$\int_0^\infty e^{ix^2}dx=\frac{(1+i)\sqrt{2\pi}}{4}$$
(The problem statement doesn't say $f$ has to be real!)
