\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:\\
\;\;\;\;-\sqrt{-0.5 \cdot \frac{F}{C}} \cdot \sqrt{2}\\
\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_2 := \mathsf{fma}\left(A, C \cdot -4, B \cdot B\right)\\
\mathbf{if}\;t_1 \leq -2.540381652642358 \cdot 10^{-186}:\\
\;\;\;\;-\frac{\sqrt{2 \cdot \left(F \cdot \left(\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)\right)\right)}}{\sqrt{t_2}}\\
\mathbf{elif}\;t_1 \leq 7.951526249968516 \cdot 10^{+172}:\\
\;\;\;\;\frac{-\sqrt{t_2 \cdot \left(2 \cdot \left(F \cdot \mathsf{fma}\left(-0.5, \frac{B \cdot B}{C}, 2 \cdot A\right)\right)\right)}}{t_2}\\
\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}:\\
\;\;\;\;-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)} \cdot \frac{\sqrt{2}}{B}\\
\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))
(- (* (sqrt (* -0.5 (/ F C))) (sqrt 2.0)))
(let* ((t_2 (fma A (* C -4.0) (* B B))))
(if (<= t_1 -2.540381652642358e-186)
(- (/ (sqrt (* 2.0 (* F (- (+ A C) (hypot B (- A C)))))) (sqrt t_2)))
(if (<= t_1 7.951526249968516e+172)
(/
(- (sqrt (* t_2 (* 2.0 (* F (fma -0.5 (/ (* B B) C) (* 2.0 A)))))))
t_2)
(if (<= t_1 INFINITY)
(/ (* A (* (sqrt 2.0) (sqrt (* -8.0 (* C F))))) t_2)
(- (* (sqrt (* F (- A (hypot A B)))) (/ (sqrt 2.0) B))))))))))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 = -(sqrt(-0.5 * (F / C)) * sqrt(2.0));
} else {
double t_2 = fma(A, (C * -4.0), (B * B));
double tmp_1;
if (t_1 <= -2.540381652642358e-186) {
tmp_1 = -(sqrt(2.0 * (F * ((A + C) - hypot(B, (A - C))))) / sqrt(t_2));
} else if (t_1 <= 7.951526249968516e+172) {
tmp_1 = -sqrt(t_2 * (2.0 * (F * fma(-0.5, ((B * B) / C), (2.0 * A))))) / t_2;
} else if (t_1 <= ((double) INFINITY)) {
tmp_1 = (A * (sqrt(2.0) * sqrt(-8.0 * (C * F)))) / t_2;
} else {
tmp_1 = -(sqrt(F * (A - hypot(A, B))) * (sqrt(2.0) / B));
}
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
Simplified54.5
Taylor expanded in A around -inf 33.2
Simplified33.2
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))) < -2.54038165264235807e-186Initial program 1.5
Simplified2.4
Applied add-sqr-sqrt_binary642.5
Applied sqrt-prod_binary642.3
Applied distribute-lft-neg-in_binary642.3
Applied times-frac_binary642.2
Simplified2.2
if -2.54038165264235807e-186 < (/.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))) < 7.951526249968516e172Initial program 49.6
Simplified48.5
Taylor expanded in C around inf 26.0
Simplified26.0
Applied *-un-lft-identity_binary6426.0
Applied associate-/r*_binary6426.0
Simplified26.0
if 7.951526249968516e172 < (/.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 58.5
Simplified39.3
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 C around 0 63.4
Simplified53.7
Final simplification35.2
herbie shell --seed 2022004
(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))))