ab-angle->ABCF B

Percentage Accurate: 53.7% → 57.1%
Time: 32.0s
Alternatives: 8
Speedup: 32.2×

Specification

?
\[\begin{array}{l} \\ \begin{array}{l} t_0 := \pi \cdot \frac{angle}{180}\\ \left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin t_0\right) \cdot \cos t_0 \end{array} \end{array} \]
(FPCore (a b angle)
 :precision binary64
 (let* ((t_0 (* PI (/ angle 180.0))))
   (* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) (sin t_0)) (cos t_0))))
double code(double a, double b, double angle) {
	double t_0 = ((double) M_PI) * (angle / 180.0);
	return ((2.0 * (pow(b, 2.0) - pow(a, 2.0))) * sin(t_0)) * cos(t_0);
}
public static double code(double a, double b, double angle) {
	double t_0 = Math.PI * (angle / 180.0);
	return ((2.0 * (Math.pow(b, 2.0) - Math.pow(a, 2.0))) * Math.sin(t_0)) * Math.cos(t_0);
}
def code(a, b, angle):
	t_0 = math.pi * (angle / 180.0)
	return ((2.0 * (math.pow(b, 2.0) - math.pow(a, 2.0))) * math.sin(t_0)) * math.cos(t_0)
function code(a, b, angle)
	t_0 = Float64(pi * Float64(angle / 180.0))
	return Float64(Float64(Float64(2.0 * Float64((b ^ 2.0) - (a ^ 2.0))) * sin(t_0)) * cos(t_0))
end
function tmp = code(a, b, angle)
	t_0 = pi * (angle / 180.0);
	tmp = ((2.0 * ((b ^ 2.0) - (a ^ 2.0))) * sin(t_0)) * cos(t_0);
end
code[a_, b_, angle_] := Block[{t$95$0 = N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(2.0 * N[(N[Power[b, 2.0], $MachinePrecision] - N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \pi \cdot \frac{angle}{180}\\
\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin t_0\right) \cdot \cos t_0
\end{array}
\end{array}

Sampling outcomes in binary64 precision:

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 8 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: 53.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \pi \cdot \frac{angle}{180}\\ \left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin t_0\right) \cdot \cos t_0 \end{array} \end{array} \]
(FPCore (a b angle)
 :precision binary64
 (let* ((t_0 (* PI (/ angle 180.0))))
   (* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) (sin t_0)) (cos t_0))))
double code(double a, double b, double angle) {
	double t_0 = ((double) M_PI) * (angle / 180.0);
	return ((2.0 * (pow(b, 2.0) - pow(a, 2.0))) * sin(t_0)) * cos(t_0);
}
public static double code(double a, double b, double angle) {
	double t_0 = Math.PI * (angle / 180.0);
	return ((2.0 * (Math.pow(b, 2.0) - Math.pow(a, 2.0))) * Math.sin(t_0)) * Math.cos(t_0);
}
def code(a, b, angle):
	t_0 = math.pi * (angle / 180.0)
	return ((2.0 * (math.pow(b, 2.0) - math.pow(a, 2.0))) * math.sin(t_0)) * math.cos(t_0)
function code(a, b, angle)
	t_0 = Float64(pi * Float64(angle / 180.0))
	return Float64(Float64(Float64(2.0 * Float64((b ^ 2.0) - (a ^ 2.0))) * sin(t_0)) * cos(t_0))
end
function tmp = code(a, b, angle)
	t_0 = pi * (angle / 180.0);
	tmp = ((2.0 * ((b ^ 2.0) - (a ^ 2.0))) * sin(t_0)) * cos(t_0);
