Maths on a Chalk Plain

A maths and science blog by Rory Phillips.

Partial Fractions V: Finding the Fractions.

Posted 11th April 2025.
Previous Post ||| Next Post Coming Soon!

Having proved that the numerators in a compliant decomposition are, without doubt, constant, we may now concern ourselves with calculating their values. For simpler examples, this can be done by hand. If you need a refresher on the method, I recommend looking back over the first post. Unfortunately, even with basic examples, its a reasonably time consuming process, and it only becomes increasingly onerous as the denominator's order continues to increase. By way of example, consider \[ \frac{ x }{ (x+1)^3(x+2) }. \] This fraction's denominator only has order four, but already we will see it is quite lengthy to solve by hand. Let us work through the solution.

First, we'll set up our identity. \[ \frac{ x }{ (x+1)^3(x+2) } \equiv \frac{ A }{ x+1 } + \frac{ B }{ (x+1)^2 } + \frac{ C }{ (x+1)^3 } + \frac{ D }{ x+2 } \] Then multiply it out. \[ x \equiv A(x+1)^2(x+2) + B(x+1)(x+2) + C(x+2) + D(x+1)^3 \] Some constants, namely \(C\) and \(D\), can be obtained trivially, as by making the appropriate substitutions, we can eliminate all other constants. \[ \textrm{let} \quad x=-1 \] \[ -1 = C(-1+2) \] \[ C = -1 \] \[ \textrm{let} \quad x=-2 \] \[ -2 = D(-2+1)^3 \] \[ D = 2 \] We can rewrite our identity with \(C\) and \(D\) replaced with their respective values. \[ x \equiv A(x+1)^2(x+2) + B(x+1)(x+2) - (x+2) + 2(x+1)^3 \] From here, we must make substitions at random to obtain further equations, as our choice of \(x\) can no longer eliminate any constants. \[ \textrm{let} \quad x=0 \] \[ 0 = A(0+1)^2(0+2) + B(0+1)(0+2) - (0+2) +2(0+1)^3 \] \[ 0 = 2A + 2B - 2 + 2 \] \[ A + B = 0 \] \[ \textrm{let} \quad x=-3 \] \[ -3 = A(-3+1)^2(-3+2) + B(-3+1)(-3+2) - (-3+2) +2(-3+1)^3 \] \[ -3 = -4A + 2B + 1 - 16 \] \[ 4A - 2B = -12 \] \[ 2A - B = -6 \] We now have a system of two linear equations, which we can solve for \(A\) and \(B\). \[ (A+B) + (2A-B) = 0 + (-6) \] \[ 3A = -6 \] \[ A = -2 \] \[ (-2) + B = 0 \] \[ B = 2 \] Consequently, the final form of our decomposition comes to \[ \frac{ x }{ (x+1)^3(x+2) } \equiv - \frac{ 2 }{ x+1 } + \frac{ 2 }{ (x+1)^2 } - \frac{ 1 }{ (x+1)^3 } + \frac{ 2 }{ x+2 }. \] As you can see, finding solutions very quickly become more complicated.

The sluggishness of the human hand restricts our horizons to very simple fractions. This is simply no good! What if we want to calculate those whose tops and bottoms have orders in the tens or hundreds? Having been provided with ample motivation, we may now set out to write a computer program to compute them for us. It is natural to start with the easy part of the task: finding the constants which are 'trivial' to compute. The code that does this is given below.

part_frac.cpp, decomposition.find_trivials(), 156-161
for (int i = 0; i < denominator.size(); i++) {
	double input = -(denominator[i].constant_term / denominator[i].coefficient);
	denominator[i].solutions.push_back(get_polynomial_value(input) / get_product(input, i, 0));
}

The so called 'trivial' values are computed by substituting such that all other constants are eliminated. Therefore, it only works for constants whose denominators are the highest power of their respective factor. \[ \frac{ C }{ (x+1)^3 } \] is an example from above. To find the value which must be substituted, we simply negate the constant term in the factor, in this case \(-1\). You will see (also above) that upon substitution of this value, everything else disappears.

We must now generalise this process so that it can be written as code. The trivial constant is always a quotient. The dividend is the LHS of the equation, \(x\) in the above example, though it can be any from a certain set of polynomials. The divisor is the product of the remaining factors that \(C\) is multiplied by, just \((x+2)\) in the example. As a word equation,
constant = numerator polynomial \(\div\) factor product.

Our code now does these steps in order. First, we find the value that we need to substitute.

double input = -(denominator[i].constant_term / denominator[i].coefficient);
We then use the word equation above to find the constant.
denominator[i].solutions.push_back(get_polynomial_value(input) / get_product(input, i, 0));}