Average Error: 29.5 → 11.3
Time: 12.0s
Precision: binary64
\[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{\left(C - A\right) - \mathsf{hypot}\left(B, C - A\right)}{B}\\ \mathbf{if}\;t_0 \leq -5.650023731990653 \cdot 10^{-18}:\\ \;\;\;\;180 \cdot \frac{1}{\frac{\pi}{\tan^{-1} t_1}}\\ \mathbf{elif}\;t_0 \leq 0:\\ \;\;\;\;180 \cdot \frac{\tan^{-1} \left(-0.5 \cdot \frac{B}{C}\right)}{\pi}\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_2 := \sqrt{t_1}\\ 180 \cdot \frac{\tan^{-1} \left(t_2 \cdot t_2\right)}{\pi} \end{array}\\ \end{array} \]
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{\left(C - A\right) - \mathsf{hypot}\left(B, C - A\right)}{B}\\
\mathbf{if}\;t_0 \leq -5.650023731990653 \cdot 10^{-18}:\\
\;\;\;\;180 \cdot \frac{1}{\frac{\pi}{\tan^{-1} t_1}}\\

\mathbf{elif}\;t_0 \leq 0:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(-0.5 \cdot \frac{B}{C}\right)}{\pi}\\

\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_2 := \sqrt{t_1}\\
180 \cdot \frac{\tan^{-1} \left(t_2 \cdot t_2\right)}{\pi}
\end{array}\\


\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 (/ (- (- C A) (hypot B (- C A))) B)))
   (if (<= t_0 -5.650023731990653e-18)
     (* 180.0 (/ 1.0 (/ PI (atan t_1))))
     (if (<= t_0 0.0)
       (* 180.0 (/ (atan (* -0.5 (/ B C))) PI))
       (let* ((t_2 (sqrt t_1))) (* 180.0 (/ (atan (* t_2 t_2)) 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 = ((C - A) - hypot(B, (C - A))) / B;
	double tmp;
	if (t_0 <= -5.650023731990653e-18) {
		tmp = 180.0 * (1.0 / (((double) M_PI) / atan(t_1)));
	} else if (t_0 <= 0.0) {
		tmp = 180.0 * (atan(-0.5 * (B / C)) / ((double) M_PI));
	} else {
		double t_2 = sqrt(t_1);
		tmp = 180.0 * (atan(t_2 * t_2) / ((double) M_PI));
	}
	return tmp;
}

Error

Bits error versus A

Bits error versus B

Bits error versus C

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if (*.f64 (/.f64 1 B) (-.f64 (-.f64 C A) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))) < -5.6500237319906533e-18

    1. Initial program 26.0

      \[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} \]
    2. Simplified8.0

      \[\leadsto \color{blue}{180 \cdot \frac{\tan^{-1} \left(\frac{\left(C - A\right) - \mathsf{hypot}\left(B, C - A\right)}{B}\right)}{\pi}} \]
    3. Applied clear-num_binary648.0

      \[\leadsto 180 \cdot \color{blue}{\frac{1}{\frac{\pi}{\tan^{-1} \left(\frac{\left(C - A\right) - \mathsf{hypot}\left(B, C - A\right)}{B}\right)}}} \]

    if -5.6500237319906533e-18 < (*.f64 (/.f64 1 B) (-.f64 (-.f64 C A) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))) < -0.0

    1. Initial program 52.4

      \[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} \]
    2. Simplified51.5

      \[\leadsto \color{blue}{180 \cdot \frac{\tan^{-1} \left(\frac{\left(C - A\right) - \mathsf{hypot}\left(B, C - A\right)}{B}\right)}{\pi}} \]
    3. Taylor expanded in C around inf 32.6

      \[\leadsto 180 \cdot \frac{\tan^{-1} \color{blue}{\left(-0.5 \cdot \frac{B}{C}\right)}}{\pi} \]

    if -0.0 < (*.f64 (/.f64 1 B) (-.f64 (-.f64 C A) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2)))))

    1. Initial program 25.6

      \[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} \]
    2. Simplified7.7

      \[\leadsto \color{blue}{180 \cdot \frac{\tan^{-1} \left(\frac{\left(C - A\right) - \mathsf{hypot}\left(B, C - A\right)}{B}\right)}{\pi}} \]
    3. Applied add-sqr-sqrt_binary647.8

      \[\leadsto 180 \cdot \frac{\tan^{-1} \color{blue}{\left(\sqrt{\frac{\left(C - A\right) - \mathsf{hypot}\left(B, C - A\right)}{B}} \cdot \sqrt{\frac{\left(C - A\right) - \mathsf{hypot}\left(B, C - A\right)}{B}}\right)}}{\pi} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification11.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{B} \cdot \left(\left(C - A\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right) \leq -5.650023731990653 \cdot 10^{-18}:\\ \;\;\;\;180 \cdot \frac{1}{\frac{\pi}{\tan^{-1} \left(\frac{\left(C - A\right) - \mathsf{hypot}\left(B, C - A\right)}{B}\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}{C}\right)}{\pi}\\ \mathbf{else}:\\ \;\;\;\;180 \cdot \frac{\tan^{-1} \left(\sqrt{\frac{\left(C - A\right) - \mathsf{hypot}\left(B, C - A\right)}{B}} \cdot \sqrt{\frac{\left(C - A\right) - \mathsf{hypot}\left(B, C - A\right)}{B}}\right)}{\pi}\\ \end{array} \]

Reproduce

herbie shell --seed 2021224 
(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)))