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}
t_0 := \frac{1}{B} \cdot \left(\left(C - A\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)\\
t_1 := \frac{\tan^{-1} \left(\frac{\left(C - A\right) - \mathsf{hypot}\left(B, C - A\right)}{B}\right)}{\pi}\\
\mathbf{if}\;t_0 \leq -5.600847269785476 \cdot 10^{-17}:\\
\;\;\;\;180 \cdot \log \left(e^{t_1}\right)\\
\mathbf{elif}\;t_0 \leq 0:\\
\;\;\;\;\frac{180 \cdot \tan^{-1} \left(0.5 \cdot \frac{B}{A}\right)}{\pi}\\
\mathbf{else}:\\
\;\;\;\;180 \cdot e^{\log t_1}\\
\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
(let* ((t_0
(* (/ 1.0 B) (- (- C A) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0))))))
(t_1 (/ (atan (/ (- (- C A) (hypot B (- C A))) B)) PI)))
(if (<= t_0 -5.600847269785476e-17)
(* 180.0 (log (exp t_1)))
(if (<= t_0 0.0)
(/ (* 180.0 (atan (* 0.5 (/ B A)))) PI)
(* 180.0 (exp (log t_1)))))))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 t_0 = (1.0 / B) * ((C - A) - sqrt(pow((A - C), 2.0) + pow(B, 2.0)));
double t_1 = atan(((C - A) - hypot(B, (C - A))) / B) / ((double) M_PI);
double tmp;
if (t_0 <= -5.600847269785476e-17) {
tmp = 180.0 * log(exp(t_1));
} else if (t_0 <= 0.0) {
tmp = (180.0 * atan(0.5 * (B / A))) / ((double) M_PI);
} else {
tmp = 180.0 * exp(log(t_1));
}
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))))) < -5.60084726978547592e-17Initial program 26.9
Simplified8.9
Applied add-log-exp_binary648.9
if -5.60084726978547592e-17 < (*.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.9
Simplified51.1
Applied associate-*r/_binary6451.1
Taylor expanded in A around -inf 30.7
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 26.7
Simplified8.4
Applied add-exp-log_binary648.6
Final simplification11.7
herbie shell --seed 2021332
(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)))