# Find $a$ such that the piecewise function $f$ is injective and $a$ such that $f$ is surjective

Let $$f(x)= \begin{cases} ax+2, & x\leq 1 \\ \ x+2a, & x\gt 1 \end{cases}$$ where $$a\in\mathbb{R}$$

Find $$a$$ such that:

$$f$$ is injective

$$f$$ is surjective

EDIT: I need $$a$$ so $$f$$ is injective first and then surjective, not both at the same time.

I usually study injectivity and surjectivity with the first derivative, but in this case I do not think i could use that because i would have to assume the function is differentiable at $$x=1$$. So I tried taking 3 cases for injectivity:

$$f(x) = f(y)$$ where $$x\leq1$$ and $$y\leq1$$

$$f(x) = f(y)$$ where $$x\gt1$$ and $$y\gt1$$

$$f(x) = f(y)$$ where $$x\leq1$$ and $$y\gt1$$

The first 2 cases were easy to solve but i am stuck at the third case as I have too many unknowns and I do not know what to do.

For surjectivity, I tried taking limits at $$+\infty$$, $$1$$ and $$-\infty$$ to figure out the Image of $$f$$, but aside from limit to $$+\infty$$ where i get $$+\infty$$, I still have $$a$$ in the result for the other limits.

How should i solve this problem ?

• I posted an answer and then deleted it. I thought that it was sufficient to find a single value of $a$ that was both injective and surjective. Instead, the OP is asking that all values of $a$ be identified so that $f(x)$ is surjective. Separately, the OP is asking for all values of $a$ such that $f(a)$ is injective. Mar 14, 2021 at 11:11

For injectivity and surjectivity, I advise finding the range of $$f$$ when restricted to $$(-\infty, 1]$$ and when $$f$$ is restricted to $$(1, \infty)$$.

The union of these two ranges produces the range of $$f$$. So, $$f$$ is surjective if and only if the union of these ranges is $$\Bbb{R}$$.

If these ranges intersect, then the function is not injective (since there is some function value attained both in $$(-\infty, 1]$$ and $$(1, \infty)$$, contradicting injectivity). Moreover, $$f$$ is injective on both subdomains and these ranges fail to intersect if and only if $$f$$ is injective over $$\Bbb{R}$$.

So, let's consider these two ranges. Let $$R_1 = f(-\infty, 1]$$ and $$R_2 = f(1, \infty)$$. Considering $$R_1$$ first, we need to consider certain possibilities for $$a$$. If $$a = 0$$, then $$f(x) = 2$$ for all $$x \le 1$$, so $$R_1 = \{2\}$$. If $$a > 0$$, then $$f$$ is increasing on $$(-\infty, 1]$$, and tends to $$-\infty$$ as $$x \to -\infty$$, so $$R_1 = (-\infty, a + 2]$$. Finally, if $$a < 0$$, then $$f$$ is decreasing, tending to $$\infty$$ as $$x \to -\infty$$, giving us $$R_1 = [a + 2, \infty)$$. In summary, $$R_1 = \begin{cases} (-\infty, a + 2] & \text{if } a > 0 \\ \{2\} & \text{if } a = 0 \\ [a + 2, \infty) & \text{if } a < 0. \end{cases}$$

On the other hand, $$f$$ is always increasing on $$(1, \infty)$$, with $$f(x) \to \infty$$ as $$x \to \infty$$, so $$R_2 = (1 + 2a, \infty).$$

Where is $$f$$ surjective? Certainly, if $$a \le 0$$, then both $$R_1$$ and $$R_2$$ are intervals with a lower bound, thus they cannot cover all of $$\Bbb{R}$$. So, we are considering $$a > 0$$ from the get-go. In order for the two intervals $$(-\infty, a + 2]$$ and $$[1 + 2a, \infty)$$ to cover $$\Bbb{R}$$, we need $$a + 2 \ge 1 + 2a \iff a \le 1$$. So, $$f$$ is surjective if and only if $$0 < a \le 1$$.

Now, $$f$$ is always injective on $$(1, \infty)$$, and $$f$$ is injective on $$(-\infty, 1]$$ if and only if $$a \neq 0$$. Note that if $$a < 0$$, then both intervals tend are unbounded above, and thus non-trivially intersect. This implies $$f$$ is not injective if $$a \le 0$$.

If $$a > 0$$, then we need the two intervals not to intersect, which occurs precisely when $$a + 2 \le 1 + 2a \iff a \ge 1$$.

Thus, in conclusion, $$f$$ is injective when $$a \in [1, \infty)$$ and is surjective when $$a \in (0, 1]$$. It is bijective precisely when $$a = 1$$.