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.9998668841342558:\\
\;\;\;\;180 \cdot \frac{1}{\frac{\pi}{\tan^{-1} \left(\frac{1}{B} \cdot \left(C - \left(B + A\right)\right)\right)}}\\
\mathbf{elif}\;\frac{1}{B} \cdot \left(\left(C - A\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right) \leq 0:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(0.5 \cdot \frac{B}{A}\right)}{\pi}\\
\mathbf{else}:\\
\;\;\;\;180 \cdot \left(\frac{1}{\sqrt{\pi}} \cdot \frac{\tan^{-1} \left(\frac{\left(B + C\right) - A}{B}\right)}{\sqrt{\pi}}\right)\\
\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.9998668841342558)
(* 180.0 (/ 1.0 (/ PI (atan (* (/ 1.0 B) (- C (+ B A)))))))
(if (<=
(* (/ 1.0 B) (- (- C A) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0)))))
0.0)
(* 180.0 (/ (atan (* 0.5 (/ B A))) PI))
(*
180.0
(* (/ 1.0 (sqrt PI)) (/ (atan (/ (- (+ B C) A) B)) (sqrt 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.9998668841342558) {
tmp = 180.0 * (1.0 / (((double) M_PI) / atan((1.0 / B) * (C - (B + A)))));
} else if (((1.0 / B) * ((C - A) - sqrt(pow((A - C), 2.0) + pow(B, 2.0)))) <= 0.0) {
tmp = 180.0 * (atan(0.5 * (B / A)) / ((double) M_PI));
} else {
tmp = 180.0 * ((1.0 / sqrt((double) M_PI)) * (atan(((B + C) - A) / B) / sqrt((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.99986688413425584Initial program 25.9
Taylor expanded around inf 14.8
Simplified14.8
rmApplied clear-num_binary6414.8
if -0.99986688413425584 < (*.f64 (/.f64 1 B) (-.f64 (-.f64 C A) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))) < -0.0Initial program 51.7
Taylor expanded around -inf 31.6
if -0.0 < (*.f64 (/.f64 1 B) (-.f64 (-.f64 C A) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))) Initial program 25.3
rmApplied add-sqr-sqrt_binary6425.9
Applied *-un-lft-identity_binary6425.9
Applied times-frac_binary6425.3
Simplified25.3
Taylor expanded around -inf 14.2
Final simplification16.7
herbie shell --seed 2021173
(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)))