ab-angle->ABCF C

Percentage Accurate: 80.0% → 80.0%
Time: 20.1s
Alternatives: 7
Speedup: 1.5×

Specification

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

\\
\begin{array}{l}
t_0 := \pi \cdot \frac{angle}{180}\\
{\left(a \cdot \cos t_0\right)}^{2} + {\left(b \cdot \sin t_0\right)}^{2}
\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 7 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: 80.0% accurate, 1.0× speedup?

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

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

Alternative 1: 80.0% accurate, 1.5× speedup?

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

\\
{a}^{2} + {\left(b \cdot \sin \left(\frac{1}{\frac{\frac{180}{angle}}{\pi}}\right)\right)}^{2}
\end{array}
Derivation
  1. Initial program 77.2%

    \[{\left(a \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
  2. Taylor expanded in angle around 0 77.5%

    \[\leadsto {\left(a \cdot \color{blue}{1}\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
  3. Step-by-step derivation
    1. associate-*r/77.5%

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

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(b \cdot \sin \color{blue}{\left(\frac{1}{\frac{180}{\pi \cdot angle}}\right)}\right)}^{2} \]
    3. *-commutative77.5%

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(b \cdot \sin \left(\frac{1}{\frac{180}{\color{blue}{angle \cdot \pi}}}\right)\right)}^{2} \]
    4. associate-/r*77.6%

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

    \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(b \cdot \sin \color{blue}{\left(\frac{1}{\frac{\frac{180}{angle}}{\pi}}\right)}\right)}^{2} \]
  5. Final simplification77.6%

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

