ab-angle->ABCF C

Percentage Accurate: 79.1% → 78.1%
Time: 4.4s
Alternatives: 10
Speedup: N/A×

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}

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.1% 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: 78.1% accurate, 1.9× speedup?

\[\begin{array}{l} b_m = \left|b\right| \\ \begin{array}{l} \mathbf{if}\;b\_m \leq 1.6 \cdot 10^{+151}:\\ \;\;\;\;\mathsf{fma}\left({\sin \left(\left(angle \cdot \pi\right) \cdot 0.005555555555555556\right)}^{2} \cdot b\_m, b\_m, a \cdot a\right)\\ \mathbf{else}:\\ \;\;\;\;a \cdot a + {\left(\left(\left(0.005555555555555556 \cdot b\_m\right) \cdot \pi\right) \cdot angle\right)}^{2}\\ \end{array} \end{array} \]
b_m = (fabs.f64 b)
(FPCore (a b_m angle)
 :precision binary64
 (if (<= b_m 1.6e+151)
   (fma
    (* (pow (sin (* (* angle PI) 0.005555555555555556)) 2.0) b_m)
    b_m
    (* a a))
   (+ (* a a) (pow (* (* (* 0.005555555555555556 b_m) PI) angle) 2.0))))
b_m = fabs(b);
double code(double a, double b_m, double angle) {
	double tmp;
	if (b_m <= 1.6e+151) {
		tmp = fma((pow(sin(((angle * ((double) M_PI)) * 0.005555555555555556)), 2.0) * b_m), b_m, (a * a));
	} else {
		tmp = (a * a) + pow((((0.005555555555555556 * b_m) * ((double) M_PI)) * angle), 2.0);
	}
	return tmp;
}
b_m = abs(b)
function code(a, b_m, angle)
	tmp = 0.0
	if (b_m <= 1.6e+151)
		tmp = fma(Float64((sin(Float64(Float64(angle * pi) * 0.005555555555555556)) ^ 2.0) * b_m), b_m, Float64(a * a));
	else
		tmp = Float64(Float64(a * a) + (Float64(Float64(Float64(0.005555555555555556 * b_m) * pi) * angle) ^ 2.0));
	end
	return tmp
end
b_m = N[Abs[b], $MachinePrecision]
code[a_, b$95$m_, angle_] := If[LessEqual[b$95$m, 1.6e+151], N[(N[(N[Power[N[Sin[N[(N[(angle * Pi), $MachinePrecision] * 0.005555555555555556), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] * b$95$m), $MachinePrecision] * b$95$m + N[(a * a), $MachinePrecision]), $MachinePrecision], N[(N[(a * a), $MachinePrecision] + N[Power[N[(N[(N[(0.005555555555555556 * b$95$m), $MachinePrecision] * Pi), $MachinePrecision] * angle), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
b_m = \left|b\right|

\\
\begin{array}{l}
\mathbf{if}\;b\_m \leq 1.6 \cdot 10^{+151}:\\
\;\;\;\;\mathsf{fma}\left({\sin \left(\left(angle \cdot \pi\right) \cdot 0.005555555555555556\right)}^{2} \cdot b\_m, b\_m, a \cdot a\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 1.59999999999999997e151

    1. Initial program 72.8%

      \[{\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. Add Preprocessing
    3. Taylor expanded in angle around 0

      \[\leadsto \color{blue}{{a}^{2}} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
    4. Step-by-step derivation
      1. unpow2N/A

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

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

      \[\leadsto \color{blue}{a \cdot a} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
    6. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \color{blue}{a \cdot a + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2}} \]
      2. lift-pow.f64N/A

        \[\leadsto a \cdot a + \color{blue}{{\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2}} \]
      3. lift-*.f64N/A

        \[\leadsto a \cdot a + {\color{blue}{\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}}^{2} \]
      4. lift-sin.f64N/A

        \[\leadsto a \cdot a + {\left(b \cdot \color{blue}{\sin \left(\pi \cdot \frac{angle}{180}\right)}\right)}^{2} \]
      5. lift-PI.f64N/A

        \[\leadsto a \cdot a + {\left(b \cdot \sin \left(\color{blue}{\mathsf{PI}\left(\right)} \cdot \frac{angle}{180}\right)\right)}^{2} \]
      6. lift-*.f64N/A

        \[\leadsto a \cdot a + {\left(b \cdot \sin \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)}\right)}^{2} \]
      7. lift-/.f64N/A

        \[\leadsto a \cdot a + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \color{blue}{\frac{angle}{180}}\right)\right)}^{2} \]
      8. +-commutativeN/A

        \[\leadsto \color{blue}{{\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} + a \cdot a} \]
      9. unpow-prod-downN/A

        \[\leadsto \color{blue}{{b}^{2} \cdot {\sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)}^{2}} + a \cdot a \]
      10. *-commutativeN/A

        \[\leadsto \color{blue}{{\sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)}^{2} \cdot {b}^{2}} + a \cdot a \]
      11. pow2N/A

        \[\leadsto {\sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)}^{2} \cdot \color{blue}{\left(b \cdot b\right)} + a \cdot a \]
      12. associate-*r*N/A

        \[\leadsto \color{blue}{\left({\sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)}^{2} \cdot b\right) \cdot b} + a \cdot a \]
    7. Applied rewrites71.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left({\sin \left(\frac{angle}{180} \cdot \pi\right)}^{2} \cdot b, b, a \cdot a\right)} \]
    8. Taylor expanded in angle around inf

      \[\leadsto \mathsf{fma}\left(\color{blue}{{\sin \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{2}} \cdot b, b, a \cdot a\right) \]
    9. Step-by-step derivation
      1. lower-pow.f64N/A

        \[\leadsto \mathsf{fma}\left({\sin \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{\color{blue}{2}} \cdot b, b, a \cdot a\right) \]
      2. lower-sin.f64N/A

        \[\leadsto \mathsf{fma}\left({\sin \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} \cdot b, b, a \cdot a\right) \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left({\sin \left(\left(angle \cdot \mathsf{PI}\left(\right)\right) \cdot \frac{1}{180}\right)}^{2} \cdot b, b, a \cdot a\right) \]
      4. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left({\sin \left(\left(angle \cdot \mathsf{PI}\left(\right)\right) \cdot \frac{1}{180}\right)}^{2} \cdot b, b, a \cdot a\right) \]
      5. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left({\sin \left(\left(angle \cdot \mathsf{PI}\left(\right)\right) \cdot \frac{1}{180}\right)}^{2} \cdot b, b, a \cdot a\right) \]
      6. lift-PI.f6471.5

        \[\leadsto \mathsf{fma}\left({\sin \left(\left(angle \cdot \pi\right) \cdot 0.005555555555555556\right)}^{2} \cdot b, b, a \cdot a\right) \]
    10. Applied rewrites71.5%

      \[\leadsto \mathsf{fma}\left(\color{blue}{{\sin \left(\left(angle \cdot \pi\right) \cdot 0.005555555555555556\right)}^{2}} \cdot b, b, a \cdot a\right) \]

    if 1.59999999999999997e151 < b

    1. Initial program 97.9%

      \[{\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. Add Preprocessing
    3. Taylor expanded in angle around 0

      \[\leadsto \color{blue}{{a}^{2}} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
    4. Step-by-step derivation
      1. unpow2N/A

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

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

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

      \[\leadsto a \cdot a + {\color{blue}{\left(angle \cdot \left(\frac{1}{180} \cdot \left(b \cdot \mathsf{PI}\left(\right)\right) + {angle}^{2} \cdot \left(\frac{-1}{34992000} \cdot \left(b \cdot {\mathsf{PI}\left(\right)}^{3}\right) + \frac{1}{22674816000000} \cdot \left({angle}^{2} \cdot \left(b \cdot {\mathsf{PI}\left(\right)}^{5}\right)\right)\right)\right)\right)}}^{2} \]
    7. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto a \cdot a + {\left(\left(\frac{1}{180} \cdot \left(b \cdot \mathsf{PI}\left(\right)\right) + {angle}^{2} \cdot \left(\frac{-1}{34992000} \cdot \left(b \cdot {\mathsf{PI}\left(\right)}^{3}\right) + \frac{1}{22674816000000} \cdot \left({angle}^{2} \cdot \left(b \cdot {\mathsf{PI}\left(\right)}^{5}\right)\right)\right)\right) \cdot \color{blue}{angle}\right)}^{2} \]
      2. lower-*.f64N/A

        \[\leadsto a \cdot a + {\left(\left(\frac{1}{180} \cdot \left(b \cdot \mathsf{PI}\left(\right)\right) + {angle}^{2} \cdot \left(\frac{-1}{34992000} \cdot \left(b \cdot {\mathsf{PI}\left(\right)}^{3}\right) + \frac{1}{22674816000000} \cdot \left({angle}^{2} \cdot \left(b \cdot {\mathsf{PI}\left(\right)}^{5}\right)\right)\right)\right) \cdot \color{blue}{angle}\right)}^{2} \]
    8. Applied rewrites96.3%

      \[\leadsto a \cdot a + {\color{blue}{\left(\mathsf{fma}\left(0.005555555555555556 \cdot b, \pi, \mathsf{fma}\left(4.410179116778721 \cdot 10^{-14} \cdot \left(angle \cdot angle\right), {\pi}^{5} \cdot b, \left({\pi}^{3} \cdot b\right) \cdot -2.8577960676726107 \cdot 10^{-8}\right) \cdot \left(angle \cdot angle\right)\right) \cdot angle\right)}}^{2} \]
    9. Taylor expanded in angle around 0

      \[\leadsto a \cdot a + {\left(\left(\frac{1}{180} \cdot \left(b \cdot \mathsf{PI}\left(\right)\right)\right) \cdot angle\right)}^{2} \]
    10. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto a \cdot a + {\left(\left(\left(\frac{1}{180} \cdot b\right) \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right)}^{2} \]
      2. lower-*.f64N/A

        \[\leadsto a \cdot a + {\left(\left(\left(\frac{1}{180} \cdot b\right) \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right)}^{2} \]
      3. lift-*.f64N/A

        \[\leadsto a \cdot a + {\left(\left(\left(\frac{1}{180} \cdot b\right) \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right)}^{2} \]
      4. lift-PI.f6497.9

        \[\leadsto a \cdot a + {\left(\left(\left(0.005555555555555556 \cdot b\right) \cdot \pi\right) \cdot angle\right)}^{2} \]
    11. Applied rewrites97.9%

      \[\leadsto a \cdot a + {\left(\left(\left(0.005555555555555556 \cdot b\right) \cdot \pi\right) \cdot angle\right)}^{2} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 2: 79.0% accurate, 1.9× speedup?

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

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

    \[{\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. Add Preprocessing
  3. Taylor expanded in angle around 0

    \[\leadsto \color{blue}{{a}^{2}} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
  4. Step-by-step derivation
    1. unpow2N/A

      \[\leadsto a \cdot \color{blue}{a} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
    2. lower-*.f6479.0

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

    \[\leadsto \color{blue}{a \cdot a} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
  6. Step-by-step derivation
    1. lift-PI.f64N/A

      \[\leadsto a \cdot a + {\left(b \cdot \sin \left(\color{blue}{\mathsf{PI}\left(\right)} \cdot \frac{angle}{180}\right)\right)}^{2} \]
    2. lift-*.f64N/A

      \[\leadsto a \cdot a + {\left(b \cdot \sin \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)}\right)}^{2} \]
    3. lift-/.f64N/A

      \[\leadsto a \cdot a + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \color{blue}{\frac{angle}{180}}\right)\right)}^{2} \]
    4. associate-*r/N/A

      \[\leadsto a \cdot a + {\left(b \cdot \sin \color{blue}{\left(\frac{\mathsf{PI}\left(\right) \cdot angle}{180}\right)}\right)}^{2} \]
    5. *-commutativeN/A

      \[\leadsto a \cdot a + {\left(b \cdot \sin \left(\frac{\color{blue}{angle \cdot \mathsf{PI}\left(\right)}}{180}\right)\right)}^{2} \]
    6. lower-/.f64N/A

      \[\leadsto a \cdot a + {\left(b \cdot \sin \color{blue}{\left(\frac{angle \cdot \mathsf{PI}\left(\right)}{180}\right)}\right)}^{2} \]
    7. lower-*.f64N/A

      \[\leadsto a \cdot a + {\left(b \cdot \sin \left(\frac{\color{blue}{angle \cdot \mathsf{PI}\left(\right)}}{180}\right)\right)}^{2} \]
    8. lift-PI.f6479.0

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

    \[\leadsto a \cdot a + {\left(b \cdot \sin \color{blue}{\left(\frac{angle \cdot \pi}{180}\right)}\right)}^{2} \]
  8. Step-by-step derivation
    1. lift-/.f64N/A

      \[\leadsto a \cdot a + {\left(b \cdot \sin \color{blue}{\left(\frac{angle \cdot \pi}{180}\right)}\right)}^{2} \]
    2. lift-PI.f64N/A

      \[\leadsto a \cdot a + {\left(b \cdot \sin \left(\frac{angle \cdot \color{blue}{\mathsf{PI}\left(\right)}}{180}\right)\right)}^{2} \]
    3. lift-*.f64N/A

      \[\leadsto a \cdot a + {\left(b \cdot \sin \left(\frac{\color{blue}{angle \cdot \mathsf{PI}\left(\right)}}{180}\right)\right)}^{2} \]
    4. associate-/l*N/A

      \[\leadsto a \cdot a + {\left(b \cdot \sin \color{blue}{\left(angle \cdot \frac{\mathsf{PI}\left(\right)}{180}\right)}\right)}^{2} \]
    5. lower-*.f64N/A

      \[\leadsto a \cdot a + {\left(b \cdot \sin \color{blue}{\left(angle \cdot \frac{\mathsf{PI}\left(\right)}{180}\right)}\right)}^{2} \]
    6. lower-/.f64N/A

      \[\leadsto a \cdot a + {\left(b \cdot \sin \left(angle \cdot \color{blue}{\frac{\mathsf{PI}\left(\right)}{180}}\right)\right)}^{2} \]
    7. lift-PI.f6479.0

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

    \[\leadsto a \cdot a + {\left(b \cdot \sin \color{blue}{\left(angle \cdot \frac{\pi}{180}\right)}\right)}^{2} \]
  10. Add Preprocessing

Alternative 3: 76.2% accurate, 2.9× speedup?

\[\begin{array}{l} b_m = \left|b\right| \\ \begin{array}{l} \mathbf{if}\;angle \leq 0.00135:\\ \;\;\;\;a \cdot a + \left({\left(angle \cdot b\_m\right)}^{2} \cdot \left(\pi \cdot \pi\right)\right) \cdot 3.08641975308642 \cdot 10^{-5}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(\frac{angle}{180} \cdot \pi\right)\right)\right) \cdot b\_m, b\_m, a \cdot a\right)\\ \end{array} \end{array} \]
b_m = (fabs.f64 b)
(FPCore (a b_m angle)
 :precision binary64
 (if (<= angle 0.00135)
   (+ (* a a) (* (* (pow (* angle b_m) 2.0) (* PI PI)) 3.08641975308642e-5))
   (fma
    (* (- 0.5 (* 0.5 (cos (* 2.0 (* (/ angle 180.0) PI))))) b_m)
    b_m
    (* a a))))
b_m = fabs(b);
double code(double a, double b_m, double angle) {
	double tmp;
	if (angle <= 0.00135) {
		tmp = (a * a) + ((pow((angle * b_m), 2.0) * (((double) M_PI) * ((double) M_PI))) * 3.08641975308642e-5);
	} else {
		tmp = fma(((0.5 - (0.5 * cos((2.0 * ((angle / 180.0) * ((double) M_PI)))))) * b_m), b_m, (a * a));
	}
	return tmp;
}
b_m = abs(b)
function code(a, b_m, angle)
	tmp = 0.0
	if (angle <= 0.00135)
		tmp = Float64(Float64(a * a) + Float64(Float64((Float64(angle * b_m) ^ 2.0) * Float64(pi * pi)) * 3.08641975308642e-5));
	else
		tmp = fma(Float64(Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(Float64(angle / 180.0) * pi))))) * b_m), b_m, Float64(a * a));
	end
	return tmp
