What is the domain and range of the rational function $\frac{x-5}{2x+1}$? This is a homework question from a precalculus class that I'm a TA for.

What is the domain and range of the function
  $$f(x) = \frac{x-5}{2x+1}\,?$$

I wanted to write up a thorough solution to this exercise for my class, and figured I'd post it online to help anyone else who may wander across it.
 A: Since $f$ is a rational function, the only restriction that we need to impose on the domain of $f$ will be to exclude values of $x$ for which the denominator of $f$ is zero$\ast$, since dividing by zero is an undefined operation. The denominator equals zero when $x = -\frac{1}{2}$, so the domain of $f$ will consist of all real number except for $-\frac{1}{2}$. If we felt inclined to, we could express this domain as either of the following:
$$
    \left(-\infty,-\frac{1}{2}\right) \cup \left(-\frac{1}{2},\infty\right)\qquad\qquad \mathbb{R}\setminus\left\{-\frac{1}{2}\right\}
$$
Now for the range of $f$, we need to find the set of all $y$ for which there exists some $x$ where
$$y = \frac{x-5}{2x+1}\,.$$
We can rearrange this equation, solving for $x$ in terms of $y$, to give us an explicit formula for which $x$ will result in a given $y$. Then we can determine the range of $f$ by noting for which $y$ the formula will be undefined. 
$$\begin{align*}
y &= \frac{x-5}{2x+1}
\\[0.7em] (2x+1)y &= x-5
\\[0.7em] 2xy-x &= -5-y
\\[0.7em] x &= -\frac{5+y}{2y-1}
\end{align*}$$
This formula is defined for all $y \neq \frac{1}{2}$; for every other real number $y$ we can use this formula to find a corresponding $x$ such that $f(x)=y$. So $\frac{1}{2}$ is the only value which is not in the range of $f$, and we can express the range of $y$ as either of the following:
$$
    \left(-\infty,\frac{1}{2}\right) \cup \left(\frac{1}{2},\infty\right)\qquad\qquad \mathbb{R}\setminus\left\{\frac{1}{2}\right\}
$$

$\ast$ Thoroughly justifying this statement is kinda complicated. I wouldn't expect my precalculus class to justify this. I suppose if you really wanted to though, you could proceed by showing $f$ can be written as a composite of the functions 
$$
  r(x) = \frac{1}{x} \qquad S_a(x) = ax \qquad T_b(x) = x+b \qquad\text{for } a,b \in \mathbb{R}\,,
$$
and since $S_a$ and $T_b$ are bijective functions $\mathbb{R} \to \mathbb{R}$, so the only domain restrictions we have to impose on $f$ are those that come from the function $r$. 
