Average Error: 29.4 → 18.6
Time: 8.1s
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} \mathbf{if}\;\tan^{-1} \left(\frac{1}{B} \cdot \left(\left(C - A\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)\right) \leq -0.7853981633974483:\\ \;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{C - \left(B + A\right)}{B}\right)}{\pi}\\ \mathbf{elif}\;\tan^{-1} \left(\frac{1}{B} \cdot \left(\left(C - A\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)\right) \leq 0:\\ \;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{0.5 \cdot \frac{B \cdot B}{A}}{B}\right)}{\pi}\\ \mathbf{else}:\\ \;\;\;\;180 \cdot \left(\tan^{-1} \left(\frac{B + \left(C - A\right)}{B}\right) \cdot \frac{1}{\pi}\right)\\ \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}
\mathbf{if}\;\tan^{-1} \left(\frac{1}{B} \cdot \left(\left(C - A\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)\right) \leq -0.7853981633974483:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{C - \left(B + A\right)}{B}\right)}{\pi}\\

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

\mathbf{else}:\\
\;\;\;\;180 \cdot \left(\tan^{-1} \left(\frac{B + \left(C - A\right)}{B}\right) \cdot \frac{1}{\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 (<=
      (atan (* (/ 1.0 B) (- (- C A) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0))))))
      -0.7853981633974483)
   (* 180.0 (/ (atan (/ (- C (+ B A)) B)) PI))
   (if (<=
        (atan
         (* (/ 1.0 B) (- (- C A) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0))))))
        0.0)
     (* 180.0 (/ (atan (/ (* 0.5 (/ (* B B) A)) B)) PI))
     (* 180.0 (* (atan (/ (+ B (- C A)) B)) (/ 1.0 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 (atan((1.0 / B) * ((C - A) - sqrt(pow((A - C), 2.0) + pow(B, 2.0)))) <= -0.7853981633974483) {
		tmp = 180.0 * (atan((C - (B + A)) / B) / ((double) M_PI));
	} else if (atan((1.0 / B) * ((C - A) - sqrt(pow((A - C), 2.0) + pow(B, 2.0)))) <= 0.0) {
		tmp = 180.0 * (atan((0.5 * ((B * B) / A)) / B) / ((double) M_PI));
	} else {
		tmp = 180.0 * (atan((B + (C - A)) / B) * (1.0 / ((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 (atan.f64 (*.f64 (/.f64 1 B) (-.f64 (-.f64 C A) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2)))))) < -0.78539816339744828

    1. Initial program 25.3

      \[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. Simplified25.3

      \[\leadsto \color{blue}{180 \cdot \frac{\tan^{-1} \left(\frac{\left(C - A\right) - \sqrt{{\left(A - C\right)}^{2} + B \cdot B}}{B}\right)}{\pi}}\]
    3. Taylor expanded around inf 14.6

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

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

    if -0.78539816339744828 < (atan.f64 (*.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 50.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. Simplified50.0

      \[\leadsto \color{blue}{180 \cdot \frac{\tan^{-1} \left(\frac{\left(C - A\right) - \sqrt{{\left(A - C\right)}^{2} + B \cdot B}}{B}\right)}{\pi}}\]
    3. Taylor expanded around -inf 38.5

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

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

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

    1. Initial program 26.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. Simplified26.6

      \[\leadsto \color{blue}{180 \cdot \frac{\tan^{-1} \left(\frac{\left(C - A\right) - \sqrt{{\left(A - C\right)}^{2} + B \cdot B}}{B}\right)}{\pi}}\]
    3. Taylor expanded around -inf 16.0

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

      \[\leadsto 180 \cdot \frac{\tan^{-1} \left(\frac{\color{blue}{B + \left(C - A\right)}}{B}\right)}{\pi}\]
    5. Using strategy rm
    6. Applied div-inv_binary6416.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\tan^{-1} \left(\frac{1}{B} \cdot \left(\left(C - A\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)\right) \leq -0.7853981633974483:\\ \;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{C - \left(B + A\right)}{B}\right)}{\pi}\\ \mathbf{elif}\;\tan^{-1} \left(\frac{1}{B} \cdot \left(\left(C - A\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)\right) \leq 0:\\ \;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{0.5 \cdot \frac{B \cdot B}{A}}{B}\right)}{\pi}\\ \mathbf{else}:\\ \;\;\;\;180 \cdot \left(\tan^{-1} \left(\frac{B + \left(C - A\right)}{B}\right) \cdot \frac{1}{\pi}\right)\\ \end{array}\]

Reproduce

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