# Are there any efficient methods to manually factor a quadratic in two variables?

For a quadratic in two variables, $$ax^2+bxy+cy^2+dx+ey+f$$ may be factored into the form $$(p_1x+q_1y+r_1)(p_2x+q_2y+r_2)$$ given that $$\det\begin{bmatrix}a & b/2 & d/2\\ b/2 & c & e/2\\d/2 & e/2 & f \end{bmatrix}=0$$.

By expanding out the general factored form:

\begin{align}&(p_1x+q_1 y+r_1)(p_2x+q_2 y+r_2) \\ = &\,p_1p_2x^2+(p_1q_2+p_2q_1)xy+q_1q_2y^2+(p_1r_2+p_2r_1)x+(q_1r_2+q_2r_1)y+r_1r_2\end{align}

It can be noted through comparison of coefficients:

$$\begin{cases}a=p_1p_2 \\ b=p_1q_2+p_2q_1 \\ c=q_1q_2 \\ d=p_1r_2+p_2r_1 \\ e=q_1r_2+q_2r_1 \\ f=r_1r_2 \end{cases} \\$$

One method to determine the values for $$p_1, p_2, q_1, q_2, r_1, r_2$$ would be through guessing and checking values that satisfy all six conditions. However, doing such a method manually is inefficient. For the univariate case, there exist several methods such as decomposition, slide and divide, as well as the quadratic formula to determine the values in a more systematic manner. Does there exist a similar procedure for the bivariate case?

• To be honest, I don't think most univariate quadratic (even if with integer coeffcients) are factorizable, let alone easily so. Dec 27, 2023 at 17:39
• Hopefully someone will write a fuller answer, but basically, a better method hinges on the fact that the degree-2 homogeneous parts must necessarily be equal, so that $ax^2+bxy+cy^2=(p_1x+q_1y)(p_2x+q_2y)$. Dec 27, 2023 at 17:40
• @GregMartin I answered with a general method that relies on taking a symmetric matrix $H$ and finding nonsingular $P$ with $P^T H P = D$ diagonal. I may have chosen a discouraging example. Dec 27, 2023 at 19:51

I made up a problem, I think I will leave in the variable $$z$$ It is Sylvester's Law of Inertia that says the matrix $$D$$ will include a zero on the diagonal. See

http://zakuski.math.utsa.edu/~jagy/Brookfield_Factoring_Forms_2016.pdf

$$66x^2 + 40 y^2 + 82 z^2 + 88 yz + 72 zx + 96 xy$$ As I made it up, I know this one does factor. If you have trouble completing the square, there is an algorithm of Lagrange;

The matrix identity called $$Q^T D Q = H$$ says the original from is equal to $$66 \left(x + \frac{8}{11}y + \frac{6}{11}z \right)^2 + \frac{56}{11} \left( y + \frac{7}{2}z \right)^2$$

Let us write this $$\frac{1}{11} \left(6 \left(11x + 8y + 6z \right)^2 + 56 \left( y + \frac{7}{2}z \right)^2 \right)$$

or $$\frac{1}{11} \left(\sqrt 6 \left(11x + 8y + 6z \right) + i \sqrt{56} \left( y + \frac{7}{2}z \right) \right) \left(\sqrt 6 \left(11x + 8y + 6z \right) - i\sqrt {56} \left( y + \frac{7}{2}z \right) \right)$$

$$\bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc$$

$$P^T H P = D$$

$$\left( \begin{array}{rrr} 1 & 0 & 0 \\ - \frac{ 8 }{ 11 } & 1 & 0 \\ 2 & - \frac{ 7 }{ 2 } & 1 \\ \end{array} \right) \left( \begin{array}{rrr} 66 & 48 & 36 \\ 48 & 40 & 44 \\ 36 & 44 & 82 \\ \end{array} \right) \left( \begin{array}{rrr} 1 & - \frac{ 8 }{ 11 } & 2 \\ 0 & 1 & - \frac{ 7 }{ 2 } \\ 0 & 0 & 1 \\ \end{array} \right) = \left( \begin{array}{rrr} 66 & 0 & 0 \\ 0 & \frac{ 56 }{ 11 } & 0 \\ 0 & 0 & 0 \\ \end{array} \right)$$ 

$$Q^T D Q = H$$

$$\left( \begin{array}{rrr} 1 & 0 & 0 \\ \frac{ 8 }{ 11 } & 1 & 0 \\ \frac{ 6 }{ 11 } & \frac{ 7 }{ 2 } & 1 \\ \end{array} \right) \left( \begin{array}{rrr} 66 & 0 & 0 \\ 0 & \frac{ 56 }{ 11 } & 0 \\ 0 & 0 & 0 \\ \end{array} \right) \left( \begin{array}{rrr} 1 & \frac{ 8 }{ 11 } & \frac{ 6 }{ 11 } \\ 0 & 1 & \frac{ 7 }{ 2 } \\ 0 & 0 & 1 \\ \end{array} \right) = \left( \begin{array}{rrr} 66 & 48 & 36 \\ 48 & 40 & 44 \\ 36 & 44 & 82 \\ \end{array} \right)$$

$$\bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc$$

Algorithm discussed at reference for linear algebra books that teach reverse Hermite method for symmetric matrices
https://en.wikipedia.org/wiki/Sylvester%27s_law_of_inertia
$$H = \left( \begin{array}{rrr} 66 & 48 & 36 \\ 48 & 40 & 44 \\ 36 & 44 & 82 \\ \end{array} \right)$$ $$D_0 = H$$ $$E_j^T D_{j-1} E_j = D_j$$ $$P_{j-1} E_j = P_j$$ $$E_j^{-1} Q_{j-1} = Q_j$$ $$P_j Q_j = Q_j P_j = I$$ $$P_j^T H P_j = D_j$$ $$Q_j^T D_j Q_j = H$$

