I'm interested in algorithms which eliminate conditional branches:
the following problem turns up in attempting to design a robust,
straight-line, numerical quadratic equation solver, in the subcase
of a double root.
Find functions f = f(a,b,c), g = g(a,b,c) such that, given any 3 real
numbers (a,b,c) /= (0,0,0) with b*b = a*c, it is guaranteed that
(f*a + g*b, f*b + g*c) /= (0,0).
One way to do this (harking back to a related discussion on math-fun
a few years back) would be to set f = h(a a + b b), g = h(b b + c c),
where define
h(x) = ceiling(|x|) / max(1, ceiling(|x|))
= 0 when x is zero, 1 otherwise.
[The absolute value is of course redundant in this application.]
But I wonder whether it's possible to solve the problem more elegantly,
using (say) polynomial f,g; alternatively, is there some obvious reason
why this might be impossible?
Fred Lunnon