Alternative 2: 80.1% accurate, 1.5× speedup?

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

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

    \[{\left(a \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
  2. Simplified77.1%

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

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

    \[\leadsto {\color{blue}{a}}^{2} + {b}^{2} \cdot {\sin \left(-0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} \]
  5. Step-by-step derivation
    1. add-sqr-sqrt66.6%

      \[\leadsto {a}^{2} + \color{blue}{\sqrt{{b}^{2} \cdot {\sin \left(-0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2}} \cdot \sqrt{{b}^{2} \cdot {\sin \left(-0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2}}} \]
    2. unpow266.6%

      \[\leadsto {a}^{2} + \color{blue}{{\left(\sqrt{{b}^{2} \cdot {\sin \left(-0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2}}\right)}^{2}} \]
  6. Applied egg-rr77.5%

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

    \[\leadsto {a}^{2} + {\left(b \cdot \sin \left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right)\right)}^{2} \]

Alternative 3: 80.1% accurate, 1.5× speedup?

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

\\
{a}^{2} + {\left(b \cdot \sin \left(\frac{angle}{\frac{180}{\pi}}\right)\right)}^{2}
\end{array}
Derivation
  1. Initial program 77.2%

    \[{\left(a \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
  2. Taylor expanded in angle around 0 77.5%

    \[\leadsto {\left(a \cdot \color{blue}{1}\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
  3. Step-by-step derivation
    1. associate-*r/77.5%

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

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(b \cdot \sin \left(\frac{\color{blue}{angle \cdot \pi}}{180}\right)\right)}^{2} \]
    3. associate-/l*77.5%

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

    \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(b \cdot \sin \color{blue}{\left(\frac{angle}{\frac{180}{\pi}}\right)}\right)}^{2} \]
  5. Final simplification77.5%

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

Alternative 4: 80.0% accurate, 1.5× speedup?

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

\\
{a}^{2} + {\left(b \cdot \sin \left(\frac{\pi}{\frac{180}{angle}}\right)\right)}^{2}
\end{array}
Derivation
  1. Initial program 77.2%

    \[{\left(a \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
  2. Taylor expanded in angle around 0 77.5%

    \[\leadsto {\left(a \cdot \color{blue}{1}\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
  3. Step-by-step derivation
    1. clear-num77.5%

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \color{blue}{\frac{1}{\frac{180}{angle}}}\right)\right)}^{2} \]
    2. un-div-inv77.6%

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

    \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(b \cdot \sin \color{blue}{\left(\frac{\pi}{\frac{180}{angle}}\right)}\right)}^{2} \]
  5. Final simplification77.6%

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

Alternative 5: 67.5% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 1.4 \cdot 10^{-78}:\\ \;\;\;\;{a}^{2}\\ \mathbf{else}:\\ \;\;\;\;{a}^{2} + {\left(0.005555555555555556 \cdot \left(angle \cdot \left(b \cdot \pi\right)\right)\right)}^{2}\\ \end{array} \end{array} \]
(FPCore (a b angle)
 :precision binary64
 (if (<= b 1.4e-78)
   (pow a 2.0)
   (+ (pow a 2.0) (pow (* 0.005555555555555556 (* angle (* b PI))) 2.0))))
double code(double a, double b, double angle) {
	double tmp;
	if (b <= 1.4e-78) {
		tmp = pow(a, 2.0);
	} else {
		tmp = pow(a, 2.0) + pow((0.005555555555555556 * (angle * (b * ((double) M_PI)))), 2.0);
	}
	return tmp;
}
public static double code(double a, double b, double angle) {
	double tmp;
	if (b <= 1.4e-78) {
		tmp = Math.pow(a, 2.0);
	} else {
		tmp = Math.pow(a, 2.0) + Math.pow((0.005555555555555556 * (angle * (b * Math.PI))), 2.0);
	}
	return tmp;
}
def code(a, b, angle):
	tmp = 0
	if b <= 1.4e-78:
		tmp = math.pow(a, 2.0)
	else:
		tmp = math.pow(a, 2.0) + math.pow((0.005555555555555556 * (angle * (b * math.pi))), 2.0)
	return tmp
function code(a, b, angle)
	tmp = 0.0
	if (b <= 1.4e-78)
		tmp = a ^ 2.0;
	else
		tmp = Float64((a ^ 2.0) + (Float64(0.005555555555555556 * Float64(angle * Float64(b * pi))) ^ 2.0));
	end
	return tmp
end
function tmp_2 = code(a, b, angle)
	tmp = 0.0;
	if (b <= 1.4e-78)
		tmp = a ^ 2.0;
	else
		tmp = (a ^ 2.0) + ((0.005555555555555556 * (angle * (b * pi))) ^ 2.0);
	end
	tmp_2 = tmp;
end
code[a_, b_, angle_] := If[LessEqual[b, 1.4e-78], N[Power[a, 2.0], $MachinePrecision], N[(N[Power[a, 2.0], $MachinePrecision] + N[Power[N[(0.005555555555555556 * N[(angle * N[(b * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.4 \cdot 10^{-78}:\\
\;\;\;\;{a}^{2}\\

\mathbf{else}:\\
\;\;\;\;{a}^{2} + {\left(0.005555555555555556 \cdot \left(angle \cdot \left(b \cdot \pi\right)\right)\right)}^{2}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 1.40000000000000012e-78

    1. Initial program 75.0%

      \[{\left(a \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
    2. Simplified74.9%

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

      \[\leadsto {\left(a \cdot \cos \left(\frac{\pi}{-180} \cdot angle\right)\right)}^{2} + \color{blue}{\frac{{b}^{2} \cdot \left(\cos \left(\left(\pi \cdot angle\right) \cdot 0\right) - \cos \left(\left(\pi \cdot angle\right) \cdot 0\right)\right)}{2}} \]
    4. Step-by-step derivation
      1. *-commutative45.7%

        \[\leadsto {\left(a \cdot \cos \left(\frac{\pi}{-180} \cdot angle\right)\right)}^{2} + \frac{\color{blue}{\left(\cos \left(\left(\pi \cdot angle\right) \cdot 0\right) - \cos \left(\left(\pi \cdot angle\right) \cdot 0\right)\right) \cdot {b}^{2}}}{2} \]
      2. associate-/l*45.7%

        \[\leadsto {\left(a \cdot \cos \left(\frac{\pi}{-180} \cdot angle\right)\right)}^{2} + \color{blue}{\frac{\cos \left(\left(\pi \cdot angle\right) \cdot 0\right) - \cos \left(\left(\pi \cdot angle\right) \cdot 0\right)}{\frac{2}{{b}^{2}}}} \]
      3. +-inverses45.7%

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

        \[\leadsto {\left(a \cdot \cos \left(\frac{\pi}{-180} \cdot angle\right)\right)}^{2} + \color{blue}{0} \]
    5. Simplified54.9%

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

      \[\leadsto {\color{blue}{a}}^{2} + 0 \]

    if 1.40000000000000012e-78 < b

    1. Initial program 81.6%

      \[{\left(a \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
    2. Taylor expanded in angle around 0 81.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 1.4 \cdot 10^{-78}:\\ \;\;\;\;{a}^{2}\\ \mathbf{else}:\\ \;\;\;\;{a}^{2} + {\left(0.005555555555555556 \cdot \left(angle \cdot \left(b \cdot \pi\right)\right)\right)}^{2}\\ \end{array} \]

Alternative 6: 67.6% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 5 \cdot 10^{-80}:\\ \;\;\;\;{a}^{2}\\ \mathbf{else}:\\ \;\;\;\;{a}^{2} + {\left(0.005555555555555556 \cdot \left(\pi \cdot \left(b \cdot angle\right)\right)\right)}^{2}\\ \end{array} \end{array} \]
(FPCore (a b angle)
 :precision binary64
 (if (<= b 5e-80)
   (pow a 2.0)
   (+ (pow a 2.0) (pow (* 0.005555555555555556 (* PI (* b angle))) 2.0))))
double code(double a, double b, double angle) {
	double tmp;
	if (b <= 5e-80) {
		tmp = pow(a, 2.0);
	} else {
		tmp = pow(a, 2.0) + pow((0.005555555555555556 * (((double) M_PI) * (b * angle))), 2.0);
	}
	return tmp;
}
public static double code(double a, double b, double angle) {
	double tmp;
	if (b <= 5e-80) {
		tmp = Math.pow(a, 2.0);
	} else {
		tmp = Math.pow(a, 2.0) + Math.pow((0.005555555555555556 * (Math.PI * (b * angle))), 2.0);
	}
	return tmp;
}
def code(a, b, angle):
	tmp = 0
	if b <= 5e-80:
		tmp = math.pow(a, 2.0)
	else:
		tmp = math.pow(a, 2.0) + math.pow((0.005555555555555556 * (math.pi * (b * angle))), 2.0)
	return tmp
function code(a, b, angle)
	tmp = 0.0
	if (b <= 5e-80)
		tmp = a ^ 2.0;
	else
		tmp = Float64((a ^ 2.0) + (Float64(0.005555555555555556 * Float64(pi * Float64(b * angle))) ^ 2.0));
	end
	return tmp
end
function tmp_2 = code(a, b, angle)
	tmp = 0.0;
	if (b <= 5e-80)
		tmp = a ^ 2.0;
	else
		tmp = (a ^ 2.0) + ((0.005555555555555556 * (pi * (b * angle))) ^ 2.0);
	end
	tmp_2 = tmp;
end
code[a_, b_, angle_] := If[LessEqual[b, 5e-80], N[Power[a, 2.0], $MachinePrecision], N[(N[Power[a, 2.0], $MachinePrecision] + N[Power[N[(0.005555555555555556 * N[(Pi * N[(b * angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq 5 \cdot 10^{-80}:\\
\;\;\;\;{a}^{2}\\

\mathbf{else}:\\
\;\;\;\;{a}^{2} + {\left(0.005555555555555556 \cdot \left(\pi \cdot \left(b \cdot angle\right)\right)\right)}^{2}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 5e-80

    1. Initial program 75.0%

      \[{\left(a \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
    2. Simplified74.9%

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

      \[\leadsto {\left(a \cdot \cos \left(\frac{\pi}{-180} \cdot angle\right)\right)}^{2} + \color{blue}{\frac{{b}^{2} \cdot \left(\cos \left(\left(\pi \cdot angle\right) \cdot 0\right) - \cos \left(\left(\pi \cdot angle\right) \cdot 0\right)\right)}{2}} \]
    4. Step-by-step derivation
      1. *-commutative45.7%

        \[\leadsto {\left(a \cdot \cos \left(\frac{\pi}{-180} \cdot angle\right)\right)}^{2} + \frac{\color{blue}{\left(\cos \left(\left(\pi \cdot angle\right) \cdot 0\right) - \cos \left(\left(\pi \cdot angle\right) \cdot 0\right)\right) \cdot {b}^{2}}}{2} \]
      2. associate-/l*45.7%

        \[\leadsto {\left(a \cdot \cos \left(\frac{\pi}{-180} \cdot angle\right)\right)}^{2} + \color{blue}{\frac{\cos \left(\left(\pi \cdot angle\right) \cdot 0\right) - \cos \left(\left(\pi \cdot angle\right) \cdot 0\right)}{\frac{2}{{b}^{2}}}} \]
      3. +-inverses45.7%

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

        \[\leadsto {\left(a \cdot \cos \left(\frac{\pi}{-180} \cdot angle\right)\right)}^{2} + \color{blue}{0} \]
    5. Simplified54.9%

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

      \[\leadsto {\color{blue}{a}}^{2} + 0 \]

    if 5e-80 < b

    1. Initial program 81.6%

      \[{\left(a \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
    2. Taylor expanded in angle around 0 81.7%

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

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

        \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(0.005555555555555556 \cdot \color{blue}{\left(\left(angle \cdot b\right) \cdot \pi\right)}\right)}^{2} \]
    5. Simplified78.6%

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

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

Alternative 7: 57.3% accurate, 6.0× speedup?

\[\begin{array}{l} \\ {a}^{2} \end{array} \]
(FPCore (a b angle) :precision binary64 (pow a 2.0))
double code(double a, double b, double angle) {
	return pow(a, 2.0);
}
real(8) function code(a, b, angle)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: angle
    code = a ** 2.0d0
end function
public static double code(double a, double b, double angle) {
	return Math.pow(a, 2.0);
}
def code(a, b, angle):
	return math.pow(a, 2.0)
function code(a, b, angle)
	return a ^ 2.0
end
function tmp = code(a, b, angle)
	tmp = a ^ 2.0;
end
code[a_, b_, angle_] := N[Power[a, 2.0], $MachinePrecision]
\begin{array}{l}

\\
{a}^{2}
\end{array}
Derivation
  1. Initial program 77.2%

    \[{\left(a \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
  2. Simplified77.1%

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

    \[\leadsto {\left(a \cdot \cos \left(\frac{\pi}{-180} \cdot angle\right)\right)}^{2} + \color{blue}{\frac{{b}^{2} \cdot \left(\cos \left(\left(\pi \cdot angle\right) \cdot 0\right) - \cos \left(\left(\pi \cdot angle\right) \cdot 0\right)\right)}{2}} \]
  4. Step-by-step derivation
    1. *-commutative38.8%

      \[\leadsto {\left(a \cdot \cos \left(\frac{\pi}{-180} \cdot angle\right)\right)}^{2} + \frac{\color{blue}{\left(\cos \left(\left(\pi \cdot angle\right) \cdot 0\right) - \cos \left(\left(\pi \cdot angle\right) \cdot 0\right)\right) \cdot {b}^{2}}}{2} \]
    2. associate-/l*38.8%

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

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

      \[\leadsto {\left(a \cdot \cos \left(\frac{\pi}{-180} \cdot angle\right)\right)}^{2} + \color{blue}{0} \]
  5. Simplified53.4%

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

    \[\leadsto {\color{blue}{a}}^{2} + 0 \]
  7. Final simplification53.8%

    \[\leadsto {a}^{2} \]

Reproduce

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