ab-angle->ABCF C

Percentage Accurate: 79.3% → 79.2%
Time: 33.1s
Alternatives: 8
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 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: 79.3% 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: 79.2% accurate, 1.0× speedup?

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

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

    \[{\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 76.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. add-sqr-sqrt39.0%

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

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

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(b \cdot \sin \left({\left(\sqrt{\pi \cdot \color{blue}{\left(angle \cdot \frac{1}{180}\right)}}\right)}^{2}\right)\right)}^{2} \]
    4. metadata-eval39.0%

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

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

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

Alternative 2: 79.3% accurate, 1.0× speedup?

\[\begin{array}{l} angle_m = \left|angle\right| \\ {a}^{2} + {\left(b \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\sin \left(angle_m \cdot \left(\pi \cdot -0.005555555555555556\right)\right)\right)\right)\right)}^{2} \end{array} \]
angle_m = (fabs.f64 angle)
(FPCore (a b angle_m)
 :precision binary64
 (+
  (pow a 2.0)
  (pow
   (* b (expm1 (log1p (sin (* angle_m (* PI -0.005555555555555556))))))
   2.0)))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
	return pow(a, 2.0) + pow((b * expm1(log1p(sin((angle_m * (((double) M_PI) * -0.005555555555555556)))))), 2.0);
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
	return Math.pow(a, 2.0) + Math.pow((b * Math.expm1(Math.log1p(Math.sin((angle_m * (Math.PI * -0.005555555555555556)))))), 2.0);
}
angle_m = math.fabs(angle)
def code(a, b, angle_m):
	return math.pow(a, 2.0) + math.pow((b * math.expm1(math.log1p(math.sin((angle_m * (math.pi * -0.005555555555555556)))))), 2.0)
angle_m = abs(angle)
function code(a, b, angle_m)
	return Float64((a ^ 2.0) + (Float64(b * expm1(log1p(sin(Float64(angle_m * Float64(pi * -0.005555555555555556)))))) ^ 2.0))
