\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{-1}{\frac{\sqrt{C}}{\sqrt{-F}}}\\
\mathbf{elif}\;t_1 \leq -7.086899042058475 \cdot 10^{-213}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_1 \leq 0:\\
\;\;\;\;-{\left(\frac{-F}{C}\right)}^{0.5}\\
\mathbf{elif}\;t_1 \leq \infty:\\
\;\;\;\;\frac{A \cdot \left(\sqrt{2} \cdot \sqrt{-8 \cdot \left(C \cdot F\right)}\right)}{\mathsf{fma}\left(A, C \cdot -4, B \cdot B\right)}\\
\mathbf{else}:\\
\;\;\;\;-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)} \cdot \frac{\sqrt{2}}{B}\\
\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))
(/ -1.0 (/ (sqrt C) (sqrt (- F))))
(if (<= t_1 -7.086899042058475e-213)
t_1
(if (<= t_1 0.0)
(- (pow (/ (- F) C) 0.5))
(if (<= t_1 INFINITY)
(/
(* A (* (sqrt 2.0) (sqrt (* -8.0 (* C F)))))
(fma A (* C -4.0) (* B B)))
(- (* (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 = -1.0 / (sqrt(C) / sqrt(-F));
} else if (t_1 <= -7.086899042058475e-213) {
tmp = t_1;
} else if (t_1 <= 0.0) {
tmp = -pow((-F / C), 0.5);
} else if (t_1 <= ((double) INFINITY)) {
tmp = (A * (sqrt(2.0) * sqrt(-8.0 * (C * F)))) / fma(A, (C * -4.0), (B * B));
} else {
tmp = -(sqrt(F * (A - hypot(A, B))) * (sqrt(2.0) / B));
}
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.6
Simplified34.6
Applied associate-*r/_binary6434.6
Applied sqrt-div_binary6424.0
Applied associate-*l/_binary6424.0
Applied sqrt-unprod_binary6423.8
Simplified23.8
Applied *-un-lft-identity_binary6423.8
Applied sqrt-prod_binary6423.8
Applied associate-/l*_binary6423.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))) < -7.0868990420584749e-213Initial program 1.4
if -7.0868990420584749e-213 < (/.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.5
Simplified60.0
Taylor expanded in A around -inf 31.9
Simplified31.9
Applied pow1/2_binary6431.9
Applied pow1/2_binary6431.9
Applied pow-prod-down_binary6431.7
Simplified31.7
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.8
Simplified26.3
Taylor expanded in A around -inf 14.6
Simplified14.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.3
Final simplification33.5
herbie shell --seed 2022005
(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))))