Example where an inverse function does not equal the elements I'm trying to find an example of a function $f: A \to B$ and $X \subset A$ so that $f^{-1}(f(X)) \ne X$, and similarly where $Y \subset B$ so that $f(f^{-1}(Y)) \ne Y$.
I thought to have $f = x^2$, which has no inverse, thus making it vacuously true that $f^{-1}(f(X)) \ne X$ and $f(f^{-1}(Y)) \ne Y$, but that seems like a copout. Any help is greatly appreciated.

Here $f^{-1}$ does not denote inverse function of $f$ but inverse image of a set, which is defined even when $f$ is not invertible. In fact your search for an invertible example will be in vain as for invertible $f,f(f^{-1}(Y))=Y$ and $f^{-1}(f(X))=X$ for all $X\subseteq A,Y\subseteq B$.
$y(x):\Bbb R\to\Bbb R,y=x^2$ is a valid example. Take $X=\{1\}\implies f^{-1}(f(X))=f^{-1}(\{1\})=\{\pm1\}$.
Take $Y=\{0,-1\}$. Then $f(f^{-1}(Y))=f(\{0\})=\{0\}$.
