\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{\frac{-1}{A}} \cdot \left(-\sqrt{F}\right)\\
\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.7548547243259833 \cdot 10^{-171}:\\
\;\;\;\;\frac{\sqrt{2 \cdot \left(F \cdot \left(B \cdot B - 4 \cdot \left(A \cdot C\right)\right)\right)}}{\sqrt{B \cdot B - 4 \cdot \left(A \cdot C\right)}} \cdot \frac{-\sqrt{\left(A + C\right) + \sqrt{{\left(A - C\right)}^{2} + B \cdot B}}}{\sqrt{B \cdot B - 4 \cdot \left(A \cdot C\right)}}\\
\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 9.65589016949328 \cdot 10^{+97}:\\
\;\;\;\;\frac{-\sqrt{\left(4 \cdot \frac{\left(C \cdot C\right) \cdot \left(F \cdot \left(B \cdot B\right)\right)}{A} + 8 \cdot \left(C \cdot \left(F \cdot \left(B \cdot B\right)\right)\right)\right) - \left(\frac{F \cdot {B}^{4}}{A} + \left(\left(C \cdot C\right) \cdot \left(A \cdot F\right)\right) \cdot 16\right)}}{{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 \infty:\\
\;\;\;\;\frac{-C \cdot \left(\sqrt{\left(A \cdot F\right) \cdot -8} \cdot \sqrt{2}\right)}{{B}^{2} - \left(4 \cdot A\right) \cdot C}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{-1}{A}} \cdot \left(-\sqrt{F}\right)\\
\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 (/ -1.0 A)) (- (sqrt F)))
(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.7548547243259833e-171)
(*
(/
(sqrt (* 2.0 (* F (- (* B B) (* 4.0 (* A C))))))
(sqrt (- (* B B) (* 4.0 (* A C)))))
(/
(- (sqrt (+ (+ A C) (sqrt (+ (pow (- A C) 2.0) (* B B))))))
(sqrt (- (* B B) (* 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)))
9.65589016949328e+97)
(/
(-
(sqrt
(-
(+
(* 4.0 (/ (* (* C C) (* F (* B B))) A))
(* 8.0 (* C (* F (* B B)))))
(+ (/ (* F (pow B 4.0)) A) (* (* (* C C) (* A F)) 16.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)))
INFINITY)
(/
(- (* C (* (sqrt (* (* A F) -8.0)) (sqrt 2.0))))
(- (pow B 2.0) (* (* 4.0 A) C)))
(* (sqrt (/ -1.0 A)) (- (sqrt F))))))))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(-1.0 / A) * -sqrt(F);
} 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.7548547243259833e-171) {
tmp = (sqrt(2.0 * (F * ((B * B) - (4.0 * (A * C))))) / sqrt((B * B) - (4.0 * (A * C)))) * (-sqrt((A + C) + sqrt(pow((A - C), 2.0) + (B * B))) / sqrt((B * B) - (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))) <= 9.65589016949328e+97) {
tmp = -sqrt(((4.0 * (((C * C) * (F * (B * B))) / A)) + (8.0 * (C * (F * (B * B))))) - (((F * pow(B, 4.0)) / A) + (((C * C) * (A * F)) * 16.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))) <= ((double) INFINITY)) {
tmp = -(C * (sqrt((A * F) * -8.0) * sqrt(2.0))) / (pow(B, 2.0) - ((4.0 * A) * C));
} else {
tmp = sqrt(-1.0 / A) * -sqrt(F);
}
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 46.9
Simplified46.9
rmApplied sqrt-unprod_binary6446.8
Simplified46.8
rmApplied div-inv_binary6446.8
Applied distribute-rgt-neg-in_binary6446.8
Applied sqrt-prod_binary6440.4
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.7548547243259833e-171Initial program 1.4
rmApplied add-sqr-sqrt_binary641.5
Applied sqrt-prod_binary641.4
Applied distribute-rgt-neg-in_binary641.4
Applied times-frac_binary641.5
Simplified1.5
Simplified1.5
if -1.7548547243259833e-171 < (/.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))) < 9.65589016949328031e97Initial program 51.0
Taylor expanded around -inf 35.7
Simplified35.7
if 9.65589016949328031e97 < (/.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 51.2
Taylor expanded around inf 15.4
Final simplification32.7
herbie shell --seed 2021173
(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))))