# Function such that its square is not integrable

I have some set $A$ of Lebesgue measure $\mu(A)=1$. Does this imply that there is some measurable function $f: \mathbb{R}^n \to \mathbb{R}$ such that $$\int_A |f| d\mu< \infty, \int_A |f|^2 d\mu= \infty$$

Certainly if $A=(0,1]$ we could take something like $f(x)=\frac{1}{\sqrt{x}}$. Is there a canonical way to solve this for arbitrary $A$?

-

Subdivide $A$ into countable disjoint sets $A_k$ of measure $C\frac{1}{k^2}$ with $C$ chosen such that the volumes add up to $\mu(A)$. Then define $f$ on $A_k$ as $k^{\alpha}$. $\alpha = 1/2$ will do. It's not canonical, but straighforward :-) I'll leave it to you to prove measurability of $f$ and existence of the $A_i$.