\frac{-\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) + \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C}\begin{array}{l}
\mathbf{if}\;\frac{-\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) + \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \leq -\infty:\\
\;\;\;\;-\sqrt{F} \cdot \sqrt{\frac{-1}{A}}\\
\mathbf{elif}\;\frac{-\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) + \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \leq -1.1357925545184748 \cdot 10^{-225}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)} \cdot \sqrt{\left(A + C\right) + \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}}}{{B}^{2} - \left(4 \cdot A\right) \cdot C}\\
\mathbf{elif}\;\frac{-\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) + \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \leq 0:\\
\;\;\;\;-\sqrt{\sqrt{F}} \cdot \sqrt{-\frac{\sqrt{F}}{A}}\\
\mathbf{elif}\;\frac{-\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) + \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \leq \infty:\\
\;\;\;\;\frac{-\left(C \cdot \left(\sqrt{2} \cdot \sqrt{\left(A \cdot F\right) \cdot -8}\right) + \frac{\left(B \cdot B\right) \cdot \left(F \cdot \sqrt{2}\right)}{\sqrt{\left(A \cdot F\right) \cdot -8}}\right)}{{B}^{2} - \left(4 \cdot A\right) \cdot C}\\
\mathbf{else}:\\
\;\;\;\;-\sqrt{F} \cdot \sqrt{\frac{-1}{A}}\\
\end{array}(FPCore (A B C F)
:precision binary64
(/
(-
(sqrt
(*
(* 2.0 (* (- (pow B 2.0) (* (* 4.0 A) C)) F))
(+ (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0)))))))
(- (pow B 2.0) (* (* 4.0 A) C))))(FPCore (A B C F)
:precision binary64
(if (<=
(/
(-
(sqrt
(*
(* 2.0 (* (- (pow B 2.0) (* (* 4.0 A) C)) F))
(+ (+ A C) (sqrt (+ (pow B 2.0) (pow (- A C) 2.0)))))))
(- (pow B 2.0) (* (* 4.0 A) C)))
(- INFINITY))
(- (* (sqrt F) (sqrt (/ -1.0 A))))
(if (<=
(/
(-
(sqrt
(*
(* 2.0 (* (- (pow B 2.0) (* (* 4.0 A) C)) F))
(+ (+ A C) (sqrt (+ (pow B 2.0) (pow (- A C) 2.0)))))))
(- (pow B 2.0) (* (* 4.0 A) C)))
-1.1357925545184748e-225)
(/
(-
(*
(sqrt (* 2.0 (* (- (pow B 2.0) (* (* 4.0 A) C)) F)))
(sqrt (+ (+ A C) (sqrt (+ (pow B 2.0) (pow (- A C) 2.0)))))))
(- (pow B 2.0) (* (* 4.0 A) C)))
(if (<=
(/
(-
(sqrt
(*
(* 2.0 (* (- (pow B 2.0) (* (* 4.0 A) C)) F))
(+ (+ A C) (sqrt (+ (pow B 2.0) (pow (- A C) 2.0)))))))
(- (pow B 2.0) (* (* 4.0 A) C)))
0.0)
(- (* (sqrt (sqrt F)) (sqrt (- (/ (sqrt F) A)))))
(if (<=
(/
(-
(sqrt
(*
(* 2.0 (* (- (pow B 2.0) (* (* 4.0 A) C)) F))
(+ (+ A C) (sqrt (+ (pow B 2.0) (pow (- A C) 2.0)))))))
(- (pow B 2.0) (* (* 4.0 A) C)))
INFINITY)
(/
(-
(+
(* C (* (sqrt 2.0) (sqrt (* (* A F) -8.0))))
(/ (* (* B B) (* F (sqrt 2.0))) (sqrt (* (* A F) -8.0)))))
(- (pow B 2.0) (* (* 4.0 A) C)))
(- (* (sqrt F) (sqrt (/ -1.0 A)))))))))double code(double A, double B, double C, double F) {
return -sqrt((2.0 * ((pow(B, 2.0) - ((4.0 * A) * C)) * F)) * ((A + C) + sqrt(pow((A - C), 2.0) + pow(B, 2.0)))) / (pow(B, 2.0) - ((4.0 * A) * C));
}
double code(double A, double B, double C, double F) {
double tmp;
if ((-sqrt((2.0 * ((pow(B, 2.0) - ((4.0 * A) * C)) * F)) * ((A + C) + sqrt(pow(B, 2.0) + pow((A - C), 2.0)))) / (pow(B, 2.0) - ((4.0 * A) * C))) <= -((double) INFINITY)) {
tmp = -(sqrt(F) * sqrt(-1.0 / A));
} else if ((-sqrt((2.0 * ((pow(B, 2.0) - ((4.0 * A) * C)) * F)) * ((A + C) + sqrt(pow(B, 2.0) + pow((A - C), 2.0)))) / (pow(B, 2.0) - ((4.0 * A) * C))) <= -1.1357925545184748e-225) {
tmp = -(sqrt(2.0 * ((pow(B, 2.0) - ((4.0 * A) * C)) * F)) * sqrt((A + C) + sqrt(pow(B, 2.0) + pow((A - C), 2.0)))) / (pow(B, 2.0) - ((4.0 * A) * C));
} else if ((-sqrt((2.0 * ((pow(B, 2.0) - ((4.0 * A) * C)) * F)) * ((A + C) + sqrt(pow(B, 2.0) + pow((A - C), 2.0)))) / (pow(B, 2.0) - ((4.0 * A) * C))) <= 0.0) {
tmp = -(sqrt(sqrt(F)) * sqrt(-(sqrt(F) / A)));
} else if ((-sqrt((2.0 * ((pow(B, 2.0) - ((4.0 * A) * C)) * F)) * ((A + C) + sqrt(pow(B, 2.0) + pow((A - C), 2.0)))) / (pow(B, 2.0) - ((4.0 * A) * C))) <= ((double) INFINITY)) {
tmp = -((C * (sqrt(2.0) * sqrt((A * F) * -8.0))) + (((B * B) * (F * sqrt(2.0))) / sqrt((A * F) * -8.0))) / (pow(B, 2.0) - ((4.0 * A) * C));
} else {
tmp = -(sqrt(F) * sqrt(-1.0 / A));
}
return tmp;
}



