180 \cdot \frac{\tan^{-1} \left(\frac{1}{B} \cdot \left(\left(C - A\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)\right)}{\pi}\begin{array}{l}
\mathbf{if}\;\frac{1}{B} \cdot \left(\left(C - A\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right) \leq -0.9999999999938105:\\
\;\;\;\;\frac{\tan^{-1} \left(\frac{C - \left(B + A\right)}{B}\right)}{\frac{\pi}{180}}\\
\mathbf{elif}\;\frac{1}{B} \cdot \left(\left(C - A\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right) \leq 5.411022703613558 \cdot 10^{-10}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{-0.5 \cdot \frac{{B}^{2}}{C}}{B}\right)}{\pi}\\
\mathbf{else}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{\left(B + C\right) - A}{B}\right)}{\pi}\\
\end{array}(FPCore (A B C) :precision binary64 (* 180.0 (/ (atan (* (/ 1.0 B) (- (- C A) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0)))))) PI)))
(FPCore (A B C)
:precision binary64
(if (<=
(* (/ 1.0 B) (- (- C A) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0)))))
-0.9999999999938105)
(/ (atan (/ (- C (+ B A)) B)) (/ PI 180.0))
(if (<=
(* (/ 1.0 B) (- (- C A) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0)))))
5.411022703613558e-10)
(* 180.0 (/ (atan (/ (* -0.5 (/ (pow B 2.0) C)) B)) PI))
(* 180.0 (/ (atan (/ (- (+ B C) A) B)) PI)))))double code(double A, double B, double C) {
return 180.0 * (atan((1.0 / B) * ((C - A) - sqrt(pow((A - C), 2.0) + pow(B, 2.0)))) / ((double) M_PI));
}
double code(double A, double B, double C) {
double tmp;
if (((1.0 / B) * ((C - A) - sqrt(pow((A - C), 2.0) + pow(B, 2.0)))) <= -0.9999999999938105) {
tmp = atan((C - (B + A)) / B) / (((double) M_PI) / 180.0);
} else if (((1.0 / B) * ((C - A) - sqrt(pow((A - C), 2.0) + pow(B, 2.0)))) <= 5.411022703613558e-10) {
tmp = 180.0 * (atan((-0.5 * (pow(B, 2.0) / C)) / B) / ((double) M_PI));
} else {
tmp = 180.0 * (atan(((B + C) - A) / B) / ((double) M_PI));
}
return tmp;
}



Bits error versus A



Bits error versus B



Bits error versus C
Results
if (*.f64 (/.f64 1 B) (-.f64 (-.f64 C A) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))) < -0.99999999999381051Initial program 26.9
Simplified26.9
Taylor expanded around inf 15.5
rmApplied associate-*r/_binary64_445315.5
Simplified15.5
rmApplied associate-/l*_binary64_445615.5
if -0.99999999999381051 < (*.f64 (/.f64 1 B) (-.f64 (-.f64 C A) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))) < 5.4110227036135582e-10Initial program 51.1
Simplified51.1
Taylor expanded around inf 38.8
if 5.4110227036135582e-10 < (*.f64 (/.f64 1 B) (-.f64 (-.f64 C A) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))) Initial program 26.9
Simplified26.9
Taylor expanded around -inf 15.4
Final simplification18.7
herbie shell --seed 2021093
(FPCore (A B C)
:name "ABCF->ab-angle angle"
:precision binary64
(* 180.0 (/ (atan (* (/ 1.0 B) (- (- C A) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0)))))) PI)))