\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}
t_0 := \left(A + C\right) + \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\\
t_1 := -\sqrt{F} \cdot \sqrt{\frac{-1}{A}}\\
t_2 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
t_3 := \frac{-\sqrt{\left(2 \cdot \left(t_2 \cdot F\right)\right) \cdot t_0}}{t_2}\\
\mathbf{if}\;t_3 \leq -\infty:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_3 \leq -1.0680617888819873 \cdot 10^{-199}:\\
\;\;\;\;\frac{-\sqrt{t_0 \cdot \left(2 \cdot \left(F \cdot \left(B \cdot B - 4 \cdot \left(A \cdot C\right)\right)\right)\right)}}{t_2}\\
\mathbf{elif}\;t_3 \leq 0 \lor \neg \left(t_3 \leq \infty\right):\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_4 := \sqrt{-8 \cdot \left(A \cdot F\right)}\\
\frac{-\left(\left(C \cdot \sqrt{2}\right) \cdot t_4 + \frac{F \cdot \left(\left(B \cdot B\right) \cdot \sqrt{2}\right)}{t_4}\right)}{t_2}
\end{array}\\
\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
(let* ((t_0 (+ (+ A C) (sqrt (+ (pow B 2.0) (pow (- A C) 2.0)))))
(t_1 (- (* (sqrt F) (sqrt (/ -1.0 A)))))
(t_2 (- (pow B 2.0) (* (* 4.0 A) C)))
(t_3 (/ (- (sqrt (* (* 2.0 (* t_2 F)) t_0))) t_2)))
(if (<= t_3 (- INFINITY))
t_1
(if (<= t_3 -1.0680617888819873e-199)
(/ (- (sqrt (* t_0 (* 2.0 (* F (- (* B B) (* 4.0 (* A C)))))))) t_2)
(if (or (<= t_3 0.0) (not (<= t_3 INFINITY)))
t_1
(let* ((t_4 (sqrt (* -8.0 (* A F)))))
(/
(-
(+ (* (* C (sqrt 2.0)) t_4) (/ (* F (* (* B B) (sqrt 2.0))) t_4)))
t_2)))))))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 t_0 = (A + C) + sqrt(pow(B, 2.0) + pow((A - C), 2.0));
double t_1 = -(sqrt(F) * sqrt(-1.0 / A));
double t_2 = pow(B, 2.0) - ((4.0 * A) * C);
double t_3 = -sqrt((2.0 * (t_2 * F)) * t_0) / t_2;
double tmp;
if (t_3 <= -((double) INFINITY)) {
tmp = t_1;
} else if (t_3 <= -1.0680617888819873e-199) {
tmp = -sqrt(t_0 * (2.0 * (F * ((B * B) - (4.0 * (A * C)))))) / t_2;
} else if ((t_3 <= 0.0) || !(t_3 <= ((double) INFINITY))) {
tmp = t_1;
} else {
double t_4 = sqrt(-8.0 * (A * F));
tmp = -(((C * sqrt(2.0)) * t_4) + ((F * ((B * B) * sqrt(2.0))) / t_4)) / t_2;
}
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 -1.0680617888819873e-199 < (/.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.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 63.4
Taylor expanded around inf 43.3
Simplified43.3
rmApplied sqrt-unprod_binary6443.2
Simplified43.2
rmApplied div-inv_binary6443.2
Applied distribute-rgt-neg-in_binary6443.2
Applied sqrt-prod_binary6437.4
Simplified37.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.0680617888819873e-199Initial program 1.5
rmApplied *-un-lft-identity_binary641.5
Applied associate-*r*_binary641.5
Simplified1.5
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 37.0
Taylor expanded around inf 16.9
Simplified16.9
Final simplification30.3
herbie shell --seed 2021198
(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))))