# Background

Recently, I have been factoring quadratic equation of the form $$x^2 + ax + b$$ into $$(x+y) \cdot (x+z)$$

e.g. From $$x^2 + 3528x + 63180$$ to $$(x+3510) \cdot (x+18)$$

Normally, it is possible to obtain $$y$$ and $$z$$ by looking into every factor of $$b$$, and find 2 of them, where there product is $$b$$ and their sum is $$a$$.

However, I find this method too tedious, especially when dealing with numbers that are hard or impossible to get its factors. So, I decided to use equations to directly obtain $$y$$ and $$z$$ given $$a$$ and $$b$$.

# Question

According to the scenario,

$$y+z=a$$ $$y \cdot z = b$$

and so, how do I solve this system of equations, so that I get

$$y = \frac{-\sqrt{a^2 - 4 \cdot b} + a}{2} \, \text{and} \, z = \frac{\sqrt{a^2 - 4 \cdot b} + a}{2}$$ $$\text{or} \, y = \frac{\sqrt{a^2 - 4 \cdot b} + a}{2} \, \text{and} \, z = \frac{-\sqrt{a^2 - 4 \cdot b} + a}{2}$$ ?

If I understood the question, you want to know how to get the formulae for the roots of the second-degree polynomial equation. That isn't that hard. First, consider the equation written in the following way (this is the standard way):$$ax^2+bx+c=0$$ and let's assume $$a\not=0$$, $$b\not=0$$ and $$c\not=0$$ (otherwise, the roots are trivial!). Since $$a\not=0$$, we can divide by $$a$$ the whole equation, leading to the following expression: $$x^2+mx+n=0;\quad m=\frac{b}{a}, n=\frac{c}{n}.$$ Now add the term $$\frac{m^2}{4}$$ in both sides (complete the square). By doing this we get $$x^2+mx+n+\dfrac{m^2}{4}=\dfrac{m^2}{4}\Longleftrightarrow \left(x+\dfrac{m}{2}\right)^2=\dfrac{m^2}{4}-n.$$ Now, just solve for $$x$$ and replace $$m$$ and $$n$$ by the original values (In terms of $$a$$, $$b$$, and $$c$$):$$\left(x+\dfrac{m}{2}\right)^2=\dfrac{m^2}{4}-n\Longrightarrow x=-\dfrac{m}{2}\pm \sqrt{\dfrac{m^2}{4}-n}\Longrightarrow x=\dfrac{-b\pm\sqrt{b^2-4ac}}{2a}.$$Now, if we call $$r_0$$ and $$r_1$$ to each of the roots we get that $$r_0+r_1=-\dfrac{b}{a};\quad r_0+r_1=\dfrac{c}{a},$$ which is the answer to your question.

Note: One can write the expressions for $$r_0$$ and $$r_1$$ in other ways, like:$$r_0=\dfrac{2c}{-b+\sqrt{b^2-4ac}};\quad r_0=\dfrac{2c}{-b-\sqrt{b^2-4ac}}$$ or $$r_0=\dfrac{q}{a};r_1=\dfrac{c}{q};\quad q=-\dfrac{1}{2}\left(b+sign(b\sqrt{b^2-4ac})\right).$$All these three ways of writting the roots are equivalent, but from the point of view of numerical computation the last one is the best amonst the three (ie, if one of the roots is very large while the other is very small, computationally speaking is more accurate and stable).

• I've heard of 'pan con tomate' but not 'arroz con tomate' like in your username: is that even a thing? – Toby Mak Feb 18 at 14:05
• @TobyMak 'pan con tomate' means 'bread with tomato', which is a typical breakfast is some regions of Spain. 'Arroz con tomate' means 'rice with tomato'. – Arroz con Tomate Feb 18 at 14:22

Note that by Vieta's formulas, $$y$$ and $$z$$ satisfy $$x^2-ax+b$$, where you can use then the quadratic formula. However, many quadratics can be factored efficiently using a substitution.

You can use the AC method in reverse. In your example, divide by the largest perfect square divisor of $$63180$$, which is $$324 = 18^2$$ to get:

$$\frac{x^2}{18^2} + \frac{98}{9}x + 195=0$$ $$\Rightarrow (\frac{x}{18})^2 + 98 \cdot 2 \cdot\frac{x}{18} + 195 = 0$$ $$\Rightarrow X = \frac{x}{18}: X^2+196X+195 = 0$$

which factorises as $$(X+195)(X+1)$$. In general, $$x^2 + (k+1)x + k$$ also factorises as $$(x+k)(x+1)$$. To find the roots of the original quadratic, find $$x$$ by using $$X = x/18$$ again.

Welcome to MSE. there is a method that always gets the solution (small to a large number) and it is like below. Assume $$x_1,x_2$$ are roots of $$ax^2+bx+c$$ we can always rewrite it as$$\forall a,c,b:ax^2+bx+c=a(x-x_1)(x-x_2)$$ even in complex roots.

• That is an interesting fact to know. But unfortunately, it didn't really answer my question. My question was asking a step-by-step solution for the system of equations mentioned above, while you showed that all quadratic equations can be factored into the other form. Could you please help me by showing a way for solving the system of equations mentioned above? – Bryan351018 Feb 17 at 11:49