# How to determine m for which $f(x)$ is surjective?

Assume that $m \in \mathbb{R}$, $f: \mathbb{R} \rightarrow \mathbb{R}$, and $f(x) = \begin{cases} x+m,&\qquad x \le 3 \\ mx+2,&\qquad x > 3 \end{cases}$

I need to find $m$ for which the function is surjective.

Do I need to study the surjectivity in both intervals or do I have to make them equal and then study it? I'm confused about this. Thank you in advance for the answer!

-

The first part of your piecewise function has positive slope, and so will pick up all the negative numbers, and some positive reals, for suitable choice of $m$. Your second part needs to pick up the rest, which includes "most" of the positive reals. In particular, you need $m > 0$, or else this won't happen. This was all just to understand what was going on in the problem.

The easiest way to actually find some $m$ which does what you want is to set the two equations equal to each other, plug in $x=3$ and solve: \begin{align*} &\quad x+m = mx+2 \\ \Rightarrow &\quad 3+m = 3m +2 \\ \Rightarrow &\quad 1=2m \\ \Rightarrow &\quad m=\frac{1}{2}. \end{align*} Now, does this work/make sense? Well, when you plug it back into your function, the first part is $x+\frac{1}{2}$ for $x\in (-\infty,3]$ and the second part is $\frac{1}{2}x + 2$ for $x\in (3,\infty)$. Then by observation it's clear that $f$ is surjective.

EDIT: As pointed out in the comments, this isn't the only solution. In particular, see the answer below by Siminore, as well as the comments to this answer.

-
Thank you! Very well explained! – Grozav Alex Ioan May 26 '12 at 13:43
I'm glad it helped! – Derek Allums May 26 '12 at 13:57
You should probably say that $m=\frac 12$ is not the only solution but $m\in(0,\frac 12]$ is. – Simon Markett May 26 '12 at 14:44
You're right. I should've said "...easiest way to find \emph{some} m is...." I'll make an edit now. – Derek Allums May 26 '12 at 16:01

The function $x+m$ is increasing. So that means, that the first interval will give you all values $(-\infty, 3+m]$. For $m<0$ the function $mx+2$ is also decreasing. But, this is a problem, because you won't be able to get big positive numbers. Thus, we must have $m>0$. In that case you will get all values $(3m+2, \infty)$. So, you need to find an $m$ such that $3+m=3m+2$ and $m>0$. This way they overlap at the point where they meet up and you don't miss any values.

-

Here is a slight generalization. Consider the equations $r_1$ and $r_2$ of two straight lines, pick $x_0 \in \mathbb{R}$ and define a function $$f(x)=\begin{cases} r_1(x) &\text{if x \leq x_0} \\ r_2(x) &\text{if x>x_0}. \end{cases}$$ A necessary condition for surjectivity is $$\left( \lim_{x \to -\infty} f(x) \right) \cdot \left( \lim_{x \to +\infty} f(x) \right) < 0.$$ Otherwise, $\sup f$ is finite, and $f$ cannot be surjective. Now, check what happens at $x_0$. If there's a jump, it must be in the "right" direction: if $r_1$ and $r_2$ are both increasing, then $r_1(x_0) \geq r_2(x_0)$, and similarly if they are both decreasing.

-