Quadratic Equation fails when a=0

Deo

New member
Joined
Sep 13, 2015
Messages
4
I'm struggling to get my head around this.

Take a very simple equation such as:

3x + 5 = 0

Plug this into the quadratic equation, and you get:

(-3 += sqrt ( 9 ) ) / 0

Divide by 0 => blows up


Obviously it is trivial to solve 3x + 5 = 0; however, the fact that the quadratic equation blows up in this scenario is highly problematic in some situations.

For example, I've written some software to solve a vector problem: Consider triangle made up of three 2d vectors. One edge is the vector P. Another edge is V*t (i.e. a vector V multiplied by a scalar t). The final edge is U*t (i.e. a vector U multiplied by the same scalar t).

P : this vector is fully known
V : this vector is fully known
U : this vector is not known, but we know that it has length s

Find the value of U and t in terms of P, V and s.

It turns out that solving this involves a quadratic equation; however, the value "a" in the quadratic equation is given by:

(V.x => x component of vector V)

a = V.x2 + V.y2 - s2


This is fine in most cases; however, where the magnitude of V is equal to s (a simply and perfectly valid example) the solution blows up because of the divide by zero.

I followed all the maths through, and it turns out that everything is correct. By hand, I come to the right solution because I have a simple linear problem to solve:

1 + t2 -2t + 1 = t2

...which is trivially t = 1;

However, plug this into the quadratic equation and it fails because a = 0.

Having a special case in my code for where a =0 (or near to zero) seems extremely cumbersome.

It seems bizarre that the quadratic equation does not work in this case...
 
I'm struggling to get my head around this.

Take a very simple equation such as:

3x + 5 = 0

Plug this into the quadratic equation, and you get:

(-3 += sqrt ( 9 ) ) / 0

Divide by 0 => blows up

Obviously it is trivial to solve 3x + 5 = 0; however, the fact that the quadratic equation blows up in this scenario is highly problematic in some situations.
Why? How is it "problemmatic" that a formula for quadratics might not work for non-quadratics? Why would you assume that the Quadratic Formula would work for non-quadratics? Especially in the case of linear equations, for which the coefficient of the squared term (that is, the value of "a" in the Formula) must, by definition, equal zero? It would be bad if the Formula did "work" somehow under those conditions! :shock:

For example, I've written some software to solve a vector problem: Consider triangle made up of three 2d vectors. One edge is the vector P. Another edge is V*t (i.e. a vector V multiplied by a scalar t). The final edge is U*t (i.e. a vector U multiplied by the same scalar t).

P : this vector is fully known
V : this vector is fully known
U : this vector is not known, but we know that it has length s

Find the value of U and t in terms of P, V and s.

It turns out that solving this involves a quadratic equation; however, the value "a" in the quadratic equation is given by:

(V.x => x component of vector V)

a = V.x2 + V.y2 - s2


This is fine in most cases; however, where the magnitude of V is equal to s (a simply and perfectly valid example) the solution blows up because of the divide by zero.
Ah. So the problem isn't that the Quadratic Formula works properly (rather than how you're wanting it to work), but that your program does not do proper error-checking and thus does not deal with special cases. The solution to this problem is to fix the program, not to break the mathematics. ;-)
 
I'm struggling to get my head around this.

Take a very simple equation such as:

3x + 5 = 0

Plug this into the quadratic equation, and you get:

(-3 += sqrt ( 9 ) ) / 0

Divide by 0 => blows up


Obviously it is trivial to solve 3x + 5 = 0; however, the fact that the quadratic equation blows up in this scenario is highly problematic in some situations.

For example, I've written some software to solve a vector problem: Consider triangle made up of three 2d vectors. One edge is the vector P. Another edge is V*t (i.e. a vector V multiplied by a scalar t). The final edge is U*t (i.e. a vector U multiplied by the same scalar t).

P : this vector is fully known
V : this vector is fully known
U : this vector is not known, but we know that it has length s

Find the value of U and t in terms of P, V and s.

It turns out that solving this involves a quadratic equation; however, the value "a" in the quadratic equation is given by:

(V.x => x component of vector V)

a = V.x2 + V.y2 - s2


This is fine in most cases; however, where the magnitude of V is equal to s (a simply and perfectly valid example) the solution blows up because of the divide by zero.

I followed all the maths through, and it turns out that everything is correct. By hand, I come to the right solution because I have a simple linear problem to solve:

1 + t2 -2t + 1 = t2

...which is trivially t = 1;

However, plug this into the quadratic equation and it fails because a = 0.

Having a special case in my code for where a =0 (or near to zero) seems extremely cumbersome.

It seems bizarre that the quadratic equation does not work in this case...

But it does if you want to extend your number system. Programming in situations like this always require 'approximations'. Where and how to do the approximations depends on just what you want and possibly the machine it will be on. As an example, since the square root can be written as a power series, let
u = 4 a c / b2
and, for u 'small', write one solution as
x0 = (-c/b) (1 + 0.25 u + ...)
depending on accuracy wanted and write the other solution as
x1 = -b/a - x0
or as NAN.

Now, one solution, x0, is returned as the proper solution as 'a goes to zero' and the other approaches the proper infinity as it should.

Or, and notice you now have a b=0 situation if you do it exactly the way suggested.
 
