Average Error: 29.3 → 11.3
Time: 23.5s
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 := 180 \cdot \frac{\tan^{-1} \left(\frac{\left(C - A\right) - \mathsf{hypot}\left(B, C - A\right)}{B}\right)}{\pi}\\ t_1 := \frac{1}{B} \cdot \left(\left(C - A\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)\\ \mathbf{if}\;t_1 \leq -3.1369805444534716 \cdot 10^{-79}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;t_1 \leq 5.686097070558954 \cdot 10^{-6}:\\ \;\;\;\;\frac{180 \cdot \tan^{-1} \left(-0.5 \cdot \mathsf{fma}\left(A, \frac{B}{C \cdot C}, \frac{B}{C}\right)\right)}{\pi}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \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 := 180 \cdot \frac{\tan^{-1} \left(\frac{\left(C - A\right) - \mathsf{hypot}\left(B, C - A\right)}{B}\right)}{\pi}\\
t_1 := \frac{1}{B} \cdot \left(\left(C - A\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)\\
\mathbf{if}\;t_1 \leq -3.1369805444534716 \cdot 10^{-79}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;t_1 \leq 5.686097070558954 \cdot 10^{-6}:\\
\;\;\;\;\frac{180 \cdot \tan^{-1} \left(-0.5 \cdot \mathsf{fma}\left(A, \frac{B}{C \cdot C}, \frac{B}{C}\right)\right)}{\pi}\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\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 (* 180.0 (/ (atan (/ (- (- C A) (hypot B (- C A))) B)) PI)))
        (t_1
         (* (/ 1.0 B) (- (- C A) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0)))))))
   (if (<= t_1 -3.1369805444534716e-79)
     t_0
     (if (<= t_1 5.686097070558954e-6)
       (/ (* 180.0 (atan (* -0.5 (fma A (/ B (* C C)) (/ B C))))) PI)
       t_0))))
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 = 180.0 * (atan((((C - A) - hypot(B, (C - A))) / B)) / ((double) M_PI));
	double t_1 = (1.0 / B) * ((C - A) - sqrt((pow((A - C), 2.0) + pow(B, 2.0))));
	double tmp;
	if (t_1 <= -3.1369805444534716e-79) {
		tmp = t_0;
	} else if (t_1 <= 5.686097070558954e-6) {
		tmp = (180.0 * atan((-0.5 * fma(A, (B / (C * C)), (B / C))))) / ((double) M_PI);
	} else {
		tmp = t_0;
	}
	return tmp;
}

Error

Bits error versus A

Bits error versus B

Bits error versus C

Derivation

  1. Split input into 2 regimes
  2. if (*.f64 (/.f64 1 B) (-.f64 (-.f64 C A) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))) < -3.13698054445347157e-79 or 5.6860970705589539e-6 < (*.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.7

      \[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.1

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

    if -3.13698054445347157e-79 < (*.f64 (/.f64 1 B) (-.f64 (-.f64 C A) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))) < 5.6860970705589539e-6

    1. Initial program 51.9

      \[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.4

      \[\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 egg-rr51.4

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

      \[\leadsto \frac{\tan^{-1} \color{blue}{\left(-\left(0.5 \cdot \frac{B}{C} + 0.5 \cdot \frac{A \cdot B}{{C}^{2}}\right)\right)} \cdot 180}{\pi} \]
    5. Simplified31.4

      \[\leadsto \frac{\tan^{-1} \color{blue}{\left(-0.5 \cdot \left(\frac{B}{C} + \frac{A}{\frac{C \cdot C}{B}}\right)\right)} \cdot 180}{\pi} \]
    6. Applied egg-rr31.4

      \[\leadsto \frac{\tan^{-1} \left(-0.5 \cdot \color{blue}{\mathsf{fma}\left(A, \frac{B}{C \cdot C}, \frac{B}{C}\right)}\right) \cdot 180}{\pi} \]
  3. Recombined 2 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 -3.1369805444534716 \cdot 10^{-79}:\\ \;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{\left(C - A\right) - \mathsf{hypot}\left(B, C - A\right)}{B}\right)}{\pi}\\ \mathbf{elif}\;\frac{1}{B} \cdot \left(\left(C - A\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right) \leq 5.686097070558954 \cdot 10^{-6}:\\ \;\;\;\;\frac{180 \cdot \tan^{-1} \left(-0.5 \cdot \mathsf{fma}\left(A, \frac{B}{C \cdot C}, \frac{B}{C}\right)\right)}{\pi}\\ \mathbf{else}:\\ \;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{\left(C - A\right) - \mathsf{hypot}\left(B, C - A\right)}{B}\right)}{\pi}\\ \end{array} \]

Reproduce

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