end
angle_m = N[Abs[angle], $MachinePrecision]
code[a_, b_, angle$95$m_] := N[(N[Power[a, 2.0], $MachinePrecision] + N[Power[N[(b * N[(Exp[N[Log[1 + N[Sin[N[(angle$95$m * N[(Pi * -0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
angle_m = \left|angle\right|

\\
{a}^{2} + {\left(b \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\sin \left(angle_m \cdot \left(\pi \cdot -0.005555555555555556\right)\right)\right)\right)\right)}^{2}
\end{array}
Derivation
  1. Initial program 76.4%

    \[{\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 76.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. add-sqr-sqrt39.0%

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

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

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(b \cdot \sin \left({\left(\sqrt{\pi \cdot \color{blue}{\left(angle \cdot \frac{1}{180}\right)}}\right)}^{2}\right)\right)}^{2} \]
    4. metadata-eval39.0%

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

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

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

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

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(b \cdot \sin \left(\sqrt{\color{blue}{{\left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right)}^{\left(\frac{2}{2}\right)}} \cdot {\left(\sqrt{\pi \cdot \left(angle \cdot 0.005555555555555556\right)}\right)}^{2}}\right)\right)}^{2} \]
    4. metadata-eval30.2%

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

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

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

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(b \cdot \sin \left(\sqrt{\left(\left(\pi \cdot angle\right) \cdot 0.005555555555555556\right) \cdot \color{blue}{{\left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right)}^{\left(\frac{2}{2}\right)}}}\right)\right)}^{2} \]
    8. metadata-eval61.7%

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(b \cdot \sin \left(\sqrt{\left(\left(\pi \cdot angle\right) \cdot 0.005555555555555556\right) \cdot {\left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right)}^{\color{blue}{1}}}\right)\right)}^{2} \]
    9. pow161.7%

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(b \cdot \sin \left(\sqrt{\left(\left(\pi \cdot angle\right) \cdot 0.005555555555555556\right) \cdot \color{blue}{\left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right)}}\right)\right)}^{2} \]
    10. associate-*r*61.7%

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(b \cdot \sin \left(\sqrt{\left(\left(\pi \cdot angle\right) \cdot 0.005555555555555556\right) \cdot \color{blue}{\left(\left(\pi \cdot angle\right) \cdot 0.005555555555555556\right)}}\right)\right)}^{2} \]
    11. swap-sqr61.3%

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(b \cdot \sin \left(\sqrt{\color{blue}{\left(\left(\pi \cdot angle\right) \cdot \left(\pi \cdot angle\right)\right) \cdot \left(0.005555555555555556 \cdot 0.005555555555555556\right)}}\right)\right)}^{2} \]
    12. *-commutative61.3%

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(b \cdot \sin \left(\sqrt{\left(\color{blue}{\left(angle \cdot \pi\right)} \cdot \left(\pi \cdot angle\right)\right) \cdot \left(0.005555555555555556 \cdot 0.005555555555555556\right)}\right)\right)}^{2} \]
    13. *-commutative61.3%

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(b \cdot \sin \left(\sqrt{\left(\left(angle \cdot \pi\right) \cdot \color{blue}{\left(angle \cdot \pi\right)}\right) \cdot \left(0.005555555555555556 \cdot 0.005555555555555556\right)}\right)\right)}^{2} \]
    14. metadata-eval61.3%

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(b \cdot \sin \left(\sqrt{\left(\left(angle \cdot \pi\right) \cdot \left(angle \cdot \pi\right)\right) \cdot \color{blue}{3.08641975308642 \cdot 10^{-5}}}\right)\right)}^{2} \]
    15. metadata-eval61.3%

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(b \cdot \sin \left(\sqrt{\left(\left(angle \cdot \pi\right) \cdot \left(angle \cdot \pi\right)\right) \cdot \color{blue}{\left(-0.005555555555555556 \cdot -0.005555555555555556\right)}}\right)\right)}^{2} \]
    16. swap-sqr61.7%

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(b \cdot \sin \left(\sqrt{\color{blue}{\left(\left(angle \cdot \pi\right) \cdot -0.005555555555555556\right) \cdot \left(\left(angle \cdot \pi\right) \cdot -0.005555555555555556\right)}}\right)\right)}^{2} \]
    17. associate-*r*61.7%

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

    \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(b \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sin \left(angle \cdot \left(\pi \cdot -0.005555555555555556\right)\right)\right)\right)}\right)}^{2} \]
  7. Final simplification76.5%

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

Alternative 3: 79.3% accurate, 1.0× speedup?

\[\begin{array}{l} angle_m = \left|angle\right| \\ {a}^{2} + {\left(b \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\sin \left(angle_m \cdot \left(\pi \cdot -0.005555555555555556\right)\right)\right)\right)\right)}^{2} \end{array} \]
angle_m = (fabs.f64 angle)
(FPCore (a b angle_m)
 :precision binary64
 (+
  (pow a 2.0)
  (pow
   (* b (log1p (expm1 (sin (* angle_m (* PI -0.005555555555555556))))))
   2.0)))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
	return pow(a, 2.0) + pow((b * log1p(expm1(sin((angle_m * (((double) M_PI) * -0.005555555555555556)))))), 2.0);
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
	return Math.pow(a, 2.0) + Math.pow((b * Math.log1p(Math.expm1(Math.sin((angle_m * (Math.PI * -0.005555555555555556)))))), 2.0);
}
angle_m = math.fabs(angle)
def code(a, b, angle_m):
	return math.pow(a, 2.0) + math.pow((b * math.log1p(math.expm1(math.sin((angle_m * (math.pi * -0.005555555555555556)))))), 2.0)
angle_m = abs(angle)
function code(a, b, angle_m)
	return Float64((a ^ 2.0) + (Float64(b * log1p(expm1(sin(Float64(angle_m * Float64(pi * -0.005555555555555556)))))) ^ 2.0))