$$H = \left( \begin{array}{rrr} 66 & 48 & 36 \\ 48 & 40 & 44 \\ 36 & 44 & 82 \\ \end{array} \right)$$

==============================================

$$E_{1} = \left( \begin{array}{rrr} 1 & - \frac{ 8 }{ 11 } & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \\ \end{array} \right)$$ $$P_{1} = \left( \begin{array}{rrr} 1 & - \frac{ 8 }{ 11 } & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \\ \end{array} \right) , \; \; \; Q_{1} = \left( \begin{array}{rrr} 1 & \frac{ 8 }{ 11 } & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \\ \end{array} \right) , \; \; \; D_{1} = \left( \begin{array}{rrr} 66 & 0 & 36 \\ 0 & \frac{ 56 }{ 11 } & \frac{ 196 }{ 11 } \\ 36 & \frac{ 196 }{ 11 } & 82 \\ \end{array} \right)$$

==============================================

$$E_{2} = \left( \begin{array}{rrr} 1 & 0 & - \frac{ 6 }{ 11 } \\ 0 & 1 & 0 \\ 0 & 0 & 1 \\ \end{array} \right)$$ $$P_{2} = \left( \begin{array}{rrr} 1 & - \frac{ 8 }{ 11 } & - \frac{ 6 }{ 11 } \\ 0 & 1 & 0 \\ 0 & 0 & 1 \\ \end{array} \right) , \; \; \; Q_{2} = \left( \begin{array}{rrr} 1 & \frac{ 8 }{ 11 } & \frac{ 6 }{ 11 } \\ 0 & 1 & 0 \\ 0 & 0 & 1 \\ \end{array} \right) , \; \; \; D_{2} = \left( \begin{array}{rrr} 66 & 0 & 0 \\ 0 & \frac{ 56 }{ 11 } & \frac{ 196 }{ 11 } \\ 0 & \frac{ 196 }{ 11 } & \frac{ 686 }{ 11 } \\ \end{array} \right)$$

==============================================

$$E_{3} = \left( \begin{array}{rrr} 1 & 0 & 0 \\ 0 & 1 & - \frac{ 7 }{ 2 } \\ 0 & 0 & 1 \\ \end{array} \right)$$ $$P_{3} = \left( \begin{array}{rrr} 1 & - \frac{ 8 }{ 11 } & 2 \\ 0 & 1 & - \frac{ 7 }{ 2 } \\ 0 & 0 & 1 \\ \end{array} \right) , \; \; \; Q_{3} = \left( \begin{array}{rrr} 1 & \frac{ 8 }{ 11 } & \frac{ 6 }{ 11 } \\ 0 & 1 & \frac{ 7 }{ 2 } \\ 0 & 0 & 1 \\ \end{array} \right) , \; \; \; D_{3} = \left( \begin{array}{rrr} 66 & 0 & 0 \\ 0 & \frac{ 56 }{ 11 } & 0 \\ 0 & 0 & 0 \\ \end{array} \right)$$

==============================================

$$\bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc$$

$$P^T H P = D$$

$$\left( \begin{array}{rrr} 1 & 0 & 0 \\ - \frac{ 8 }{ 11 } & 1 & 0 \\ 2 & - \frac{ 7 }{ 2 } & 1 \\ \end{array} \right) \left( \begin{array}{rrr} 66 & 48 & 36 \\ 48 & 40 & 44 \\ 36 & 44 & 82 \\ \end{array} \right) \left( \begin{array}{rrr} 1 & - \frac{ 8 }{ 11 } & 2 \\ 0 & 1 & - \frac{ 7 }{ 2 } \\ 0 & 0 & 1 \\ \end{array} \right) = \left( \begin{array}{rrr} 66 & 0 & 0 \\ 0 & \frac{ 56 }{ 11 } & 0 \\ 0 & 0 & 0 \\ \end{array} \right)$$ 

$$Q^T D Q = H$$

$$\left( \begin{array}{rrr} 1 & 0 & 0 \\ \frac{ 8 }{ 11 } & 1 & 0 \\ \frac{ 6 }{ 11 } & \frac{ 7 }{ 2 } & 1 \\ \end{array} \right) \left( \begin{array}{rrr} 66 & 0 & 0 \\ 0 & \frac{ 56 }{ 11 } & 0 \\ 0 & 0 & 0 \\ \end{array} \right) \left( \begin{array}{rrr} 1 & \frac{ 8 }{ 11 } & \frac{ 6 }{ 11 } \\ 0 & 1 & \frac{ 7 }{ 2 } \\ 0 & 0 & 1 \\ \end{array} \right) = \left( \begin{array}{rrr} 66 & 48 & 36 \\ 48 & 40 & 44 \\ 36 & 44 & 82 \\ \end{array} \right)$$

$$\bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc$$

• Unrelated, but didn't know you were at UTSA. Dec 27, 2023 at 20:22
• @SeanRoberson not me, my grad school friend Dmitry Gokhman. Dec 27, 2023 at 20:30

First note that you can multiply the first factor by a constant $$\alpha$$ and divide the second one by the same number, and you get the original polynomial. So wlog assume $$a\ne 0$$. Then you can choose $$p_1=1$$ and $$p_2=a$$. Look at the next two equations: $$b=p_1q_2+p_2q_1=q_2+aq_1\\c=q_1q_2$$multiply the last equation by $$a$$: $$aq_1+q_2=b\\(aq_1)q_2=ac$$ So $$aq_1$$ and $$q_2$$ are solutions of the quadratic $$z^2-bz+ac=0$$ You can also now find $$r_1$$ and $$r_2$$ from the fourth and fifth equations (linear system of two equations with two variables).