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...
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...