Why? How is it "problemmatic" that a formula for quadratics might not work for non-quadratics? Why would you assume that the Quadratic Formula would work for non-quadratics? Especially in the case of linear equations, for which the coefficient of the squared term (that is, the value of "a" in the Formula) must, by definition, equal zero? It would be bad if the Formula did "work" somehow under those conditions! :shock:

You could have worded this a lot more succinctly:

The definition of a quadratic is:

ax2 + bx + c

...where a, b and c are numbers and a is nonzero. That's all I needed to know ;)

I don't think it was that big a stretch of the imagination to understand what I was actually asking, which was this:

Is there a formula for the solution to any polynomial with degree <=2?


I suppose there is, but it's conditional:

if a nonzero => use the quadratic formula
else
if b is non-zero => -c/b
else
=> c

..very cumbersome.



I wondered if there might be an expression similar to the quadratic formula which encapsulates this complexity.

I.e. it naturally resolves itself to -c/b in the case where a = 0.

If not, can you prove that there is not?
 
You could have worded this a lot more succinctly:

The definition of a quadratic is:

ax2 + bx + c

...where a, b and c are numbers and a is nonzero. That's all I needed to know
Sorry; I'd kind of assumed, since you're in post-calculus "Advanced Math", that you knew what quadratics were. :oops:

I wondered if there might be an expression similar to the quadratic formula which encapsulates this complexity.

I.e. it naturally resolves itself to -c/b in the case where a = 0.
I can't think of any manner in which a formula (which necessarily assumes a single context) would handle cases with differing contexts. Perhaps you could propose an example of such a formula, something with which you are familiar, which suggested to you that something similar might exist for solving polynomials of varying degrees?
 
Sorry; I'd kind of assumed, since you're in post-calculus "Advanced Math", that you knew what quadratics were. :oops:

Fair point. :) Alas my academic days are many many years past and some of the basics have long since abandoned me.


I can't think of any manner in which a formula (which necessarily assumes a single context) would handle cases with differing contexts. Perhaps you could propose an example of such a formula, something with which you are familiar, which suggested to you that something similar might exist for solving polynomials of varying degrees?

I've already stated the problem in a single context: any polynomial with degree <= 2. Can you even formally define what you mean by "context"? It seems to be something arbitrary of your own construction.

Your answer boils down to "because that's the way it is". It may well be correct, but it is far from a satisfactory answer.

To elaborate on why I find it unsatisfactory, suppose we take the quadratic : ax2 + bx + c

As a tends to zero, (ax2 + bx + c) tends to (bx + c). So clearly there is a nice smooth continuum between a quadratic and a first order polynomial.

So it's it at least a little bit interesting that there is not a continuum between the quadratic formula and -c/b as a tends to zero?

To be perfectly honest, I'm not even convinced that there isn't. I wouldn't be surprised if someone who is hot on limits is able to demonstrate that the quadratic formula does indeed resolve to -c/b as a tends to zero. Further more, it wouldn't surprise me if the very definition of a quadratic has been made stricter than necessary precisely because of this fact: that plugging in specific values with a=0 fails for conventional calculators.

I appreciate that this may all be a nonsensical supposition; however, I would (genuinely) appreciate a more satiating explanation to the contrary.
 
...To elaborate on why I find it unsatisfactory, suppose we take the quadratic : ax2 + bx + c

As a tends to zero, (ax2 + bx + c) tends to (bx + c). So clearly there is a nice smooth continuum between a quadratic and a first order polynomial.

So it's it at least a little bit interesting that there is not a continuum between the quadratic formula and -c/b as a tends to zero?

...

The implementation of the theoretical world of mathematics to the practical world of programming is not always a nice smooth continuum. Things like the if-then-else constructs need to be used to implement theory because theory itself is not a nice smooth continuum. In this case there is a distinct break at a=0 in both the theoretical and practical world. At a=0 in the theoretical world the equation is no longer a quadratic, so in the practical world one must test in some way for that.

As far as tending toward zero, if I'm actually writing all the code myself and don't have a package I trust, there are several situations which can arise when the coefficients become large and/or small. For example, it is not just the value of a being small you have to worry about, it is also the relative sizes of a, b, and c. If a=-c=10-50 and b=0, the solution is x=-1 and x=1 but do you really want to put that in your quadratic formula on a computer.
 
Thanks Ishuda, I actually missed your first post, probably because I was baited by Stapel's prickly and not particularly helpful answers. I have an unfortunately tendency to be equally prickly in response.


With respect to your second answer:

In this case there is a distinct break at a=0 in both the theoretical and practical world.

Is this really true? Having now read your first response it seems there may indeed be a way to interpret the quadratic formula such that it does indeed "work" at a=0.

In which case I would be so bold as to say that the "a must be nonzero" constraint that is part of the definition of a quadratic is there only to protect one from the fact that it doesn't agree very well with a computer (or long division).
 
...there may indeed be a way to interpret the quadratic formula such that it does indeed "work" at a=0. In which case I would be so bold as to say that the "a must be nonzero" constraint that is part of the definition of a quadratic is there only to protect one from the fact that it doesn't agree very well with a computer (or long division).
Ah, yes; that unhelpful, vague, ego-protecting mathematical prickliness about division by zero. Such an unproven trifle! ;)
 
Top