\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 := \sqrt{F \cdot -0.5}\\
t_1 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
t_2 := \frac{-\sqrt{\left(2 \cdot \left(t_1 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}}{t_1}\\
t_3 := -\frac{t_0}{\sqrt{C}} \cdot \sqrt{2}\\
\mathbf{if}\;t_2 \leq -4.252930674637676 \cdot 10^{+216}:\\
\;\;\;\;t_3\\
\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_4 := \mathsf{fma}\left(A, C \cdot -4, B \cdot B\right)\\
\mathbf{if}\;t_2 \leq -1.7291938347211952 \cdot 10^{-222}:\\
\;\;\;\;\frac{-\sqrt{\left(2 \cdot t_4\right) \cdot \left(F \cdot \left(\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)\right)\right)}}{t_4}\\
\mathbf{elif}\;t_2 \leq 0:\\
\;\;\;\;t_3\\
\mathbf{elif}\;t_2 \leq \infty:\\
\;\;\;\;\begin{array}{l}
t_5 := \sqrt{-8 \cdot \left(C \cdot F\right)}\\
\frac{\mathsf{fma}\left(A, \sqrt{2} \cdot t_5, \frac{F \cdot \left(\sqrt{2} \cdot \left(B \cdot B\right)\right)}{t_5}\right)}{t_4}
\end{array}\\
\mathbf{else}:\\
\;\;\;\;-\frac{t_0 \cdot \sqrt{2}}{\sqrt{C}}\\
\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 (sqrt (* F -0.5)))
(t_1 (- (pow B 2.0) (* (* 4.0 A) C)))
(t_2
(/
(-
(sqrt
(*
(* 2.0 (* t_1 F))
(- (+ A C) (sqrt (+ (pow B 2.0) (pow (- A C) 2.0)))))))
t_1))
(t_3 (- (* (/ t_0 (sqrt C)) (sqrt 2.0)))))
(if (<= t_2 -4.252930674637676e+216)
t_3
(let* ((t_4 (fma A (* C -4.0) (* B B))))
(if (<= t_2 -1.7291938347211952e-222)
(/ (- (sqrt (* (* 2.0 t_4) (* F (- (+ A C) (hypot B (- A C))))))) t_4)
(if (<= t_2 0.0)
t_3
(if (<= t_2 INFINITY)
(let* ((t_5 (sqrt (* -8.0 (* C F)))))
(/
(fma A (* (sqrt 2.0) t_5) (/ (* F (* (sqrt 2.0) (* B B))) t_5))
t_4))
(- (/ (* t_0 (sqrt 2.0)) (sqrt C))))))))))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 = sqrt(F * -0.5);
double t_1 = pow(B, 2.0) - ((4.0 * A) * C);
double t_2 = -sqrt((2.0 * (t_1 * F)) * ((A + C) - sqrt(pow(B, 2.0) + pow((A - C), 2.0)))) / t_1;
double t_3 = -((t_0 / sqrt(C)) * sqrt(2.0));
double tmp;
if (t_2 <= -4.252930674637676e+216) {
tmp = t_3;
} else {
double t_4 = fma(A, (C * -4.0), (B * B));
double tmp_1;
if (t_2 <= -1.7291938347211952e-222) {
tmp_1 = -sqrt((2.0 * t_4) * (F * ((A + C) - hypot(B, (A - C))))) / t_4;
} else if (t_2 <= 0.0) {
tmp_1 = t_3;
} else if (t_2 <= ((double) INFINITY)) {
double t_5 = sqrt(-8.0 * (C * F));
tmp_1 = fma(A, (sqrt(2.0) * t_5), ((F * (sqrt(2.0) * (B * B))) / t_5)) / t_4;
} else {
tmp_1 = -((t_0 * sqrt(2.0)) / sqrt(C));
}
tmp = tmp_1;
}
return tmp;
}



Bits error versus A



Bits error versus B



Bits error versus C



Bits error versus F
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))) < -4.2529306746376758e216 or -1.7291938347211952e-222 < (/.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 62.4
Simplified56.8
Taylor expanded in A around -inf 32.8
Simplified32.8
Applied associate-*r/_binary6432.7
Applied sqrt-div_binary6424.9
if -4.2529306746376758e216 < (/.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.7291938347211952e-222Initial program 1.3
Simplified1.2
Applied associate-*r*_binary641.2
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.2
Simplified27.5
Taylor expanded in A around -inf 15.6
Simplified15.6
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))) Initial program 64.0
Simplified63.5
Taylor expanded in A around -inf 52.4
Simplified52.4
Applied associate-*r/_binary6452.4
Applied sqrt-div_binary6448.5
Applied associate-*l/_binary6448.5
Final simplification30.8
herbie shell --seed 2021224
(FPCore (A B C F)
:name "ABCF->ab-angle b"
: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))))