(FPCore (a b c)
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))
↓
(FPCore (a b c)
:precision binary64
(if (<= b -3.5e+141)
(- (/ c b) (/ b a))
(if (<= b 5.2e-105)
(/ (- (sqrt (+ (* b b) (* c (* a -4.0)))) b) (* a 2.0))
(/ 0.5 (fma 0.5 (/ a b) (* -0.5 (/ b c)))))))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
↓
double code(double a, double b, double c) {
double tmp;
if (b <= -3.5e+141) {
tmp = (c / b) - (b / a);
} else if (b <= 5.2e-105) {
tmp = (sqrt(((b * b) + (c * (a * -4.0)))) - b) / (a * 2.0);
} else {
tmp = 0.5 / fma(0.5, (a / b), (-0.5 * (b / c)));
}
return tmp;
}
function code(a, b, c)
return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))) / Float64(2.0 * a))
end
↓
function code(a, b, c)
tmp = 0.0
if (b <= -3.5e+141)
tmp = Float64(Float64(c / b) - Float64(b / a));
elseif (b <= 5.2e-105)
tmp = Float64(Float64(sqrt(Float64(Float64(b * b) + Float64(c * Float64(a * -4.0)))) - b) / Float64(a * 2.0));
else
tmp = Float64(0.5 / fma(0.5, Float64(a / b), Float64(-0.5 * Float64(b / c))));
end
return tmp
end
(/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 a 2)): 0 points increase in error, 0 points decrease in error
(/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (Rewrite<= *-commutative_binary64 (*.f64 2 a))): 0 points increase in error, 0 points decrease in error
(/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 a 2)): 0 points increase in error, 0 points decrease in error
(/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (Rewrite<= *-commutative_binary64 (*.f64 2 a))): 0 points increase in error, 0 points decrease in error
(/.f64 1/2 (fma.f64 1/2 (/.f64 a b) (*.f64 -1/2 (/.f64 b c)))): 0 points increase in error, 0 points decrease in error
(/.f64 1/2 (fma.f64 1/2 (/.f64 a b) (*.f64 (Rewrite<= metadata-eval (/.f64 2 -4)) (/.f64 b c)))): 2 points increase in error, 0 points decrease in error
(/.f64 1/2 (fma.f64 1/2 (/.f64 a b) (*.f64 (/.f64 2 (Rewrite<= rem-square-sqrt_binary64 (*.f64 (sqrt.f64 -4) (sqrt.f64 -4)))) (/.f64 b c)))): 0 points increase in error, 2 points decrease in error
(/.f64 1/2 (fma.f64 1/2 (/.f64 a b) (*.f64 (/.f64 2 (Rewrite<= unpow2_binary64 (pow.f64 (sqrt.f64 -4) 2))) (/.f64 b c)))): 2 points increase in error, 0 points decrease in error
(/.f64 1/2 (fma.f64 1/2 (/.f64 a b) (Rewrite<= times-frac_binary64 (/.f64 (*.f64 2 b) (*.f64 (pow.f64 (sqrt.f64 -4) 2) c))))): 0 points increase in error, 2 points decrease in error
(/.f64 1/2 (fma.f64 1/2 (/.f64 a b) (/.f64 (*.f64 2 b) (Rewrite<= *-commutative_binary64 (*.f64 c (pow.f64 (sqrt.f64 -4) 2)))))): 0 points increase in error, 2 points decrease in error
(/.f64 1/2 (fma.f64 1/2 (/.f64 a b) (Rewrite<= associate-*r/_binary64 (*.f64 2 (/.f64 b (*.f64 c (pow.f64 (sqrt.f64 -4) 2))))))): 2 points increase in error, 0 points decrease in error
(/.f64 1/2 (Rewrite<= fma-def_binary64 (+.f64 (*.f64 1/2 (/.f64 a b)) (*.f64 2 (/.f64 b (*.f64 c (pow.f64 (sqrt.f64 -4) 2))))))): 0 points increase in error, 2 points decrease in error
(/.f64 1/2 (Rewrite<= +-commutative_binary64 (+.f64 (*.f64 2 (/.f64 b (*.f64 c (pow.f64 (sqrt.f64 -4) 2)))) (*.f64 1/2 (/.f64 a b))))): 0 points increase in error, 0 points decrease in error
herbie shell --seed 2022340
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))