For some constants a and b let
f(x) = 8 - x if x <= 4
f(x) = ax + b if x > 4
The function f has the property that f(f(x)) = x for all x. What is a + b?
f(f(x)) = x for all x is a condition that says the function f is its own inverse.
We know that a function that is its own inverse must have a graph that is symmetric with respect to the line y =x.
The red graph is a plot of the function f(x) = 8 -x, x<=4. If we reflect the red graph in the line y =x (the faint dashed line) in order to make it symmetric with respect to it, we get the blue graph.
The red and the blue graph have the same equation, but different domains; the blue graph is defined for values of x to the right of 4, whereas the red graph has values of x to the left of 4 as domain.
Since the two pieces of the function have the same equation we must have
f(x) = ax +b = 8 - x = -x +8,
that is, a = -1 and b =8, and thus a + b = -1 + 8 = 7.