Using a formula, define a function $f:A\to B$ which is surjective but not injective. Let $A=[3,6]$, $B=[0,2]$.  Using a formula, define a function $f:A\to B$ which is surjective but not injective.  Prove that your function is surjective but not injective.

A possible function that may meet this requirement that I chose is:
$f(x)=2\sin(\pi x - 3\pi)$

This is surjective, and not injective. I can prove that it is not injective easily, by using a counterexample. For example, I can just show that $f(3)=f(5)=0$, and $3\neq 5$.
The part that I need help on is proving that it is surjective. Here is what I have so far:

Claim: $f $ is surjective.
Pf: A function is surjective by definition if for every $b\in B$, there is some $a \in A$ such that $f(a)=b$.
Our function $f$ has a range of $[-2,2]$ when the domain is all real numbers. When the domain is $[3,6]$, the image will be still $[-2,2]$. This means that for every $b \in B$, there is some $a \in A$ such that $f(a)=b$. Thus, we have proved directly that $f$ is surjective.

This proof seems incomplete, or inneffecient. Any advice or suggestions would be appreciated.
 A: This doesn't work because $f$ is not even a function from $A$ to $B$: as you observed yourself, the image of $f$ is $[-2,2]$.  For $f$ to be a surjection from $A$ to $B$, it first has to be a function from $A$ to $B$, which means that its image on $A$ must be contained in $B$.
A: Look for much simpler functions. Like
$$
f(x)= 
\begin{cases} 
0 & \text{ for } 3 \leq x \leq 5\\
2x-10 & \text{ for } 5 \leq x \leq 6
\end{cases}
$$
The idea is to go constant for sometime and then use a line to cover the range.

A: Your "function" is not actually a function to $B=[0,2]$ because $2 \sin (\pi x -3 \pi)$ can take values, like $-1$, that is not contained in $B$.
However, there is a tiny modification. Take $f(x)= \sin (\pi x - 3 \pi) + 1$
A: First, let's map $A=[3,6]$ to $[-2,2]$ bijectively:
$$
x\mapsto \small\frac 4 3 x- 6\colon [3,6] \to \left[- 2, 2\right ].
$$
Now take the absolute value:
$$
f(x) = \big\lvert \small\frac 4 3 x- 6\big\rvert.
$$
Then $f$ maps $[3,6]$ onto $[0,2]$ but is not injective as, for example, $f(4) = f(5)$.
