\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 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
t_1 := \frac{-\sqrt{\left(2 \cdot \left(t_0 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}}{t_0}\\
t_2 := \sqrt{-F}\\
\mathbf{if}\;t_1 \leq -4.219261108436416 \cdot 10^{+203}:\\
\;\;\;\;\frac{-1}{\frac{\sqrt{C}}{t_2}}\\
\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_3 := \mathsf{fma}\left(A, C \cdot -4, B \cdot B\right)\\
\mathbf{if}\;t_1 \leq -1.9628409073321262 \cdot 10^{-202}:\\
\;\;\;\;\frac{-1}{\frac{t_3}{\sqrt{t_3 \cdot \left(2 \cdot \left(F \cdot \left(\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)\right)\right)\right)}}}\\
\mathbf{elif}\;t_1 \leq 0:\\
\;\;\;\;-\frac{{\left(-F\right)}^{0.5}}{\sqrt{C}}\\
\mathbf{elif}\;t_1 \leq \infty:\\
\;\;\;\;\begin{array}{l}
t_4 := \sqrt{-8 \cdot \left(C \cdot F\right)}\\
\frac{\mathsf{fma}\left(A, \sqrt{2} \cdot t_4, \frac{F \cdot \left(\left(B \cdot B\right) \cdot \sqrt{2}\right)}{t_4}\right)}{t_3}
\end{array}\\
\mathbf{else}:\\
\;\;\;\;t_2 \cdot \frac{-1}{\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 (- (pow B 2.0) (* (* 4.0 A) C)))
(t_1
(/
(-
(sqrt
(*
(* 2.0 (* t_0 F))
(- (+ A C) (sqrt (+ (pow B 2.0) (pow (- A C) 2.0)))))))
t_0))
(t_2 (sqrt (- F))))
(if (<= t_1 -4.219261108436416e+203)
(/ -1.0 (/ (sqrt C) t_2))
(let* ((t_3 (fma A (* C -4.0) (* B B))))
(if (<= t_1 -1.9628409073321262e-202)
(/
-1.0
(/ t_3 (sqrt (* t_3 (* 2.0 (* F (- (+ A C) (hypot B (- A C)))))))))
(if (<= t_1 0.0)
(- (/ (pow (- F) 0.5) (sqrt C)))
(if (<= t_1 INFINITY)
(let* ((t_4 (sqrt (* -8.0 (* C F)))))
(/
(fma A (* (sqrt 2.0) t_4) (/ (* F (* (* B B) (sqrt 2.0))) t_4))
t_3))
(* t_2 (/ -1.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 = pow(B, 2.0) - ((4.0 * A) * C);
double t_1 = -sqrt((2.0 * (t_0 * F)) * ((A + C) - sqrt(pow(B, 2.0) + pow((A - C), 2.0)))) / t_0;
double t_2 = sqrt(-F);
double tmp;
if (t_1 <= -4.219261108436416e+203) {
tmp = -1.0 / (sqrt(C) / t_2);
} else {
double t_3 = fma(A, (C * -4.0), (B * B));
double tmp_1;
if (t_1 <= -1.9628409073321262e-202) {
tmp_1 = -1.0 / (t_3 / sqrt(t_3 * (2.0 * (F * ((A + C) - hypot(B, (A - C)))))));
} else if (t_1 <= 0.0) {
tmp_1 = -(pow(-F, 0.5) / sqrt(C));
} else if (t_1 <= ((double) INFINITY)) {
double t_4 = sqrt(-8.0 * (C * F));
tmp_1 = fma(A, (sqrt(2.0) * t_4), ((F * ((B * B) * sqrt(2.0))) / t_4)) / t_3;
} else {
tmp_1 = t_2 * (-1.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.2192611084364161e203Initial program 62.3
Simplified52.7
Taylor expanded in A around -inf 36.1
Simplified36.1
Applied associate-*r/_binary6436.1
Applied sqrt-div_binary6423.7
Applied associate-*l/_binary6423.7
Applied sqrt-unprod_binary6423.6
Simplified23.6
Applied clear-num_binary6423.6
if -4.2192611084364161e203 < (/.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.962840907332126e-202Initial program 1.1
Simplified1.3
Applied *-un-lft-identity_binary641.3
Applied distribute-lft-neg-in_binary641.3
Applied associate-/l*_binary641.4
if -1.962840907332126e-202 < (/.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 60.3
Simplified58.9
Taylor expanded in A around -inf 33.5
Simplified33.5
Applied associate-*r/_binary6433.5
Applied sqrt-div_binary6430.3
Applied associate-*l/_binary6430.3
Applied pow1/2_binary6430.3
Applied pow1/2_binary6430.3
Applied pow-prod-down_binary6430.2
Simplified30.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 38.4
Simplified25.8
Taylor expanded in A around -inf 15.9
Simplified15.9
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.6
Applied associate-*l/_binary6448.6
Applied sqrt-unprod_binary6448.5
Simplified48.5
Applied div-inv_binary6448.5
Final simplification31.6
herbie shell --seed 2021280
(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))))