end
b_m = N[Abs[b], $MachinePrecision]
code[a_, b$95$m_, angle_] := If[LessEqual[angle, 0.00135], N[(N[(a * a), $MachinePrecision] + N[(N[(N[Power[N[(angle * b$95$m), $MachinePrecision], 2.0], $MachinePrecision] * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision], N[(N[(N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * b$95$m), $MachinePrecision] * b$95$m + N[(a * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
b_m = \left|b\right|

\\
\begin{array}{l}
\mathbf{if}\;angle \leq 0.00135:\\
\;\;\;\;a \cdot a + \left({\left(angle \cdot b\_m\right)}^{2} \cdot \left(\pi \cdot \pi\right)\right) \cdot 3.08641975308642 \cdot 10^{-5}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(\frac{angle}{180} \cdot \pi\right)\right)\right) \cdot b\_m, b\_m, a \cdot a\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if angle < 0.0013500000000000001

    1. Initial program 85.9%

      \[{\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. Add Preprocessing
    3. Taylor expanded in angle around 0

      \[\leadsto \color{blue}{{a}^{2}} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
    4. Step-by-step derivation
      1. unpow2N/A

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

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

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

      \[\leadsto a \cdot a + \color{blue}{\frac{1}{32400} \cdot \left({angle}^{2} \cdot \left({b}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)} \]
    7. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto a \cdot a + \left({angle}^{2} \cdot \left({b}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right) \cdot \color{blue}{\frac{1}{32400}} \]
      2. lower-*.f64N/A

        \[\leadsto a \cdot a + \left({angle}^{2} \cdot \left({b}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right) \cdot \color{blue}{\frac{1}{32400}} \]
      3. *-commutativeN/A

        \[\leadsto a \cdot a + \left({angle}^{2} \cdot \left({\mathsf{PI}\left(\right)}^{2} \cdot {b}^{2}\right)\right) \cdot \frac{1}{32400} \]
      4. unpow-prod-downN/A

        \[\leadsto a \cdot a + \left({angle}^{2} \cdot {\left(\mathsf{PI}\left(\right) \cdot b\right)}^{2}\right) \cdot \frac{1}{32400} \]
      5. pow-prod-downN/A

        \[\leadsto a \cdot a + {\left(angle \cdot \left(\mathsf{PI}\left(\right) \cdot b\right)\right)}^{2} \cdot \frac{1}{32400} \]
      6. *-commutativeN/A

        \[\leadsto a \cdot a + {\left(angle \cdot \left(b \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} \cdot \frac{1}{32400} \]
      7. lower-pow.f64N/A

        \[\leadsto a \cdot a + {\left(angle \cdot \left(b \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} \cdot \frac{1}{32400} \]
      8. *-commutativeN/A

        \[\leadsto a \cdot a + {\left(angle \cdot \left(\mathsf{PI}\left(\right) \cdot b\right)\right)}^{2} \cdot \frac{1}{32400} \]
      9. *-commutativeN/A

        \[\leadsto a \cdot a + {\left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot angle\right)}^{2} \cdot \frac{1}{32400} \]
      10. lower-*.f64N/A

        \[\leadsto a \cdot a + {\left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot angle\right)}^{2} \cdot \frac{1}{32400} \]
      11. *-commutativeN/A

        \[\leadsto a \cdot a + {\left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right)}^{2} \cdot \frac{1}{32400} \]
      12. lower-*.f64N/A

        \[\leadsto a \cdot a + {\left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right)}^{2} \cdot \frac{1}{32400} \]
      13. lift-PI.f6482.1

        \[\leadsto a \cdot a + {\left(\left(b \cdot \pi\right) \cdot angle\right)}^{2} \cdot 3.08641975308642 \cdot 10^{-5} \]
    8. Applied rewrites82.1%

      \[\leadsto a \cdot a + \color{blue}{{\left(\left(b \cdot \pi\right) \cdot angle\right)}^{2} \cdot 3.08641975308642 \cdot 10^{-5}} \]
    9. Step-by-step derivation
      1. lift-pow.f64N/A

        \[\leadsto a \cdot a + {\left(\left(b \cdot \pi\right) \cdot angle\right)}^{2} \cdot \frac{1}{32400} \]
      2. lift-*.f64N/A

        \[\leadsto a \cdot a + {\left(\left(b \cdot \pi\right) \cdot angle\right)}^{2} \cdot \frac{1}{32400} \]
      3. lift-PI.f64N/A

        \[\leadsto a \cdot a + {\left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right)}^{2} \cdot \frac{1}{32400} \]
      4. lift-*.f64N/A

        \[\leadsto a \cdot a + {\left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right)}^{2} \cdot \frac{1}{32400} \]
      5. unpow-prod-downN/A

        \[\leadsto a \cdot a + \left({\left(b \cdot \mathsf{PI}\left(\right)\right)}^{2} \cdot {angle}^{2}\right) \cdot \frac{1}{32400} \]
      6. pow-prod-downN/A

        \[\leadsto a \cdot a + \left(\left({b}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right) \cdot {angle}^{2}\right) \cdot \frac{1}{32400} \]
      7. *-commutativeN/A

        \[\leadsto a \cdot a + \left({angle}^{2} \cdot \left({b}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right) \cdot \frac{1}{32400} \]
      8. associate-*r*N/A

        \[\leadsto a \cdot a + \left(\left({angle}^{2} \cdot {b}^{2}\right) \cdot {\mathsf{PI}\left(\right)}^{2}\right) \cdot \frac{1}{32400} \]
      9. lower-*.f64N/A

        \[\leadsto a \cdot a + \left(\left({angle}^{2} \cdot {b}^{2}\right) \cdot {\mathsf{PI}\left(\right)}^{2}\right) \cdot \frac{1}{32400} \]
      10. pow-prod-downN/A

        \[\leadsto a \cdot a + \left({\left(angle \cdot b\right)}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right) \cdot \frac{1}{32400} \]
      11. lower-pow.f64N/A

        \[\leadsto a \cdot a + \left({\left(angle \cdot b\right)}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right) \cdot \frac{1}{32400} \]
      12. lower-*.f64N/A

        \[\leadsto a \cdot a + \left({\left(angle \cdot b\right)}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right) \cdot \frac{1}{32400} \]
      13. unpow2N/A

        \[\leadsto a \cdot a + \left({\left(angle \cdot b\right)}^{2} \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \frac{1}{32400} \]
      14. lower-*.f64N/A

        \[\leadsto a \cdot a + \left({\left(angle \cdot b\right)}^{2} \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \frac{1}{32400} \]
      15. lift-PI.f64N/A

        \[\leadsto a \cdot a + \left({\left(angle \cdot b\right)}^{2} \cdot \left(\pi \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \frac{1}{32400} \]
      16. lift-PI.f6482.2

        \[\leadsto a \cdot a + \left({\left(angle \cdot b\right)}^{2} \cdot \left(\pi \cdot \pi\right)\right) \cdot 3.08641975308642 \cdot 10^{-5} \]
    10. Applied rewrites82.2%

      \[\leadsto a \cdot a + \left({\left(angle \cdot b\right)}^{2} \cdot \left(\pi \cdot \pi\right)\right) \cdot 3.08641975308642 \cdot 10^{-5} \]

    if 0.0013500000000000001 < angle

    1. Initial program 58.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. Add Preprocessing
    3. Taylor expanded in angle around 0

      \[\leadsto \color{blue}{{a}^{2}} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
    4. Step-by-step derivation
      1. unpow2N/A

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

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

      \[\leadsto \color{blue}{a \cdot a} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
    6. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \color{blue}{a \cdot a + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2}} \]
      2. lift-pow.f64N/A

        \[\leadsto a \cdot a + \color{blue}{{\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2}} \]
      3. lift-*.f64N/A

        \[\leadsto a \cdot a + {\color{blue}{\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}}^{2} \]
      4. lift-sin.f64N/A

        \[\leadsto a \cdot a + {\left(b \cdot \color{blue}{\sin \left(\pi \cdot \frac{angle}{180}\right)}\right)}^{2} \]
      5. lift-PI.f64N/A

        \[\leadsto a \cdot a + {\left(b \cdot \sin \left(\color{blue}{\mathsf{PI}\left(\right)} \cdot \frac{angle}{180}\right)\right)}^{2} \]
      6. lift-*.f64N/A

        \[\leadsto a \cdot a + {\left(b \cdot \sin \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)}\right)}^{2} \]
      7. lift-/.f64N/A

        \[\leadsto a \cdot a + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \color{blue}{\frac{angle}{180}}\right)\right)}^{2} \]
      8. +-commutativeN/A

        \[\leadsto \color{blue}{{\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} + a \cdot a} \]
      9. unpow-prod-downN/A

        \[\leadsto \color{blue}{{b}^{2} \cdot {\sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)}^{2}} + a \cdot a \]
      10. *-commutativeN/A

        \[\leadsto \color{blue}{{\sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)}^{2} \cdot {b}^{2}} + a \cdot a \]
      11. pow2N/A

        \[\leadsto {\sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)}^{2} \cdot \color{blue}{\left(b \cdot b\right)} + a \cdot a \]
      12. associate-*r*N/A

        \[\leadsto \color{blue}{\left({\sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)}^{2} \cdot b\right) \cdot b} + a \cdot a \]
    7. Applied rewrites58.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left({\sin \left(\frac{angle}{180} \cdot \pi\right)}^{2} \cdot b, b, a \cdot a\right)} \]
    8. Step-by-step derivation
      1. lift-pow.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{{\sin \left(\frac{angle}{180} \cdot \pi\right)}^{2}} \cdot b, b, a \cdot a\right) \]
      2. lift-sin.f64N/A

        \[\leadsto \mathsf{fma}\left({\color{blue}{\sin \left(\frac{angle}{180} \cdot \pi\right)}}^{2} \cdot b, b, a \cdot a\right) \]
      3. lift-PI.f64N/A

        \[\leadsto \mathsf{fma}\left({\sin \left(\frac{angle}{180} \cdot \color{blue}{\mathsf{PI}\left(\right)}\right)}^{2} \cdot b, b, a \cdot a\right) \]
      4. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left({\sin \color{blue}{\left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)}}^{2} \cdot b, b, a \cdot a\right) \]
      5. lift-/.f64N/A

        \[\leadsto \mathsf{fma}\left({\sin \left(\color{blue}{\frac{angle}{180}} \cdot \mathsf{PI}\left(\right)\right)}^{2} \cdot b, b, a \cdot a\right) \]
      6. unpow2N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right) \cdot \sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)} \cdot b, b, a \cdot a\right) \]
      7. sqr-sin-aN/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(2 \cdot \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)\right)} \cdot b, b, a \cdot a\right) \]
      8. lower--.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(2 \cdot \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)\right)} \cdot b, b, a \cdot a\right) \]
      9. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{2} - \color{blue}{\frac{1}{2} \cdot \cos \left(2 \cdot \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \cdot b, b, a \cdot a\right) \]
      10. lower-cos.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{2} - \frac{1}{2} \cdot \color{blue}{\cos \left(2 \cdot \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \cdot b, b, a \cdot a\right) \]
      11. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{2} - \frac{1}{2} \cdot \cos \color{blue}{\left(2 \cdot \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \cdot b, b, a \cdot a\right) \]
      12. lift-/.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(2 \cdot \left(\color{blue}{\frac{angle}{180}} \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot b, b, a \cdot a\right) \]
      13. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(2 \cdot \color{blue}{\left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)}\right)\right) \cdot b, b, a \cdot a\right) \]
      14. lift-PI.f6458.3

        \[\leadsto \mathsf{fma}\left(\left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(\frac{angle}{180} \cdot \color{blue}{\pi}\right)\right)\right) \cdot b, b, a \cdot a\right) \]
    9. Applied rewrites58.3%

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(\frac{angle}{180} \cdot \pi\right)\right)\right)} \cdot b, b, a \cdot a\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 4: 76.3% accurate, 3.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b\_m \leq 7.6 \cdot 10^{-96}:\\
\;\;\;\;a \cdot a\\

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


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

    1. Initial program 77.6%

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

      \[\leadsto \color{blue}{{a}^{2}} \]
    4. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto a \cdot \color{blue}{a} \]
      2. lower-*.f6476.4

        \[\leadsto a \cdot \color{blue}{a} \]
    5. Applied rewrites76.4%

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

    if 7.6000000000000001e-96 < b

    1. Initial program 79.9%

      \[{\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. Add Preprocessing
    3. Taylor expanded in angle around 0

      \[\leadsto \color{blue}{{a}^{2}} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
    4. Step-by-step derivation
      1. unpow2N/A

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

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

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

      \[\leadsto a \cdot a + \color{blue}{\frac{1}{32400} \cdot \left({angle}^{2} \cdot \left({b}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)} \]
    7. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto a \cdot a + \left({angle}^{2} \cdot \left({b}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right) \cdot \color{blue}{\frac{1}{32400}} \]
      2. lower-*.f64N/A

        \[\leadsto a \cdot a + \left({angle}^{2} \cdot \left({b}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right) \cdot \color{blue}{\frac{1}{32400}} \]
      3. *-commutativeN/A

        \[\leadsto a \cdot a + \left({angle}^{2} \cdot \left({\mathsf{PI}\left(\right)}^{2} \cdot {b}^{2}\right)\right) \cdot \frac{1}{32400} \]
      4. unpow-prod-downN/A

        \[\leadsto a \cdot a + \left({angle}^{2} \cdot {\left(\mathsf{PI}\left(\right) \cdot b\right)}^{2}\right) \cdot \frac{1}{32400} \]
      5. pow-prod-downN/A

        \[\leadsto a \cdot a + {\left(angle \cdot \left(\mathsf{PI}\left(\right) \cdot b\right)\right)}^{2} \cdot \frac{1}{32400} \]
      6. *-commutativeN/A

        \[\leadsto a \cdot a + {\left(angle \cdot \left(b \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} \cdot \frac{1}{32400} \]
      7. lower-pow.f64N/A

        \[\leadsto a \cdot a + {\left(angle \cdot \left(b \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} \cdot \frac{1}{32400} \]
      8. *-commutativeN/A

        \[\leadsto a \cdot a + {\left(angle \cdot \left(\mathsf{PI}\left(\right) \cdot b\right)\right)}^{2} \cdot \frac{1}{32400} \]
      9. *-commutativeN/A

        \[\leadsto a \cdot a + {\left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot angle\right)}^{2} \cdot \frac{1}{32400} \]
      10. lower-*.f64N/A

        \[\leadsto a \cdot a + {\left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot angle\right)}^{2} \cdot \frac{1}{32400} \]
      11. *-commutativeN/A

        \[\leadsto a \cdot a + {\left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right)}^{2} \cdot \frac{1}{32400} \]
      12. lower-*.f64N/A

        \[\leadsto a \cdot a + {\left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right)}^{2} \cdot \frac{1}{32400} \]
      13. lift-PI.f6476.2

        \[\leadsto a \cdot a + {\left(\left(b \cdot \pi\right) \cdot angle\right)}^{2} \cdot 3.08641975308642 \cdot 10^{-5} \]
    8. Applied rewrites76.2%

      \[\leadsto a \cdot a + \color{blue}{{\left(\left(b \cdot \pi\right) \cdot angle\right)}^{2} \cdot 3.08641975308642 \cdot 10^{-5}} \]
    9. Step-by-step derivation
      1. lift-pow.f64N/A

        \[\leadsto a \cdot a + {\left(\left(b \cdot \pi\right) \cdot angle\right)}^{2} \cdot \frac{1}{32400} \]
      2. lift-*.f64N/A

        \[\leadsto a \cdot a + {\left(\left(b \cdot \pi\right) \cdot angle\right)}^{2} \cdot \frac{1}{32400} \]
      3. lift-PI.f64N/A

        \[\leadsto a \cdot a + {\left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right)}^{2} \cdot \frac{1}{32400} \]
      4. lift-*.f64N/A

        \[\leadsto a \cdot a + {\left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right)}^{2} \cdot \frac{1}{32400} \]
      5. unpow-prod-downN/A

        \[\leadsto a \cdot a + \left({\left(b \cdot \mathsf{PI}\left(\right)\right)}^{2} \cdot {angle}^{2}\right) \cdot \frac{1}{32400} \]
      6. pow-prod-downN/A

        \[\leadsto a \cdot a + \left(\left({b}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right) \cdot {angle}^{2}\right) \cdot \frac{1}{32400} \]
      7. *-commutativeN/A

        \[\leadsto a \cdot a + \left({angle}^{2} \cdot \left({b}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right) \cdot \frac{1}{32400} \]
      8. associate-*r*N/A

        \[\leadsto a \cdot a + \left(\left({angle}^{2} \cdot {b}^{2}\right) \cdot {\mathsf{PI}\left(\right)}^{2}\right) \cdot \frac{1}{32400} \]
      9. lower-*.f64N/A

        \[\leadsto a \cdot a + \left(\left({angle}^{2} \cdot {b}^{2}\right) \cdot {\mathsf{PI}\left(\right)}^{2}\right) \cdot \frac{1}{32400} \]
      10. pow-prod-downN/A

        \[\leadsto a \cdot a + \left({\left(angle \cdot b\right)}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right) \cdot \frac{1}{32400} \]
      11. lower-pow.f64N/A

        \[\leadsto a \cdot a + \left({\left(angle \cdot b\right)}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right) \cdot \frac{1}{32400} \]
      12. lower-*.f64N/A

        \[\leadsto a \cdot a + \left({\left(angle \cdot b\right)}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right) \cdot \frac{1}{32400} \]
      13. unpow2N/A

        \[\leadsto a \cdot a + \left({\left(angle \cdot b\right)}^{2} \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \frac{1}{32400} \]
      14. lower-*.f64N/A

        \[\leadsto a \cdot a + \left({\left(angle \cdot b\right)}^{2} \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \frac{1}{32400} \]
      15. lift-PI.f64N/A

        \[\leadsto a \cdot a + \left({\left(angle \cdot b\right)}^{2} \cdot \left(\pi \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \frac{1}{32400} \]
      16. lift-PI.f6476.3

        \[\leadsto a \cdot a + \left({\left(angle \cdot b\right)}^{2} \cdot \left(\pi \cdot \pi\right)\right) \cdot 3.08641975308642 \cdot 10^{-5} \]
    10. Applied rewrites76.3%

      \[\leadsto a \cdot a + \left({\left(angle \cdot b\right)}^{2} \cdot \left(\pi \cdot \pi\right)\right) \cdot 3.08641975308642 \cdot 10^{-5} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 5: 76.4% accurate, 3.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b\_m \leq 7.6 \cdot 10^{-96}:\\
\;\;\;\;a \cdot a\\

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


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

    1. Initial program 77.6%

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

      \[\leadsto \color{blue}{{a}^{2}} \]
    4. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto a \cdot \color{blue}{a} \]
      2. lower-*.f6476.4

        \[\leadsto a \cdot \color{blue}{a} \]
    5. Applied rewrites76.4%

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

    if 7.6000000000000001e-96 < b

    1. Initial program 79.9%

      \[{\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. Add Preprocessing
    3. Taylor expanded in angle around 0

      \[\leadsto \color{blue}{{a}^{2}} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
    4. Step-by-step derivation
      1. unpow2N/A

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

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

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

      \[\leadsto a \cdot a + {\color{blue}{\left(angle \cdot \left(\frac{1}{180} \cdot \left(b \cdot \mathsf{PI}\left(\right)\right) + {angle}^{2} \cdot \left(\frac{-1}{34992000} \cdot \left(b \cdot {\mathsf{PI}\left(\right)}^{3}\right) + \frac{1}{22674816000000} \cdot \left({angle}^{2} \cdot \left(b \cdot {\mathsf{PI}\left(\right)}^{5}\right)\right)\right)\right)\right)}}^{2} \]
    7. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto a \cdot a + {\left(\left(\frac{1}{180} \cdot \left(b \cdot \mathsf{PI}\left(\right)\right) + {angle}^{2} \cdot \left(\frac{-1}{34992000} \cdot \left(b \cdot {\mathsf{PI}\left(\right)}^{3}\right) + \frac{1}{22674816000000} \cdot \left({angle}^{2} \cdot \left(b \cdot {\mathsf{PI}\left(\right)}^{5}\right)\right)\right)\right) \cdot \color{blue}{angle}\right)}^{2} \]
      2. lower-*.f64N/A

        \[\leadsto a \cdot a + {\left(\left(\frac{1}{180} \cdot \left(b \cdot \mathsf{PI}\left(\right)\right) + {angle}^{2} \cdot \left(\frac{-1}{34992000} \cdot \left(b \cdot {\mathsf{PI}\left(\right)}^{3}\right) + \frac{1}{22674816000000} \cdot \left({angle}^{2} \cdot \left(b \cdot {\mathsf{PI}\left(\right)}^{5}\right)\right)\right)\right) \cdot \color{blue}{angle}\right)}^{2} \]
    8. Applied rewrites75.5%

      \[\leadsto a \cdot a + {\color{blue}{\left(\mathsf{fma}\left(0.005555555555555556 \cdot b, \pi, \mathsf{fma}\left(4.410179116778721 \cdot 10^{-14} \cdot \left(angle \cdot angle\right), {\pi}^{5} \cdot b, \left({\pi}^{3} \cdot b\right) \cdot -2.8577960676726107 \cdot 10^{-8}\right) \cdot \left(angle \cdot angle\right)\right) \cdot angle\right)}}^{2} \]
    9. Taylor expanded in angle around 0

      \[\leadsto a \cdot a + {\left(\left(\frac{1}{180} \cdot \left(b \cdot \mathsf{PI}\left(\right)\right)\right) \cdot angle\right)}^{2} \]
    10. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto a \cdot a + {\left(\left(\left(\frac{1}{180} \cdot b\right) \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right)}^{2} \]
      2. lower-*.f64N/A

        \[\leadsto a \cdot a + {\left(\left(\left(\frac{1}{180} \cdot b\right) \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right)}^{2} \]
      3. lift-*.f64N/A

        \[\leadsto a \cdot a + {\left(\left(\left(\frac{1}{180} \cdot b\right) \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right)}^{2} \]
      4. lift-PI.f6476.4

        \[\leadsto a \cdot a + {\left(\left(\left(0.005555555555555556 \cdot b\right) \cdot \pi\right) \cdot angle\right)}^{2} \]
    11. Applied rewrites76.4%

      \[\leadsto a \cdot a + {\left(\left(\left(0.005555555555555556 \cdot b\right) \cdot \pi\right) \cdot angle\right)}^{2} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 6: 76.3% accurate, 10.0× speedup?

\[\begin{array}{l} b_m = \left|b\right| \\ \begin{array}{l} t_0 := \left(b\_m \cdot \pi\right) \cdot angle\\ \mathbf{if}\;b\_m \leq 7.6 \cdot 10^{-96}:\\ \;\;\;\;a \cdot a\\ \mathbf{else}:\\ \;\;\;\;a \cdot a + \left(t\_0 \cdot t\_0\right) \cdot 3.08641975308642 \cdot 10^{-5}\\ \end{array} \end{array} \]
b_m = (fabs.f64 b)
(FPCore (a b_m angle)
 :precision binary64
 (let* ((t_0 (* (* b_m PI) angle)))
   (if (<= b_m 7.6e-96)
     (* a a)
     (+ (* a a) (* (* t_0 t_0) 3.08641975308642e-5)))))
b_m = fabs(b);
double code(double a, double b_m, double angle) {
	double t_0 = (b_m * ((double) M_PI)) * angle;
	double tmp;
	if (b_m <= 7.6e-96) {
		tmp = a * a;
	} else {
		tmp = (a * a) + ((t_0 * t_0) * 3.08641975308642e-5);
	}
	return tmp;
}
b_m = Math.abs(b);
public static double code(double a, double b_m, double angle) {
	double t_0 = (b_m * Math.PI) * angle;
	double tmp;
	if (b_m <= 7.6e-96) {
		tmp = a * a;
	} else {
		tmp = (a * a) + ((t_0 * t_0) * 3.08641975308642e-5);
	}
	return tmp;
}
b_m = math.fabs(b)
def code(a, b_m, angle):
	t_0 = (b_m * math.pi) * angle
	tmp = 0
	if b_m <= 7.6e-96:
		tmp = a * a
	else:
		tmp = (a * a) + ((t_0 * t_0) * 3.08641975308642e-5)
	return tmp
b_m = abs(b)
function code(a, b_m, angle)
	t_0 = Float64(Float64(b_m * pi) * angle)
	tmp = 0.0
	if (b_m <= 7.6e-96)
		tmp = Float64(a * a);
	else
		tmp = Float64(Float64(a * a) + Float64(Float64(t_0 * t_0) * 3.08641975308642e-5));
	end
	return tmp
end
b_m = abs(b);
function tmp_2 = code(a, b_m, angle)
	t_0 = (b_m * pi) * angle;
	tmp = 0.0;
	if (b_m <= 7.6e-96)
		tmp = a * a;
	else
		tmp = (a * a) + ((t_0 * t_0) * 3.08641975308642e-5);
	end
	tmp_2 = tmp;
end
b_m = N[Abs[b], $MachinePrecision]
code[a_, b$95$m_, angle_] := Block[{t$95$0 = N[(N[(b$95$m * Pi), $MachinePrecision] * angle), $MachinePrecision]}, If[LessEqual[b$95$m, 7.6e-96], N[(a * a), $MachinePrecision], N[(N[(a * a), $MachinePrecision] + N[(N[(t$95$0 * t$95$0), $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
b_m = \left|b\right|

\\
\begin{array}{l}
t_0 := \left(b\_m \cdot \pi\right) \cdot angle\\
\mathbf{if}\;b\_m \leq 7.6 \cdot 10^{-96}:\\
\;\;\;\;a \cdot a\\

\mathbf{else}:\\
\;\;\;\;a \cdot a + \left(t\_0 \cdot t\_0\right) \cdot 3.08641975308642 \cdot 10^{-5}\\


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

    1. Initial program 77.6%

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

      \[\leadsto \color{blue}{{a}^{2}} \]
    4. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto a \cdot \color{blue}{a} \]
      2. lower-*.f6476.4

        \[\leadsto a \cdot \color{blue}{a} \]
    5. Applied rewrites76.4%

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

    if 7.6000000000000001e-96 < b

    1. Initial program 79.9%

      \[{\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. Add Preprocessing
    3. Taylor expanded in angle around 0

      \[\leadsto \color{blue}{{a}^{2}} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
    4. Step-by-step derivation
      1. unpow2N/A

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

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

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

      \[\leadsto a \cdot a + \color{blue}{\frac{1}{32400} \cdot \left({angle}^{2} \cdot \left({b}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)} \]
    7. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto a \cdot a + \left({angle}^{2} \cdot \left({b}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right) \cdot \color{blue}{\frac{1}{32400}} \]
      2. lower-*.f64N/A

        \[\leadsto a \cdot a + \left({angle}^{2} \cdot \left({b}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right) \cdot \color{blue}{\frac{1}{32400}} \]
      3. *-commutativeN/A

        \[\leadsto a \cdot a + \left({angle}^{2} \cdot \left({\mathsf{PI}\left(\right)}^{2} \cdot {b}^{2}\right)\right) \cdot \frac{1}{32400} \]
      4. unpow-prod-downN/A

        \[\leadsto a \cdot a + \left({angle}^{2} \cdot {\left(\mathsf{PI}\left(\right) \cdot b\right)}^{2}\right) \cdot \frac{1}{32400} \]
      5. pow-prod-downN/A

        \[\leadsto a \cdot a + {\left(angle \cdot \left(\mathsf{PI}\left(\right) \cdot b\right)\right)}^{2} \cdot \frac{1}{32400} \]
      6. *-commutativeN/A

        \[\leadsto a \cdot a + {\left(angle \cdot \left(b \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} \cdot \frac{1}{32400} \]
      7. lower-pow.f64N/A

        \[\leadsto a \cdot a + {\left(angle \cdot \left(b \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} \cdot \frac{1}{32400} \]
      8. *-commutativeN/A

        \[\leadsto a \cdot a + {\left(angle \cdot \left(\mathsf{PI}\left(\right) \cdot b\right)\right)}^{2} \cdot \frac{1}{32400} \]
      9. *-commutativeN/A

        \[\leadsto a \cdot a + {\left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot angle\right)}^{2} \cdot \frac{1}{32400} \]
      10. lower-*.f64N/A

        \[\leadsto a \cdot a + {\left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot angle\right)}^{2} \cdot \frac{1}{32400} \]
      11. *-commutativeN/A

        \[\leadsto a \cdot a + {\left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right)}^{2} \cdot \frac{1}{32400} \]
      12. lower-*.f64N/A

        \[\leadsto a \cdot a + {\left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right)}^{2} \cdot \frac{1}{32400} \]
      13. lift-PI.f6476.2

        \[\leadsto a \cdot a + {\left(\left(b \cdot \pi\right) \cdot angle\right)}^{2} \cdot 3.08641975308642 \cdot 10^{-5} \]
    8. Applied rewrites76.2%

      \[\leadsto a \cdot a + \color{blue}{{\left(\left(b \cdot \pi\right) \cdot angle\right)}^{2} \cdot 3.08641975308642 \cdot 10^{-5}} \]
    9. Step-by-step derivation
      1. lift-pow.f64N/A

        \[\leadsto a \cdot a + {\left(\left(b \cdot \pi\right) \cdot angle\right)}^{2} \cdot \frac{1}{32400} \]
      2. lift-*.f64N/A

        \[\leadsto a \cdot a + {\left(\left(b \cdot \pi\right) \cdot angle\right)}^{2} \cdot \frac{1}{32400} \]
      3. lift-PI.f64N/A

        \[\leadsto a \cdot a + {\left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right)}^{2} \cdot \frac{1}{32400} \]
      4. lift-*.f64N/A

        \[\leadsto a \cdot a + {\left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right)}^{2} \cdot \frac{1}{32400} \]
      5. unpow2N/A

        \[\leadsto a \cdot a + \left(\left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right) \cdot \left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right)\right) \cdot \frac{1}{32400} \]
      6. lower-*.f64N/A

        \[\leadsto a \cdot a + \left(\left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right) \cdot \left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right)\right) \cdot \frac{1}{32400} \]
      7. lift-*.f64N/A

        \[\leadsto a \cdot a + \left(\left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right) \cdot \left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right)\right) \cdot \frac{1}{32400} \]
      8. lift-PI.f64N/A

        \[\leadsto a \cdot a + \left(\left(\left(b \cdot \pi\right) \cdot angle\right) \cdot \left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right)\right) \cdot \frac{1}{32400} \]
      9. lift-*.f64N/A

        \[\leadsto a \cdot a + \left(\left(\left(b \cdot \pi\right) \cdot angle\right) \cdot \left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right)\right) \cdot \frac{1}{32400} \]
      10. lift-*.f64N/A

        \[\leadsto a \cdot a + \left(\left(\left(b \cdot \pi\right) \cdot angle\right) \cdot \left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right)\right) \cdot \frac{1}{32400} \]
      11. lift-PI.f64N/A

        \[\leadsto a \cdot a + \left(\left(\left(b \cdot \pi\right) \cdot angle\right) \cdot \left(\left(b \cdot \pi\right) \cdot angle\right)\right) \cdot \frac{1}{32400} \]
      12. lift-*.f6476.2

        \[\leadsto a \cdot a + \left(\left(\left(b \cdot \pi\right) \cdot angle\right) \cdot \left(\left(b \cdot \pi\right) \cdot angle\right)\right) \cdot 3.08641975308642 \cdot 10^{-5} \]
    10. Applied rewrites76.2%

      \[\leadsto a \cdot a + \left(\left(\left(b \cdot \pi\right) \cdot angle\right) \cdot \left(\left(b \cdot \pi\right) \cdot angle\right)\right) \cdot 3.08641975308642 \cdot 10^{-5} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 7: 72.6% accurate, 10.4× speedup?

\[\begin{array}{l} b_m = \left|b\right| \\ \begin{array}{l} \mathbf{if}\;b\_m \leq 7.6 \cdot 10^{-96}:\\ \;\;\;\;a \cdot a\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\left(\left(\left(angle \cdot angle\right) \cdot b\_m\right) \cdot \left(\pi \cdot \pi\right)\right) \cdot 3.08641975308642 \cdot 10^{-5}, b\_m, a \cdot a\right)\\ \end{array} \end{array} \]
b_m = (fabs.f64 b)
(FPCore (a b_m angle)
 :precision binary64
 (if (<= b_m 7.6e-96)
   (* a a)
   (fma
    (* (* (* (* angle angle) b_m) (* PI PI)) 3.08641975308642e-5)
    b_m
    (* a a))))
b_m = fabs(b);
double code(double a, double b_m, double angle) {
	double tmp;
	if (b_m <= 7.6e-96) {
		tmp = a * a;
	} else {
		tmp = fma(((((angle * angle) * b_m) * (((double) M_PI) * ((double) M_PI))) * 3.08641975308642e-5), b_m, (a * a));
	}
	return tmp;
}
b_m = abs(b)
function code(a, b_m, angle)
	tmp = 0.0
	if (b_m <= 7.6e-96)
		tmp = Float64(a * a);
	else
		tmp = fma(Float64(Float64(Float64(Float64(angle * angle) * b_m) * Float64(pi * pi)) * 3.08641975308642e-5), b_m, Float64(a * a));
	end
	return tmp
end
b_m = N[Abs[b], $MachinePrecision]
code[a_, b$95$m_, angle_] := If[LessEqual[b$95$m, 7.6e-96], N[(a * a), $MachinePrecision], N[(N[(N[(N[(N[(angle * angle), $MachinePrecision] * b$95$m), $MachinePrecision] * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision] * b$95$m + N[(a * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
b_m = \left|b\right|

\\
\begin{array}{l}
\mathbf{if}\;b\_m \leq 7.6 \cdot 10^{-96}:\\
\;\;\;\;a \cdot a\\

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


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

    1. Initial program 77.6%

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

      \[\leadsto \color{blue}{{a}^{2}} \]
    4. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto a \cdot \color{blue}{a} \]
      2. lower-*.f6476.4

        \[\leadsto a \cdot \color{blue}{a} \]
    5. Applied rewrites76.4%

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

    if 7.6000000000000001e-96 < b

    1. Initial program 79.9%

      \[{\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. Add Preprocessing
    3. Taylor expanded in angle around 0

      \[\leadsto \color{blue}{{a}^{2}} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
    4. Step-by-step derivation
      1. unpow2N/A

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

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

      \[\leadsto \color{blue}{a \cdot a} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
    6. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \color{blue}{a \cdot a + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2}} \]
      2. lift-pow.f64N/A

        \[\leadsto a \cdot a + \color{blue}{{\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2}} \]
      3. lift-*.f64N/A

        \[\leadsto a \cdot a + {\color{blue}{\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}}^{2} \]
      4. lift-sin.f64N/A

        \[\leadsto a \cdot a + {\left(b \cdot \color{blue}{\sin \left(\pi \cdot \frac{angle}{180}\right)}\right)}^{2} \]
      5. lift-PI.f64N/A

        \[\leadsto a \cdot a + {\left(b \cdot \sin \left(\color{blue}{\mathsf{PI}\left(\right)} \cdot \frac{angle}{180}\right)\right)}^{2} \]
      6. lift-*.f64N/A

        \[\leadsto a \cdot a + {\left(b \cdot \sin \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)}\right)}^{2} \]
      7. lift-/.f64N/A

        \[\leadsto a \cdot a + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \color{blue}{\frac{angle}{180}}\right)\right)}^{2} \]
      8. +-commutativeN/A

        \[\leadsto \color{blue}{{\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} + a \cdot a} \]
      9. unpow-prod-downN/A

        \[\leadsto \color{blue}{{b}^{2} \cdot {\sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)}^{2}} + a \cdot a \]
      10. *-commutativeN/A

        \[\leadsto \color{blue}{{\sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)}^{2} \cdot {b}^{2}} + a \cdot a \]
      11. pow2N/A

        \[\leadsto {\sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)}^{2} \cdot \color{blue}{\left(b \cdot b\right)} + a \cdot a \]
      12. associate-*r*N/A

        \[\leadsto \color{blue}{\left({\sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)}^{2} \cdot b\right) \cdot b} + a \cdot a \]
    7. Applied rewrites74.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left({\sin \left(\frac{angle}{180} \cdot \pi\right)}^{2} \cdot b, b, a \cdot a\right)} \]
    8. Taylor expanded in angle around 0

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1}{32400} \cdot \left({angle}^{2} \cdot \left(b \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)}, b, a \cdot a\right) \]
    9. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{32400} \cdot {angle}^{2}\right) \cdot \color{blue}{\left(b \cdot {\mathsf{PI}\left(\right)}^{2}\right)}, b, a \cdot a\right) \]
      2. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{32400} \cdot {angle}^{2}\right) \cdot \color{blue}{\left(b \cdot {\mathsf{PI}\left(\right)}^{2}\right)}, b, a \cdot a\right) \]
      3. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{32400} \cdot {angle}^{2}\right) \cdot \left(\color{blue}{b} \cdot {\mathsf{PI}\left(\right)}^{2}\right), b, a \cdot a\right) \]
      4. pow2N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{32400} \cdot \left(angle \cdot angle\right)\right) \cdot \left(b \cdot {\mathsf{PI}\left(\right)}^{2}\right), b, a \cdot a\right) \]
      5. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{32400} \cdot \left(angle \cdot angle\right)\right) \cdot \left(b \cdot {\mathsf{PI}\left(\right)}^{2}\right), b, a \cdot a\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{32400} \cdot \left(angle \cdot angle\right)\right) \cdot \left({\mathsf{PI}\left(\right)}^{2} \cdot \color{blue}{b}\right), b, a \cdot a\right) \]
      7. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{32400} \cdot \left(angle \cdot angle\right)\right) \cdot \left({\mathsf{PI}\left(\right)}^{2} \cdot \color{blue}{b}\right), b, a \cdot a\right) \]
      8. unpow2N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{32400} \cdot \left(angle \cdot angle\right)\right) \cdot \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot b\right), b, a \cdot a\right) \]
      9. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{32400} \cdot \left(angle \cdot angle\right)\right) \cdot \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot b\right), b, a \cdot a\right) \]
      10. lift-PI.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{32400} \cdot \left(angle \cdot angle\right)\right) \cdot \left(\left(\pi \cdot \mathsf{PI}\left(\right)\right) \cdot b\right), b, a \cdot a\right) \]
      11. lift-PI.f6470.5

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(3.08641975308642 \cdot 10^{-5} \cdot \left(angle \cdot angle\right)\right) \cdot \left(\left(\pi \cdot \pi\right) \cdot b\right)}, b, a \cdot a\right) \]
    11. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{32400} \cdot \left(angle \cdot angle\right)\right) \cdot \color{blue}{\left(\left(\pi \cdot \pi\right) \cdot b\right)}, b, a \cdot a\right) \]
      2. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{32400} \cdot \left(angle \cdot angle\right)\right) \cdot \left(\color{blue}{\left(\pi \cdot \pi\right)} \cdot b\right), b, a \cdot a\right) \]
      3. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{32400} \cdot \left(angle \cdot angle\right)\right) \cdot \left(\left(\pi \cdot \color{blue}{\pi}\right) \cdot b\right), b, a \cdot a\right) \]
      4. pow2N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{32400} \cdot {angle}^{2}\right) \cdot \left(\left(\pi \cdot \color{blue}{\pi}\right) \cdot b\right), b, a \cdot a\right) \]
      5. associate-*l*N/A

        \[\leadsto \mathsf{fma}\left(\frac{1}{32400} \cdot \color{blue}{\left({angle}^{2} \cdot \left(\left(\pi \cdot \pi\right) \cdot b\right)\right)}, b, a \cdot a\right) \]
      6. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{1}{32400} \cdot \left({angle}^{2} \cdot \left(\left(\pi \cdot \pi\right) \cdot \color{blue}{b}\right)\right), b, a \cdot a\right) \]
      7. lift-PI.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{1}{32400} \cdot \left({angle}^{2} \cdot \left(\left(\mathsf{PI}\left(\right) \cdot \pi\right) \cdot b\right)\right), b, a \cdot a\right) \]
      8. lift-PI.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{1}{32400} \cdot \left({angle}^{2} \cdot \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot b\right)\right), b, a \cdot a\right) \]
      9. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{1}{32400} \cdot \left({angle}^{2} \cdot \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot b\right)\right), b, a \cdot a\right) \]
      10. pow2N/A

        \[\leadsto \mathsf{fma}\left(\frac{1}{32400} \cdot \left({angle}^{2} \cdot \left({\mathsf{PI}\left(\right)}^{2} \cdot b\right)\right), b, a \cdot a\right) \]
      11. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\frac{1}{32400} \cdot \left({angle}^{2} \cdot \left(b \cdot \color{blue}{{\mathsf{PI}\left(\right)}^{2}}\right)\right), b, a \cdot a\right) \]
      12. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\left({angle}^{2} \cdot \left(b \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right) \cdot \color{blue}{\frac{1}{32400}}, b, a \cdot a\right) \]
      13. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left({angle}^{2} \cdot \left(b \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right) \cdot \color{blue}{\frac{1}{32400}}, b, a \cdot a\right) \]
    12. Applied rewrites70.6%

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

