were to try and use it to fill the top rows, we would "fall off" the right side, thus the third sum is the first coefficient of the remainder, as in regular synthetic division. But the values of the remainder are not divided by the leading coefficient of the divisor: Now we can read off the coefficients of the answer. As in expanded synthetic division, the last two values (2 is the degree of the divisor) are the coefficients of the remainder, and the remaining values are the coefficients of the quotient: and the result is Compact Expanded Synthetic Division However, the diagonal format above becomes less space-efficient when the degree of the divisor exceeds half of the degree of the dividend. Consider the following division: It is easy to see that we have complete freedom to write each product in any row as long as it is in the correct column, so the algorithm can be compactified by a greedy strategy, as illustrated in the division below: The following describes how to perform the algorithm; this algorithm includes steps for dividing non-monic divisors: Python implementation The following snippet implements Expanded Synthetic Division in Python for arbitrary univariate polynomials: def expanded_synthetic_division(dividend, divisor): """Fast polynomial division by using Expanded Synthetic Division. Also works with non-monic polynomials. Dividend and divisor are both polynomials, which are here simply lists of coefficients. E.g.: x**2 + 3*x + 5 will be represented as [1, 3, 5] """ out = list(dividend) # Copy the dividend normalizer = divisor[0] for i in range(len(dividend) - len(divisor) + 1): # For general polynomial division (when polynomials are non-monic), # we need to normalize by dividing the coefficient with the divisor's first coefficient out[i] /= normalizer coef = out[i] if coef != 0: # Useless to multiply if coef is 0 # In synthetic division, we always skip the first coefficient of the divisor, # because it is only used to normalize the dividend coefficients for j in range(1, len(divisor)): out[i + j] += -divisor[j] * coef # The resulting out contains both the quotient and the remainder, # the remainder being the size of the divisor (the remainder # has necessarily the same degree as the divisor since it is # what we couldn't divide from the dividend), so we compute the index # where this separation is, and return the quotient and remainder. separator = 1 - len(divisor)