ab-angle->ABCF B

Percentage Accurate: 54.4% → 58.2%
Time: 26.1s
Alternatives: 5
Speedup: 27.9×

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 5 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.4% 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: 58.2% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
t_0 := \pi \cdot \frac{angle}{180}\\
\cos t\_0 \cdot \left(\left(2 \cdot \left(\left(b - a\right) \cdot \left(b + a\right)\right)\right) \cdot \sin t\_0\right)
\end{array}
\end{array}
Derivation
  1. Initial program 58.9%

    \[\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right) \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. unpow258.9%

      \[\leadsto \left(\left(2 \cdot \left(\color{blue}{b \cdot b} - {a}^{2}\right)\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right) \]
    2. unpow258.9%

      \[\leadsto \left(\left(2 \cdot \left(b \cdot b - \color{blue}{a \cdot a}\right)\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right) \]
    3. difference-of-squares63.3%

      \[\leadsto \left(\left(2 \cdot \color{blue}{\left(\left(b + a\right) \cdot \left(b - a\right)\right)}\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right) \]
  4. Applied egg-rr63.3%

    \[\leadsto \left(\left(2 \cdot \color{blue}{\left(\left(b + a\right) \cdot \left(b - a\right)\right)}\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right) \]
  5. Final simplification63.3%

    \[\leadsto \cos \left(\pi \cdot \frac{angle}{180}\right) \cdot \left(\left(2 \cdot \left(\left(b - a\right) \cdot \left(b + a\right)\right)\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \]
  6. Add Preprocessing

Alternative 2: 58.1% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
t_0 := angle \cdot \frac{\pi}{-180}\\
2 \cdot \left(\cos t\_0 \cdot \left(\sin t\_0 \cdot \left(\left(b + a\right) \cdot \left(a - b\right)\right)\right)\right)
\end{array}
\end{array}
Derivation
  1. Initial program 58.9%

    \[\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right) \]
  2. Simplified58.4%

    \[\leadsto \color{blue}{2 \cdot \left(\cos \left(angle \cdot \frac{\pi}{-180}\right) \cdot \left(\sin \left(angle \cdot \frac{\pi}{-180}\right) \cdot \left({a}^{2} - {b}^{2}\right)\right)\right)} \]
  3. Add Preprocessing
  4. Step-by-step derivation
    1. unpow258.4%

      \[\leadsto 2 \cdot \left(\cos \left(angle \cdot \frac{\pi}{-180}\right) \cdot \left(\sin \left(angle \cdot \frac{\pi}{-180}\right) \cdot \left(\color{blue}{a \cdot a} - {b}^{2}\right)\right)\right) \]
    2. unpow258.4%

      \[\leadsto 2 \cdot \left(\cos \left(angle \cdot \frac{\pi}{-180}\right) \cdot \left(\sin \left(angle \cdot \frac{\pi}{-180}\right) \cdot \left(a \cdot a - \color{blue}{b \cdot b}\right)\right)\right) \]
    3. difference-of-squares62.4%

      \[\leadsto 2 \cdot \left(\cos \left(angle \cdot \frac{\pi}{-180}\right) \cdot \left(\sin \left(angle \cdot \frac{\pi}{-180}\right) \cdot \color{blue}{\left(\left(a + b\right) \cdot \left(a - b\right)\right)}\right)\right) \]
  5. Applied egg-rr62.4%

    \[\leadsto 2 \cdot \left(\cos \left(angle \cdot \frac{\pi}{-180}\right) \cdot \left(\sin \left(angle \cdot \frac{\pi}{-180}\right) \cdot \color{blue}{\left(\left(a + b\right) \cdot \left(a - b\right)\right)}\right)\right) \]
  6. Final simplification62.4%

    \[\leadsto 2 \cdot \left(\cos \left(angle \cdot \frac{\pi}{-180}\right) \cdot \left(\sin \left(angle \cdot \frac{\pi}{-180}\right) \cdot \left(\left(b + a\right) \cdot \left(a - b\right)\right)\right)\right) \]
  7. Add Preprocessing

Alternative 3: 56.6% accurate, 3.4× speedup?

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

\\
\begin{array}{l}
t_0 := \left(b - a\right) \cdot \left(b + a\right)\\
t_1 := \pi \cdot \frac{angle}{180}\\
\mathbf{if}\;a \leq 2 \cdot 10^{+219}:\\
\;\;\;\;\left(2 \cdot t\_0\right) \cdot \sin t\_1\\

\mathbf{else}:\\
\;\;\;\;\cos t\_1 \cdot \left(0.011111111111111112 \cdot \left(angle \cdot \left(t\_0 \cdot \pi\right)\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < 1.99999999999999993e219

    1. Initial program 59.6%

      \[\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. unpow259.6%

        \[\leadsto \left(\left(2 \cdot \left(\color{blue}{b \cdot b} - {a}^{2}\right)\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right) \]
      2. unpow259.6%

        \[\leadsto \left(\left(2 \cdot \left(b \cdot b - \color{blue}{a \cdot a}\right)\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right) \]
      3. difference-of-squares62.3%

        \[\leadsto \left(\left(2 \cdot \color{blue}{\left(\left(b + a\right) \cdot \left(b - a\right)\right)}\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right) \]
    4. Applied egg-rr62.3%

      \[\leadsto \left(\left(2 \cdot \color{blue}{\left(\left(b + a\right) \cdot \left(b - a\right)\right)}\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right) \]
    5. Step-by-step derivation
      1. add-cbrt-cube60.2%

        \[\leadsto \left(\left(2 \cdot \left(\left(b + a\right) \cdot \left(b - a\right)\right)\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\color{blue}{\sqrt[3]{\left(\pi \cdot \pi\right) \cdot \pi}} \cdot \frac{angle}{180}\right) \]
      2. pow360.2%

        \[\leadsto \left(\left(2 \cdot \left(\left(b + a\right) \cdot \left(b - a\right)\right)\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\sqrt[3]{\color{blue}{{\pi}^{3}}} \cdot \frac{angle}{180}\right) \]
    6. Applied egg-rr60.2%

      \[\leadsto \left(\left(2 \cdot \left(\left(b + a\right) \cdot \left(b - a\right)\right)\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\color{blue}{\sqrt[3]{{\pi}^{3}}} \cdot \frac{angle}{180}\right) \]
    7. Taylor expanded in angle around 0 56.5%

      \[\leadsto \left(\left(2 \cdot \left(\left(b + a\right) \cdot \left(b - a\right)\right)\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \color{blue}{1} \]

    if 1.99999999999999993e219 < a

    1. Initial program 50.8%

      \[\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. unpow250.8%

        \[\leadsto \left(\left(2 \cdot \left(\color{blue}{b \cdot b} - {a}^{2}\right)\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right) \]
      2. unpow250.8%

        \[\leadsto \left(\left(2 \cdot \left(b \cdot b - \color{blue}{a \cdot a}\right)\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right) \]
      3. difference-of-squares73.9%

        \[\leadsto \left(\left(2 \cdot \color{blue}{\left(\left(b + a\right) \cdot \left(b - a\right)\right)}\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right) \]
    4. Applied egg-rr73.9%

      \[\leadsto \left(\left(2 \cdot \color{blue}{\left(\left(b + a\right) \cdot \left(b - a\right)\right)}\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right) \]
    5. Taylor expanded in angle around 0 64.8%

      \[\leadsto \color{blue}{\left(0.011111111111111112 \cdot \left(angle \cdot \left(\pi \cdot \left(\left(a + b\right) \cdot \left(b - a\right)\right)\right)\right)\right)} \cdot \cos \left(\pi \cdot \frac{angle}{180}\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification57.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq 2 \cdot 10^{+219}:\\ \;\;\;\;\left(2 \cdot \left(\left(b - a\right) \cdot \left(b + a\right)\right)\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\\ \mathbf{else}:\\ \;\;\;\;\cos \left(\pi \cdot \frac{angle}{180}\right) \cdot \left(0.011111111111111112 \cdot \left(angle \cdot \left(\left(\left(b - a\right) \cdot \left(b + a\right)\right) \cdot \pi\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 56.4% accurate, 3.5× speedup?

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

\\
\begin{array}{l}
t_0 := \left(b - a\right) \cdot \left(b + a\right)\\
\mathbf{if}\;a \leq 10^{+187}:\\
\;\;\;\;\left(2 \cdot t\_0\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\\

\mathbf{else}:\\
\;\;\;\;2 \cdot \left(0.005555555555555556 \cdot \left(angle \cdot \left(t\_0 \cdot \pi\right)\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < 9.99999999999999907e186

    1. Initial program 60.6%

      \[\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. unpow260.6%

        \[\leadsto \left(\left(2 \cdot \left(\color{blue}{b \cdot b} - {a}^{2}\right)\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right) \]
      2. unpow260.6%

        \[\leadsto \left(\left(2 \cdot \left(b \cdot b - \color{blue}{a \cdot a}\right)\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right) \]
      3. difference-of-squares62.9%

        \[\leadsto \left(\left(2 \cdot \color{blue}{\left(\left(b + a\right) \cdot \left(b - a\right)\right)}\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right) \]
    4. Applied egg-rr62.9%

      \[\leadsto \left(\left(2 \cdot \color{blue}{\left(\left(b + a\right) \cdot \left(b - a\right)\right)}\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right) \]
    5. Step-by-step derivation
      1. add-cbrt-cube60.8%

        \[\leadsto \left(\left(2 \cdot \left(\left(b + a\right) \cdot \left(b - a\right)\right)\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\color{blue}{\sqrt[3]{\left(\pi \cdot \pi\right) \cdot \pi}} \cdot \frac{angle}{180}\right) \]
      2. pow360.8%

        \[\leadsto \left(\left(2 \cdot \left(\left(b + a\right) \cdot \left(b - a\right)\right)\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\sqrt[3]{\color{blue}{{\pi}^{3}}} \cdot \frac{angle}{180}\right) \]
    6. Applied egg-rr60.8%

      \[\leadsto \left(\left(2 \cdot \left(\left(b + a\right) \cdot \left(b - a\right)\right)\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\color{blue}{\sqrt[3]{{\pi}^{3}}} \cdot \frac{angle}{180}\right) \]
    7. Taylor expanded in angle around 0 56.4%

      \[\leadsto \left(\left(2 \cdot \left(\left(b + a\right) \cdot \left(b - a\right)\right)\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \color{blue}{1} \]

    if 9.99999999999999907e186 < a

    1. Initial program 46.4%

      \[\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right) \]
    2. Simplified46.4%

      \[\leadsto \color{blue}{2 \cdot \left(\left({b}^{2} - {a}^{2}\right) \cdot \left(\sin \left(\pi \cdot \frac{angle}{180}\right) \cdot \cos \left(\frac{\pi \cdot angle}{-180}\right)\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in angle around 0 49.6%

      \[\leadsto 2 \cdot \color{blue}{\left(0.005555555555555556 \cdot \left(angle \cdot \left(\pi \cdot \left({b}^{2} - {a}^{2}\right)\right)\right)\right)} \]
    5. Step-by-step derivation
      1. unpow246.4%

        \[\leadsto \left(\left(2 \cdot \left(\color{blue}{b \cdot b} - {a}^{2}\right)\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right) \]
      2. unpow246.4%

        \[\leadsto \left(\left(2 \cdot \left(b \cdot b - \color{blue}{a \cdot a}\right)\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right) \]
      3. difference-of-squares65.9%

        \[\leadsto \left(\left(2 \cdot \color{blue}{\left(\left(b + a\right) \cdot \left(b - a\right)\right)}\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right) \]
    6. Applied egg-rr65.9%

      \[\leadsto 2 \cdot \left(0.005555555555555556 \cdot \left(angle \cdot \left(\pi \cdot \color{blue}{\left(\left(b + a\right) \cdot \left(b - a\right)\right)}\right)\right)\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification57.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq 10^{+187}:\\ \;\;\;\;\left(2 \cdot \left(\left(b - a\right) \cdot \left(b + a\right)\right)\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(0.005555555555555556 \cdot \left(angle \cdot \left(\left(\left(b - a\right) \cdot \left(b + a\right)\right) \cdot \pi\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 54.5% accurate, 27.9× speedup?

\[\begin{array}{l} \\ 2 \cdot \left(0.005555555555555556 \cdot \left(angle \cdot \left(\left(\left(b - a\right) \cdot \left(b + a\right)\right) \cdot \pi\right)\right)\right) \end{array} \]
(FPCore (a b angle)
 :precision binary64
 (* 2.0 (* 0.005555555555555556 (* angle (* (* (- b a) (+ b a)) PI)))))
double code(double a, double b, double angle) {
	return 2.0 * (0.005555555555555556 * (angle * (((b - a) * (b + a)) * ((double) M_PI))));
}
public static double code(double a, double b, double angle) {
	return 2.0 * (0.005555555555555556 * (angle * (((b - a) * (b + a)) * Math.PI)));
}
def code(a, b, angle):
	return 2.0 * (0.005555555555555556 * (angle * (((b - a) * (b + a)) * math.pi)))
function code(a, b, angle)
	return Float64(2.0 * Float64(0.005555555555555556 * Float64(angle * Float64(Float64(Float64(b - a) * Float64(b + a)) * pi))))
end
function tmp = code(a, b, angle)
	tmp = 2.0 * (0.005555555555555556 * (angle * (((b - a) * (b + a)) * pi)));
end
code[a_, b_, angle_] := N[(2.0 * N[(0.005555555555555556 * N[(angle * N[(N[(N[(b - a), $MachinePrecision] * N[(b + a), $MachinePrecision]), $MachinePrecision] * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
2 \cdot \left(0.005555555555555556 \cdot \left(angle \cdot \left(\left(\left(b - a\right) \cdot \left(b + a\right)\right) \cdot \pi\right)\right)\right)
\end{array}
Derivation
  1. Initial program 58.9%

    \[\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right) \]
  2. Simplified58.4%

    \[\leadsto \color{blue}{2 \cdot \left(\left({b}^{2} - {a}^{2}\right) \cdot \left(\sin \left(\pi \cdot \frac{angle}{180}\right) \cdot \cos \left(\frac{\pi \cdot angle}{-180}\right)\right)\right)} \]
  3. Add Preprocessing
  4. Taylor expanded in angle around 0 52.9%

    \[\leadsto 2 \cdot \color{blue}{\left(0.005555555555555556 \cdot \left(angle \cdot \left(\pi \cdot \left({b}^{2} - {a}^{2}\right)\right)\right)\right)} \]
  5. Step-by-step derivation
    1. unpow258.9%

      \[\leadsto \left(\left(2 \cdot \left(\color{blue}{b \cdot b} - {a}^{2}\right)\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right) \]
    2. unpow258.9%

      \[\leadsto \left(\left(2 \cdot \left(b \cdot b - \color{blue}{a \cdot a}\right)\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right) \]
    3. difference-of-squares63.3%

      \[\leadsto \left(\left(2 \cdot \color{blue}{\left(\left(b + a\right) \cdot \left(b - a\right)\right)}\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right) \]
  6. Applied egg-rr56.5%

    \[\leadsto 2 \cdot \left(0.005555555555555556 \cdot \left(angle \cdot \left(\pi \cdot \color{blue}{\left(\left(b + a\right) \cdot \left(b - a\right)\right)}\right)\right)\right) \]
  7. Final simplification56.5%

    \[\leadsto 2 \cdot \left(0.005555555555555556 \cdot \left(angle \cdot \left(\left(\left(b - a\right) \cdot \left(b + a\right)\right) \cdot \pi\right)\right)\right) \]
  8. Add Preprocessing

Reproduce

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