Alternative 8: 72.5% accurate, 10.4× speedup?

\[\begin{array}{l} b_m = \left|b\right| \\ \begin{array}{l} \mathbf{if}\;b\_m \leq 7.6 \cdot 10^{-96}:\\ \;\;\;\;a \cdot a\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\left(\left(\pi \cdot \pi\right) \cdot b\_m\right) \cdot \left(\left(3.08641975308642 \cdot 10^{-5} \cdot angle\right) \cdot angle\right), b\_m, a \cdot a\right)\\ \end{array} \end{array} \]
b_m = (fabs.f64 b)
(FPCore (a b_m angle)
 :precision binary64
 (if (<= b_m 7.6e-96)
   (* a a)
   (fma
    (* (* (* PI PI) b_m) (* (* 3.08641975308642e-5 angle) angle))
    b_m
    (* a a))))
b_m = fabs(b);
double code(double a, double b_m, double angle) {
	double tmp;
	if (b_m <= 7.6e-96) {
		tmp = a * a;
	} else {
		tmp = fma((((((double) M_PI) * ((double) M_PI)) * b_m) * ((3.08641975308642e-5 * angle) * angle)), b_m, (a * a));
	}
	return tmp;
}
b_m = abs(b)
function code(a, b_m, angle)
	tmp = 0.0
	if (b_m <= 7.6e-96)
		tmp = Float64(a * a);
	else
		tmp = fma(Float64(Float64(Float64(pi * pi) * b_m) * Float64(Float64(3.08641975308642e-5 * angle) * angle)), b_m, Float64(a * a));
	end
	return tmp
