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 := \tan^{-1} \left(\frac{\left(C - A\right) - \mathsf{hypot}\left(B, C - A\right)}{B}\right)\\
\mathbf{if}\;t_0 \leq -5.2401113661299585 \cdot 10^{-5}:\\
\;\;\;\;180 \cdot \frac{1}{\frac{\pi}{t_1}}\\
\mathbf{elif}\;t_0 \leq 0:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(0.5 \cdot \frac{B}{A}\right)}{\pi}\\
\mathbf{else}:\\
\;\;\;\;180 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{t_1}{\pi}\right)\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
(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))))
(if (<= t_0 -5.2401113661299585e-5)
(* 180.0 (/ 1.0 (/ PI t_1)))
(if (<= t_0 0.0)
(* 180.0 (/ (atan (* 0.5 (/ B A))) PI))
(* 180.0 (log1p (expm1 (/ t_1 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 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 tmp;
if (t_0 <= -5.2401113661299585e-5) {
tmp = 180.0 * (1.0 / (((double) M_PI) / t_1));
} else if (t_0 <= 0.0) {
tmp = 180.0 * (atan((0.5 * (B / A))) / ((double) M_PI));
} else {
tmp = 180.0 * log1p(expm1((t_1 / ((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))))) < -5.2401113661299585e-5Initial program 25.6
Simplified8.1
Applied clear-num_binary648.1
if -5.2401113661299585e-5 < (*.f64 (/.f64 1 B) (-.f64 (-.f64 C A) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))) < 0.0Initial program 53.3
Simplified52.7
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.4
Simplified7.5
Applied log1p-expm1-u_binary647.5
Final simplification10.7
herbie shell --seed 2022125
(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)))