\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}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;-\frac{{\left(-F\right)}^{0.5}}{\sqrt{C}}\\
\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_2 := \mathsf{fma}\left(A, C \cdot -4, B \cdot B\right)\\
\mathbf{if}\;t_1 \leq -3.6630033190351204 \cdot 10^{-209}:\\
\;\;\;\;\begin{array}{l}
t_3 := \sqrt{\mathsf{hypot}\left(B, A - C\right)}\\
\frac{-\sqrt{\left(2 \cdot \left(F \cdot \left(A + C\right)\right)\right) \cdot t_2 + t_2 \cdot \left(\left(F \cdot \left(t_3 \cdot t_3\right)\right) \cdot -2\right)}}{t_2}
\end{array}\\
\mathbf{elif}\;t_1 \leq 0:\\
\;\;\;\;\sqrt{-F} \cdot \frac{-1}{\sqrt{C}}\\
\mathbf{elif}\;t_1 \leq \infty:\\
\;\;\;\;\frac{A \cdot \left(\sqrt{2} \cdot \sqrt{-8 \cdot \left(C \cdot F\right)}\right)}{t_2}\\
\mathbf{else}:\\
\;\;\;\;-\frac{\sqrt{F \cdot -0.5}}{\frac{\sqrt{C}}{\sqrt{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 (- (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)))
(if (<= t_1 (- INFINITY))
(- (/ (pow (- F) 0.5) (sqrt C)))
(let* ((t_2 (fma A (* C -4.0) (* B B))))
(if (<= t_1 -3.6630033190351204e-209)
(let* ((t_3 (sqrt (hypot B (- A C)))))
(/
(-
(sqrt
(+
(* (* 2.0 (* F (+ A C))) t_2)
(* t_2 (* (* F (* t_3 t_3)) -2.0)))))
t_2))
(if (<= t_1 0.0)
(* (sqrt (- F)) (/ -1.0 (sqrt C)))
(if (<= t_1 INFINITY)
(/ (* A (* (sqrt 2.0) (sqrt (* -8.0 (* C F))))) t_2)
(- (/ (sqrt (* F -0.5)) (/ (sqrt C) (sqrt 2.0)))))))))))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 tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = -(pow(-F, 0.5) / sqrt(C));
} else {
double t_2 = fma(A, (C * -4.0), (B * B));
double tmp_1;
if (t_1 <= -3.6630033190351204e-209) {
double t_3_2 = sqrt(hypot(B, (A - C)));
tmp_1 = -sqrt(((2.0 * (F * (A + C))) * t_2) + (t_2 * ((F * (t_3_2 * t_3_2)) * -2.0))) / t_2;
} else if (t_1 <= 0.0) {
tmp_1 = sqrt(-F) * (-1.0 / sqrt(C));
} else if (t_1 <= ((double) INFINITY)) {
tmp_1 = (A * (sqrt(2.0) * sqrt(-8.0 * (C * F)))) / t_2;
} else {
tmp_1 = -(sqrt(F * -0.5) / (sqrt(C) / sqrt(2.0)));
}
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))) < -inf.0Initial program 64.0
Simplified53.8
Taylor expanded in A around -inf 34.0
Simplified34.0
Applied associate-*r/_binary6434.0
Applied sqrt-div_binary6423.5
Applied associate-*l/_binary6423.5
Applied pow1/2_binary6423.5
Applied pow1/2_binary6423.5
Applied pow-prod-down_binary6423.4
Simplified23.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))) < -3.6630033190351204e-209Initial program 1.5
Simplified2.4
Applied add-sqr-sqrt_binary642.5
Applied cancel-sign-sub-inv_binary642.5
Applied distribute-rgt-in_binary642.5
Applied distribute-rgt-in_binary642.5
Applied distribute-rgt-in_binary642.5
if -3.6630033190351204e-209 < (/.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.0
Simplified59.1
Taylor expanded in A around -inf 32.3
Simplified32.3
Applied associate-*r/_binary6432.3
Applied sqrt-div_binary6429.1
Applied associate-*l/_binary6429.1
Applied sqrt-unprod_binary6429.0
Simplified29.0
Applied div-inv_binary6429.0
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.6
Simplified26.0
Taylor expanded in A around -inf 14.8
Simplified14.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))) Initial program 64.0
Simplified63.6
Taylor expanded in A around -inf 53.6
Simplified53.6
Applied associate-*r/_binary6453.6
Applied sqrt-div_binary6449.2
Applied associate-*l/_binary6449.2
Applied associate-/l*_binary6449.2
Final simplification31.4
herbie shell --seed 2021275
(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))))