end
b_m = N[Abs[b], $MachinePrecision]
code[a_, b$95$m_, angle_] := If[LessEqual[b$95$m, 7.6e-96], N[(a * a), $MachinePrecision], N[(N[(N[(N[(Pi * Pi), $MachinePrecision] * b$95$m), $MachinePrecision] * N[(N[(3.08641975308642e-5 * angle), $MachinePrecision] * angle), $MachinePrecision]), $MachinePrecision] * b$95$m + N[(a * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
b_m = \left|b\right|

\\
\begin{array}{l}
\mathbf{if}\;b\_m \leq 7.6 \cdot 10^{-96}:\\
\;\;\;\;a \cdot a\\

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


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

    1. Initial program 77.6%

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

      \[\leadsto \color{blue}{{a}^{2}} \]
    4. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto a \cdot \color{blue}{a} \]
      2. lower-*.f6476.4

        \[\leadsto a \cdot \color{blue}{a} \]
    5. Applied rewrites76.4%

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

    if 7.6000000000000001e-96 < b

    1. Initial program 79.9%

      \[{\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. Add Preprocessing
    3. Taylor expanded in angle around 0

      \[\leadsto \color{blue}{{a}^{2}} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
    4. Step-by-step derivation
      1. unpow2N/A

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

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

      \[\leadsto \color{blue}{a \cdot a} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
    6. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \color{blue}{a \cdot a + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2}} \]
      2. lift-pow.f64N/A

        \[\leadsto a \cdot a + \color{blue}{{\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2}} \]
      3. lift-*.f64N/A

        \[\leadsto a \cdot a + {\color{blue}{\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}}^{2} \]
      4. lift-sin.f64N/A

        \[\leadsto a \cdot a + {\left(b \cdot \color{blue}{\sin \left(\pi \cdot \frac{angle}{180}\right)}\right)}^{2} \]
      5. lift-PI.f64N/A

        \[\leadsto a \cdot a + {\left(b \cdot \sin \left(\color{blue}{\mathsf{PI}\left(\right)} \cdot \frac{angle}{180}\right)\right)}^{2} \]
      6. lift-*.f64N/A

        \[\leadsto a \cdot a + {\left(b \cdot \sin \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)}\right)}^{2} \]
      7. lift-/.f64N/A

        \[\leadsto a \cdot a + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \color{blue}{\frac{angle}{180}}\right)\right)}^{2} \]
      8. +-commutativeN/A

        \[\leadsto \color{blue}{{\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} + a \cdot a} \]
      9. unpow-prod-downN/A

        \[\leadsto \color{blue}{{b}^{2} \cdot {\sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)}^{2}} + a \cdot a \]
      10. *-commutativeN/A

        \[\leadsto \color{blue}{{\sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)}^{2} \cdot {b}^{2}} + a \cdot a \]
      11. pow2N/A

        \[\leadsto {\sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)}^{2} \cdot \color{blue}{\left(b \cdot b\right)} + a \cdot a \]
      12. associate-*r*N/A

        \[\leadsto \color{blue}{\left({\sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)}^{2} \cdot b\right) \cdot b} + a \cdot a \]
    7. Applied rewrites74.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left({\sin \left(\frac{angle}{180} \cdot \pi\right)}^{2} \cdot b, b, a \cdot a\right)} \]
    8. Taylor expanded in angle around 0

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1}{32400} \cdot \left({angle}^{2} \cdot \left(b \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)}, b, a \cdot a\right) \]
    9. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{32400} \cdot {angle}^{2}\right) \cdot \color{blue}{\left(b \cdot {\mathsf{PI}\left(\right)}^{2}\right)}, b, a \cdot a\right) \]
      2. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{32400} \cdot {angle}^{2}\right) \cdot \color{blue}{\left(b \cdot {\mathsf{PI}\left(\right)}^{2}\right)}, b, a \cdot a\right) \]
      3. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{32400} \cdot {angle}^{2}\right) \cdot \left(\color{blue}{b} \cdot {\mathsf{PI}\left(\right)}^{2}\right), b, a \cdot a\right) \]
      4. pow2N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{32400} \cdot \left(angle \cdot angle\right)\right) \cdot \left(b \cdot {\mathsf{PI}\left(\right)}^{2}\right), b, a \cdot a\right) \]
      5. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{32400} \cdot \left(angle \cdot angle\right)\right) \cdot \left(b \cdot {\mathsf{PI}\left(\right)}^{2}\right), b, a \cdot a\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{32400} \cdot \left(angle \cdot angle\right)\right) \cdot \left({\mathsf{PI}\left(\right)}^{2} \cdot \color{blue}{b}\right), b, a \cdot a\right) \]
      7. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{32400} \cdot \left(angle \cdot angle\right)\right) \cdot \left({\mathsf{PI}\left(\right)}^{2} \cdot \color{blue}{b}\right), b, a \cdot a\right) \]
      8. unpow2N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{32400} \cdot \left(angle \cdot angle\right)\right) \cdot \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot b\right), b, a \cdot a\right) \]
      9. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{32400} \cdot \left(angle \cdot angle\right)\right) \cdot \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot b\right), b, a \cdot a\right) \]
      10. lift-PI.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{32400} \cdot \left(angle \cdot angle\right)\right) \cdot \left(\left(\pi \cdot \mathsf{PI}\left(\right)\right) \cdot b\right), b, a \cdot a\right) \]
      11. lift-PI.f6470.5

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(3.08641975308642 \cdot 10^{-5} \cdot \left(angle \cdot angle\right)\right) \cdot \left(\left(\pi \cdot \pi\right) \cdot b\right)}, b, a \cdot a\right) \]
    11. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{32400} \cdot \left(angle \cdot angle\right)\right) \cdot \color{blue}{\left(\left(\pi \cdot \pi\right) \cdot b\right)}, b, a \cdot a\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\left(\left(\pi \cdot \pi\right) \cdot b\right) \cdot \color{blue}{\left(\frac{1}{32400} \cdot \left(angle \cdot angle\right)\right)}, b, a \cdot a\right) \]
      3. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\left(\pi \cdot \pi\right) \cdot b\right) \cdot \left(\color{blue}{\frac{1}{32400}} \cdot \left(angle \cdot angle\right)\right), b, a \cdot a\right) \]
      4. lift-PI.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\left(\mathsf{PI}\left(\right) \cdot \pi\right) \cdot b\right) \cdot \left(\frac{1}{32400} \cdot \left(angle \cdot angle\right)\right), b, a \cdot a\right) \]
      5. lift-PI.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot b\right) \cdot \left(\frac{1}{32400} \cdot \left(angle \cdot angle\right)\right), b, a \cdot a\right) \]
      6. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot b\right) \cdot \left(\frac{1}{32400} \cdot \left(angle \cdot angle\right)\right), b, a \cdot a\right) \]
      7. pow2N/A

        \[\leadsto \mathsf{fma}\left(\left({\mathsf{PI}\left(\right)}^{2} \cdot b\right) \cdot \left(\frac{1}{32400} \cdot \left(angle \cdot angle\right)\right), b, a \cdot a\right) \]
      8. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\left(b \cdot {\mathsf{PI}\left(\right)}^{2}\right) \cdot \left(\color{blue}{\frac{1}{32400}} \cdot \left(angle \cdot angle\right)\right), b, a \cdot a\right) \]
      9. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(b \cdot {\mathsf{PI}\left(\right)}^{2}\right) \cdot \color{blue}{\left(\frac{1}{32400} \cdot \left(angle \cdot angle\right)\right)}, b, a \cdot a\right) \]
      10. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\left({\mathsf{PI}\left(\right)}^{2} \cdot b\right) \cdot \left(\color{blue}{\frac{1}{32400}} \cdot \left(angle \cdot angle\right)\right), b, a \cdot a\right) \]
      11. pow2N/A

        \[\leadsto \mathsf{fma}\left(\left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot b\right) \cdot \left(\frac{1}{32400} \cdot \left(angle \cdot angle\right)\right), b, a \cdot a\right) \]
      12. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot b\right) \cdot \left(\frac{1}{32400} \cdot \left(angle \cdot angle\right)\right), b, a \cdot a\right) \]
      13. lift-PI.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\left(\pi \cdot \mathsf{PI}\left(\right)\right) \cdot b\right) \cdot \left(\frac{1}{32400} \cdot \left(angle \cdot angle\right)\right), b, a \cdot a\right) \]
      14. lift-PI.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\left(\pi \cdot \pi\right) \cdot b\right) \cdot \left(\frac{1}{32400} \cdot \left(angle \cdot angle\right)\right), b, a \cdot a\right) \]
      15. lift-*.f6470.5

        \[\leadsto \mathsf{fma}\left(\left(\left(\pi \cdot \pi\right) \cdot b\right) \cdot \left(\color{blue}{3.08641975308642 \cdot 10^{-5}} \cdot \left(angle \cdot angle\right)\right), b, a \cdot a\right) \]
      16. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\left(\pi \cdot \pi\right) \cdot b\right) \cdot \left(\frac{1}{32400} \cdot \color{blue}{\left(angle \cdot angle\right)}\right), b, a \cdot a\right) \]
      17. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\left(\pi \cdot \pi\right) \cdot b\right) \cdot \left(\frac{1}{32400} \cdot \left(angle \cdot \color{blue}{angle}\right)\right), b, a \cdot a\right) \]
      18. associate-*r*N/A

        \[\leadsto \mathsf{fma}\left(\left(\left(\pi \cdot \pi\right) \cdot b\right) \cdot \left(\left(\frac{1}{32400} \cdot angle\right) \cdot \color{blue}{angle}\right), b, a \cdot a\right) \]
      19. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\left(\pi \cdot \pi\right) \cdot b\right) \cdot \left(\left(\frac{1}{32400} \cdot angle\right) \cdot \color{blue}{angle}\right), b, a \cdot a\right) \]
      20. lower-*.f6470.5

        \[\leadsto \mathsf{fma}\left(\left(\left(\pi \cdot \pi\right) \cdot b\right) \cdot \left(\left(3.08641975308642 \cdot 10^{-5} \cdot angle\right) \cdot angle\right), b, a \cdot a\right) \]
    12. Applied rewrites70.5%

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

