ab-angle->ABCF C

Percentage Accurate: 79.6% → 79.6%
Time: 1.1min
Alternatives: 10
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 10 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.6% 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.6% accurate, 1.0× speedup?

\[\begin{array}{l} angle = |angle|\\ \\ {a}^{2} + {\left(\sin \left(\mathsf{expm1}\left(\mathsf{log1p}\left(angle \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right)\right) \cdot b\right)}^{2} \end{array} \]
NOTE: angle should be positive before calling this function
(FPCore (a b angle)
 :precision binary64
 (+
  (pow a 2.0)
  (pow (* (sin (expm1 (log1p (* angle (* PI 0.005555555555555556))))) b) 2.0)))
angle = abs(angle);
double code(double a, double b, double angle) {
	return pow(a, 2.0) + pow((sin(expm1(log1p((angle * (((double) M_PI) * 0.005555555555555556))))) * b), 2.0);
}
angle = Math.abs(angle);
public static double code(double a, double b, double angle) {
	return Math.pow(a, 2.0) + Math.pow((Math.sin(Math.expm1(Math.log1p((angle * (Math.PI * 0.005555555555555556))))) * b), 2.0);
}
angle = abs(angle)
def code(a, b, angle):
	return math.pow(a, 2.0) + math.pow((math.sin(math.expm1(math.log1p((angle * (math.pi * 0.005555555555555556))))) * b), 2.0)
angle = abs(angle)
function code(a, b, angle)
	return Float64((a ^ 2.0) + (Float64(sin(expm1(log1p(Float64(angle * Float64(pi * 0.005555555555555556))))) * b) ^ 2.0))
end
NOTE: angle should be positive before calling this function
code[a_, b_, angle_] := N[(N[Power[a, 2.0], $MachinePrecision] + N[Power[N[(N[Sin[N[(Exp[N[Log[1 + N[(angle * N[(Pi * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision] * b), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
angle = |angle|\\
\\
{a}^{2} + {\left(\sin \left(\mathsf{expm1}\left(\mathsf{log1p}\left(angle \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right)\right) \cdot b\right)}^{2}
\end{array}
Derivation
  1. Initial program 75.7%

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

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

    \[\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. Step-by-step derivation
    1. *-commutative75.8%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto {\left(a \cdot 1\right)}^{2} + {\color{blue}{\left(\sin \left(angle \cdot \frac{\pi}{180}\right) \cdot b\right)}}^{2} \]
  6. Step-by-step derivation
    1. expm1-log1p-u60.4%

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(\sin \color{blue}{\left(\mathsf{expm1}\left(\mathsf{log1p}\left(angle \cdot \frac{\pi}{180}\right)\right)\right)} \cdot b\right)}^{2} \]
    2. div-inv60.4%

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(\sin \left(\mathsf{expm1}\left(\mathsf{log1p}\left(angle \cdot \color{blue}{\left(\pi \cdot \frac{1}{180}\right)}\right)\right)\right) \cdot b\right)}^{2} \]
    3. metadata-eval60.4%

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

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

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

Alternative 2: 79.6% accurate, 1.5× speedup?

\[\begin{array}{l} angle = |angle|\\ \\ {a}^{2} + {\left(b \cdot \sin \left(\pi \cdot \left(angle \cdot -0.005555555555555556\right)\right)\right)}^{2} \end{array} \]
NOTE: angle should be positive before calling this function
(FPCore (a b angle)
 :precision binary64
 (+ (pow a 2.0) (pow (* b (sin (* PI (* angle -0.005555555555555556)))) 2.0)))
angle = abs(angle);
double code(double a, double b, double angle) {
	return pow(a, 2.0) + pow((b * sin((((double) M_PI) * (angle * -0.005555555555555556)))), 2.0);
}
angle = Math.abs(angle);
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);
}
angle = abs(angle)
def code(a, b, angle):
	return math.pow(a, 2.0) + math.pow((b * math.sin((math.pi * (angle * -0.005555555555555556)))), 2.0)
angle = abs(angle)
function code(a, b, angle)
	return Float64((a ^ 2.0) + (Float64(b * sin(Float64(pi * Float64(angle * -0.005555555555555556)))) ^ 2.0))
end
angle = abs(angle)
function tmp = code(a, b, angle)
	tmp = (a ^ 2.0) + ((b * sin((pi * (angle * -0.005555555555555556)))) ^ 2.0);
end
NOTE: angle should be positive before calling this function
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}
angle = |angle|\\
\\
{a}^{2} + {\left(b \cdot \sin \left(\pi \cdot \left(angle \cdot -0.005555555555555556\right)\right)\right)}^{2}
\end{array}
Derivation
  1. Initial program 75.7%

    \[{\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. Step-by-step derivation
    1. unpow275.7%

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

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

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

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

      \[\leadsto {\left(a \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + \color{blue}{{\left(\left(-b\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2}} \]
    6. distribute-lft-neg-out75.7%

      \[\leadsto {\left(a \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\color{blue}{\left(-b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}}^{2} \]
    7. distribute-rgt-neg-in75.7%

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

      \[\leadsto {\left(a \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \color{blue}{\sin \left(-\pi \cdot \frac{angle}{180}\right)}\right)}^{2} \]
    9. distribute-rgt-neg-out75.7%

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

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

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

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

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

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

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

Alternative 3: 79.6% accurate, 1.5× speedup?

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

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

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

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

Alternative 4: 79.5% accurate, 1.5× speedup?

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

    \[{\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. Step-by-step derivation
    1. unpow275.7%

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

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

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

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

      \[\leadsto {\left(a \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + \color{blue}{{\left(\left(-b\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2}} \]
    6. distribute-lft-neg-out75.7%

      \[\leadsto {\left(a \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\color{blue}{\left(-b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}}^{2} \]
    7. distribute-rgt-neg-in75.7%

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

      \[\leadsto {\left(a \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \color{blue}{\sin \left(-\pi \cdot \frac{angle}{180}\right)}\right)}^{2} \]
    9. distribute-rgt-neg-out75.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \color{blue}{\left(\sqrt{\frac{angle}{180}} \cdot \sqrt{\frac{angle}{180}}\right)}\right)\right)}^{2} \]
    12. add-sqr-sqrt75.8%

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

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

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

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

Alternative 5: 79.6% accurate, 1.5× speedup?

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

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

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

    \[\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. Step-by-step derivation
    1. *-commutative75.8%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 66.6% accurate, 2.0× speedup?

\[\begin{array}{l} angle = |angle|\\ \\ \begin{array}{l} \mathbf{if}\;b \leq 2.2 \cdot 10^{-13}:\\ \;\;\;\;a \cdot a\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(3.08641975308642 \cdot 10^{-5}, {\left(\pi \cdot \left(angle \cdot b\right)\right)}^{2}, a \cdot a\right)\\ \end{array} \end{array} \]
NOTE: angle should be positive before calling this function
(FPCore (a b angle)
 :precision binary64
 (if (<= b 2.2e-13)
   (* a a)
   (fma 3.08641975308642e-5 (pow (* PI (* angle b)) 2.0) (* a a))))
angle = abs(angle);
double code(double a, double b, double angle) {
	double tmp;
	if (b <= 2.2e-13) {
		tmp = a * a;
	} else {
		tmp = fma(3.08641975308642e-5, pow((((double) M_PI) * (angle * b)), 2.0), (a * a));
	}
	return tmp;
}
angle = abs(angle)
function code(a, b, angle)
	tmp = 0.0
	if (b <= 2.2e-13)
		tmp = Float64(a * a);
	else
		tmp = fma(3.08641975308642e-5, (Float64(pi * Float64(angle * b)) ^ 2.0), Float64(a * a));
	end
	return tmp
end
NOTE: angle should be positive before calling this function
code[a_, b_, angle_] := If[LessEqual[b, 2.2e-13], N[(a * a), $MachinePrecision], N[(3.08641975308642e-5 * N[Power[N[(Pi * N[(angle * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
angle = |angle|\\
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.2 \cdot 10^{-13}:\\
\;\;\;\;a \cdot a\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(3.08641975308642 \cdot 10^{-5}, {\left(\pi \cdot \left(angle \cdot b\right)\right)}^{2}, a \cdot a\right)\\


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

    1. Initial program 74.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. Taylor expanded in angle around 0 74.3%

      \[\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 67.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. *-commutative67.6%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{a}^{2}} \]
    9. Step-by-step derivation
      1. unpow258.9%

        \[\leadsto \color{blue}{a \cdot a} \]
    10. Simplified58.9%

      \[\leadsto \color{blue}{a \cdot a} \]

    if 2.19999999999999997e-13 < b

    1. Initial program 80.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. Taylor expanded in angle around 0 79.8%

      \[\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.9%

      \[\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.9%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(3.08641975308642 \cdot 10^{-5}, {angle}^{2} \cdot \left({b}^{2} \cdot {\pi}^{2}\right), {a}^{2}\right)} \]
      2. unpow256.1%

        \[\leadsto \mathsf{fma}\left(3.08641975308642 \cdot 10^{-5}, \color{blue}{\left(angle \cdot angle\right)} \cdot \left({b}^{2} \cdot {\pi}^{2}\right), {a}^{2}\right) \]
      3. *-commutative56.1%

        \[\leadsto \mathsf{fma}\left(3.08641975308642 \cdot 10^{-5}, \left(angle \cdot angle\right) \cdot \color{blue}{\left({\pi}^{2} \cdot {b}^{2}\right)}, {a}^{2}\right) \]
      4. unpow256.1%

        \[\leadsto \mathsf{fma}\left(3.08641975308642 \cdot 10^{-5}, \left(angle \cdot angle\right) \cdot \left(\color{blue}{\left(\pi \cdot \pi\right)} \cdot {b}^{2}\right), {a}^{2}\right) \]
      5. unpow256.1%

        \[\leadsto \mathsf{fma}\left(3.08641975308642 \cdot 10^{-5}, \left(angle \cdot angle\right) \cdot \left(\left(\pi \cdot \pi\right) \cdot \color{blue}{\left(b \cdot b\right)}\right), {a}^{2}\right) \]
      6. swap-sqr56.1%

        \[\leadsto \mathsf{fma}\left(3.08641975308642 \cdot 10^{-5}, \left(angle \cdot angle\right) \cdot \color{blue}{\left(\left(\pi \cdot b\right) \cdot \left(\pi \cdot b\right)\right)}, {a}^{2}\right) \]
      7. swap-sqr76.0%

        \[\leadsto \mathsf{fma}\left(3.08641975308642 \cdot 10^{-5}, \color{blue}{\left(angle \cdot \left(\pi \cdot b\right)\right) \cdot \left(angle \cdot \left(\pi \cdot b\right)\right)}, {a}^{2}\right) \]
      8. unpow276.0%

        \[\leadsto \mathsf{fma}\left(3.08641975308642 \cdot 10^{-5}, \color{blue}{{\left(angle \cdot \left(\pi \cdot b\right)\right)}^{2}}, {a}^{2}\right) \]
      9. *-commutative76.0%

        \[\leadsto \mathsf{fma}\left(3.08641975308642 \cdot 10^{-5}, {\left(angle \cdot \color{blue}{\left(b \cdot \pi\right)}\right)}^{2}, {a}^{2}\right) \]
      10. associate-*r*76.2%

        \[\leadsto \mathsf{fma}\left(3.08641975308642 \cdot 10^{-5}, {\color{blue}{\left(\left(angle \cdot b\right) \cdot \pi\right)}}^{2}, {a}^{2}\right) \]
      11. unpow276.2%

        \[\leadsto \mathsf{fma}\left(3.08641975308642 \cdot 10^{-5}, {\left(\left(angle \cdot b\right) \cdot \pi\right)}^{2}, \color{blue}{a \cdot a}\right) \]
    10. Simplified76.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(3.08641975308642 \cdot 10^{-5}, {\left(\left(angle \cdot b\right) \cdot \pi\right)}^{2}, a \cdot a\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification63.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 2.2 \cdot 10^{-13}:\\ \;\;\;\;a \cdot a\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(3.08641975308642 \cdot 10^{-5}, {\left(\pi \cdot \left(angle \cdot b\right)\right)}^{2}, a \cdot a\right)\\ \end{array} \]

Alternative 7: 66.7% accurate, 2.0× speedup?

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

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


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

    1. Initial program 74.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. Taylor expanded in angle around 0 74.3%

      \[\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 67.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. *-commutative67.6%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{a}^{2}} \]
    9. Step-by-step derivation
      1. unpow258.9%

        \[\leadsto \color{blue}{a \cdot a} \]
    10. Simplified58.9%

      \[\leadsto \color{blue}{a \cdot a} \]

    if 2.8999999999999998e-13 < b

    1. Initial program 80.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. Taylor expanded in angle around 0 79.8%

      \[\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.9%

      \[\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.9%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 66.7% accurate, 2.0× speedup?

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

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


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

    1. Initial program 74.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. Taylor expanded in angle around 0 74.3%

      \[\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 67.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. *-commutative67.6%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{a}^{2}} \]
    9. Step-by-step derivation
      1. unpow258.9%

        \[\leadsto \color{blue}{a \cdot a} \]
    10. Simplified58.9%

      \[\leadsto \color{blue}{a \cdot a} \]

    if 2.19999999999999997e-13 < b

    1. Initial program 80.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. Taylor expanded in angle around 0 79.8%

      \[\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.9%

      \[\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.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 66.7% accurate, 2.0× speedup?

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

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


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

    1. Initial program 74.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. Taylor expanded in angle around 0 74.3%

      \[\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 67.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. *-commutative67.6%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{a}^{2}} \]
    9. Step-by-step derivation
      1. unpow258.9%

        \[\leadsto \color{blue}{a \cdot a} \]
    10. Simplified58.9%

      \[\leadsto \color{blue}{a \cdot a} \]

    if 2.6e-13 < b

    1. Initial program 80.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. Taylor expanded in angle around 0 79.8%

      \[\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.9%

      \[\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.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 56.5% accurate, 205.0× speedup?

\[\begin{array}{l} angle = |angle|\\ \\ a \cdot a \end{array} \]
NOTE: angle should be positive before calling this function
(FPCore (a b angle) :precision binary64 (* a a))
angle = abs(angle);
double code(double a, double b, double angle) {
	return a * a;
}
NOTE: angle should be positive before calling this function
real(8) function code(a, b, angle)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: angle
    code = a * a
end function
angle = Math.abs(angle);
public static double code(double a, double b, double angle) {
	return a * a;
}
angle = abs(angle)
def code(a, b, angle):
	return a * a
angle = abs(angle)
function code(a, b, angle)
	return Float64(a * a)
end
angle = abs(angle)
function tmp = code(a, b, angle)
	tmp = a * a;
end
NOTE: angle should be positive before calling this function
code[a_, b_, angle_] := N[(a * a), $MachinePrecision]
\begin{array}{l}
angle = |angle|\\
\\
a \cdot a
\end{array}
Derivation
  1. Initial program 75.7%

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

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

    \[\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. *-commutative69.9%

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{{a}^{2}} \]
  9. Step-by-step derivation
    1. unpow251.9%

      \[\leadsto \color{blue}{a \cdot a} \]
  10. Simplified51.9%

    \[\leadsto \color{blue}{a \cdot a} \]
  11. Final simplification51.9%

    \[\leadsto a \cdot a \]

Reproduce

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