ABCF->ab-angle angle

Percentage Accurate: 54.1% → 82.2%
Time: 15.1s
Alternatives: 12
Speedup: 2.5×

Specification

?
\[\begin{array}{l} \\ 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} \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)))
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));
}
public static double code(double A, double B, double C) {
	return 180.0 * (Math.atan(((1.0 / B) * ((C - A) - Math.sqrt((Math.pow((A - C), 2.0) + Math.pow(B, 2.0)))))) / Math.PI);
}
def code(A, B, C):
	return 180.0 * (math.atan(((1.0 / B) * ((C - A) - math.sqrt((math.pow((A - C), 2.0) + math.pow(B, 2.0)))))) / math.pi)
function code(A, B, C)
	return Float64(180.0 * Float64(atan(Float64(Float64(1.0 / B) * Float64(Float64(C - A) - sqrt(Float64((Float64(A - C) ^ 2.0) + (B ^ 2.0)))))) / pi))
end
function tmp = code(A, B, C)
	tmp = 180.0 * (atan(((1.0 / B) * ((C - A) - sqrt((((A - C) ^ 2.0) + (B ^ 2.0)))))) / pi);
end
code[A_, B_, C_] := N[(180.0 * N[(N[ArcTan[N[(N[(1.0 / B), $MachinePrecision] * N[(N[(C - A), $MachinePrecision] - N[Sqrt[N[(N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
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}
\end{array}

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 12 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 54.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ 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} \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)))
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));
}
public static double code(double A, double B, double C) {
	return 180.0 * (Math.atan(((1.0 / B) * ((C - A) - Math.sqrt((Math.pow((A - C), 2.0) + Math.pow(B, 2.0)))))) / Math.PI);
}
def code(A, B, C):
	return 180.0 * (math.atan(((1.0 / B) * ((C - A) - math.sqrt((math.pow((A - C), 2.0) + math.pow(B, 2.0)))))) / math.pi)
function code(A, B, C)
	return Float64(180.0 * Float64(atan(Float64(Float64(1.0 / B) * Float64(Float64(C - A) - sqrt(Float64((Float64(A - C) ^ 2.0) + (B ^ 2.0)))))) / pi))
end
function tmp = code(A, B, C)
	tmp = 180.0 * (atan(((1.0 / B) * ((C - A) - sqrt((((A - C) ^ 2.0) + (B ^ 2.0)))))) / pi);
end
code[A_, B_, C_] := N[(180.0 * N[(N[ArcTan[N[(N[(1.0 / B), $MachinePrecision] * N[(N[(C - A), $MachinePrecision] - N[Sqrt[N[(N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
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}
\end{array}

Alternative 1: 82.2% accurate, 1.5× speedup?

\[\begin{array}{l} B\_m = \left|B\right| \\ B\_s = \mathsf{copysign}\left(1, B\right) \\ B\_s \cdot \begin{array}{l} \mathbf{if}\;A \leq -9 \cdot 10^{+86}:\\ \;\;\;\;180 \cdot \frac{\tan^{-1} \left(-1 \cdot \frac{\mathsf{fma}\left(-0.5, B\_m, -0.5 \cdot \frac{B\_m \cdot C}{A}\right)}{A}\right)}{\pi}\\ \mathbf{elif}\;A \leq 1.9 \cdot 10^{-195}:\\ \;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{1}{B\_m} \cdot \left(C - \mathsf{hypot}\left(C, B\_m\right)\right)\right)}{\pi}\\ \mathbf{elif}\;A \leq 9.6 \cdot 10^{-135}:\\ \;\;\;\;180 \cdot \frac{\tan^{-1} \left(\mathsf{fma}\left(\frac{A}{C}, B\_m, B\_m\right) \cdot \frac{-0.5}{C}\right)}{\pi}\\ \mathbf{else}:\\ \;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{\left(C - A\right) - B\_m}{B\_m}\right)}{\pi}\\ \end{array} \end{array} \]
B\_m = (fabs.f64 B)
B\_s = (copysign.f64 #s(literal 1 binary64) B)
(FPCore (B_s A B_m C)
 :precision binary64
 (*
  B_s
  (if (<= A -9e+86)
    (*
     180.0
     (/ (atan (* -1.0 (/ (fma -0.5 B_m (* -0.5 (/ (* B_m C) A))) A))) PI))
    (if (<= A 1.9e-195)
      (* 180.0 (/ (atan (* (/ 1.0 B_m) (- C (hypot C B_m)))) PI))
      (if (<= A 9.6e-135)
        (* 180.0 (/ (atan (* (fma (/ A C) B_m B_m) (/ -0.5 C))) PI))
        (* 180.0 (/ (atan (/ (- (- C A) B_m) B_m)) PI)))))))
B\_m = fabs(B);
B\_s = copysign(1.0, B);
double code(double B_s, double A, double B_m, double C) {
	double tmp;
	if (A <= -9e+86) {
		tmp = 180.0 * (atan((-1.0 * (fma(-0.5, B_m, (-0.5 * ((B_m * C) / A))) / A))) / ((double) M_PI));
	} else if (A <= 1.9e-195) {
		tmp = 180.0 * (atan(((1.0 / B_m) * (C - hypot(C, B_m)))) / ((double) M_PI));
	} else if (A <= 9.6e-135) {
		tmp = 180.0 * (atan((fma((A / C), B_m, B_m) * (-0.5 / C))) / ((double) M_PI));
	} else {
		tmp = 180.0 * (atan((((C - A) - B_m) / B_m)) / ((double) M_PI));
	}
	return B_s * tmp;
}
B\_m = abs(B)
B\_s = copysign(1.0, B)
function code(B_s, A, B_m, C)
	tmp = 0.0
	if (A <= -9e+86)
		tmp = Float64(180.0 * Float64(atan(Float64(-1.0 * Float64(fma(-0.5, B_m, Float64(-0.5 * Float64(Float64(B_m * C) / A))) / A))) / pi));
	elseif (A <= 1.9e-195)
		tmp = Float64(180.0 * Float64(atan(Float64(Float64(1.0 / B_m) * Float64(C - hypot(C, B_m)))) / pi));
	elseif (A <= 9.6e-135)
		tmp = Float64(180.0 * Float64(atan(Float64(fma(Float64(A / C), B_m, B_m) * Float64(-0.5 / C))) / pi));
	else
		tmp = Float64(180.0 * Float64(atan(Float64(Float64(Float64(C - A) - B_m) / B_m)) / pi));
	end
	return Float64(B_s * tmp)
end
B\_m = N[Abs[B], $MachinePrecision]
B\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[B]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[B$95$s_, A_, B$95$m_, C_] := N[(B$95$s * If[LessEqual[A, -9e+86], N[(180.0 * N[(N[ArcTan[N[(-1.0 * N[(N[(-0.5 * B$95$m + N[(-0.5 * N[(N[(B$95$m * C), $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision], If[LessEqual[A, 1.9e-195], N[(180.0 * N[(N[ArcTan[N[(N[(1.0 / B$95$m), $MachinePrecision] * N[(C - N[Sqrt[C ^ 2 + B$95$m ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision], If[LessEqual[A, 9.6e-135], N[(180.0 * N[(N[ArcTan[N[(N[(N[(A / C), $MachinePrecision] * B$95$m + B$95$m), $MachinePrecision] * N[(-0.5 / C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision], N[(180.0 * N[(N[ArcTan[N[(N[(N[(C - A), $MachinePrecision] - B$95$m), $MachinePrecision] / B$95$m), $MachinePrecision]], $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision]]]]), $MachinePrecision]
\begin{array}{l}
B\_m = \left|B\right|
\\
B\_s = \mathsf{copysign}\left(1, B\right)

\\
B\_s \cdot \begin{array}{l}
\mathbf{if}\;A \leq -9 \cdot 10^{+86}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(-1 \cdot \frac{\mathsf{fma}\left(-0.5, B\_m, -0.5 \cdot \frac{B\_m \cdot C}{A}\right)}{A}\right)}{\pi}\\

\mathbf{elif}\;A \leq 1.9 \cdot 10^{-195}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{1}{B\_m} \cdot \left(C - \mathsf{hypot}\left(C, B\_m\right)\right)\right)}{\pi}\\

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

\mathbf{else}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{\left(C - A\right) - B\_m}{B\_m}\right)}{\pi}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if A < -8.99999999999999986e86

    1. Initial program 54.1%

      \[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. Taylor expanded in A around -inf

      \[\leadsto 180 \cdot \frac{\tan^{-1} \color{blue}{\left(-1 \cdot \frac{\frac{-1}{2} \cdot B + \frac{-1}{2} \cdot \frac{B \cdot C}{A}}{A}\right)}}{\pi} \]
    3. Applied rewrites33.7%

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

    if -8.99999999999999986e86 < A < 1.90000000000000006e-195

    1. Initial program 54.1%

      \[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. Applied rewrites78.2%

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

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

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

      \[\leadsto 180 \cdot \frac{\tan^{-1} \left(\frac{1}{B} \cdot \left(C - \mathsf{hypot}\left(\color{blue}{C}, B\right)\right)\right)}{\pi} \]
    6. Applied rewrites64.7%

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

    if 1.90000000000000006e-195 < A < 9.5999999999999994e-135

    1. Initial program 54.1%

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

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

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

      \[\leadsto 180 \cdot \frac{\tan^{-1} \color{blue}{\left(\frac{\mathsf{fma}\left(-0.5, B, -0.5 \cdot \frac{A \cdot B}{C}\right)}{C}\right)}}{\pi} \]
    5. Applied rewrites33.0%

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

    if 9.5999999999999994e-135 < A

    1. Initial program 54.1%

      \[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. Taylor expanded in B around inf

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

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

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

Alternative 2: 75.9% accurate, 0.6× speedup?

\[\begin{array}{l} B\_m = \left|B\right| \\ B\_s = \mathsf{copysign}\left(1, B\right) \\ B\_s \cdot \begin{array}{l} \mathbf{if}\;180 \cdot \frac{\tan^{-1} \left(\frac{1}{B\_m} \cdot \left(\left(C - A\right) - \sqrt{{\left(A - C\right)}^{2} + {B\_m}^{2}}\right)\right)}{\pi} \leq -0.005:\\ \;\;\;\;\tan^{-1} \left(\frac{\left(C - A\right) - \mathsf{hypot}\left(C - A, B\_m\right)}{B\_m}\right) \cdot \frac{180}{\pi}\\ \mathbf{else}:\\ \;\;\;\;180 \cdot \frac{\tan^{-1} \left(\mathsf{fma}\left(\frac{A}{C}, B\_m, B\_m\right) \cdot \frac{-0.5}{C}\right)}{\pi}\\ \end{array} \end{array} \]
B\_m = (fabs.f64 B)
B\_s = (copysign.f64 #s(literal 1 binary64) B)
(FPCore (B_s A B_m C)
 :precision binary64
 (*
  B_s
  (if (<=
       (*
        180.0
        (/
         (atan
          (*
           (/ 1.0 B_m)
           (- (- C A) (sqrt (+ (pow (- A C) 2.0) (pow B_m 2.0))))))
         PI))
       -0.005)
    (* (atan (/ (- (- C A) (hypot (- C A) B_m)) B_m)) (/ 180.0 PI))
    (* 180.0 (/ (atan (* (fma (/ A C) B_m B_m) (/ -0.5 C))) PI)))))
B\_m = fabs(B);
B\_s = copysign(1.0, B);
double code(double B_s, double A, double B_m, double C) {
	double tmp;
	if ((180.0 * (atan(((1.0 / B_m) * ((C - A) - sqrt((pow((A - C), 2.0) + pow(B_m, 2.0)))))) / ((double) M_PI))) <= -0.005) {
		tmp = atan((((C - A) - hypot((C - A), B_m)) / B_m)) * (180.0 / ((double) M_PI));
	} else {
		tmp = 180.0 * (atan((fma((A / C), B_m, B_m) * (-0.5 / C))) / ((double) M_PI));
	}
	return B_s * tmp;
}
B\_m = abs(B)
B\_s = copysign(1.0, B)
function code(B_s, A, B_m, C)
	tmp = 0.0
	if (Float64(180.0 * Float64(atan(Float64(Float64(1.0 / B_m) * Float64(Float64(C - A) - sqrt(Float64((Float64(A - C) ^ 2.0) + (B_m ^ 2.0)))))) / pi)) <= -0.005)
		tmp = Float64(atan(Float64(Float64(Float64(C - A) - hypot(Float64(C - A), B_m)) / B_m)) * Float64(180.0 / pi));
	else
		tmp = Float64(180.0 * Float64(atan(Float64(fma(Float64(A / C), B_m, B_m) * Float64(-0.5 / C))) / pi));
	end
	return Float64(B_s * tmp)
end
B\_m = N[Abs[B], $MachinePrecision]
B\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[B]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[B$95$s_, A_, B$95$m_, C_] := N[(B$95$s * If[LessEqual[N[(180.0 * N[(N[ArcTan[N[(N[(1.0 / B$95$m), $MachinePrecision] * N[(N[(C - A), $MachinePrecision] - N[Sqrt[N[(N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision], -0.005], N[(N[ArcTan[N[(N[(N[(C - A), $MachinePrecision] - N[Sqrt[N[(C - A), $MachinePrecision] ^ 2 + B$95$m ^ 2], $MachinePrecision]), $MachinePrecision] / B$95$m), $MachinePrecision]], $MachinePrecision] * N[(180.0 / Pi), $MachinePrecision]), $MachinePrecision], N[(180.0 * N[(N[ArcTan[N[(N[(N[(A / C), $MachinePrecision] * B$95$m + B$95$m), $MachinePrecision] * N[(-0.5 / C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
B\_m = \left|B\right|
\\
B\_s = \mathsf{copysign}\left(1, B\right)

\\
B\_s \cdot \begin{array}{l}
\mathbf{if}\;180 \cdot \frac{\tan^{-1} \left(\frac{1}{B\_m} \cdot \left(\left(C - A\right) - \sqrt{{\left(A - C\right)}^{2} + {B\_m}^{2}}\right)\right)}{\pi} \leq -0.005:\\
\;\;\;\;\tan^{-1} \left(\frac{\left(C - A\right) - \mathsf{hypot}\left(C - A, B\_m\right)}{B\_m}\right) \cdot \frac{180}{\pi}\\

\mathbf{else}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(\mathsf{fma}\left(\frac{A}{C}, B\_m, B\_m\right) \cdot \frac{-0.5}{C}\right)}{\pi}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 #s(literal 180 binary64) (/.f64 (atan.f64 (*.f64 (/.f64 #s(literal 1 binary64) B) (-.f64 (-.f64 C A) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) #s(literal 2 binary64)) (pow.f64 B #s(literal 2 binary64))))))) (PI.f64))) < -0.0050000000000000001

    1. Initial program 54.1%

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

      \[\leadsto \color{blue}{\tan^{-1} \left(\frac{\left(C - A\right) - \sqrt{\mathsf{fma}\left(C - A, C - A, B \cdot B\right)}}{B}\right) \cdot \frac{180}{\pi}} \]
    3. Applied rewrites78.3%

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

    if -0.0050000000000000001 < (*.f64 #s(literal 180 binary64) (/.f64 (atan.f64 (*.f64 (/.f64 #s(literal 1 binary64) B) (-.f64 (-.f64 C A) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) #s(literal 2 binary64)) (pow.f64 B #s(literal 2 binary64))))))) (PI.f64)))

    1. Initial program 54.1%

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

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

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

      \[\leadsto 180 \cdot \frac{\tan^{-1} \color{blue}{\left(\frac{\mathsf{fma}\left(-0.5, B, -0.5 \cdot \frac{A \cdot B}{C}\right)}{C}\right)}}{\pi} \]
    5. Applied rewrites33.0%

      \[\leadsto 180 \cdot \frac{\tan^{-1} \color{blue}{\left(\mathsf{fma}\left(\frac{A}{C}, B, B\right) \cdot \frac{-0.5}{C}\right)}}{\pi} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 3: 75.2% accurate, 1.6× speedup?

\[\begin{array}{l} B\_m = \left|B\right| \\ B\_s = \mathsf{copysign}\left(1, B\right) \\ B\_s \cdot \begin{array}{l} \mathbf{if}\;A \leq -2.4 \cdot 10^{+86}:\\ \;\;\;\;180 \cdot \frac{\tan^{-1} \left(-1 \cdot \frac{\mathsf{fma}\left(-0.5, B\_m, -0.5 \cdot \frac{B\_m \cdot C}{A}\right)}{A}\right)}{\pi}\\ \mathbf{else}:\\ \;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{\left(C - A\right) - B\_m}{B\_m}\right)}{\pi}\\ \end{array} \end{array} \]
B\_m = (fabs.f64 B)
B\_s = (copysign.f64 #s(literal 1 binary64) B)
(FPCore (B_s A B_m C)
 :precision binary64
 (*
  B_s
  (if (<= A -2.4e+86)
    (*
     180.0
     (/ (atan (* -1.0 (/ (fma -0.5 B_m (* -0.5 (/ (* B_m C) A))) A))) PI))
    (* 180.0 (/ (atan (/ (- (- C A) B_m) B_m)) PI)))))
B\_m = fabs(B);
B\_s = copysign(1.0, B);
double code(double B_s, double A, double B_m, double C) {
	double tmp;
	if (A <= -2.4e+86) {
		tmp = 180.0 * (atan((-1.0 * (fma(-0.5, B_m, (-0.5 * ((B_m * C) / A))) / A))) / ((double) M_PI));
	} else {
		tmp = 180.0 * (atan((((C - A) - B_m) / B_m)) / ((double) M_PI));
	}
	return B_s * tmp;
}
B\_m = abs(B)
B\_s = copysign(1.0, B)
function code(B_s, A, B_m, C)
	tmp = 0.0
	if (A <= -2.4e+86)
		tmp = Float64(180.0 * Float64(atan(Float64(-1.0 * Float64(fma(-0.5, B_m, Float64(-0.5 * Float64(Float64(B_m * C) / A))) / A))) / pi));
	else
		tmp = Float64(180.0 * Float64(atan(Float64(Float64(Float64(C - A) - B_m) / B_m)) / pi));
	end
	return Float64(B_s * tmp)
end
B\_m = N[Abs[B], $MachinePrecision]
B\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[B]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[B$95$s_, A_, B$95$m_, C_] := N[(B$95$s * If[LessEqual[A, -2.4e+86], N[(180.0 * N[(N[ArcTan[N[(-1.0 * N[(N[(-0.5 * B$95$m + N[(-0.5 * N[(N[(B$95$m * C), $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision], N[(180.0 * N[(N[ArcTan[N[(N[(N[(C - A), $MachinePrecision] - B$95$m), $MachinePrecision] / B$95$m), $MachinePrecision]], $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
B\_m = \left|B\right|
\\
B\_s = \mathsf{copysign}\left(1, B\right)

\\
B\_s \cdot \begin{array}{l}
\mathbf{if}\;A \leq -2.4 \cdot 10^{+86}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(-1 \cdot \frac{\mathsf{fma}\left(-0.5, B\_m, -0.5 \cdot \frac{B\_m \cdot C}{A}\right)}{A}\right)}{\pi}\\

\mathbf{else}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{\left(C - A\right) - B\_m}{B\_m}\right)}{\pi}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if A < -2.4e86

    1. Initial program 54.1%

      \[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. Taylor expanded in A around -inf

      \[\leadsto 180 \cdot \frac{\tan^{-1} \color{blue}{\left(-1 \cdot \frac{\frac{-1}{2} \cdot B + \frac{-1}{2} \cdot \frac{B \cdot C}{A}}{A}\right)}}{\pi} \]
    3. Applied rewrites33.7%

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

    if -2.4e86 < A

    1. Initial program 54.1%

      \[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. Taylor expanded in B around inf

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

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

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

Alternative 4: 74.8% accurate, 2.3× speedup?

\[\begin{array}{l} B\_m = \left|B\right| \\ B\_s = \mathsf{copysign}\left(1, B\right) \\ B\_s \cdot \begin{array}{l} \mathbf{if}\;A \leq -6.2 \cdot 10^{+86}:\\ \;\;\;\;180 \cdot \frac{\tan^{-1} \left(B\_m \cdot \frac{0.5}{A}\right)}{\pi}\\ \mathbf{else}:\\ \;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{\left(C - A\right) - B\_m}{B\_m}\right)}{\pi}\\ \end{array} \end{array} \]
B\_m = (fabs.f64 B)
B\_s = (copysign.f64 #s(literal 1 binary64) B)
(FPCore (B_s A B_m C)
 :precision binary64
 (*
  B_s
  (if (<= A -6.2e+86)
    (* 180.0 (/ (atan (* B_m (/ 0.5 A))) PI))
    (* 180.0 (/ (atan (/ (- (- C A) B_m) B_m)) PI)))))
B\_m = fabs(B);
B\_s = copysign(1.0, B);
double code(double B_s, double A, double B_m, double C) {
	double tmp;
	if (A <= -6.2e+86) {
		tmp = 180.0 * (atan((B_m * (0.5 / A))) / ((double) M_PI));
	} else {
		tmp = 180.0 * (atan((((C - A) - B_m) / B_m)) / ((double) M_PI));
	}
	return B_s * tmp;
}
B\_m = Math.abs(B);
B\_s = Math.copySign(1.0, B);
public static double code(double B_s, double A, double B_m, double C) {
	double tmp;
	if (A <= -6.2e+86) {
		tmp = 180.0 * (Math.atan((B_m * (0.5 / A))) / Math.PI);
	} else {
		tmp = 180.0 * (Math.atan((((C - A) - B_m) / B_m)) / Math.PI);
	}
	return B_s * tmp;
}
B\_m = math.fabs(B)
B\_s = math.copysign(1.0, B)
def code(B_s, A, B_m, C):
	tmp = 0
	if A <= -6.2e+86:
		tmp = 180.0 * (math.atan((B_m * (0.5 / A))) / math.pi)
	else:
		tmp = 180.0 * (math.atan((((C - A) - B_m) / B_m)) / math.pi)
	return B_s * tmp
B\_m = abs(B)
B\_s = copysign(1.0, B)
function code(B_s, A, B_m, C)
	tmp = 0.0
	if (A <= -6.2e+86)
		tmp = Float64(180.0 * Float64(atan(Float64(B_m * Float64(0.5 / A))) / pi));
	else
		tmp = Float64(180.0 * Float64(atan(Float64(Float64(Float64(C - A) - B_m) / B_m)) / pi));
	end
	return Float64(B_s * tmp)
end
B\_m = abs(B);
B\_s = sign(B) * abs(1.0);
function tmp_2 = code(B_s, A, B_m, C)
	tmp = 0.0;
	if (A <= -6.2e+86)
		tmp = 180.0 * (atan((B_m * (0.5 / A))) / pi);
	else
		tmp = 180.0 * (atan((((C - A) - B_m) / B_m)) / pi);
	end
	tmp_2 = B_s * tmp;
end
B\_m = N[Abs[B], $MachinePrecision]
B\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[B]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[B$95$s_, A_, B$95$m_, C_] := N[(B$95$s * If[LessEqual[A, -6.2e+86], N[(180.0 * N[(N[ArcTan[N[(B$95$m * N[(0.5 / A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision], N[(180.0 * N[(N[ArcTan[N[(N[(N[(C - A), $MachinePrecision] - B$95$m), $MachinePrecision] / B$95$m), $MachinePrecision]], $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
B\_m = \left|B\right|
\\
B\_s = \mathsf{copysign}\left(1, B\right)

\\
B\_s \cdot \begin{array}{l}
\mathbf{if}\;A \leq -6.2 \cdot 10^{+86}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(B\_m \cdot \frac{0.5}{A}\right)}{\pi}\\

\mathbf{else}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{\left(C - A\right) - B\_m}{B\_m}\right)}{\pi}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if A < -6.2000000000000004e86

    1. Initial program 54.1%

      \[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. Taylor expanded in A around -inf

      \[\leadsto 180 \cdot \frac{\tan^{-1} \color{blue}{\left(\frac{1}{2} \cdot \frac{B}{A}\right)}}{\pi} \]
    3. Applied rewrites26.3%

      \[\leadsto 180 \cdot \frac{\tan^{-1} \color{blue}{\left(0.5 \cdot \frac{B}{A}\right)}}{\pi} \]
    4. Applied rewrites26.3%

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

    if -6.2000000000000004e86 < A

    1. Initial program 54.1%

      \[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. Taylor expanded in B around inf

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

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

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

Alternative 5: 69.4% accurate, 2.2× speedup?

\[\begin{array}{l} B\_m = \left|B\right| \\ B\_s = \mathsf{copysign}\left(1, B\right) \\ B\_s \cdot \begin{array}{l} \mathbf{if}\;A \leq -6.2 \cdot 10^{+86}:\\ \;\;\;\;180 \cdot \frac{\tan^{-1} \left(B\_m \cdot \frac{0.5}{A}\right)}{\pi}\\ \mathbf{elif}\;A \leq 5.8 \cdot 10^{+169}:\\ \;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{C}{B\_m} - 1\right)}{\pi}\\ \mathbf{else}:\\ \;\;\;\;\tan^{-1} \left(\frac{-2 \cdot A}{B\_m}\right) \cdot \frac{180}{\pi}\\ \end{array} \end{array} \]
B\_m = (fabs.f64 B)
B\_s = (copysign.f64 #s(literal 1 binary64) B)
(FPCore (B_s A B_m C)
 :precision binary64
 (*
  B_s
  (if (<= A -6.2e+86)
    (* 180.0 (/ (atan (* B_m (/ 0.5 A))) PI))
    (if (<= A 5.8e+169)
      (* 180.0 (/ (atan (- (/ C B_m) 1.0)) PI))
      (* (atan (/ (* -2.0 A) B_m)) (/ 180.0 PI))))))
B\_m = fabs(B);
B\_s = copysign(1.0, B);
double code(double B_s, double A, double B_m, double C) {
	double tmp;
	if (A <= -6.2e+86) {
		tmp = 180.0 * (atan((B_m * (0.5 / A))) / ((double) M_PI));
	} else if (A <= 5.8e+169) {
		tmp = 180.0 * (atan(((C / B_m) - 1.0)) / ((double) M_PI));
	} else {
		tmp = atan(((-2.0 * A) / B_m)) * (180.0 / ((double) M_PI));
	}
	return B_s * tmp;
}
B\_m = Math.abs(B);
B\_s = Math.copySign(1.0, B);
public static double code(double B_s, double A, double B_m, double C) {
	double tmp;
	if (A <= -6.2e+86) {
		tmp = 180.0 * (Math.atan((B_m * (0.5 / A))) / Math.PI);
	} else if (A <= 5.8e+169) {
		tmp = 180.0 * (Math.atan(((C / B_m) - 1.0)) / Math.PI);
	} else {
		tmp = Math.atan(((-2.0 * A) / B_m)) * (180.0 / Math.PI);
	}
	return B_s * tmp;
}
B\_m = math.fabs(B)
B\_s = math.copysign(1.0, B)
def code(B_s, A, B_m, C):
	tmp = 0
	if A <= -6.2e+86:
		tmp = 180.0 * (math.atan((B_m * (0.5 / A))) / math.pi)
	elif A <= 5.8e+169:
		tmp = 180.0 * (math.atan(((C / B_m) - 1.0)) / math.pi)
	else:
		tmp = math.atan(((-2.0 * A) / B_m)) * (180.0 / math.pi)
	return B_s * tmp
B\_m = abs(B)
B\_s = copysign(1.0, B)
function code(B_s, A, B_m, C)
	tmp = 0.0
	if (A <= -6.2e+86)
		tmp = Float64(180.0 * Float64(atan(Float64(B_m * Float64(0.5 / A))) / pi));
	elseif (A <= 5.8e+169)
		tmp = Float64(180.0 * Float64(atan(Float64(Float64(C / B_m) - 1.0)) / pi));
	else
		tmp = Float64(atan(Float64(Float64(-2.0 * A) / B_m)) * Float64(180.0 / pi));
	end
	return Float64(B_s * tmp)
end
B\_m = abs(B);
B\_s = sign(B) * abs(1.0);
function tmp_2 = code(B_s, A, B_m, C)
	tmp = 0.0;
	if (A <= -6.2e+86)
		tmp = 180.0 * (atan((B_m * (0.5 / A))) / pi);
	elseif (A <= 5.8e+169)
		tmp = 180.0 * (atan(((C / B_m) - 1.0)) / pi);
	else
		tmp = atan(((-2.0 * A) / B_m)) * (180.0 / pi);
	end
	tmp_2 = B_s * tmp;
end
B\_m = N[Abs[B], $MachinePrecision]
B\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[B]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[B$95$s_, A_, B$95$m_, C_] := N[(B$95$s * If[LessEqual[A, -6.2e+86], N[(180.0 * N[(N[ArcTan[N[(B$95$m * N[(0.5 / A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision], If[LessEqual[A, 5.8e+169], N[(180.0 * N[(N[ArcTan[N[(N[(C / B$95$m), $MachinePrecision] - 1.0), $MachinePrecision]], $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision], N[(N[ArcTan[N[(N[(-2.0 * A), $MachinePrecision] / B$95$m), $MachinePrecision]], $MachinePrecision] * N[(180.0 / Pi), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
B\_m = \left|B\right|
\\
B\_s = \mathsf{copysign}\left(1, B\right)

\\
B\_s \cdot \begin{array}{l}
\mathbf{if}\;A \leq -6.2 \cdot 10^{+86}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(B\_m \cdot \frac{0.5}{A}\right)}{\pi}\\

\mathbf{elif}\;A \leq 5.8 \cdot 10^{+169}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{C}{B\_m} - 1\right)}{\pi}\\

\mathbf{else}:\\
\;\;\;\;\tan^{-1} \left(\frac{-2 \cdot A}{B\_m}\right) \cdot \frac{180}{\pi}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if A < -6.2000000000000004e86

    1. Initial program 54.1%

      \[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. Taylor expanded in A around -inf

      \[\leadsto 180 \cdot \frac{\tan^{-1} \color{blue}{\left(\frac{1}{2} \cdot \frac{B}{A}\right)}}{\pi} \]
    3. Applied rewrites26.3%

      \[\leadsto 180 \cdot \frac{\tan^{-1} \color{blue}{\left(0.5 \cdot \frac{B}{A}\right)}}{\pi} \]
    4. Applied rewrites26.3%

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

    if -6.2000000000000004e86 < A < 5.8000000000000001e169

    1. Initial program 54.1%

      \[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. Taylor expanded in B around inf

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

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

      \[\leadsto 180 \cdot \frac{\tan^{-1} \left(\frac{C}{B} - 1\right)}{\pi} \]
    5. Applied rewrites56.5%

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

    if 5.8000000000000001e169 < A

    1. Initial program 54.1%

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

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

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

      \[\leadsto \tan^{-1} \left(\frac{\color{blue}{-2 \cdot A}}{B}\right) \cdot \frac{180}{\pi} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 6: 69.4% accurate, 2.2× speedup?

\[\begin{array}{l} B\_m = \left|B\right| \\ B\_s = \mathsf{copysign}\left(1, B\right) \\ B\_s \cdot \begin{array}{l} \mathbf{if}\;A \leq -6.2 \cdot 10^{+86}:\\ \;\;\;\;180 \cdot \frac{\tan^{-1} \left(0.5 \cdot \frac{B\_m}{A}\right)}{\pi}\\ \mathbf{elif}\;A \leq 5.8 \cdot 10^{+169}:\\ \;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{C}{B\_m} - 1\right)}{\pi}\\ \mathbf{else}:\\ \;\;\;\;\tan^{-1} \left(\frac{-2 \cdot A}{B\_m}\right) \cdot \frac{180}{\pi}\\ \end{array} \end{array} \]
B\_m = (fabs.f64 B)
B\_s = (copysign.f64 #s(literal 1 binary64) B)
(FPCore (B_s A B_m C)
 :precision binary64
 (*
  B_s
  (if (<= A -6.2e+86)
    (* 180.0 (/ (atan (* 0.5 (/ B_m A))) PI))
    (if (<= A 5.8e+169)
      (* 180.0 (/ (atan (- (/ C B_m) 1.0)) PI))
      (* (atan (/ (* -2.0 A) B_m)) (/ 180.0 PI))))))
B\_m = fabs(B);
B\_s = copysign(1.0, B);
double code(double B_s, double A, double B_m, double C) {
	double tmp;
	if (A <= -6.2e+86) {
		tmp = 180.0 * (atan((0.5 * (B_m / A))) / ((double) M_PI));
	} else if (A <= 5.8e+169) {
		tmp = 180.0 * (atan(((C / B_m) - 1.0)) / ((double) M_PI));
	} else {
		tmp = atan(((-2.0 * A) / B_m)) * (180.0 / ((double) M_PI));
	}
	return B_s * tmp;
}
B\_m = Math.abs(B);
B\_s = Math.copySign(1.0, B);
public static double code(double B_s, double A, double B_m, double C) {
	double tmp;
	if (A <= -6.2e+86) {
		tmp = 180.0 * (Math.atan((0.5 * (B_m / A))) / Math.PI);
	} else if (A <= 5.8e+169) {
		tmp = 180.0 * (Math.atan(((C / B_m) - 1.0)) / Math.PI);
	} else {
		tmp = Math.atan(((-2.0 * A) / B_m)) * (180.0 / Math.PI);
	}
	return B_s * tmp;
}
B\_m = math.fabs(B)
B\_s = math.copysign(1.0, B)
def code(B_s, A, B_m, C):
	tmp = 0
	if A <= -6.2e+86:
		tmp = 180.0 * (math.atan((0.5 * (B_m / A))) / math.pi)
	elif A <= 5.8e+169:
		tmp = 180.0 * (math.atan(((C / B_m) - 1.0)) / math.pi)
	else:
		tmp = math.atan(((-2.0 * A) / B_m)) * (180.0 / math.pi)
	return B_s * tmp
B\_m = abs(B)
B\_s = copysign(1.0, B)
function code(B_s, A, B_m, C)
	tmp = 0.0
	if (A <= -6.2e+86)
		tmp = Float64(180.0 * Float64(atan(Float64(0.5 * Float64(B_m / A))) / pi));
	elseif (A <= 5.8e+169)
		tmp = Float64(180.0 * Float64(atan(Float64(Float64(C / B_m) - 1.0)) / pi));
	else
		tmp = Float64(atan(Float64(Float64(-2.0 * A) / B_m)) * Float64(180.0 / pi));
	end
	return Float64(B_s * tmp)
end
B\_m = abs(B);
B\_s = sign(B) * abs(1.0);
function tmp_2 = code(B_s, A, B_m, C)
	tmp = 0.0;
	if (A <= -6.2e+86)
		tmp = 180.0 * (atan((0.5 * (B_m / A))) / pi);
	elseif (A <= 5.8e+169)
		tmp = 180.0 * (atan(((C / B_m) - 1.0)) / pi);
	else
		tmp = atan(((-2.0 * A) / B_m)) * (180.0 / pi);
	end
	tmp_2 = B_s * tmp;
end
B\_m = N[Abs[B], $MachinePrecision]
B\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[B]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[B$95$s_, A_, B$95$m_, C_] := N[(B$95$s * If[LessEqual[A, -6.2e+86], N[(180.0 * N[(N[ArcTan[N[(0.5 * N[(B$95$m / A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision], If[LessEqual[A, 5.8e+169], N[(180.0 * N[(N[ArcTan[N[(N[(C / B$95$m), $MachinePrecision] - 1.0), $MachinePrecision]], $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision], N[(N[ArcTan[N[(N[(-2.0 * A), $MachinePrecision] / B$95$m), $MachinePrecision]], $MachinePrecision] * N[(180.0 / Pi), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
B\_m = \left|B\right|
\\
B\_s = \mathsf{copysign}\left(1, B\right)

\\
B\_s \cdot \begin{array}{l}
\mathbf{if}\;A \leq -6.2 \cdot 10^{+86}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(0.5 \cdot \frac{B\_m}{A}\right)}{\pi}\\

\mathbf{elif}\;A \leq 5.8 \cdot 10^{+169}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{C}{B\_m} - 1\right)}{\pi}\\

\mathbf{else}:\\
\;\;\;\;\tan^{-1} \left(\frac{-2 \cdot A}{B\_m}\right) \cdot \frac{180}{\pi}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if A < -6.2000000000000004e86

    1. Initial program 54.1%

      \[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. Taylor expanded in A around -inf

      \[\leadsto 180 \cdot \frac{\tan^{-1} \color{blue}{\left(\frac{1}{2} \cdot \frac{B}{A}\right)}}{\pi} \]
    3. Applied rewrites26.3%

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

    if -6.2000000000000004e86 < A < 5.8000000000000001e169

    1. Initial program 54.1%

      \[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. Taylor expanded in B around inf

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

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

      \[\leadsto 180 \cdot \frac{\tan^{-1} \left(\frac{C}{B} - 1\right)}{\pi} \]
    5. Applied rewrites56.5%

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

    if 5.8000000000000001e169 < A

    1. Initial program 54.1%

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

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

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

      \[\leadsto \tan^{-1} \left(\frac{\color{blue}{-2 \cdot A}}{B}\right) \cdot \frac{180}{\pi} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 7: 69.4% accurate, 2.2× speedup?

\[\begin{array}{l} B\_m = \left|B\right| \\ B\_s = \mathsf{copysign}\left(1, B\right) \\ B\_s \cdot \begin{array}{l} \mathbf{if}\;A \leq -6.2 \cdot 10^{+86}:\\ \;\;\;\;\tan^{-1} \left(0.5 \cdot \frac{B\_m}{A}\right) \cdot \frac{180}{\pi}\\ \mathbf{elif}\;A \leq 5.8 \cdot 10^{+169}:\\ \;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{C}{B\_m} - 1\right)}{\pi}\\ \mathbf{else}:\\ \;\;\;\;\tan^{-1} \left(\frac{-2 \cdot A}{B\_m}\right) \cdot \frac{180}{\pi}\\ \end{array} \end{array} \]
B\_m = (fabs.f64 B)
B\_s = (copysign.f64 #s(literal 1 binary64) B)
(FPCore (B_s A B_m C)
 :precision binary64
 (*
  B_s
  (if (<= A -6.2e+86)
    (* (atan (* 0.5 (/ B_m A))) (/ 180.0 PI))
    (if (<= A 5.8e+169)
      (* 180.0 (/ (atan (- (/ C B_m) 1.0)) PI))
      (* (atan (/ (* -2.0 A) B_m)) (/ 180.0 PI))))))
B\_m = fabs(B);
B\_s = copysign(1.0, B);
double code(double B_s, double A, double B_m, double C) {
	double tmp;
	if (A <= -6.2e+86) {
		tmp = atan((0.5 * (B_m / A))) * (180.0 / ((double) M_PI));
	} else if (A <= 5.8e+169) {
		tmp = 180.0 * (atan(((C / B_m) - 1.0)) / ((double) M_PI));
	} else {
		tmp = atan(((-2.0 * A) / B_m)) * (180.0 / ((double) M_PI));
	}
	return B_s * tmp;
}
B\_m = Math.abs(B);
B\_s = Math.copySign(1.0, B);
public static double code(double B_s, double A, double B_m, double C) {
	double tmp;
	if (A <= -6.2e+86) {
		tmp = Math.atan((0.5 * (B_m / A))) * (180.0 / Math.PI);
	} else if (A <= 5.8e+169) {
		tmp = 180.0 * (Math.atan(((C / B_m) - 1.0)) / Math.PI);
	} else {
		tmp = Math.atan(((-2.0 * A) / B_m)) * (180.0 / Math.PI);
	}
	return B_s * tmp;
}
B\_m = math.fabs(B)
B\_s = math.copysign(1.0, B)
def code(B_s, A, B_m, C):
	tmp = 0
	if A <= -6.2e+86:
		tmp = math.atan((0.5 * (B_m / A))) * (180.0 / math.pi)
	elif A <= 5.8e+169:
		tmp = 180.0 * (math.atan(((C / B_m) - 1.0)) / math.pi)
	else:
		tmp = math.atan(((-2.0 * A) / B_m)) * (180.0 / math.pi)
	return B_s * tmp
B\_m = abs(B)
B\_s = copysign(1.0, B)
function code(B_s, A, B_m, C)
	tmp = 0.0
	if (A <= -6.2e+86)
		tmp = Float64(atan(Float64(0.5 * Float64(B_m / A))) * Float64(180.0 / pi));
	elseif (A <= 5.8e+169)
		tmp = Float64(180.0 * Float64(atan(Float64(Float64(C / B_m) - 1.0)) / pi));
	else
		tmp = Float64(atan(Float64(Float64(-2.0 * A) / B_m)) * Float64(180.0 / pi));
	end
	return Float64(B_s * tmp)
end
B\_m = abs(B);
B\_s = sign(B) * abs(1.0);
function tmp_2 = code(B_s, A, B_m, C)
	tmp = 0.0;
	if (A <= -6.2e+86)
		tmp = atan((0.5 * (B_m / A))) * (180.0 / pi);
	elseif (A <= 5.8e+169)
		tmp = 180.0 * (atan(((C / B_m) - 1.0)) / pi);
	else
		tmp = atan(((-2.0 * A) / B_m)) * (180.0 / pi);
	end
	tmp_2 = B_s * tmp;
end
B\_m = N[Abs[B], $MachinePrecision]
B\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[B]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[B$95$s_, A_, B$95$m_, C_] := N[(B$95$s * If[LessEqual[A, -6.2e+86], N[(N[ArcTan[N[(0.5 * N[(B$95$m / A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(180.0 / Pi), $MachinePrecision]), $MachinePrecision], If[LessEqual[A, 5.8e+169], N[(180.0 * N[(N[ArcTan[N[(N[(C / B$95$m), $MachinePrecision] - 1.0), $MachinePrecision]], $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision], N[(N[ArcTan[N[(N[(-2.0 * A), $MachinePrecision] / B$95$m), $MachinePrecision]], $MachinePrecision] * N[(180.0 / Pi), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
B\_m = \left|B\right|
\\
B\_s = \mathsf{copysign}\left(1, B\right)

\\
B\_s \cdot \begin{array}{l}
\mathbf{if}\;A \leq -6.2 \cdot 10^{+86}:\\
\;\;\;\;\tan^{-1} \left(0.5 \cdot \frac{B\_m}{A}\right) \cdot \frac{180}{\pi}\\

\mathbf{elif}\;A \leq 5.8 \cdot 10^{+169}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{C}{B\_m} - 1\right)}{\pi}\\

\mathbf{else}:\\
\;\;\;\;\tan^{-1} \left(\frac{-2 \cdot A}{B\_m}\right) \cdot \frac{180}{\pi}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if A < -6.2000000000000004e86

    1. Initial program 54.1%

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

      \[\leadsto \color{blue}{\tan^{-1} \left(\frac{\left(C - A\right) - \sqrt{\mathsf{fma}\left(C - A, C - A, B \cdot B\right)}}{B}\right) \cdot \frac{180}{\pi}} \]
    3. Applied rewrites78.3%

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

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

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

    if -6.2000000000000004e86 < A < 5.8000000000000001e169

    1. Initial program 54.1%

      \[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. Taylor expanded in B around inf

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

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

      \[\leadsto 180 \cdot \frac{\tan^{-1} \left(\frac{C}{B} - 1\right)}{\pi} \]
    5. Applied rewrites56.5%

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

    if 5.8000000000000001e169 < A

    1. Initial program 54.1%

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

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

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

      \[\leadsto \tan^{-1} \left(\frac{\color{blue}{-2 \cdot A}}{B}\right) \cdot \frac{180}{\pi} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 8: 69.3% accurate, 2.2× speedup?

\[\begin{array}{l} B\_m = \left|B\right| \\ B\_s = \mathsf{copysign}\left(1, B\right) \\ B\_s \cdot \begin{array}{l} \mathbf{if}\;A \leq -6.2 \cdot 10^{+86}:\\ \;\;\;\;\tan^{-1} \left(0.5 \cdot \frac{B\_m}{A}\right) \cdot \frac{180}{\pi}\\ \mathbf{elif}\;A \leq 5.8 \cdot 10^{+169}:\\ \;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{C}{B\_m} - 1\right)}{\pi}\\ \mathbf{else}:\\ \;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{C - A}{B\_m}\right)}{\pi}\\ \end{array} \end{array} \]
B\_m = (fabs.f64 B)
B\_s = (copysign.f64 #s(literal 1 binary64) B)
(FPCore (B_s A B_m C)
 :precision binary64
 (*
  B_s
  (if (<= A -6.2e+86)
    (* (atan (* 0.5 (/ B_m A))) (/ 180.0 PI))
    (if (<= A 5.8e+169)
      (* 180.0 (/ (atan (- (/ C B_m) 1.0)) PI))
      (* 180.0 (/ (atan (/ (- C A) B_m)) PI))))))
B\_m = fabs(B);
B\_s = copysign(1.0, B);
double code(double B_s, double A, double B_m, double C) {
	double tmp;
	if (A <= -6.2e+86) {
		tmp = atan((0.5 * (B_m / A))) * (180.0 / ((double) M_PI));
	} else if (A <= 5.8e+169) {
		tmp = 180.0 * (atan(((C / B_m) - 1.0)) / ((double) M_PI));
	} else {
		tmp = 180.0 * (atan(((C - A) / B_m)) / ((double) M_PI));
	}
	return B_s * tmp;
}
B\_m = Math.abs(B);
B\_s = Math.copySign(1.0, B);
public static double code(double B_s, double A, double B_m, double C) {
	double tmp;
	if (A <= -6.2e+86) {
		tmp = Math.atan((0.5 * (B_m / A))) * (180.0 / Math.PI);
	} else if (A <= 5.8e+169) {
		tmp = 180.0 * (Math.atan(((C / B_m) - 1.0)) / Math.PI);
	} else {
		tmp = 180.0 * (Math.atan(((C - A) / B_m)) / Math.PI);
	}
	return B_s * tmp;
}
B\_m = math.fabs(B)
B\_s = math.copysign(1.0, B)
def code(B_s, A, B_m, C):
	tmp = 0
	if A <= -6.2e+86:
		tmp = math.atan((0.5 * (B_m / A))) * (180.0 / math.pi)
	elif A <= 5.8e+169:
		tmp = 180.0 * (math.atan(((C / B_m) - 1.0)) / math.pi)
	else:
		tmp = 180.0 * (math.atan(((C - A) / B_m)) / math.pi)
	return B_s * tmp
B\_m = abs(B)
B\_s = copysign(1.0, B)
function code(B_s, A, B_m, C)
	tmp = 0.0
	if (A <= -6.2e+86)
		tmp = Float64(atan(Float64(0.5 * Float64(B_m / A))) * Float64(180.0 / pi));
	elseif (A <= 5.8e+169)
		tmp = Float64(180.0 * Float64(atan(Float64(Float64(C / B_m) - 1.0)) / pi));
	else
		tmp = Float64(180.0 * Float64(atan(Float64(Float64(C - A) / B_m)) / pi));
	end
	return Float64(B_s * tmp)
end
B\_m = abs(B);
B\_s = sign(B) * abs(1.0);
function tmp_2 = code(B_s, A, B_m, C)
	tmp = 0.0;
	if (A <= -6.2e+86)
		tmp = atan((0.5 * (B_m / A))) * (180.0 / pi);
	elseif (A <= 5.8e+169)
		tmp = 180.0 * (atan(((C / B_m) - 1.0)) / pi);
	else
		tmp = 180.0 * (atan(((C - A) / B_m)) / pi);
	end
	tmp_2 = B_s * tmp;
end
B\_m = N[Abs[B], $MachinePrecision]
B\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[B]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[B$95$s_, A_, B$95$m_, C_] := N[(B$95$s * If[LessEqual[A, -6.2e+86], N[(N[ArcTan[N[(0.5 * N[(B$95$m / A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(180.0 / Pi), $MachinePrecision]), $MachinePrecision], If[LessEqual[A, 5.8e+169], N[(180.0 * N[(N[ArcTan[N[(N[(C / B$95$m), $MachinePrecision] - 1.0), $MachinePrecision]], $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision], N[(180.0 * N[(N[ArcTan[N[(N[(C - A), $MachinePrecision] / B$95$m), $MachinePrecision]], $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
B\_m = \left|B\right|
\\
B\_s = \mathsf{copysign}\left(1, B\right)

\\
B\_s \cdot \begin{array}{l}
\mathbf{if}\;A \leq -6.2 \cdot 10^{+86}:\\
\;\;\;\;\tan^{-1} \left(0.5 \cdot \frac{B\_m}{A}\right) \cdot \frac{180}{\pi}\\

\mathbf{elif}\;A \leq 5.8 \cdot 10^{+169}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{C}{B\_m} - 1\right)}{\pi}\\

\mathbf{else}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{C - A}{B\_m}\right)}{\pi}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if A < -6.2000000000000004e86

    1. Initial program 54.1%

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

      \[\leadsto \color{blue}{\tan^{-1} \left(\frac{\left(C - A\right) - \sqrt{\mathsf{fma}\left(C - A, C - A, B \cdot B\right)}}{B}\right) \cdot \frac{180}{\pi}} \]
    3. Applied rewrites78.3%

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

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

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

    if -6.2000000000000004e86 < A < 5.8000000000000001e169

    1. Initial program 54.1%

      \[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. Taylor expanded in B around inf

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

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

      \[\leadsto 180 \cdot \frac{\tan^{-1} \left(\frac{C}{B} - 1\right)}{\pi} \]
    5. Applied rewrites56.5%

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

    if 5.8000000000000001e169 < A

    1. Initial program 54.1%

      \[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. Taylor expanded in B around inf

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

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

      \[\leadsto 180 \cdot \frac{\tan^{-1} \left(\frac{C - A}{\color{blue}{B}}\right)}{\pi} \]
    5. Applied rewrites34.5%

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

Alternative 9: 59.2% accurate, 2.5× speedup?

\[\begin{array}{l} B\_m = \left|B\right| \\ B\_s = \mathsf{copysign}\left(1, B\right) \\ B\_s \cdot \begin{array}{l} \mathbf{if}\;B\_m \leq 1.05 \cdot 10^{-104}:\\ \;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{C - A}{B\_m}\right)}{\pi}\\ \mathbf{else}:\\ \;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{C}{B\_m} - 1\right)}{\pi}\\ \end{array} \end{array} \]
B\_m = (fabs.f64 B)
B\_s = (copysign.f64 #s(literal 1 binary64) B)
(FPCore (B_s A B_m C)
 :precision binary64
 (*
  B_s
  (if (<= B_m 1.05e-104)
    (* 180.0 (/ (atan (/ (- C A) B_m)) PI))
    (* 180.0 (/ (atan (- (/ C B_m) 1.0)) PI)))))
B\_m = fabs(B);
B\_s = copysign(1.0, B);
double code(double B_s, double A, double B_m, double C) {
	double tmp;
	if (B_m <= 1.05e-104) {
		tmp = 180.0 * (atan(((C - A) / B_m)) / ((double) M_PI));
	} else {
		tmp = 180.0 * (atan(((C / B_m) - 1.0)) / ((double) M_PI));
	}
	return B_s * tmp;
}
B\_m = Math.abs(B);
B\_s = Math.copySign(1.0, B);
public static double code(double B_s, double A, double B_m, double C) {
	double tmp;
	if (B_m <= 1.05e-104) {
		tmp = 180.0 * (Math.atan(((C - A) / B_m)) / Math.PI);
	} else {
		tmp = 180.0 * (Math.atan(((C / B_m) - 1.0)) / Math.PI);
	}
	return B_s * tmp;
}
B\_m = math.fabs(B)
B\_s = math.copysign(1.0, B)
def code(B_s, A, B_m, C):
	tmp = 0
	if B_m <= 1.05e-104:
		tmp = 180.0 * (math.atan(((C - A) / B_m)) / math.pi)
	else:
		tmp = 180.0 * (math.atan(((C / B_m) - 1.0)) / math.pi)
	return B_s * tmp
B\_m = abs(B)
B\_s = copysign(1.0, B)
function code(B_s, A, B_m, C)
	tmp = 0.0
	if (B_m <= 1.05e-104)
		tmp = Float64(180.0 * Float64(atan(Float64(Float64(C - A) / B_m)) / pi));
	else
		tmp = Float64(180.0 * Float64(atan(Float64(Float64(C / B_m) - 1.0)) / pi));
	end
	return Float64(B_s * tmp)
end
B\_m = abs(B);
B\_s = sign(B) * abs(1.0);
function tmp_2 = code(B_s, A, B_m, C)
	tmp = 0.0;
	if (B_m <= 1.05e-104)
		tmp = 180.0 * (atan(((C - A) / B_m)) / pi);
	else
		tmp = 180.0 * (atan(((C / B_m) - 1.0)) / pi);
	end
	tmp_2 = B_s * tmp;
end
B\_m = N[Abs[B], $MachinePrecision]
B\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[B]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[B$95$s_, A_, B$95$m_, C_] := N[(B$95$s * If[LessEqual[B$95$m, 1.05e-104], N[(180.0 * N[(N[ArcTan[N[(N[(C - A), $MachinePrecision] / B$95$m), $MachinePrecision]], $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision], N[(180.0 * N[(N[ArcTan[N[(N[(C / B$95$m), $MachinePrecision] - 1.0), $MachinePrecision]], $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
B\_m = \left|B\right|
\\
B\_s = \mathsf{copysign}\left(1, B\right)

\\
B\_s \cdot \begin{array}{l}
\mathbf{if}\;B\_m \leq 1.05 \cdot 10^{-104}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{C - A}{B\_m}\right)}{\pi}\\

\mathbf{else}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{C}{B\_m} - 1\right)}{\pi}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if B < 1.04999999999999999e-104

    1. Initial program 54.1%

      \[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. Taylor expanded in B around inf

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

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

      \[\leadsto 180 \cdot \frac{\tan^{-1} \left(\frac{C - A}{\color{blue}{B}}\right)}{\pi} \]
    5. Applied rewrites34.5%

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

    if 1.04999999999999999e-104 < B

    1. Initial program 54.1%

      \[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. Taylor expanded in B around inf

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

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

      \[\leadsto 180 \cdot \frac{\tan^{-1} \left(\frac{C}{B} - 1\right)}{\pi} \]
    5. Applied rewrites56.5%

      \[\leadsto 180 \cdot \frac{\tan^{-1} \left(\frac{C}{B} - 1\right)}{\pi} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 10: 52.8% accurate, 2.5× speedup?

\[\begin{array}{l} B\_m = \left|B\right| \\ B\_s = \mathsf{copysign}\left(1, B\right) \\ B\_s \cdot \begin{array}{l} \mathbf{if}\;B\_m \leq 4.5 \cdot 10^{-70}:\\ \;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{C - A}{B\_m}\right)}{\pi}\\ \mathbf{else}:\\ \;\;\;\;180 \cdot \frac{\tan^{-1} -1}{\pi}\\ \end{array} \end{array} \]
B\_m = (fabs.f64 B)
B\_s = (copysign.f64 #s(literal 1 binary64) B)
(FPCore (B_s A B_m C)
 :precision binary64
 (*
  B_s
  (if (<= B_m 4.5e-70)
    (* 180.0 (/ (atan (/ (- C A) B_m)) PI))
    (* 180.0 (/ (atan -1.0) PI)))))
B\_m = fabs(B);
B\_s = copysign(1.0, B);
double code(double B_s, double A, double B_m, double C) {
	double tmp;
	if (B_m <= 4.5e-70) {
		tmp = 180.0 * (atan(((C - A) / B_m)) / ((double) M_PI));
	} else {
		tmp = 180.0 * (atan(-1.0) / ((double) M_PI));
	}
	return B_s * tmp;
}
B\_m = Math.abs(B);
B\_s = Math.copySign(1.0, B);
public static double code(double B_s, double A, double B_m, double C) {
	double tmp;
	if (B_m <= 4.5e-70) {
		tmp = 180.0 * (Math.atan(((C - A) / B_m)) / Math.PI);
	} else {
		tmp = 180.0 * (Math.atan(-1.0) / Math.PI);
	}
	return B_s * tmp;
}
B\_m = math.fabs(B)
B\_s = math.copysign(1.0, B)
def code(B_s, A, B_m, C):
	tmp = 0
	if B_m <= 4.5e-70:
		tmp = 180.0 * (math.atan(((C - A) / B_m)) / math.pi)
	else:
		tmp = 180.0 * (math.atan(-1.0) / math.pi)
	return B_s * tmp
B\_m = abs(B)
B\_s = copysign(1.0, B)
function code(B_s, A, B_m, C)
	tmp = 0.0
	if (B_m <= 4.5e-70)
		tmp = Float64(180.0 * Float64(atan(Float64(Float64(C - A) / B_m)) / pi));
	else
		tmp = Float64(180.0 * Float64(atan(-1.0) / pi));
	end
	return Float64(B_s * tmp)
end
B\_m = abs(B);
B\_s = sign(B) * abs(1.0);
function tmp_2 = code(B_s, A, B_m, C)
	tmp = 0.0;
	if (B_m <= 4.5e-70)
		tmp = 180.0 * (atan(((C - A) / B_m)) / pi);
	else
		tmp = 180.0 * (atan(-1.0) / pi);
	end
	tmp_2 = B_s * tmp;
end
B\_m = N[Abs[B], $MachinePrecision]
B\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[B]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[B$95$s_, A_, B$95$m_, C_] := N[(B$95$s * If[LessEqual[B$95$m, 4.5e-70], N[(180.0 * N[(N[ArcTan[N[(N[(C - A), $MachinePrecision] / B$95$m), $MachinePrecision]], $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision], N[(180.0 * N[(N[ArcTan[-1.0], $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
B\_m = \left|B\right|
\\
B\_s = \mathsf{copysign}\left(1, B\right)

\\
B\_s \cdot \begin{array}{l}
\mathbf{if}\;B\_m \leq 4.5 \cdot 10^{-70}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{C - A}{B\_m}\right)}{\pi}\\

\mathbf{else}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} -1}{\pi}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if B < 4.50000000000000022e-70

    1. Initial program 54.1%

      \[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. Taylor expanded in B around inf

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

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

      \[\leadsto 180 \cdot \frac{\tan^{-1} \left(\frac{C - A}{\color{blue}{B}}\right)}{\pi} \]
    5. Applied rewrites34.5%

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

    if 4.50000000000000022e-70 < B

    1. Initial program 54.1%

      \[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. Taylor expanded in B around inf

      \[\leadsto 180 \cdot \frac{\tan^{-1} \color{blue}{-1}}{\pi} \]
    3. Applied rewrites40.4%

      \[\leadsto 180 \cdot \frac{\tan^{-1} \color{blue}{-1}}{\pi} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 11: 47.6% accurate, 2.8× speedup?

\[\begin{array}{l} B\_m = \left|B\right| \\ B\_s = \mathsf{copysign}\left(1, B\right) \\ B\_s \cdot \begin{array}{l} \mathbf{if}\;B\_m \leq 4.6 \cdot 10^{-83}:\\ \;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{C}{B\_m}\right)}{\pi}\\ \mathbf{else}:\\ \;\;\;\;180 \cdot \frac{\tan^{-1} -1}{\pi}\\ \end{array} \end{array} \]
B\_m = (fabs.f64 B)
B\_s = (copysign.f64 #s(literal 1 binary64) B)
(FPCore (B_s A B_m C)
 :precision binary64
 (*
  B_s
  (if (<= B_m 4.6e-83)
    (* 180.0 (/ (atan (/ C B_m)) PI))
    (* 180.0 (/ (atan -1.0) PI)))))
B\_m = fabs(B);
B\_s = copysign(1.0, B);
double code(double B_s, double A, double B_m, double C) {
	double tmp;
	if (B_m <= 4.6e-83) {
		tmp = 180.0 * (atan((C / B_m)) / ((double) M_PI));
	} else {
		tmp = 180.0 * (atan(-1.0) / ((double) M_PI));
	}
	return B_s * tmp;
}
B\_m = Math.abs(B);
B\_s = Math.copySign(1.0, B);
public static double code(double B_s, double A, double B_m, double C) {
	double tmp;
	if (B_m <= 4.6e-83) {
		tmp = 180.0 * (Math.atan((C / B_m)) / Math.PI);
	} else {
		tmp = 180.0 * (Math.atan(-1.0) / Math.PI);
	}
	return B_s * tmp;
}
B\_m = math.fabs(B)
B\_s = math.copysign(1.0, B)
def code(B_s, A, B_m, C):
	tmp = 0
	if B_m <= 4.6e-83:
		tmp = 180.0 * (math.atan((C / B_m)) / math.pi)
	else:
		tmp = 180.0 * (math.atan(-1.0) / math.pi)
	return B_s * tmp
B\_m = abs(B)
B\_s = copysign(1.0, B)
function code(B_s, A, B_m, C)
	tmp = 0.0
	if (B_m <= 4.6e-83)
		tmp = Float64(180.0 * Float64(atan(Float64(C / B_m)) / pi));
	else
		tmp = Float64(180.0 * Float64(atan(-1.0) / pi));
	end
	return Float64(B_s * tmp)
end
B\_m = abs(B);
B\_s = sign(B) * abs(1.0);
function tmp_2 = code(B_s, A, B_m, C)
	tmp = 0.0;
	if (B_m <= 4.6e-83)
		tmp = 180.0 * (atan((C / B_m)) / pi);
	else
		tmp = 180.0 * (atan(-1.0) / pi);
	end
	tmp_2 = B_s * tmp;
end
B\_m = N[Abs[B], $MachinePrecision]
B\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[B]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[B$95$s_, A_, B$95$m_, C_] := N[(B$95$s * If[LessEqual[B$95$m, 4.6e-83], N[(180.0 * N[(N[ArcTan[N[(C / B$95$m), $MachinePrecision]], $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision], N[(180.0 * N[(N[ArcTan[-1.0], $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
B\_m = \left|B\right|
\\
B\_s = \mathsf{copysign}\left(1, B\right)

\\
B\_s \cdot \begin{array}{l}
\mathbf{if}\;B\_m \leq 4.6 \cdot 10^{-83}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{C}{B\_m}\right)}{\pi}\\

\mathbf{else}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} -1}{\pi}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if B < 4.59999999999999979e-83

    1. Initial program 54.1%

      \[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. Taylor expanded in B around inf

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

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

      \[\leadsto 180 \cdot \frac{\tan^{-1} \left(\frac{C - A}{\color{blue}{B}}\right)}{\pi} \]
    5. Applied rewrites34.5%

      \[\leadsto 180 \cdot \frac{\tan^{-1} \left(\frac{C - A}{\color{blue}{B}}\right)}{\pi} \]
    6. Taylor expanded in A around 0

      \[\leadsto 180 \cdot \frac{\tan^{-1} \left(\frac{C}{B}\right)}{\pi} \]
    7. Applied rewrites23.5%

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

    if 4.59999999999999979e-83 < B

    1. Initial program 54.1%

      \[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. Taylor expanded in B around inf

      \[\leadsto 180 \cdot \frac{\tan^{-1} \color{blue}{-1}}{\pi} \]
    3. Applied rewrites40.4%

      \[\leadsto 180 \cdot \frac{\tan^{-1} \color{blue}{-1}}{\pi} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 12: 40.4% accurate, 4.1× speedup?

\[\begin{array}{l} B\_m = \left|B\right| \\ B\_s = \mathsf{copysign}\left(1, B\right) \\ B\_s \cdot \left(180 \cdot \frac{\tan^{-1} -1}{\pi}\right) \end{array} \]
B\_m = (fabs.f64 B)
B\_s = (copysign.f64 #s(literal 1 binary64) B)
(FPCore (B_s A B_m C) :precision binary64 (* B_s (* 180.0 (/ (atan -1.0) PI))))
B\_m = fabs(B);
B\_s = copysign(1.0, B);
double code(double B_s, double A, double B_m, double C) {
	return B_s * (180.0 * (atan(-1.0) / ((double) M_PI)));
}
B\_m = Math.abs(B);
B\_s = Math.copySign(1.0, B);
public static double code(double B_s, double A, double B_m, double C) {
	return B_s * (180.0 * (Math.atan(-1.0) / Math.PI));
}
B\_m = math.fabs(B)
B\_s = math.copysign(1.0, B)
def code(B_s, A, B_m, C):
	return B_s * (180.0 * (math.atan(-1.0) / math.pi))
B\_m = abs(B)
B\_s = copysign(1.0, B)
function code(B_s, A, B_m, C)
	return Float64(B_s * Float64(180.0 * Float64(atan(-1.0) / pi)))
end
B\_m = abs(B);
B\_s = sign(B) * abs(1.0);
function tmp = code(B_s, A, B_m, C)
	tmp = B_s * (180.0 * (atan(-1.0) / pi));
end
B\_m = N[Abs[B], $MachinePrecision]
B\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[B]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[B$95$s_, A_, B$95$m_, C_] := N[(B$95$s * N[(180.0 * N[(N[ArcTan[-1.0], $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B\_m = \left|B\right|
\\
B\_s = \mathsf{copysign}\left(1, B\right)

\\
B\_s \cdot \left(180 \cdot \frac{\tan^{-1} -1}{\pi}\right)
\end{array}
Derivation
  1. Initial program 54.1%

    \[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. Taylor expanded in B around inf

    \[\leadsto 180 \cdot \frac{\tan^{-1} \color{blue}{-1}}{\pi} \]
  3. Applied rewrites40.4%

    \[\leadsto 180 \cdot \frac{\tan^{-1} \color{blue}{-1}}{\pi} \]
  4. Add Preprocessing

Reproduce

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