How to solve without solving by inspection? $\frac{x+5}{x+k}=\frac{-kx+5}{x-1}$ Background: This is from a test review on functions. The original problem was

Find the value of $k$ so that the function $f(x) = \frac{x+5}{x+k}$ will be its own inverse.

I found the answer by inspection, and then tried to solve it through more rigorous means. Continuing from the question title, I cross multiplied and used the quadratic formula on $k.$
$x^2+4x-5=5x+5k-kx^2-k^2x$
$k^2x+k(x^2-5)+(x^2-x-5)=0$
$k = \frac{-x+5\pm\sqrt{x^4-10x^2+25-4x(x^2-x-5)}}{2x}$
$k = \frac{-x+5\pm\sqrt{x^4-4x^3-6x^2+20x+25}}{2x}$
This is where I got stuck. Any ideas?
 A: You are close but you went in the wrong direction.  Rearrange equation 2 as follows
$x^2(k+1) + x(k^2-1) -5k - 5 = 0$
Now factor out an $k+1$ and you get $(k+1)(x^2+x(k-1) - 5) = 0$.
Now this equation must be zero for any $x$ you pick so no value of $k$ will do that except $k=-1$
A: You can use the fact that the $x$-intercept and the $y$-intercept get switched, OR you can use the fact that the horizontal asymptote and the vertical asymptote get switched.
(ADDED A FEW MINUTES LATER)
Since I am pretty sure the intended solution of this problem is how I suggested (and not by the heavy algebraic manipulations that others have given), I thought it best to give some more details.
The $x$- and $y$-intercepts of $\;y = \frac{x+5}{x+k}\;$ are $(-5,0)$ and $(0,\frac{5}{k}).$ Therefore, the $x$- and $y$-intercepts of the inverse will be $(\frac{5}{k},0)$ and $(0,-5).$ (Recall that if $(a,b)$ is on the graph of the original function, then $(b,a)$ will be on the graph of the inverse.) Since the function and its inverse are the same function (hence their graphs will be identical), it follows that $\;(-5,0) = (\frac{5}{k},0)\;$ and $\;(0,\frac{5}{k}) = (0,-5),\;$ and each of these equations gives us $\;-5 = \frac{5}{k},\;$ or $k = -1.$
Alternatively, the horizontal asymptote of $\;y = \frac{x+5}{x+k}\;$ is $y = 1$ and the vertical asymptote of $\;y = \frac{x+5}{x+k}\;$ is $x=-k.$ Therefore, the inverse will have a horizontal asymptote of $y = -k$ and a vertical asymptote of $x = 1.$ (When you perform the transformation that replaces $x$ with $y$ and replaces $y$ with $x,$ the line $y=1$ gets transformed into the line $x=1$ and the line $x=-k$ gets transformed into the line $y=-k.$ Also, if the graph gets close to the former lines far from the origin, the graph of the inverse gets close to the latter lines far from the origin, and thus the latter lines are also asymptotes.) Now, since the function and its inverse are the same function (hence their graphs will be identical), we immediately get that $k = -1.$
A: For the original problem, you can also use the fact that a self-inverse function requires that  $ \ f \ \circ \ f (x) \ = \ f( \ f(x) \ ) \ =  \ x \ $ .  (A rational function of linear polynomials is easily shown to be one-to-one.) Hence,
$$ \ \frac{\left(\frac{x+5}{x+k}\right)  + 5 }{  \left(\frac{x+5}{x+k}\right)  + k } \ \ = \ \ x  \ \ \Rightarrow \ \ \frac{\left(\frac{x+5}{x+k}\right)  + 5 }{  \left(\frac{x+5}{x+k}\right)  + k } \ \cdot \ \frac{x+k}{x+k} \ \ = \ \ x $$
$$\Rightarrow \ \ \frac{ ( x+5)   + 5  \ (x + k) }{  (x+5)   + k \ (x+k)  }  \ \ = \ \ x  \ \ \Rightarrow \ \ \frac{   6x    + (5 k+5) }{  (k+1)x   + (k ^2 + 5) } \ \ = \ \ x \ \ . $$
For this last equation to hold, the "constant term" $ \ (5k \ + \ 5) \ $ in the numerator and the "linear term" $ \ (k \ + \ 1) \ x  \ $ must vanish.  The one value of $ \ k \ $ for which this occurs also makes the "constant term" $ \ (k^2 \ +  \ 5) \ $ in the denominator match the coefficient of the "linear term" $ \ 6x \ $ in the numerator, thereby satisfying the equation.
Alternatively, in the spirit of Dave L. Renfro's answer, the domain(range) of a one-to-one function is the same as the range(domain) of its inverse.  Finding the asymptotes of $ \ f(x) \ $ tells us that the domain of the function is $  \ x \ \neq \ -k \ $ and the range is $  \ y \ \neq \ 1 \ $ (in $ \ \mathbb{R}  $ ).  But for a self-inverse function, its domain and range are identical.  Thus, $ \ -k \ = \ 1 \ $ .
A: Start by swapping the variables:
$$y=f(x)=\frac{x+5}{x+k}\implies x=\frac{y+5}{y+k}$$
and solving for $y$ from here:
$$\begin{align*}
x&=\frac{y+5}{y+k}\\[1ex]
xy+kx&=y+5\\[1ex]
xy-y&=5-kx\\[1ex]
y(x-1)&=5-kx\\[1ex]
y&=\frac{5-kx}{x-1}
\end{align*}$$
A: You want to have $f(f(x))=x$, that becomes
$$
x=\frac{f(x)+5}{f(x)+k}
$$
that is,
$$
xf(x)+kx=f(x)+5
$$
or
$$
f(x)=\frac{-kx+5}{x-1}
$$
Now let's try $f(0)$; according to the definition we have
$$
f(0)=\frac{0+5}{0+k}=\frac{5}{k}
$$
and the condition about the inverse gives
$$
f(0)=\frac{0+5}{0-1}=-5
$$
from which we obtain the necessary condition $k=-1$. Now substitute to check the necessary condition is also sufficient.
A: [I realized after posting that this observation is included in a previous answer.] The line $y=\lim_{x\to\infty}f(x)=1$ is a horizontal asymptote of the graph of $y=f(x)=\frac{x+5}{x+k}$. Therefore $x=1$ is a vertical asymptote of the graph of $y=f^{-1}(x)=f(x)$, which can only happen if $k=-1$. A bit of algebra verifies that the one possible answer, $f(x)= \frac{x+5}{x-1}$, is in fact its own inverse.
