Is there any way to write the quadratic formula such that it works for $ac= 0$ without having to make it piecewise?

The traditional solution of $x = (-b \pm \sqrt{b^2 - 4ac}) / 2a$ breaks when $a = 0$, and the less-traditional solution of $x = 2c / (-b \pm \sqrt{b^2 - 4ac})$ breaks when $c = 0$... so I'm wondering if there is a formula that works for both cases.

My attempt was to make the formula "symmetric" with respect to $a$ and $c$ by substituting $$x = y \sqrt{c/a}$$ to get $$y^{+1} + y^{-1} = -b/\sqrt{ac} = 2 w$$

whose solution is

$$y = -w \pm \sqrt{w^2 - 4}$$

which is clearly symmetric with respect to $a$ and $c$, but which doesn't really seem to get me anywhere if $ac = 0$.

(If this is impossible, it'd be nice if I could get some kind of theoretical explanation for it instead of a plain "this is not possible".)

• I still don't get this line: "[...] breaks when $a=0$." Considering $a=0$ at all doesn't seem very sensible. – Daniel W. Farlow May 5 '15 at 7:30
• @MagicMan: It's pretty sensible, I want a polynomial that gives me the right answer for all polynomials up to degree 2, and it seems strange to need a different formula for a sub-case of a general case. – Mehrdad May 5 '15 at 7:34
• Why the close vote? This is a perfectly valid question. – Jair Taylor May 5 '15 at 7:41
• @JairTaylor I voted to close as unclear what you're asking because...well, it's kind of unclear what is being asked. As Mark's answer points out, and what my comment addresses, considering $a=0$ gives you a linear equation, not a quadratic one, and hence any application of a "quadratic" formula seems nonsensical. It's not so much about the question's validity so much as it is not very clear what is being asked exactly. Maybe that will explain Mark's less than comprehensive answer (which, I presume, was the cause of the most recent edit). More detail needs to be added IMO. – Daniel W. Farlow May 5 '15 at 7:51
• Well, what Mehrdad wants is a formula for solutions of arbitrary polynomials $ax^2 + bx + c$. That's not a ill-defined problem. – Jair Taylor May 5 '15 at 7:57

I think you will always have a problem, because the "missing" solution for $a=0$ is a solution at infinity. You need two answers for the quadratic, and reducing this to the linear case will give an undefined expression representing the missing root.

Apologies, I had to get out before filling in the detail, but here is some more comment.

Taking the conventional quadratic formula with small $a$ and fixed $b,c$and examining the highest order terms, the two solutions become $-\frac {b}a$ and $-\frac cb$ plus lower order pieces.

So we have a large solution (sign depending on the sign of $a$ and which is the non-zero solution of $ax^2+bx=0$ - when $x$ is large $c$ becomes irrelevant) and a solution close to the solution of the linear equation $bx+c=0$ - where $x$ is small, the quadratic term is negligible.

Note that the second version of the solution with $c$ in the numerator has one solution which reduces to the form $\frac {2c}0$ when $a=0$, so it doesn't actually recover anything better.

To reduce a form which gives two solutions to the single solution for a linear equation requires some reduction of two solutions to one. They could become equal, but clearly that is not going to happen here (a quadratic with equal solutions is nothing like linear). Or they could disappear into a singularity or undefined space.

• I don't understand where infinity came from. If $a = 0$ then we just have $x = -c/b$ as the only solution... neither $x = +\infty$ nor $x = -\infty$ is a solution. – Mehrdad May 5 '15 at 7:50
• @Mehrdad Take the limit as $a \to 0$ - I don't have time to write it out now. Look at what happens for small $a$ - the quadratic has two solutions. – Mark Bennet May 5 '15 at 7:53
• Ohhh I see it now! Interesting point, +1. – Mehrdad May 5 '15 at 7:55
• Turns out there's a formula that works, see my own answer :) – Mehrdad May 5 '15 at 8:39
• @Mehrdad - OK, if that is what you were looking for. – Mark Bennet May 5 '15 at 8:52

Answering my own question, but I just realized this algorithm on Wikipedia works if we cheat a little and don't consider $\operatorname{sgn}(x) = |x| \div x$ a "piecewise" function:

{\begin{aligned}x_{1}&={\frac {-b-\operatorname{sgn}(b)\,{\sqrt {b^{2}-4ac}}}{2a}}\\x_{2}&={\frac {2c}{-b-\operatorname{sgn}(b)\,{\sqrt {b^{2}-4ac}}}}\end{aligned}}

• The first of these does not work for $a=0$. So you get your solution to the linear equation by having one of the two expressions undefined. But that is what happens with the quadratic formula too. – Mark Bennet May 5 '15 at 8:55
• @MarkBennet: It's not undefined, but infinity -- and as you pointed out, one of the roots is indeed infinity! – Mehrdad May 5 '15 at 9:04
• This finds solutions in the extended real number line. What does sgn return if b is zero? – Yakk May 5 '15 at 14:20
• @Yakk I think Wikipedia is trying to be too clever with notation (an unfortunate habit for mathematicians!) The point they were trying to make was that you know $x_1x_2 = c/a$. To avoid numerical cancellation you calculate the root $x_1$ with the largest modulus using the quadratic formula, taking the same sign for $-b$ and $\pm\sqrt{b^2 - 4ac}$, and then find $x_2 = c/(ax_1)$. If $b = 0$ both roots have the same modulus, so it doesn't matter which one you calculate first. – alephzero May 5 '15 at 14:55
• @Yakk: The sign of zero is zero. – Mehrdad May 5 '15 at 17:10

$x=(−b±\sqrt{b^2−4ac})/2a ...(1)$

Take limit $a \rightarrow 0,$ apply L'Hospital rule and you should get

$x = -c/b$ (solution of $bx + c = 0$) and another solution of infinity (neglecting since not defined).

There should not be any problem in equation (1) for the case of $c = 0$.

To find a symmetric formula for $ac$, both $a$ and $c$ must have equal significance in the quadratic equation which is not the case, that's why it's not possible.

• I think you mean $...b^2...$ in your first line. Just add a ^ between the b and the 2. – Rohinb97 May 5 '15 at 12:21
• @Rohinb97 : Thanks. I have edited it. – Bhaskar May 6 '15 at 5:30