\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 := \left(A + C\right) + \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\\
t_1 := -\sqrt{F} \cdot {\left(\frac{-1}{A}\right)}^{0.5}\\
t_2 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
t_3 := \frac{-\sqrt{\left(2 \cdot \left(t_2 \cdot F\right)\right) \cdot t_0}}{t_2}\\
\mathbf{if}\;t_3 \leq -3.821865190877986 \cdot 10^{+232}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_3 \leq -4.885000933447799 \cdot 10^{-179}:\\
\;\;\;\;\frac{-\sqrt{t_0 \cdot \left(2 \cdot \left(\sqrt{t_2} \cdot \left(F \cdot \sqrt{B \cdot B - 4 \cdot \left(A \cdot C\right)}\right)\right)\right)}}{t_2}\\
\mathbf{elif}\;t_3 \leq 0 \lor \neg \left(t_3 \leq \infty\right):\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{-\left(C \cdot \sqrt{2}\right) \cdot \sqrt{-8 \cdot \left(A \cdot F\right)}}{t_2}\\
\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 (+ (+ A C) (sqrt (+ (pow B 2.0) (pow (- A C) 2.0)))))
(t_1 (- (* (sqrt F) (pow (/ -1.0 A) 0.5))))
(t_2 (- (pow B 2.0) (* (* 4.0 A) C)))
(t_3 (/ (- (sqrt (* (* 2.0 (* t_2 F)) t_0))) t_2)))
(if (<= t_3 -3.821865190877986e+232)
t_1
(if (<= t_3 -4.885000933447799e-179)
(/
(-
(sqrt
(*
t_0
(* 2.0 (* (sqrt t_2) (* F (sqrt (- (* B B) (* 4.0 (* A C))))))))))
t_2)
(if (or (<= t_3 0.0) (not (<= t_3 INFINITY)))
t_1
(/ (- (* (* C (sqrt 2.0)) (sqrt (* -8.0 (* A F))))) t_2))))))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 = (A + C) + sqrt(pow(B, 2.0) + pow((A - C), 2.0));
double t_1 = -(sqrt(F) * pow((-1.0 / A), 0.5));
double t_2 = pow(B, 2.0) - ((4.0 * A) * C);
double t_3 = -sqrt((2.0 * (t_2 * F)) * t_0) / t_2;
double tmp;
if (t_3 <= -3.821865190877986e+232) {
tmp = t_1;
} else if (t_3 <= -4.885000933447799e-179) {
tmp = -sqrt(t_0 * (2.0 * (sqrt(t_2) * (F * sqrt((B * B) - (4.0 * (A * C))))))) / t_2;
} else if ((t_3 <= 0.0) || !(t_3 <= ((double) INFINITY))) {
tmp = t_1;
} else {
tmp = -((C * sqrt(2.0)) * sqrt(-8.0 * (A * F))) / t_2;
}
return tmp;
}



Bits error versus A



Bits error versus B



Bits error versus C



Bits error versus F
Results
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))) < -3.82186519087798615e232 or -4.8850009334477987e-179 < (/.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.0 or +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 62.8
Taylor expanded around inf 44.2
Simplified44.2
rmApplied sqrt-unprod_binary6444.1
Simplified44.1
rmApplied div-inv_binary6444.1
Applied distribute-rgt-neg-in_binary6444.1
Applied sqrt-prod_binary6438.0
Simplified38.0
rmApplied pow1_binary6438.0
Applied sqrt-pow1_binary6438.0
Simplified38.0
if -3.82186519087798615e232 < (/.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.8850009334477987e-179Initial program 1.2
rmApplied add-sqr-sqrt_binary641.3
Applied associate-*l*_binary641.3
Simplified1.3
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
Taylor expanded around inf 15.7
Simplified15.7
Final simplification31.1
herbie shell --seed 2021205
(FPCore (A B C F)
:name "ABCF->ab-angle a"
: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))))