The CES Utility Function
A more general way of modeling substitutability is via a constant elasticity of substitution (CES) utility function, which may be written \(u(x_1,x_2) = \left(\alpha x_1^r + (1  \alpha)x_2^r\right)^{1 \over r}\) A little math shows that the MRS of this utility function is \(MRS = {\alpha \over 1  \alpha} \left( {x_2 \over x_1}\right)^{1  r}\) There are two parameters in this utility function:

$\alpha$, as usual, measures how much the agent likes good 1, relative to good 2. This is a number between 0 and 1; when $\alpha = {1 \over 2}$, the utility function weighs the two goods equally. The higher $\alpha$ is, the more the agent likes good 1; this is illustrated by a higher MRS, or a higher willingness to give up good 2 to get good 1. If $\alpha = 1$, it means the agent doesn’t care about good 2 at all, and the utility function just becomes $u(x_1,x_2) = x_1$. (When $\alpha = 0$, likewise, the utility function becomes $u(x_1,x_2) = x_2$.)

$r$ measures the complementarity or substitutability of the two goods: when $r > 0$, the goods are substitutes, and when $r < 0$, the goods are complements. It affects how quickly the MRS changes as you move down and to the right along an indifference curve. The more substitutable goods are, the less quickly the MRS changes, and the “shallower” the indifference curves are.
You can check to see that the marginal utilities for this are positive, so the preferences are monotonic. For any $r < 1$ the MRS is decreasing as you move down and to the right (i.e., as $x_1$ increases and $x_2$ decreases), so the preferences are also convex. For any $r > 1$ the MRS is increasing as you move down and to the right, so the preferences are concave.
Try playing with $\alpha$ and $r$ in the diagram below to see how the indifference map changes:
Note that when $r$ is an extremely large negative number, the indifference curves approach the Lshaped curves of the perfect complements utility function; when $r = 0$, the indifference curves resemble those of a CobbDouglas utility function; and when $r = 1$, the indifference curves are linear like a perfect substitutes utility function. In fact, if you compare the MRS of those utility functions, you can confirm that this is the case. It also illustrates that there is a wide range of preference that are complements but not perfect complements (with $\infty < r < 0$) and substitutes but not perfect substitutes (with $0 < r < 1$).