randRangeNonZero(-5, 5) randRangeNonZero(-5, 5) randRangeNonZero(-5, 5) randRangeNonZero(-5, 5)
A + B -A * D - B * C expr(["+", ["*", E, "x"], F]) expr(C === -D ? ["+", "x^2", C*D] : ["+", "x^2", ["*", -C - D, "x"], C*D] ) expr(["+", "x", -C]) expr(["+", "x", -D])

Expand \dfrac{NUMER}{DENOM} using partial fractions.

A B C D
B A D C
a + a
x-a x-a

First, factor the denominator to find the denominators of the two fractions we will split our fraction into.

DENOM = (ADENOM)(BDENOM)

Because the original denominator can be factored into these two parts, we can write out our original fraction as the sum of two fractions whose denominators are the two factors we just found.

\dfrac{NUMER}{ (ADENOM)(BDENOM) } = \dfrac{?}{ADENOM} + \dfrac{?}{BDENOM}

Now, we replace the numerators with polynomials of a degree one less than the degree of the polynomial in the denominator.

In our case, both of the denominators have a degree of 1, so we replace our numerators with polynomials of degree 0, or constants. We will use the constants A and B.

\dfrac{NUMER}{ (ADENOM)(BDENOM) } = \dfrac{A}{ADENOM} + \dfrac{B}{BDENOM}

Now, to get rid of the fractions, we multiply by the common denominator, (ADENOM)(BDENOM).

NUMER = A(BDENOM) + B(ADENOM)

Now we can solve for A and B. An easy way to do this is to try to choose values for x that will get one of A or B to cancel out, and then solve for the other one.

Let's try to cancel out B. We see that if we plug in C for x, the term with B cancels out, and we are left with:

expr(["+", E * C, F]) = A(expr(["+", C, -D]))

E * C + F = expr(["*", C - D, "A"])

A=A

We can do the same thing to solve for B, but instead plugging in D for x:

expr(["+", E * D, F]) = B(expr(["+", D, -C]))

E * D + F = expr(["*", D - C, "B"])

B=B

Now, we plug back in to our fractions, and get:

\dfrac{NUMER}{DENOM} = \dfrac{A}{ADENOM} + \dfrac{B}{BDENOM}