For some constants $a$ and $b,$ let $$f(x) = \left\{ \begin{array}{cl} 9 - 2x & \text{if } x \le 3, \\ ax + b & \text{if } x > 3. \end{array} \right.$$The function $f$ has the property that $f(f(x)) = x$ for all $x.$ What is $a + b?$
At first, I thought of plugging $x=1,$ to get $a+b,$ but that wouldn't be much of a help, as $1<3.$ Solution?
Assuming $a$ and $b$ exist such that they satisfy the given conditions. For $x = 0$, we get $f(x) = 9$.
It is given that, $f(f(x)) = x$
$$\therefore 9a + b = 0$$
Simillarly using $x = 1$, and $f(f(x)) = x$ we get,
$$7a + b = 1$$
Solving these two equations gives:
$$a = \frac{-1}{2}, b = \frac{9}{2}$$
Now let's show that with these values for $a$ and $b$ $f(f(x)) = x$, $\forall x \in \mathbb{R}$.
Case I: $x < 3$
It is obvious that $x < 3 \implies f(x) > 3$.
Therefore, $f(f(x)) = f(9-2x) = \frac{-1}{2}(9-2x) + \frac{9}{2} = x$
Case II: $x = 3$
$x = 3 \implies f(x) = 3 \implies f(f(x)) = 3 = x$
Case II: $x > 3$
Again it is obvious that $x > 3 \implies f(x) < 3$.
Therefore, $f(f(x)) = f(ax + b) = 9 - 2 (\frac{-1}{2}x + \frac{9}{2}) = x$