Alternative 9: 72.5% accurate, 10.4× speedup?

\[\begin{array}{l} b_m = \left|b\right| \\ \begin{array}{l} \mathbf{if}\;b\_m \leq 7.6 \cdot 10^{-96}:\\ \;\;\;\;a \cdot a\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\left(3.08641975308642 \cdot 10^{-5} \cdot \left(angle \cdot angle\right)\right) \cdot \left(\left(\pi \cdot \pi\right) \cdot b\_m\right), b\_m, a \cdot a\right)\\ \end{array} \end{array} \]
b_m = (fabs.f64 b)
(FPCore (a b_m angle)
 :precision binary64
 (if (<= b_m 7.6e-96)
   (* a a)
   (fma
    (* (* 3.08641975308642e-5 (* angle angle)) (* (* PI PI) b_m))
    b_m
    (* a a))))
b_m = fabs(b);
double code(double a, double b_m, double angle) {
	double tmp;
	if (b_m <= 7.6e-96) {
		tmp = a * a;
	} else {
		tmp = fma(((3.08641975308642e-5 * (angle * angle)) * ((((double) M_PI) * ((double) M_PI)) * b_m)), b_m, (a * a));
	}
	return tmp;
}
b_m = abs(b)
function code(a, b_m, angle)
	tmp = 0.0
	if (b_m <= 7.6e-96)
		tmp = Float64(a * a);
	else
		tmp = fma(Float64(Float64(3.08641975308642e-5 * Float64(angle * angle)) * Float64(Float64(pi * pi) * b_m)), b_m, Float64(a * a));
	end
	return tmp