end
code[a_, b_, angle_] := Block[{t$95$0 = N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(2.0 * N[(N[Power[b, 2.0], $MachinePrecision] - N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \pi \cdot \frac{angle}{180}\\
\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin t_0\right) \cdot \cos t_0
\end{array}
\end{array}

Alternative 1: 57.1% accurate, 0.8× speedup?

\[\begin{array}{l} a_m = \left|a\right| \\ \begin{array}{l} t_0 := 2 \cdot \left(\left(a_m + b\right) \cdot \left(b - a_m\right)\right)\\ t_1 := \sqrt[3]{angle \cdot \pi}\\ \mathbf{if}\;a_m \leq 10^{+113}:\\ \;\;\;\;t_0 \cdot \left(\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right) \cdot \cos \left(\sqrt[3]{\pi \cdot {\pi}^{2}} \cdot \frac{angle}{180}\right)\right)\\ \mathbf{elif}\;a_m \leq 1.2 \cdot 10^{+264}:\\ \;\;\;\;t_0 \cdot \sin \left(\frac{angle}{\frac{180}{\pi}}\right)\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot \left(\sin \left(\frac{{t_1}^{2}}{180} \cdot t_1\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)\\ \end{array} \end{array} \]
a_m = (fabs.f64 a)
(FPCore (a_m b angle)
 :precision binary64
 (let* ((t_0 (* 2.0 (* (+ a_m b) (- b a_m)))) (t_1 (cbrt (* angle PI))))
   (if (<= a_m 1e+113)
     (*
      t_0
      (*
       (sin (* 0.005555555555555556 (* angle PI)))
       (cos (* (cbrt (* PI (pow PI 2.0))) (/ angle 180.0)))))
     (if (<= a_m 1.2e+264)
       (* t_0 (sin (/ angle (/ 180.0 PI))))
       (*
        t_0
        (*
         (sin (* (/ (pow t_1 2.0) 180.0) t_1))
         (cos (* PI (/ angle 180.0)))))))))
a_m = fabs(a);
double code(double a_m, double b, double angle) {
	double t_0 = 2.0 * ((a_m + b) * (b - a_m));
	double t_1 = cbrt((angle * ((double) M_PI)));
	double tmp;
	if (a_m <= 1e+113) {
		tmp = t_0 * (sin((0.005555555555555556 * (angle * ((double) M_PI)))) * cos((cbrt((((double) M_PI) * pow(((double) M_PI), 2.0))) * (angle / 180.0))));
	} else if (a_m <= 1.2e+264) {
		tmp = t_0 * sin((angle / (180.0 / ((double) M_PI))));
	} else {
		tmp = t_0 * (sin(((pow(t_1, 2.0) / 180.0) * t_1)) * cos((((double) M_PI) * (angle / 180.0))));
	}
	return tmp;
}
a_m = Math.abs(a);
public static double code(double a_m, double b, double angle) {
	double t_0 = 2.0 * ((a_m + b) * (b - a_m));
	double t_1 = Math.cbrt((angle * Math.PI));
	double tmp;
	if (a_m <= 1e+113) {
		tmp = t_0 * (Math.sin((0.005555555555555556 * (angle * Math.PI))) * Math.cos((Math.cbrt((Math.PI * Math.pow(Math.PI, 2.0))) * (angle / 180.0))));
	} else if (a_m <= 1.2e+264) {
		tmp = t_0 * Math.sin((angle / (180.0 / Math.PI)));
	} else {
		tmp = t_0 * (Math.sin(((Math.pow(t_1, 2.0) / 180.0) * t_1)) * Math.cos((Math.PI * (angle / 180.0))));
	}
	return tmp;
}
a_m = abs(a)
function code(a_m, b, angle)
	t_0 = Float64(2.0 * Float64(Float64(a_m + b) * Float64(b - a_m)))
	t_1 = cbrt(Float64(angle * pi))
	tmp = 0.0
	if (a_m <= 1e+113)
		tmp = Float64(t_0 * Float64(sin(Float64(0.005555555555555556 * Float64(angle * pi))) * cos(Float64(cbrt(Float64(pi * (pi ^ 2.0))) * Float64(angle / 180.0)))));
	elseif (a_m <= 1.2e+264)
		tmp = Float64(t_0 * sin(Float64(angle / Float64(180.0 / pi))));
	else
		tmp = Float64(t_0 * Float64(sin(Float64(Float64((t_1 ^ 2.0) / 180.0) * t_1)) * cos(Float64(pi * Float64(angle / 180.0)))));
	end
	return tmp
end
a_m = N[Abs[a], $MachinePrecision]
code[a$95$m_, b_, angle_] := Block[{t$95$0 = N[(2.0 * N[(N[(a$95$m + b), $MachinePrecision] * N[(b - a$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(angle * Pi), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[a$95$m, 1e+113], N[(t$95$0 * N[(N[Sin[N[(0.005555555555555556 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(N[Power[N[(Pi * N[Power[Pi, 2.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a$95$m, 1.2e+264], N[(t$95$0 * N[Sin[N[(angle / N[(180.0 / Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(N[Sin[N[(N[(N[Power[t$95$1, 2.0], $MachinePrecision] / 180.0), $MachinePrecision] * t$95$1), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
a_m = \left|a\right|

\\
\begin{array}{l}
t_0 := 2 \cdot \left(\left(a_m + b\right) \cdot \left(b - a_m\right)\right)\\
t_1 := \sqrt[3]{angle \cdot \pi}\\
\mathbf{if}\;a_m \leq 10^{+113}:\\
\;\;\;\;t_0 \cdot \left(\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right) \cdot \cos \left(\sqrt[3]{\pi \cdot {\pi}^{2}} \cdot \frac{angle}{180}\right)\right)\\

\mathbf{elif}\;a_m \leq 1.2 \cdot 10^{+264}:\\
\;\;\;\;t_0 \cdot \sin \left(\frac{angle}{\frac{180}{\pi}}\right)\\

\mathbf{else}:\\
\;\;\;\;t_0 \cdot \left(\sin \left(\frac{{t_1}^{2}}{180} \cdot t_1\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 2: 53.7% accurate, 0.8× speedup?

\[\begin{array}{l} a_m = \left|a\right| \\ \begin{array}{l} t_0 := 2 \cdot \left(\left(a_m + b\right) \cdot \left(b - a_m\right)\right)\\ \mathbf{if}\;a_m \leq 1.16 \cdot 10^{+113}:\\ \;\;\;\;t_0 \cdot \left(\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right) \cdot \cos \left(\sqrt[3]{\pi \cdot {\pi}^{2}} \cdot \frac{angle}{180}\right)\right)\\ \mathbf{elif}\;a_m \leq 2 \cdot 10^{+238}:\\ \;\;\;\;t_0 \cdot \sin \left(\frac{angle}{\frac{180}{\pi}}\right)\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot \left(\cos \left(\pi \cdot \frac{angle}{180}\right) \cdot \sin \left(e^{\log \left(0.005555555555555556 \cdot angle\right) + \log \pi}\right)\right)\\ \end{array} \end{array} \]
a_m = (fabs.f64 a)
(FPCore (a_m b angle)
 :precision binary64
 (let* ((t_0 (* 2.0 (* (+ a_m b) (- b a_m)))))
   (if (<= a_m 1.16e+113)
     (*
      t_0
      (*
       (sin (* 0.005555555555555556 (* angle PI)))
       (cos (* (cbrt (* PI (pow PI 2.0))) (/ angle 180.0)))))
     (if (<= a_m 2e+238)
       (* t_0 (sin (/ angle (/ 180.0 PI))))
       (*
        t_0
        (*
         (cos (* PI (/ angle 180.0)))
         (sin (exp (+ (log (* 0.005555555555555556 angle)) (log PI))))))))))
a_m = fabs(a);
double code(double a_m, double b, double angle) {
	double t_0 = 2.0 * ((a_m + b) * (b - a_m));
	double tmp;
	if (a_m <= 1.16e+113) {
		tmp = t_0 * (sin((0.005555555555555556 * (angle * ((double) M_PI)))) * cos((cbrt((((double) M_PI) * pow(((double) M_PI), 2.0))) * (angle / 180.0))));
	} else if (a_m <= 2e+238) {
		tmp = t_0 * sin((angle / (180.0 / ((double) M_PI))));
	} else {
		tmp = t_0 * (cos((((double) M_PI) * (angle / 180.0))) * sin(exp((log((0.005555555555555556 * angle)) + log(((double) M_PI))))));
	}
	return tmp;
}
a_m = Math.abs(a);
public static double code(double a_m, double b, double angle) {
	double t_0 = 2.0 * ((a_m + b) * (b - a_m));
	double tmp;
	if (a_m <= 1.16e+113) {
		tmp = t_0 * (Math.sin((0.005555555555555556 * (angle * Math.PI))) * Math.cos((Math.cbrt((Math.PI * Math.pow(Math.PI, 2.0))) * (angle / 180.0))));
	} else if (a_m <= 2e+238) {
		tmp = t_0 * Math.sin((angle / (180.0 / Math.PI)));
	} else {
		tmp = t_0 * (Math.cos((Math.PI * (angle / 180.0))) * Math.sin(Math.exp((Math.log((0.005555555555555556 * angle)) + Math.log(Math.PI)))));
	}
	return tmp;
}
a_m = abs(a)
function code(a_m, b, angle)
	t_0 = Float64(2.0 * Float64(Float64(a_m + b) * Float64(b - a_m)))
	tmp = 0.0
	if (a_m <= 1.16e+113)
		tmp = Float64(t_0 * Float64(sin(Float64(0.005555555555555556 * Float64(angle * pi))) * cos(Float64(cbrt(Float64(pi * (pi ^ 2.0))) * Float64(angle / 180.0)))));
	elseif (a_m <= 2e+238)
		tmp = Float64(t_0 * sin(Float64(angle / Float64(180.0 / pi))));
	else
		tmp = Float64(t_0 * Float64(cos(Float64(pi * Float64(angle / 180.0))) * sin(exp(Float64(log(Float64(0.005555555555555556 * angle)) + log(pi))))));
	end
	return tmp
end
a_m = N[Abs[a], $MachinePrecision]
code[a$95$m_, b_, angle_] := Block[{t$95$0 = N[(2.0 * N[(N[(a$95$m + b), $MachinePrecision] * N[(b - a$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a$95$m, 1.16e+113], N[(t$95$0 * N[(N[Sin[N[(0.005555555555555556 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(N[Power[N[(Pi * N[Power[Pi, 2.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a$95$m, 2e+238], N[(t$95$0 * N[Sin[N[(angle / N[(180.0 / Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(N[Cos[N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sin[N[Exp[N[(N[Log[N[(0.005555555555555556 * angle), $MachinePrecision]], $MachinePrecision] + N[Log[Pi], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
a_m = \left|a\right|

\\
\begin{array}{l}
t_0 := 2 \cdot \left(\left(a_m + b\right) \cdot \left(b - a_m\right)\right)\\
\mathbf{if}\;a_m \leq 1.16 \cdot 10^{+113}:\\
\;\;\;\;t_0 \cdot \left(\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right) \cdot \cos \left(\sqrt[3]{\pi \cdot {\pi}^{2}} \cdot \frac{angle}{180}\right)\right)\\

\mathbf{elif}\;a_m \leq 2 \cdot 10^{+238}:\\
\;\;\;\;t_0 \cdot \sin \left(\frac{angle}{\frac{180}{\pi}}\right)\\

\mathbf{else}:\\
\;\;\;\;t_0 \cdot \left(\cos \left(\pi \cdot \frac{angle}{180}\right) \cdot \sin \left(e^{\log \left(0.005555555555555556 \cdot angle\right) + \log \pi}\right)\right)\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 3: 57.2% accurate, 1.0× speedup?

\[\begin{array}{l} a_m = \left|a\right| \\ \begin{array}{l} t_0 := 2 \cdot \left(\left(a_m + b\right) \cdot \left(b - a_m\right)\right)\\ \mathbf{if}\;a_m \leq 1.25 \cdot 10^{+113} \lor \neg \left(a_m \leq 10^{+264}\right):\\ \;\;\;\;t_0 \cdot \left(\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right) \cdot \cos \left(\sqrt[3]{\pi \cdot {\pi}^{2}} \cdot \frac{angle}{180}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot \sin \left(\frac{angle}{\frac{180}{\pi}}\right)\\ \end{array} \end{array} \]
a_m = (fabs.f64 a)
(FPCore (a_m b angle)
 :precision binary64
 (let* ((t_0 (* 2.0 (* (+ a_m b) (- b a_m)))))
   (if (or (<= a_m 1.25e+113) (not (<= a_m 1e+264)))
     (*
      t_0
      (*
       (sin (* 0.005555555555555556 (* angle PI)))
       (cos (* (cbrt (* PI (pow PI 2.0))) (/ angle 180.0)))))
     (* t_0 (sin (/ angle (/ 180.0 PI)))))))
a_m = fabs(a);
double code(double a_m, double b, double angle) {
	double t_0 = 2.0 * ((a_m + b) * (b - a_m));
	double tmp;
	if ((a_m <= 1.25e+113) || !(a_m <= 1e+264)) {
		tmp = t_0 * (sin((0.005555555555555556 * (angle * ((double) M_PI)))) * cos((cbrt((((double) M_PI) * pow(((double) M_PI), 2.0))) * (angle / 180.0))));
	} else {
		tmp = t_0 * sin((angle / (180.0 / ((double) M_PI))));
	}
	return tmp;
}
a_m = Math.abs(a);
public static double code(double a_m, double b, double angle) {
	double t_0 = 2.0 * ((a_m + b) * (b - a_m));
	double tmp;
	if ((a_m <= 1.25e+113) || !(a_m <= 1e+264)) {
		tmp = t_0 * (Math.sin((0.005555555555555556 * (angle * Math.PI))) * Math.cos((Math.cbrt((Math.PI * Math.pow(Math.PI, 2.0))) * (angle / 180.0))));
	} else {
		tmp = t_0 * Math.sin((angle / (180.0 / Math.PI)));
	}
	return tmp;
}
a_m = abs(a)
function code(a_m, b, angle)
	t_0 = Float64(2.0 * Float64(Float64(a_m + b) * Float64(b - a_m)))
	tmp = 0.0
	if ((a_m <= 1.25e+113) || !(a_m <= 1e+264))
		tmp = Float64(t_0 * Float64(sin(Float64(0.005555555555555556 * Float64(angle * pi))) * cos(Float64(cbrt(Float64(pi * (pi ^ 2.0))) * Float64(angle / 180.0)))));
	else
		tmp = Float64(t_0 * sin(Float64(angle / Float64(180.0 / pi))));
	end
	return tmp
end
a_m = N[Abs[a], $MachinePrecision]
code[a$95$m_, b_, angle_] := Block[{t$95$0 = N[(2.0 * N[(N[(a$95$m + b), $MachinePrecision] * N[(b - a$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[a$95$m, 1.25e+113], N[Not[LessEqual[a$95$m, 1e+264]], $MachinePrecision]], N[(t$95$0 * N[(N[Sin[N[(0.005555555555555556 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(N[Power[N[(Pi * N[Power[Pi, 2.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[Sin[N[(angle / N[(180.0 / Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
a_m = \left|a\right|

\\
\begin{array}{l}
t_0 := 2 \cdot \left(\left(a_m + b\right) \cdot \left(b - a_m\right)\right)\\
\mathbf{if}\;a_m \leq 1.25 \cdot 10^{+113} \lor \neg \left(a_m \leq 10^{+264}\right):\\
\;\;\;\;t_0 \cdot \left(\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right) \cdot \cos \left(\sqrt[3]{\pi \cdot {\pi}^{2}} \cdot \frac{angle}{180}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;t_0 \cdot \sin \left(\frac{angle}{\frac{180}{\pi}}\right)\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 4: 57.4% accurate, 1.8× speedup?

\[\begin{array}{l} a_m = \left|a\right| \\ \begin{array}{l} t_0 := angle \cdot \frac{\pi}{-180}\\ \mathbf{if}\;\frac{angle}{180} \leq 3 \cdot 10^{+168}:\\ \;\;\;\;\cos t_0 \cdot \left(\sin t_0 \cdot \left(2 \cdot \left(\left(a_m + b\right) \cdot \left(a_m - b\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right) \cdot \left(\left(\left(a_m + b\right) \cdot \left(b - a_m\right)\right) \cdot \sin \left(\left(angle \cdot \pi\right) \cdot -0.005555555555555556\right)\right)\right)\\ \end{array} \end{array} \]
a_m = (fabs.f64 a)
(FPCore (a_m b angle)
 :precision binary64
 (let* ((t_0 (* angle (/ PI -180.0))))
   (if (<= (/ angle 180.0) 3e+168)
     (* (cos t_0) (* (sin t_0) (* 2.0 (* (+ a_m b) (- a_m b)))))
     (*
      2.0
      (*
       (cos (* 0.005555555555555556 (* angle PI)))
       (*
        (* (+ a_m b) (- b a_m))
        (sin (* (* angle PI) -0.005555555555555556))))))))
a_m = fabs(a);
double code(double a_m, double b, double angle) {
	double t_0 = angle * (((double) M_PI) / -180.0);
	double tmp;
	if ((angle / 180.0) <= 3e+168) {
		tmp = cos(t_0) * (sin(t_0) * (2.0 * ((a_m + b) * (a_m - b))));
	} else {
		tmp = 2.0 * (cos((0.005555555555555556 * (angle * ((double) M_PI)))) * (((a_m + b) * (b - a_m)) * sin(((angle * ((double) M_PI)) * -0.005555555555555556))));
	}
	return tmp;
}
a_m = Math.abs(a);
public static double code(double a_m, double b, double angle) {
	double t_0 = angle * (Math.PI / -180.0);
	double tmp;
	if ((angle / 180.0) <= 3e+168) {
		tmp = Math.cos(t_0) * (Math.sin(t_0) * (2.0 * ((a_m + b) * (a_m - b))));
	} else {
		tmp = 2.0 * (Math.cos((0.005555555555555556 * (angle * Math.PI))) * (((a_m + b) * (b - a_m)) * Math.sin(((angle * Math.PI) * -0.005555555555555556))));
	}
	return tmp;
}
a_m = math.fabs(a)
def code(a_m, b, angle):
	t_0 = angle * (math.pi / -180.0)
	tmp = 0
	if (angle / 180.0) <= 3e+168:
		tmp = math.cos(t_0) * (math.sin(t_0) * (2.0 * ((a_m + b) * (a_m - b))))
	else:
		tmp = 2.0 * (math.cos((0.005555555555555556 * (angle * math.pi))) * (((a_m + b) * (b - a_m)) * math.sin(((angle * math.pi) * -0.005555555555555556))))
	return tmp
a_m = abs(a)
function code(a_m, b, angle)
	t_0 = Float64(angle * Float64(pi / -180.0))
	tmp = 0.0
	if (Float64(angle / 180.0) <= 3e+168)
		tmp = Float64(cos(t_0) * Float64(sin(t_0) * Float64(2.0 * Float64(Float64(a_m + b) * Float64(a_m - b)))));
	else
		tmp = Float64(2.0 * Float64(cos(Float64(0.005555555555555556 * Float64(angle * pi))) * Float64(Float64(Float64(a_m + b) * Float64(b - a_m)) * sin(Float64(Float64(angle * pi) * -0.005555555555555556)))));
	end
	return tmp
end
a_m = abs(a);
function tmp_2 = code(a_m, b, angle)
	t_0 = angle * (pi / -180.0);
	tmp = 0.0;
	if ((angle / 180.0) <= 3e+168)
		tmp = cos(t_0) * (sin(t_0) * (2.0 * ((a_m + b) * (a_m - b))));
	else
		tmp = 2.0 * (cos((0.005555555555555556 * (angle * pi))) * (((a_m + b) * (b - a_m)) * sin(((angle * pi) * -0.005555555555555556))));
	end
	tmp_2 = tmp;
end
a_m = N[Abs[a], $MachinePrecision]
code[a$95$m_, b_, angle_] := Block[{t$95$0 = N[(angle * N[(Pi / -180.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(angle / 180.0), $MachinePrecision], 3e+168], N[(N[Cos[t$95$0], $MachinePrecision] * N[(N[Sin[t$95$0], $MachinePrecision] * N[(2.0 * N[(N[(a$95$m + b), $MachinePrecision] * N[(a$95$m - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(N[Cos[N[(0.005555555555555556 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[(N[(a$95$m + b), $MachinePrecision] * N[(b - a$95$m), $MachinePrecision]), $MachinePrecision] * N[Sin[N[(N[(angle * Pi), $MachinePrecision] * -0.005555555555555556), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
a_m = \left|a\right|

\\
\begin{array}{l}
t_0 := angle \cdot \frac{\pi}{-180}\\
\mathbf{if}\;\frac{angle}{180} \leq 3 \cdot 10^{+168}:\\
\;\;\;\;\cos t_0 \cdot \left(\sin t_0 \cdot \left(2 \cdot \left(\left(a_m + b\right) \cdot \left(a_m - b\right)\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;2 \cdot \left(\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right) \cdot \left(\left(\left(a_m + b\right) \cdot \left(b - a_m\right)\right) \cdot \sin \left(\left(angle \cdot \pi\right) \cdot -0.005555555555555556\right)\right)\right)\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 5: 57.2% accurate, 1.8× speedup?

\[\begin{array}{l} a_m = \left|a\right| \\ \begin{array}{l} t_0 := \left(a_m + b\right) \cdot \left(b - a_m\right)\\ \mathbf{if}\;\frac{angle}{180} \leq 3 \cdot 10^{+168}:\\ \;\;\;\;\left(2 \cdot t_0\right) \cdot \left(\sin \left(\frac{angle}{\frac{180}{\pi}}\right) \cdot \cos \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right) \cdot \left(t_0 \cdot \sin \left(\left(angle \cdot \pi\right) \cdot -0.005555555555555556\right)\right)\right)\\ \end{array} \end{array} \]
a_m = (fabs.f64 a)
(FPCore (a_m b angle)
 :precision binary64
 (let* ((t_0 (* (+ a_m b) (- b a_m))))
   (if (<= (/ angle 180.0) 3e+168)
     (*
      (* 2.0 t_0)
      (*
       (sin (/ angle (/ 180.0 PI)))
       (cos (* PI (* 0.005555555555555556 angle)))))
     (*
      2.0
      (*
       (cos (* 0.005555555555555556 (* angle PI)))
       (* t_0 (sin (* (* angle PI) -0.005555555555555556))))))))
a_m = fabs(a);
double code(double a_m, double b, double angle) {
	double t_0 = (a_m + b) * (b - a_m);
	double tmp;
	if ((angle / 180.0) <= 3e+168) {
		tmp = (2.0 * t_0) * (sin((angle / (180.0 / ((double) M_PI)))) * cos((((double) M_PI) * (0.005555555555555556 * angle))));
	} else {
		tmp = 2.0 * (cos((0.005555555555555556 * (angle * ((double) M_PI)))) * (t_0 * sin(((angle * ((double) M_PI)) * -0.005555555555555556))));
	}
	return tmp;
}
a_m = Math.abs(a);
public static double code(double a_m, double b, double angle) {
	double t_0 = (a_m + b) * (b - a_m);
	double tmp;
	if ((angle / 180.0) <= 3e+168) {
		tmp = (2.0 * t_0) * (Math.sin((angle / (180.0 / Math.PI))) * Math.cos((Math.PI * (0.005555555555555556 * angle))));
	} else {
		tmp = 2.0 * (Math.cos((0.005555555555555556 * (angle * Math.PI))) * (t_0 * Math.sin(((angle * Math.PI) * -0.005555555555555556))));
	}
	return tmp;
}
a_m = math.fabs(a)
def code(a_m, b, angle):
	t_0 = (a_m + b) * (b - a_m)
	tmp = 0
	if (angle / 180.0) <= 3e+168:
		tmp = (2.0 * t_0) * (math.sin((angle / (180.0 / math.pi))) * math.cos((math.pi * (0.005555555555555556 * angle))))
	else:
		tmp = 2.0 * (math.cos((0.005555555555555556 * (angle * math.pi))) * (t_0 * math.sin(((angle * math.pi) * -0.005555555555555556))))
	return tmp
a_m = abs(a)
function code(a_m, b, angle)
	t_0 = Float64(Float64(a_m + b) * Float64(b - a_m))
	tmp = 0.0
	if (Float64(angle / 180.0) <= 3e+168)
		tmp = Float64(Float64(2.0 * t_0) * Float64(sin(Float64(angle / Float64(180.0 / pi))) * cos(Float64(pi * Float64(0.005555555555555556 * angle)))));
	else
		tmp = Float64(2.0 * Float64(cos(Float64(0.005555555555555556 * Float64(angle * pi))) * Float64(t_0 * sin(Float64(Float64(angle * pi) * -0.005555555555555556)))));
	end
	return tmp
end
a_m = abs(a);
function tmp_2 = code(a_m, b, angle)
	t_0 = (a_m + b) * (b - a_m);
	tmp = 0.0;
	if ((angle / 180.0) <= 3e+168)
		tmp = (2.0 * t_0) * (sin((angle / (180.0 / pi))) * cos((pi * (0.005555555555555556 * angle))));
	else
		tmp = 2.0 * (cos((0.005555555555555556 * (angle * pi))) * (t_0 * sin(((angle * pi) * -0.005555555555555556))));
	end
	tmp_2 = tmp;
end
a_m = N[Abs[a], $MachinePrecision]
code[a$95$m_, b_, angle_] := Block[{t$95$0 = N[(N[(a$95$m + b), $MachinePrecision] * N[(b - a$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(angle / 180.0), $MachinePrecision], 3e+168], N[(N[(2.0 * t$95$0), $MachinePrecision] * N[(N[Sin[N[(angle / N[(180.0 / Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(Pi * N[(0.005555555555555556 * angle), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(N[Cos[N[(0.005555555555555556 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(t$95$0 * N[Sin[N[(N[(angle * Pi), $MachinePrecision] * -0.005555555555555556), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
a_m = \left|a\right|

\\
\begin{array}{l}
t_0 := \left(a_m + b\right) \cdot \left(b - a_m\right)\\
\mathbf{if}\;\frac{angle}{180} \leq 3 \cdot 10^{+168}:\\
\;\;\;\;\left(2 \cdot t_0\right) \cdot \left(\sin \left(\frac{angle}{\frac{180}{\pi}}\right) \cdot \cos \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;2 \cdot \left(\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right) \cdot \left(t_0 \cdot \sin \left(\left(angle \cdot \pi\right) \cdot -0.005555555555555556\right)\right)\right)\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 6: 57.5% accurate, 1.9× speedup?

\[\begin{array}{l} a_m = \left|a\right| \\ \begin{array}{l} t_0 := \left(a_m + b\right) \cdot \left(b - a_m\right)\\ t_1 := 0.005555555555555556 \cdot \left(angle \cdot \pi\right)\\ t_2 := \cos t_1\\ \mathbf{if}\;angle \leq 4.5 \cdot 10^{+170}:\\ \;\;\;\;2 \cdot \left(t_2 \cdot \left(t_0 \cdot \sin t_1\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(t_2 \cdot \left(t_0 \cdot \sin \left(\left(angle \cdot \pi\right) \cdot -0.005555555555555556\right)\right)\right)\\ \end{array} \end{array} \]
a_m = (fabs.f64 a)
(FPCore (a_m b angle)
 :precision binary64
 (let* ((t_0 (* (+ a_m b) (- b a_m)))
        (t_1 (* 0.005555555555555556 (* angle PI)))
        (t_2 (cos t_1)))
   (if (<= angle 4.5e+170)
     (* 2.0 (* t_2 (* t_0 (sin t_1))))
     (* 2.0 (* t_2 (* t_0 (sin (* (* angle PI) -0.005555555555555556))))))))
a_m = fabs(a);
double code(double a_m, double b, double angle) {
	double t_0 = (a_m + b) * (b - a_m);
	double t_1 = 0.005555555555555556 * (angle * ((double) M_PI));
	double t_2 = cos(t_1);
	double tmp;
	if (angle <= 4.5e+170) {
		tmp = 2.0 * (t_2 * (t_0 * sin(t_1)));
	} else {
		tmp = 2.0 * (t_2 * (t_0 * sin(((angle * ((double) M_PI)) * -0.005555555555555556))));
	}
	return tmp;
}
a_m = Math.abs(a);
public static double code(double a_m, double b, double angle) {
	double t_0 = (a_m + b) * (b - a_m);
	double t_1 = 0.005555555555555556 * (angle * Math.PI);
	double t_2 = Math.cos(t_1);
	double tmp;
	if (angle <= 4.5e+170) {
		tmp = 2.0 * (t_2 * (t_0 * Math.sin(t_1)));
	} else {
		tmp = 2.0 * (t_2 * (t_0 * Math.sin(((angle * Math.PI) * -0.005555555555555556))));
	}
	return tmp;
}
a_m = math.fabs(a)
def code(a_m, b, angle):
	t_0 = (a_m + b) * (b - a_m)
	t_1 = 0.005555555555555556 * (angle * math.pi)
	t_2 = math.cos(t_1)
	tmp = 0
	if angle <= 4.5e+170:
		tmp = 2.0 * (t_2 * (t_0 * math.sin(t_1)))
	else:
		tmp = 2.0 * (t_2 * (t_0 * math.sin(((angle * math.pi) * -0.005555555555555556))))
	return tmp
a_m = abs(a)
function code(a_m, b, angle)
	t_0 = Float64(Float64(a_m + b) * Float64(b - a_m))
	t_1 = Float64(0.005555555555555556 * Float64(angle * pi))
	t_2 = cos(t_1)
	tmp = 0.0
	if (angle <= 4.5e+170)
		tmp = Float64(2.0 * Float64(t_2 * Float64(t_0 * sin(t_1))));
	else
		tmp = Float64(2.0 * Float64(t_2 * Float64(t_0 * sin(Float64(Float64(angle * pi) * -0.005555555555555556)))));
	end
	return tmp
end
a_m = abs(a);
function tmp_2 = code(a_m, b, angle)
	t_0 = (a_m + b) * (b - a_m);
	t_1 = 0.005555555555555556 * (angle * pi);
	t_2 = cos(t_1);
	tmp = 0.0;
	if (angle <= 4.5e+170)
		tmp = 2.0 * (t_2 * (t_0 * sin(t_1)));
	else
		tmp = 2.0 * (t_2 * (t_0 * sin(((angle * pi) * -0.005555555555555556))));
	end
	tmp_2 = tmp;
end
a_m = N[Abs[a], $MachinePrecision]
code[a$95$m_, b_, angle_] := Block[{t$95$0 = N[(N[(a$95$m + b), $MachinePrecision] * N[(b - a$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.005555555555555556 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[t$95$1], $MachinePrecision]}, If[LessEqual[angle, 4.5e+170], N[(2.0 * N[(t$95$2 * N[(t$95$0 * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(t$95$2 * N[(t$95$0 * N[Sin[N[(N[(angle * Pi), $MachinePrecision] * -0.005555555555555556), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
a_m = \left|a\right|

\\
\begin{array}{l}
t_0 := \left(a_m + b\right) \cdot \left(b - a_m\right)\\
t_1 := 0.005555555555555556 \cdot \left(angle \cdot \pi\right)\\
t_2 := \cos t_1\\
\mathbf{if}\;angle \leq 4.5 \cdot 10^{+170}:\\
\;\;\;\;2 \cdot \left(t_2 \cdot \left(t_0 \cdot \sin t_1\right)\right)\\

\mathbf{else}:\\
\;\;\;\;2 \cdot \left(t_2 \cdot \left(t_0 \cdot \sin \left(\left(angle \cdot \pi\right) \cdot -0.005555555555555556\right)\right)\right)\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 7: 56.3% accurate, 3.6× speedup?

\[\begin{array}{l} a_m = \left|a\right| \\ \left(2 \cdot \left(\left(a_m + b\right) \cdot \left(b - a_m\right)\right)\right) \cdot \sin \left(\frac{angle}{\frac{180}{\pi}}\right) \end{array} \]
a_m = (fabs.f64 a)
(FPCore (a_m b angle)
 :precision binary64
 (* (* 2.0 (* (+ a_m b) (- b a_m))) (sin (/ angle (/ 180.0 PI)))))
a_m = fabs(a);
double code(double a_m, double b, double angle) {
	return (2.0 * ((a_m + b) * (b - a_m))) * sin((angle / (180.0 / ((double) M_PI))));
}
a_m = Math.abs(a);
public static double code(double a_m, double b, double angle) {
	return (2.0 * ((a_m + b) * (b - a_m))) * Math.sin((angle / (180.0 / Math.PI)));
}
a_m = math.fabs(a)
def code(a_m, b, angle):
	return (2.0 * ((a_m + b) * (b - a_m))) * math.sin((angle / (180.0 / math.pi)))
a_m = abs(a)
function code(a_m, b, angle)
	return Float64(Float64(2.0 * Float64(Float64(a_m + b) * Float64(b - a_m))) * sin(Float64(angle / Float64(180.0 / pi))))
end
a_m = abs(a);
function tmp = code(a_m, b, angle)
	tmp = (2.0 * ((a_m + b) * (b - a_m))) * sin((angle / (180.0 / pi)));
end
a_m = N[Abs[a], $MachinePrecision]
code[a$95$m_, b_, angle_] := N[(N[(2.0 * N[(N[(a$95$m + b), $MachinePrecision] * N[(b - a$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[N[(angle / N[(180.0 / Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a_m = \left|a\right|

\\
\left(2 \cdot \left(\left(a_m + b\right) \cdot \left(b - a_m\right)\right)\right) \cdot \sin \left(\frac{angle}{\frac{180}{\pi}}\right)
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 8: 54.2% accurate, 32.2× speedup?

\[\begin{array}{l} a_m = \left|a\right| \\ 0.011111111111111112 \cdot \left(angle \cdot \left(\left(\left(a_m + b\right) \cdot \left(b - a_m\right)\right) \cdot \pi\right)\right) \end{array} \]
a_m = (fabs.f64 a)
(FPCore (a_m b angle)
 :precision binary64
 (* 0.011111111111111112 (* angle (* (* (+ a_m b) (- b a_m)) PI))))
a_m = fabs(a);
double code(double a_m, double b, double angle) {
	return 0.011111111111111112 * (angle * (((a_m + b) * (b - a_m)) * ((double) M_PI)));
}
a_m = Math.abs(a);
public static double code(double a_m, double b, double angle) {
	return 0.011111111111111112 * (angle * (((a_m + b) * (b - a_m)) * Math.PI));
}
a_m = math.fabs(a)
def code(a_m, b, angle):
	return 0.011111111111111112 * (angle * (((a_m + b) * (b - a_m)) * math.pi))
a_m = abs(a)
function code(a_m, b, angle)
	return Float64(0.011111111111111112 * Float64(angle * Float64(Float64(Float64(a_m + b) * Float64(b - a_m)) * pi)))
end
a_m = abs(a);
function tmp = code(a_m, b, angle)
	tmp = 0.011111111111111112 * (angle * (((a_m + b) * (b - a_m)) * pi));
end
a_m = N[Abs[a], $MachinePrecision]
code[a$95$m_, b_, angle_] := N[(0.011111111111111112 * N[(angle * N[(N[(N[(a$95$m + b), $MachinePrecision] * N[(b - a$95$m), $MachinePrecision]), $MachinePrecision] * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a_m = \left|a\right|

\\
0.011111111111111112 \cdot \left(angle \cdot \left(\left(\left(a_m + b\right) \cdot \left(b - a_m\right)\right) \cdot \pi\right)\right)
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Reproduce

?
herbie shell --seed 2024006 
(FPCore (a b angle)
  :name "ab-angle->ABCF B"
  :precision binary64
  (* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) (sin (* PI (/ angle 180.0)))) (cos (* PI (/ angle 180.0)))))