end
angle_m = N[Abs[angle], $MachinePrecision]
code[a_, b_, angle$95$m_] := N[(N[Power[a, 2.0], $MachinePrecision] + N[Power[N[(b * N[Log[1 + N[(Exp[N[Sin[N[(angle$95$m * N[(Pi * -0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
angle_m = \left|angle\right|

\\
{a}^{2} + {\left(b \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\sin \left(angle_m \cdot \left(\pi \cdot -0.005555555555555556\right)\right)\right)\right)\right)}^{2}
\end{array}
Derivation
  1. Initial program 76.4%

    \[{\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 76.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. add-sqr-sqrt39.0%

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

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

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(b \cdot \sin \left({\left(\sqrt{\pi \cdot \color{blue}{\left(angle \cdot \frac{1}{180}\right)}}\right)}^{2}\right)\right)}^{2} \]
    4. metadata-eval39.0%

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

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

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

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

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(b \cdot \sin \left(\sqrt{\color{blue}{{\left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right)}^{\left(\frac{2}{2}\right)}} \cdot {\left(\sqrt{\pi \cdot \left(angle \cdot 0.005555555555555556\right)}\right)}^{2}}\right)\right)}^{2} \]
    4. metadata-eval30.2%

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

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

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

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(b \cdot \sin \left(\sqrt{\left(\left(\pi \cdot angle\right) \cdot 0.005555555555555556\right) \cdot \color{blue}{{\left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right)}^{\left(\frac{2}{2}\right)}}}\right)\right)}^{2} \]
    8. metadata-eval61.7%

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(b \cdot \sin \left(\sqrt{\left(\left(\pi \cdot angle\right) \cdot 0.005555555555555556\right) \cdot {\left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right)}^{\color{blue}{1}}}\right)\right)}^{2} \]
    9. pow161.7%

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(b \cdot \sin \left(\sqrt{\left(\left(\pi \cdot angle\right) \cdot 0.005555555555555556\right) \cdot \color{blue}{\left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right)}}\right)\right)}^{2} \]
    10. associate-*r*61.7%

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(b \cdot \sin \left(\sqrt{\left(\left(\pi \cdot angle\right) \cdot 0.005555555555555556\right) \cdot \color{blue}{\left(\left(\pi \cdot angle\right) \cdot 0.005555555555555556\right)}}\right)\right)}^{2} \]
    11. swap-sqr61.3%

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(b \cdot \sin \left(\sqrt{\color{blue}{\left(\left(\pi \cdot angle\right) \cdot \left(\pi \cdot angle\right)\right) \cdot \left(0.005555555555555556 \cdot 0.005555555555555556\right)}}\right)\right)}^{2} \]
    12. *-commutative61.3%

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(b \cdot \sin \left(\sqrt{\left(\color{blue}{\left(angle \cdot \pi\right)} \cdot \left(\pi \cdot angle\right)\right) \cdot \left(0.005555555555555556 \cdot 0.005555555555555556\right)}\right)\right)}^{2} \]
    13. *-commutative61.3%

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(b \cdot \sin \left(\sqrt{\left(\left(angle \cdot \pi\right) \cdot \color{blue}{\left(angle \cdot \pi\right)}\right) \cdot \left(0.005555555555555556 \cdot 0.005555555555555556\right)}\right)\right)}^{2} \]
    14. metadata-eval61.3%

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(b \cdot \sin \left(\sqrt{\left(\left(angle \cdot \pi\right) \cdot \left(angle \cdot \pi\right)\right) \cdot \color{blue}{3.08641975308642 \cdot 10^{-5}}}\right)\right)}^{2} \]
    15. metadata-eval61.3%

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(b \cdot \sin \left(\sqrt{\left(\left(angle \cdot \pi\right) \cdot \left(angle \cdot \pi\right)\right) \cdot \color{blue}{\left(-0.005555555555555556 \cdot -0.005555555555555556\right)}}\right)\right)}^{2} \]
    16. swap-sqr61.7%

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(b \cdot \sin \left(\sqrt{\color{blue}{\left(\left(angle \cdot \pi\right) \cdot -0.005555555555555556\right) \cdot \left(\left(angle \cdot \pi\right) \cdot -0.005555555555555556\right)}}\right)\right)}^{2} \]
    17. associate-*r*61.7%

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

    \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(b \cdot \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\sin \left(angle \cdot \left(\pi \cdot -0.005555555555555556\right)\right)\right)\right)}\right)}^{2} \]
  7. Final simplification76.5%

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