end
b_m = N[Abs[b], $MachinePrecision]
code[a_, b$95$m_, angle_] := If[LessEqual[b$95$m, 7.6e-96], N[(a * a), $MachinePrecision], N[(N[(N[(3.08641975308642e-5 * N[(angle * angle), $MachinePrecision]), $MachinePrecision] * N[(N[(Pi * Pi), $MachinePrecision] * b$95$m), $MachinePrecision]), $MachinePrecision] * b$95$m + N[(a * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
b_m = \left|b\right|

\\
\begin{array}{l}
\mathbf{if}\;b\_m \leq 7.6 \cdot 10^{-96}:\\
\;\;\;\;a \cdot a\\

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


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

    1. Initial program 77.6%

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

      \[\leadsto \color{blue}{{a}^{2}} \]
    4. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto a \cdot \color{blue}{a} \]
      2. lower-*.f6476.4

        \[\leadsto a \cdot \color{blue}{a} \]
    5. Applied rewrites76.4%

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

    if 7.6000000000000001e-96 < b

    1. Initial program 79.9%

      \[{\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. Add Preprocessing
    3. Taylor expanded in angle around 0

      \[\leadsto \color{blue}{{a}^{2}} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
    4. Step-by-step derivation
      1. unpow2N/A

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

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

      \[\leadsto \color{blue}{a \cdot a} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
    6. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \color{blue}{a \cdot a + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2}} \]
      2. lift-pow.f64N/A

        \[\leadsto a \cdot a + \color{blue}{{\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2}} \]
      3. lift-*.f64N/A

        \[\leadsto a \cdot a + {\color{blue}{\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}}^{2} \]
      4. lift-sin.f64N/A

        \[\leadsto a \cdot a + {\left(b \cdot \color{blue}{\sin \left(\pi \cdot \frac{angle}{180}\right)}\right)}^{2} \]
      5. lift-PI.f64N/A

        \[\leadsto a \cdot a + {\left(b \cdot \sin \left(\color{blue}{\mathsf{PI}\left(\right)} \cdot \frac{angle}{180}\right)\right)}^{2} \]
      6. lift-*.f64N/A

        \[\leadsto a \cdot a + {\left(b \cdot \sin \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)}\right)}^{2} \]
      7. lift-/.f64N/A

        \[\leadsto a \cdot a + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \color{blue}{\frac{angle}{180}}\right)\right)}^{2} \]
      8. +-commutativeN/A

        \[\leadsto \color{blue}{{\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} + a \cdot a} \]
      9. unpow-prod-downN/A

        \[\leadsto \color{blue}{{b}^{2} \cdot {\sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)}^{2}} + a \cdot a \]
      10. *-commutativeN/A

        \[\leadsto \color{blue}{{\sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)}^{2} \cdot {b}^{2}} + a \cdot a \]
      11. pow2N/A

        \[\leadsto {\sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)}^{2} \cdot \color{blue}{\left(b \cdot b\right)} + a \cdot a \]
      12. associate-*r*N/A

        \[\leadsto \color{blue}{\left({\sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)}^{2} \cdot b\right) \cdot b} + a \cdot a \]
    7. Applied rewrites74.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left({\sin \left(\frac{angle}{180} \cdot \pi\right)}^{2} \cdot b, b, a \cdot a\right)} \]
    8. Taylor expanded in angle around 0

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1}{32400} \cdot \left({angle}^{2} \cdot \left(b \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)}, b, a \cdot a\right) \]
    9. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{32400} \cdot {angle}^{2}\right) \cdot \color{blue}{\left(b \cdot {\mathsf{PI}\left(\right)}^{2}\right)}, b, a \cdot a\right) \]
      2. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{32400} \cdot {angle}^{2}\right) \cdot \color{blue}{\left(b \cdot {\mathsf{PI}\left(\right)}^{2}\right)}, b, a \cdot a\right) \]
      3. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{32400} \cdot {angle}^{2}\right) \cdot \left(\color{blue}{b} \cdot {\mathsf{PI}\left(\right)}^{2}\right), b, a \cdot a\right) \]
      4. pow2N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{32400} \cdot \left(angle \cdot angle\right)\right) \cdot \left(b \cdot {\mathsf{PI}\left(\right)}^{2}\right), b, a \cdot a\right) \]
      5. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{32400} \cdot \left(angle \cdot angle\right)\right) \cdot \left(b \cdot {\mathsf{PI}\left(\right)}^{2}\right), b, a \cdot a\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{32400} \cdot \left(angle \cdot angle\right)\right) \cdot \left({\mathsf{PI}\left(\right)}^{2} \cdot \color{blue}{b}\right), b, a \cdot a\right) \]
      7. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{32400} \cdot \left(angle \cdot angle\right)\right) \cdot \left({\mathsf{PI}\left(\right)}^{2} \cdot \color{blue}{b}\right), b, a \cdot a\right) \]
      8. unpow2N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{32400} \cdot \left(angle \cdot angle\right)\right) \cdot \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot b\right), b, a \cdot a\right) \]
      9. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{32400} \cdot \left(angle \cdot angle\right)\right) \cdot \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot b\right), b, a \cdot a\right) \]
      10. lift-PI.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{32400} \cdot \left(angle \cdot angle\right)\right) \cdot \left(\left(\pi \cdot \mathsf{PI}\left(\right)\right) \cdot b\right), b, a \cdot a\right) \]
      11. lift-PI.f6470.5

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

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

