Let $A$ and $B$ be subsets of $\mathbb R$. Consider the function $f:A \longrightarrow B$ given by $f(x)=(x-5)^{2}+2$. For which $A$ and $B$ does $f$ have an inverse?
My answer
$f$ has an inverse iff $f$ is bijective. So I will like to choose a domain which makes $f$ an bijection. First I find the critical point of the parabola $f'(x)=0 \implies x=5$. This means that $A=[5,\infty[$ and $B=[f(5),\infty[=[2,\infty[$. But when I look up the answer $A$ and $B$ are swapped. Why?
I think you have gotten the answer you seek from the comment section (that is, the answer key is incorrect). I will show that all possible pairs $(A,B)$ are in a 1-1 correspondence with the set $\mathcal{F}$ of all functions $\phi:[2,\infty)\to \{-1,0,1\}$ with $\phi(2)\geq 0$. Note that $\mathcal{F}$ has cardinality $2^\mathfrak{c}$ where $\mathfrak{c}$ is the continuum.
For a given pair $(A,B)$, we define for each $t\geq 2$ the following: $$\phi_{A,B}(t)=\left\{\begin{array}{ll} 0&\text{if}\ t\notin B\\ 1&\text{if}\ t\in B\wedge \left(f|_{A}\right)^{-1}(t)\geq 5\\ -1&\text{if}\ t\in B\wedge \left(f|_{A}\right)^{-1}(t)<5.\end{array}\right.$$ Then, $\phi_{A,B}\in \mathcal{F}$.
For a given $\phi\in\mathcal{F}$, we define the pair $(A_\phi,B_\phi)$ as follows: $$A_\phi=\big\{5-\sqrt{t-2}\ :\ \phi(t)=-1\big\}\cup \big\{5+\sqrt{t-2}\ : \phi(t)=1\big\}$$ and $$B_\phi=\phi^{-1}\big(\{-1,1\}\big)=\big\{t\in\mathbb{R}\ :\ \phi(t)=\pm1\big\}.$$ Then we can see that $f_\phi:A_\phi\to B_\phi$ given by the restriction of $f$ onto $A_\phi$ is bijective with inverse $$f_\phi^{-1}(y)=\left\{\begin{array}{ll} 5-\sqrt{y-2}&\text{if}\ \phi(y)=-1\\ 5+\sqrt{y-2}&\text{if}\ \phi(y)=1. \end{array}\right.$$
Now $A$ is maximal if and only if $\phi_{A,B}^{-1}(0)$ is empty, so $B=[2,\infty)$. If $A$ is a connected subset of $\Bbb{R}$, then $A$ is either a subinterval of $(-\infty,5]$ or a subinterval of $[5,\infty)$. Particularly, if $A$ is both connected and maximal, then $A=(-\infty,5]$ or $A=[5,\infty)$, with $B=[2,\infty)$.