Alternative 4: 79.2% accurate, 1.5× speedup?

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

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

    \[{\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 76.5%

    \[\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 b around 0 76.0%

    \[\leadsto {\left(a \cdot 1\right)}^{2} + {\color{blue}{\left(b \cdot \sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)}}^{2} \]
  4. Final simplification76.0%

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

Alternative 5: 79.3% accurate, 1.5× speedup?

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

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

    \[{\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 76.5%

    \[\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 inf 76.0%

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

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(b \cdot \sin \color{blue}{\left(\left(0.005555555555555556 \cdot angle\right) \cdot \pi\right)}\right)}^{2} \]
    2. *-commutative76.4%

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(b \cdot \sin \left(\color{blue}{\left(angle \cdot 0.005555555555555556\right)} \cdot \pi\right)\right)}^{2} \]
    3. *-commutative76.4%

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(b \cdot \sin \color{blue}{\left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right)}\right)}^{2} \]
    4. *-commutative76.4%

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

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

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

Alternative 6: 79.3% accurate, 1.5× speedup?

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

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

    \[{\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 76.5%

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

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

Alternative 7: 66.4% accurate, 2.0× speedup?

\[\begin{array}{l} angle_m = \left|angle\right| \\ \begin{array}{l} \mathbf{if}\;b \leq 5.9 \cdot 10^{-21}:\\ \;\;\;\;{a}^{2}\\ \mathbf{else}:\\ \;\;\;\;{\left(\mathsf{hypot}\left(a, b \cdot \left(angle_m \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right)\right)}^{2}\\ \end{array} \end{array} \]
angle_m = (fabs.f64 angle)
(FPCore (a b angle_m)
 :precision binary64
 (if (<= b 5.9e-21)
   (pow a 2.0)
   (pow (hypot a (* b (* angle_m (* PI 0.005555555555555556)))) 2.0)))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
	double tmp;
	if (b <= 5.9e-21) {
		tmp = pow(a, 2.0);
	} else {
		tmp = pow(hypot(a, (b * (angle_m * (((double) M_PI) * 0.005555555555555556)))), 2.0);
	}
	return tmp;
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
	double tmp;
	if (b <= 5.9e-21) {
		tmp = Math.pow(a, 2.0);
	} else {
		tmp = Math.pow(Math.hypot(a, (b * (angle_m * (Math.PI * 0.005555555555555556)))), 2.0);
	}
	return tmp;
}
angle_m = math.fabs(angle)
def code(a, b, angle_m):
	tmp = 0
	if b <= 5.9e-21:
		tmp = math.pow(a, 2.0)
	else:
		tmp = math.pow(math.hypot(a, (b * (angle_m * (math.pi * 0.005555555555555556)))), 2.0)
	return tmp
angle_m = abs(angle)
function code(a, b, angle_m)
	tmp = 0.0
	if (b <= 5.9e-21)
		tmp = a ^ 2.0;
	else
		tmp = hypot(a, Float64(b * Float64(angle_m * Float64(pi * 0.005555555555555556)))) ^ 2.0;
	end
	return tmp
end
angle_m = abs(angle);
function tmp_2 = code(a, b, angle_m)
	tmp = 0.0;
	if (b <= 5.9e-21)
		tmp = a ^ 2.0;
	else
		tmp = hypot(a, (b * (angle_m * (pi * 0.005555555555555556)))) ^ 2.0;
	end
	tmp_2 = tmp;
end
angle_m = N[Abs[angle], $MachinePrecision]
code[a_, b_, angle$95$m_] := If[LessEqual[b, 5.9e-21], N[Power[a, 2.0], $MachinePrecision], N[Power[N[Sqrt[a ^ 2 + N[(b * N[(angle$95$m * N[(Pi * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision], 2.0], $MachinePrecision]]
\begin{array}{l}
angle_m = \left|angle\right|

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

\mathbf{else}:\\
\;\;\;\;{\left(\mathsf{hypot}\left(a, b \cdot \left(angle_m \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right)\right)}^{2}\\


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

    1. Initial program 75.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 75.4%

      \[\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 70.8%

      \[\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. *-commutative70.8%

        \[\leadsto {\left(a \cdot 1\right)}^{2} + {\color{blue}{\left(\left(angle \cdot \left(b \cdot \pi\right)\right) \cdot 0.005555555555555556\right)}}^{2} \]
      2. unpow-prod-down70.4%

        \[\leadsto {\left(a \cdot 1\right)}^{2} + \color{blue}{{\left(angle \cdot \left(b \cdot \pi\right)\right)}^{2} \cdot {0.005555555555555556}^{2}} \]
      3. associate-*r*70.4%

        \[\leadsto {\left(a \cdot 1\right)}^{2} + {\color{blue}{\left(\left(angle \cdot b\right) \cdot \pi\right)}}^{2} \cdot {0.005555555555555556}^{2} \]
      4. *-commutative70.4%

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

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

      \[\leadsto {\left(a \cdot 1\right)}^{2} + \color{blue}{{\left(\pi \cdot \left(angle \cdot b\right)\right)}^{2} \cdot 3.08641975308642 \cdot 10^{-5}} \]
    6. Taylor expanded in a around inf 63.1%

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

    if 5.9000000000000003e-21 < b

    1. Initial program 80.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 80.1%

      \[\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 75.1%

      \[\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. *-commutative75.1%

        \[\leadsto {\left(a \cdot 1\right)}^{2} + {\color{blue}{\left(\left(angle \cdot \left(b \cdot \pi\right)\right) \cdot 0.005555555555555556\right)}}^{2} \]
      2. unpow-prod-down75.0%

        \[\leadsto {\left(a \cdot 1\right)}^{2} + \color{blue}{{\left(angle \cdot \left(b \cdot \pi\right)\right)}^{2} \cdot {0.005555555555555556}^{2}} \]
      3. associate-*r*75.0%

        \[\leadsto {\left(a \cdot 1\right)}^{2} + {\color{blue}{\left(\left(angle \cdot b\right) \cdot \pi\right)}}^{2} \cdot {0.005555555555555556}^{2} \]
      4. *-commutative75.0%

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

        \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(\pi \cdot \left(angle \cdot b\right)\right)}^{2} \cdot \color{blue}{3.08641975308642 \cdot 10^{-5}} \]
    5. Applied egg-rr75.0%

      \[\leadsto {\left(a \cdot 1\right)}^{2} + \color{blue}{{\left(\pi \cdot \left(angle \cdot b\right)\right)}^{2} \cdot 3.08641975308642 \cdot 10^{-5}} \]
    6. Step-by-step derivation
      1. expm1-log1p-u73.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(a \cdot 1\right)}^{2} + {\left(\pi \cdot \left(angle \cdot b\right)\right)}^{2} \cdot 3.08641975308642 \cdot 10^{-5}\right)\right)} \]
      2. expm1-udef61.8%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left({\left(a \cdot 1\right)}^{2} + {\left(\pi \cdot \left(angle \cdot b\right)\right)}^{2} \cdot 3.08641975308642 \cdot 10^{-5}\right)} - 1} \]
    7. Applied egg-rr61.8%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left({\left(\mathsf{hypot}\left(a, \left(b \cdot \left(angle \cdot \pi\right)\right) \cdot 0.005555555555555556\right)\right)}^{2}\right)} - 1} \]
    8. Step-by-step derivation
      1. expm1-def73.2%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(\mathsf{hypot}\left(a, \left(b \cdot \left(angle \cdot \pi\right)\right) \cdot 0.005555555555555556\right)\right)}^{2}\right)\right)} \]
      2. expm1-log1p75.1%

        \[\leadsto \color{blue}{{\left(\mathsf{hypot}\left(a, \left(b \cdot \left(angle \cdot \pi\right)\right) \cdot 0.005555555555555556\right)\right)}^{2}} \]
      3. associate-*l*75.0%

        \[\leadsto {\left(\mathsf{hypot}\left(a, \color{blue}{b \cdot \left(\left(angle \cdot \pi\right) \cdot 0.005555555555555556\right)}\right)\right)}^{2} \]
      4. remove-double-div75.0%

        \[\leadsto {\left(\mathsf{hypot}\left(a, b \cdot \left(\left(\color{blue}{\frac{1}{\frac{1}{angle}}} \cdot \pi\right) \cdot 0.005555555555555556\right)\right)\right)}^{2} \]
      5. associate-*l/75.0%

        \[\leadsto {\left(\mathsf{hypot}\left(a, b \cdot \left(\color{blue}{\frac{1 \cdot \pi}{\frac{1}{angle}}} \cdot 0.005555555555555556\right)\right)\right)}^{2} \]
      6. *-lft-identity75.0%

        \[\leadsto {\left(\mathsf{hypot}\left(a, b \cdot \left(\frac{\color{blue}{\pi}}{\frac{1}{angle}} \cdot 0.005555555555555556\right)\right)\right)}^{2} \]
      7. associate-/r/75.0%

        \[\leadsto {\left(\mathsf{hypot}\left(a, b \cdot \color{blue}{\frac{\pi}{\frac{\frac{1}{angle}}{0.005555555555555556}}}\right)\right)}^{2} \]
      8. associate-/l*74.9%

        \[\leadsto {\left(\mathsf{hypot}\left(a, b \cdot \color{blue}{\frac{\pi \cdot 0.005555555555555556}{\frac{1}{angle}}}\right)\right)}^{2} \]
      9. associate-/r/75.2%

        \[\leadsto {\left(\mathsf{hypot}\left(a, b \cdot \color{blue}{\left(\frac{\pi \cdot 0.005555555555555556}{1} \cdot angle\right)}\right)\right)}^{2} \]
      10. /-rgt-identity75.2%

        \[\leadsto {\left(\mathsf{hypot}\left(a, b \cdot \left(\color{blue}{\left(\pi \cdot 0.005555555555555556\right)} \cdot angle\right)\right)\right)}^{2} \]
      11. *-commutative75.2%

        \[\leadsto {\left(\mathsf{hypot}\left(a, b \cdot \color{blue}{\left(angle \cdot \left(\pi \cdot 0.005555555555555556\right)\right)}\right)\right)}^{2} \]
    9. Simplified75.2%

      \[\leadsto \color{blue}{{\left(\mathsf{hypot}\left(a, b \cdot \left(angle \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right)\right)}^{2}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification65.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 5.9 \cdot 10^{-21}:\\ \;\;\;\;{a}^{2}\\ \mathbf{else}:\\ \;\;\;\;{\left(\mathsf{hypot}\left(a, b \cdot \left(angle \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right)\right)}^{2}\\ \end{array} \]

Alternative 8: 56.2% accurate, 6.0× speedup?

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

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

    \[{\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 76.5%

    \[\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 71.8%

    \[\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. *-commutative71.8%

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\color{blue}{\left(\left(angle \cdot \left(b \cdot \pi\right)\right) \cdot 0.005555555555555556\right)}}^{2} \]
    2. unpow-prod-down71.4%

      \[\leadsto {\left(a \cdot 1\right)}^{2} + \color{blue}{{\left(angle \cdot \left(b \cdot \pi\right)\right)}^{2} \cdot {0.005555555555555556}^{2}} \]
    3. associate-*r*71.4%

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\color{blue}{\left(\left(angle \cdot b\right) \cdot \pi\right)}}^{2} \cdot {0.005555555555555556}^{2} \]
    4. *-commutative71.4%

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

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

    \[\leadsto {\left(a \cdot 1\right)}^{2} + \color{blue}{{\left(\pi \cdot \left(angle \cdot b\right)\right)}^{2} \cdot 3.08641975308642 \cdot 10^{-5}} \]
  6. Taylor expanded in a around inf 58.9%

    \[\leadsto \color{blue}{{a}^{2}} \]
  7. Final simplification58.9%

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

Reproduce

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