Bits error versus A



Bits error versus B



Bits error versus C



Bits error versus F
Results
if (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (+.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C))) < -inf.0 or +inf.0 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (+.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C))) Initial program 64.0
Taylor expanded around inf 47.2
Simplified47.2
rmApplied sqrt-unprod_binary64_350847.1
Simplified47.1
rmApplied div-inv_binary64_348547.1
Applied distribute-rgt-neg-in_binary64_344647.1
Applied sqrt-prod_binary64_350440.8
Simplified40.8
if -inf.0 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (+.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C))) < -1.13579255451847484e-225Initial program 1.3
rmApplied sqrt-prod_binary64_35041.3
if -1.13579255451847484e-225 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (+.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C))) < -0.0Initial program 61.7
Taylor expanded around inf 32.9
Simplified32.9
rmApplied sqrt-unprod_binary64_350832.7
Simplified32.7
rmApplied *-un-lft-identity_binary64_348832.7
Applied add-sqr-sqrt_binary64_351032.8
Applied times-frac_binary64_349432.8
Applied distribute-rgt-neg-in_binary64_344632.8
Applied sqrt-prod_binary64_350428.7
Simplified28.7
if -0.0 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (+.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C))) < +inf.0Initial program 39.5
Taylor expanded around inf 15.1
Simplified15.1
Final simplification31.0
herbie shell --seed 2021044
(FPCore (A B C F)
:name "ABCF->ab-angle a"
:precision binary64
(/ (- (sqrt (* (* 2.0 (* (- (pow B 2.0) (* (* 4.0 A) C)) F)) (+ (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0))))))) (- (pow B 2.0) (* (* 4.0 A) C))))