Alternative 10: 57.1% accurate, 74.7× speedup?

\[\begin{array}{l} b_m = \left|b\right| \\ a \cdot a \end{array} \]
b_m = (fabs.f64 b)
(FPCore (a b_m angle) :precision binary64 (* a a))
b_m = fabs(b);
double code(double a, double b_m, double angle) {
	return a * a;
}
b_m =     private
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(a, b_m, angle)
use fmin_fmax_functions
    real(8), intent (in) :: a
    real(8), intent (in) :: b_m
    real(8), intent (in) :: angle
    code = a * a
end function
b_m = Math.abs(b);
public static double code(double a, double b_m, double angle) {
	return a * a;
}
b_m = math.fabs(b)
def code(a, b_m, angle):
	return a * a
b_m = abs(b)
function code(a, b_m, angle)
	return Float64(a * a)
end
b_m = abs(b);
function tmp = code(a, b_m, angle)
	tmp = a * a;
end
b_m = N[Abs[b], $MachinePrecision]
code[a_, b$95$m_, angle_] := N[(a * a), $MachinePrecision]
\begin{array}{l}
b_m = \left|b\right|

\\
a \cdot a
\end{array}
Derivation
  1. Initial program 79.1%

    \[{\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. Add Preprocessing
  3. Taylor expanded in angle around 0

    \[\leadsto \color{blue}{{a}^{2}} \]
  4. Step-by-step derivation
    1. unpow2N/A

      \[\leadsto a \cdot \color{blue}{a} \]
    2. lower-*.f6457.1

      \[\leadsto a \cdot \color{blue}{a} \]
  5. Applied rewrites57.1%

    \[\leadsto \color{blue}{a \cdot a} \]
  6. Add Preprocessing

Reproduce

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