[Math] Determine whether a piecewise function is injective or surjective

functionsreal-analysis

I have the following piecewise function, and I want to determine if it is injective or surjective (or both) and then calculate the inverse.
$$f : \mathbb{R} \to \mathbb{R}$$
$$f(x) = \left\{
\begin{array}{lr}
x^2 – 2, & \text{if } x \gt 0,\\
x-1, & \text{if } x \leq 0.
\end{array}
\right.
$$

I have watched videos and read a couple of questions on here, but I cannot find a clear answer. For injectivity, one suggested going through each case and checking that if $f(x) = f(y) \implies x = y$

Case 1: $x,y > 0$

$x^2 – 2 = y^2 – 2$

Clearly, $x = y$

Case 2: $x,y \leq 0$

The same as above applies for this case. $x-1 = y-1$

What if $x > 0 \text{ and } y \leq 0\text{?}$

And how should I check if this function is surjective?

Best Answer

If $x>0$ and $y\leq 0$, then obviously $x\neq y$. So if we can find $x>0$ and $y\leq 0$, such that $f(x)=f(y)$, we've shown $f$ is not injective. Consider: $$ \begin{aligned} f(x)&=f(y)\\ x^2-2&=y-1\\ x^2&=y+1\\ x&=\sqrt{y+1} \end{aligned} $$ What would now be a constriction on $y$ for this equation to hold? And what can you conclude then about injectivity?

As far as surjectivity goes: check the surjectivity in cases too, and then decide on the "total" surjectivity. I will show you how to do this for $x>0$:

We know that for $x>0$, we have that $f(x)=x^2-2$. Now I don't know how rigorous you want this to be, but I would think it's fine to immediately state that $f(x)$ covers $(-2,\infty)$, for $x>0$. You can do the same for $x\leq 0$, and then conclude on surjectivity by considering the union of both sets.

edit

I realised that checking surjectivity could have be done a little bit more rigorously, so I will show that too:

Let $y\in\mathbb R$. If $y\in(-\infty,-1]$, then for $x=y+1$, $f(x)=x-1=y$. If $y\in(-1,\infty)$, then for $x=\sqrt{y+2}$, $f(x)=x^2-2=y$. Hence, $f$ is surjective.