# The remainder when dividing an arbitrary polynomial by a quadratic

I'm currently working through the introductory materials for an online math olympiad class, and I saw this problem:

Given a polynomial $$P(x)$$, compute the remainder of $$P(x)$$ when divided by $$(x-a)(x-b)$$ in terms of $$a,b,P(a),P(b)$$

I didn't really know any algorithm for doing this, so I just used some intuition about dividing a polynomial by a linear term. If I was just dividing $$P(x)$$ by $$(x-a)$$, I know the remainder is $$P(a)$$, and we might see this expressed as $$P(x)=(x-a)Q(x)+P(a)$$ for some polynomial $$Q(x)$$. So I tried to generalize this to dividing by a quadratic term. I figured we'd have something in the form $$P(x)=(x-a)(x-b)Q(x)+R(x)$$, where $$R(x)$$ is a linear polynomial, and also the remainder.

I figured, since we have two degrees of freedom for $$R(x)$$ (since it must be linear.) I guessed I could determine $$R(x)$$ by making sure the equation $$P(x)=(x-a)(x-b)Q(x)+R(x)$$ was satisfied at $$x=a$$ and $$x=b$$. This means we want $$P(a)=R(a)$$ and $$P(b)=R(b)$$. The gives us exactly one line for $$R(x)$$, which is:

$$R(x)=\frac{P(a)-P(b)}{a-b}(x-a)+P(a)$$

And I'm pretty sure this is the correct remainder, but I'm not satisfied with my answer for two reasons. First, it looks really messy. And furthermore, I feel like there must be a simpler way to do this. I have no idea how I'd generalize this to division by cubics or quartics (Not that it's part of the problem, but it's a natural extension of it,) which usually means there's a simpler approach.

My question: Is there more to this? Am I missing a more general method?

Thank you!

Note: Some may complain that this is a homework question, but I'd like to point out that 1. I already have the answer, I just want to know if there's a better solution, and 2. This problem isn't even required and I'm not getting a meaningful grade out of this.

• +1 to your question. Further, I think that you have misunderstood mathSE reviewers' reaction to homework questions. Their negative reaction is confined to questions that do not make a reasonable attempt to conform to this article. The negative reaction is not because the question is from homework but is (instead) because the OP (i.e. original poster) made no effort to show his work or provide background. To me, your posting is the exact opposite, which is why I upvoted it. Commented Aug 25, 2021 at 3:46
• You can also write it as $\,R(x)=\frac{x-b}{a-b}P(a)+\frac{x-a}{b-a}P(b)\,$ which makes it more obvious how it generalizes. When the roots $\,a_k\,$ of the divisor are known, the remainder can indeed be determined as the polynomial interpolation between the points $\,\left(a_k, P(a_k)\right)\,$. Coincidentally, that question has just been asked in a different form here.
– dxiv
Commented Aug 25, 2021 at 3:54
• I would say that this is just the Point-Point Form for the equation of a line, standard high-school stuff in the US: if your two points are $(x_1,y_1)$ and $(x_2,y_2)$, then the line joining them is $\frac{Y-y_1}{X-x_1}=\frac{y_2-y_1}{x_2-x_1}$. Here, the two points are $(a,P(a))$ and $(b,P(b))$. This is exactly what you got, but if you have the right background, there’s no fuss, no muss. Commented Aug 25, 2021 at 3:57

If you write it as $$\frac{x-b}{a-b}P(a) + \frac{x-a}{b-a}P(b)$$, it becomes easier to see how to generalize it to higher degrees.
$$R(x) = \frac{(x-b)(x-c)}{(a-b)(a-c)}P(a) + \frac{(x-a)(x-c)}{(b-a)(b-c)}P(b) + \frac{(x-a)(x-b)}{(c-a)(c-b)}P(c)$$
All you have to do is note that $$R(a) = P(a)$$, $$R(b) = P(b)$$, $$R(c) = P(c)$$ and, since only one such quadratic can exist, this is the one.
• Or it may be written as $$R(x) = \sum_{j = 1}^{n}\frac{\prod_{i\neq j}^{n}(x-a_i)}{\prod_{i\neq j}^{n}(a_j - a_i)}P(a_j)$$ Commented Aug 25, 2021 at 6:56