ab-angle->ABCF C

Percentage Accurate: 79.6% → 79.5%
Time: 15.6s
Alternatives: 13
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}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 13 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 79.6% accurate, 1.0× speedup?

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

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

Alternative 1: 79.5% accurate, 1.9× speedup?

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

\\
a \cdot a + {\left(b \cdot \sin \left(\frac{\pi}{\frac{180}{angle}}\right)\right)}^{2}
\end{array}
Derivation
  1. Initial program 78.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(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
  4. Step-by-step derivation
    1. unpow2N/A

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

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

    \[\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. clear-numN/A

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

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

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

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

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

Alternative 2: 79.4% accurate, 1.9× speedup?

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

\\
a \cdot a + {\left(b \cdot \sin \left(\frac{\pi \cdot angle}{180}\right)\right)}^{2}
\end{array}
Derivation
  1. Initial program 78.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(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
  4. Step-by-step derivation
    1. unpow2N/A

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

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

    \[\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. 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} \]
    3. lower-/.f64N/A

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

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

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

Alternative 3: 79.5% accurate, 2.0× speedup?

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

\\
a \cdot a + {\left(b \cdot \sin \left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right)\right)}^{2}
\end{array}
Derivation
  1. Initial program 78.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(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
  4. Step-by-step derivation
    1. unpow2N/A

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

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

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

    \[\leadsto a \cdot a + {\color{blue}{\left({\left(\mathsf{fma}\left(\cos \left(\left(\pi \cdot angle\right) \cdot 0.011111111111111112\right), -0.5, 0.5\right) \cdot \left(b \cdot b\right)\right)}^{0.5}\right)}}^{2} \]
  7. Applied rewrites78.8%

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

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

Alternative 4: 79.6% accurate, 2.0× speedup?

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

\\
a \cdot a + {\left(b \cdot \sin \left(angle \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right)}^{2}
\end{array}
Derivation
  1. Initial program 78.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(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
  4. Step-by-step derivation
    1. unpow2N/A

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

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

    \[\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 \left(\mathsf{PI}\left(\right) \cdot \color{blue}{\frac{angle}{180}}\right)\right)}^{2} \]
    3. 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} \]
    4. lift-sin.f64N/A

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

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

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

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

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

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

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

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

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

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

      \[\leadsto a \cdot a + {\left(\sin \left(angle \cdot \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \frac{1}{180}\right)}\right) \cdot b\right)}^{2} \]
    15. lower-*.f6478.8

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

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

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

Alternative 5: 76.3% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{angle}{180} \leq 10^{-5}:\\ \;\;\;\;a \cdot a + {\left(b \cdot \left(angle \cdot \left(\pi \cdot \mathsf{fma}\left(\left(angle \cdot angle\right) \cdot -2.8577960676726107 \cdot 10^{-8}, \pi \cdot \pi, 0.005555555555555556\right)\right)\right)\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(b \cdot \mathsf{fma}\left(-0.5, \cos \left(\pi \cdot \left(angle \cdot 0.011111111111111112\right)\right), 0.5\right), b, a \cdot a\right)\\ \end{array} \end{array} \]
(FPCore (a b angle)
 :precision binary64
 (if (<= (/ angle 180.0) 1e-5)
   (+
    (* a a)
    (pow
     (*
      b
      (*
       angle
       (*
        PI
        (fma
         (* (* angle angle) -2.8577960676726107e-8)
         (* PI PI)
         0.005555555555555556))))
     2.0))
   (fma
    (* b (fma -0.5 (cos (* PI (* angle 0.011111111111111112))) 0.5))
    b
    (* a a))))
double code(double a, double b, double angle) {
	double tmp;
	if ((angle / 180.0) <= 1e-5) {
		tmp = (a * a) + pow((b * (angle * (((double) M_PI) * fma(((angle * angle) * -2.8577960676726107e-8), (((double) M_PI) * ((double) M_PI)), 0.005555555555555556)))), 2.0);
	} else {
		tmp = fma((b * fma(-0.5, cos((((double) M_PI) * (angle * 0.011111111111111112))), 0.5)), b, (a * a));
	}
	return tmp;
}
function code(a, b, angle)
	tmp = 0.0
	if (Float64(angle / 180.0) <= 1e-5)
		tmp = Float64(Float64(a * a) + (Float64(b * Float64(angle * Float64(pi * fma(Float64(Float64(angle * angle) * -2.8577960676726107e-8), Float64(pi * pi), 0.005555555555555556)))) ^ 2.0));
	else
		tmp = fma(Float64(b * fma(-0.5, cos(Float64(pi * Float64(angle * 0.011111111111111112))), 0.5)), b, Float64(a * a));
	end
	return tmp
end
code[a_, b_, angle_] := If[LessEqual[N[(angle / 180.0), $MachinePrecision], 1e-5], N[(N[(a * a), $MachinePrecision] + N[Power[N[(b * N[(angle * N[(Pi * N[(N[(N[(angle * angle), $MachinePrecision] * -2.8577960676726107e-8), $MachinePrecision] * N[(Pi * Pi), $MachinePrecision] + 0.005555555555555556), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(N[(b * N[(-0.5 * N[Cos[N[(Pi * N[(angle * 0.011111111111111112), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision] * b + N[(a * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\frac{angle}{180} \leq 10^{-5}:\\
\;\;\;\;a \cdot a + {\left(b \cdot \left(angle \cdot \left(\pi \cdot \mathsf{fma}\left(\left(angle \cdot angle\right) \cdot -2.8577960676726107 \cdot 10^{-8}, \pi \cdot \pi, 0.005555555555555556\right)\right)\right)\right)}^{2}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 angle #s(literal 180 binary64)) < 1.00000000000000008e-5

    1. Initial program 87.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(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    4. Step-by-step derivation
      1. unpow2N/A

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

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

      \[\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 + {\left(b \cdot \color{blue}{\left(angle \cdot \left(\frac{-1}{34992000} \cdot \left({angle}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right) + \frac{1}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}\right)}^{2} \]
    7. Step-by-step derivation
      1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

        \[\leadsto a \cdot a + {\left(b \cdot \left(angle \cdot \left(\color{blue}{\left(\left(\frac{-1}{34992000} \cdot {angle}^{2}\right) \cdot {\mathsf{PI}\left(\right)}^{2}\right) \cdot \mathsf{PI}\left(\right)} + \frac{1}{180} \cdot \mathsf{PI}\left(\right)\right)\right)\right)}^{2} \]
      12. distribute-rgt-outN/A

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

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

      \[\leadsto a \cdot a + {\left(b \cdot \color{blue}{\left(angle \cdot \left(\pi \cdot \mathsf{fma}\left(\left(angle \cdot angle\right) \cdot -2.8577960676726107 \cdot 10^{-8}, \pi \cdot \pi, 0.005555555555555556\right)\right)\right)}\right)}^{2} \]

    if 1.00000000000000008e-5 < (/.f64 angle #s(literal 180 binary64))

    1. Initial program 57.3%

      \[{\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(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    4. Step-by-step derivation
      1. unpow2N/A

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

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

      \[\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. 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} \]
      3. lower-/.f64N/A

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

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

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

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

Alternative 6: 76.3% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{angle}{180} \leq 10^{-5}:\\ \;\;\;\;a \cdot a + {\left(angle \cdot \left(b \cdot \left(\pi \cdot \mathsf{fma}\left(\left(angle \cdot angle\right) \cdot -2.8577960676726107 \cdot 10^{-8}, \pi \cdot \pi, 0.005555555555555556\right)\right)\right)\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(b \cdot \mathsf{fma}\left(-0.5, \cos \left(\pi \cdot \left(angle \cdot 0.011111111111111112\right)\right), 0.5\right), b, a \cdot a\right)\\ \end{array} \end{array} \]
(FPCore (a b angle)
 :precision binary64
 (if (<= (/ angle 180.0) 1e-5)
   (+
    (* a a)
    (pow
     (*
      angle
      (*
       b
       (*
        PI
        (fma
         (* (* angle angle) -2.8577960676726107e-8)
         (* PI PI)
         0.005555555555555556))))
     2.0))
   (fma
    (* b (fma -0.5 (cos (* PI (* angle 0.011111111111111112))) 0.5))
    b
    (* a a))))
double code(double a, double b, double angle) {
	double tmp;
	if ((angle / 180.0) <= 1e-5) {
		tmp = (a * a) + pow((angle * (b * (((double) M_PI) * fma(((angle * angle) * -2.8577960676726107e-8), (((double) M_PI) * ((double) M_PI)), 0.005555555555555556)))), 2.0);
	} else {
		tmp = fma((b * fma(-0.5, cos((((double) M_PI) * (angle * 0.011111111111111112))), 0.5)), b, (a * a));
	}
	return tmp;
}
function code(a, b, angle)
	tmp = 0.0
	if (Float64(angle / 180.0) <= 1e-5)
		tmp = Float64(Float64(a * a) + (Float64(angle * Float64(b * Float64(pi * fma(Float64(Float64(angle * angle) * -2.8577960676726107e-8), Float64(pi * pi), 0.005555555555555556)))) ^ 2.0));
	else
		tmp = fma(Float64(b * fma(-0.5, cos(Float64(pi * Float64(angle * 0.011111111111111112))), 0.5)), b, Float64(a * a));
	end
	return tmp
end
code[a_, b_, angle_] := If[LessEqual[N[(angle / 180.0), $MachinePrecision], 1e-5], N[(N[(a * a), $MachinePrecision] + N[Power[N[(angle * N[(b * N[(Pi * N[(N[(N[(angle * angle), $MachinePrecision] * -2.8577960676726107e-8), $MachinePrecision] * N[(Pi * Pi), $MachinePrecision] + 0.005555555555555556), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(N[(b * N[(-0.5 * N[Cos[N[(Pi * N[(angle * 0.011111111111111112), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision] * b + N[(a * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\frac{angle}{180} \leq 10^{-5}:\\
\;\;\;\;a \cdot a + {\left(angle \cdot \left(b \cdot \left(\pi \cdot \mathsf{fma}\left(\left(angle \cdot angle\right) \cdot -2.8577960676726107 \cdot 10^{-8}, \pi \cdot \pi, 0.005555555555555556\right)\right)\right)\right)}^{2}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 angle #s(literal 180 binary64)) < 1.00000000000000008e-5

    1. Initial program 87.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(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    4. Step-by-step derivation
      1. unpow2N/A

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

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

      \[\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}{34992000} \cdot \left({angle}^{2} \cdot \left(b \cdot {\mathsf{PI}\left(\right)}^{3}\right)\right) + \frac{1}{180} \cdot \left(b \cdot \mathsf{PI}\left(\right)\right)\right)\right)}}^{2} \]
    7. Step-by-step derivation
      1. *-commutativeN/A

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

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

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

        \[\leadsto a \cdot a + {\left(angle \cdot \color{blue}{\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)\right)\right)}\right)}^{2} \]
      5. lower-*.f64N/A

        \[\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)\right)\right)\right)}}^{2} \]
      6. *-commutativeN/A

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

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

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

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

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

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

      \[\leadsto a \cdot a + {\color{blue}{\left(angle \cdot \left(b \cdot \left(\pi \cdot \mathsf{fma}\left(\left(angle \cdot angle\right) \cdot -2.8577960676726107 \cdot 10^{-8}, \pi \cdot \pi, 0.005555555555555556\right)\right)\right)\right)}}^{2} \]

    if 1.00000000000000008e-5 < (/.f64 angle #s(literal 180 binary64))

    1. Initial program 57.3%

      \[{\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(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    4. Step-by-step derivation
      1. unpow2N/A

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

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

      \[\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. 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} \]
      3. lower-/.f64N/A

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

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

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

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

Alternative 7: 76.9% accurate, 3.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{angle}{180} \leq 10^{-5}:\\ \;\;\;\;a \cdot a + {\left(b \cdot \left(angle \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(b \cdot \mathsf{fma}\left(-0.5, \cos \left(\pi \cdot \left(angle \cdot 0.011111111111111112\right)\right), 0.5\right), b, a \cdot a\right)\\ \end{array} \end{array} \]
(FPCore (a b angle)
 :precision binary64
 (if (<= (/ angle 180.0) 1e-5)
   (+ (* a a) (pow (* b (* angle (* PI 0.005555555555555556))) 2.0))
   (fma
    (* b (fma -0.5 (cos (* PI (* angle 0.011111111111111112))) 0.5))
    b
    (* a a))))
double code(double a, double b, double angle) {
	double tmp;
	if ((angle / 180.0) <= 1e-5) {
		tmp = (a * a) + pow((b * (angle * (((double) M_PI) * 0.005555555555555556))), 2.0);
	} else {
		tmp = fma((b * fma(-0.5, cos((((double) M_PI) * (angle * 0.011111111111111112))), 0.5)), b, (a * a));
	}
	return tmp;
}
function code(a, b, angle)
	tmp = 0.0
	if (Float64(angle / 180.0) <= 1e-5)
		tmp = Float64(Float64(a * a) + (Float64(b * Float64(angle * Float64(pi * 0.005555555555555556))) ^ 2.0));
	else
		tmp = fma(Float64(b * fma(-0.5, cos(Float64(pi * Float64(angle * 0.011111111111111112))), 0.5)), b, Float64(a * a));
	end
	return tmp
end
code[a_, b_, angle_] := If[LessEqual[N[(angle / 180.0), $MachinePrecision], 1e-5], N[(N[(a * a), $MachinePrecision] + N[Power[N[(b * N[(angle * N[(Pi * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(N[(b * N[(-0.5 * N[Cos[N[(Pi * N[(angle * 0.011111111111111112), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision] * b + N[(a * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 angle #s(literal 180 binary64)) < 1.00000000000000008e-5

    1. Initial program 87.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(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    4. Step-by-step derivation
      1. unpow2N/A

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

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

      \[\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(\frac{1}{180} \cdot \left(angle \cdot \left(b \cdot \mathsf{PI}\left(\right)\right)\right)\right)}}^{2} \]
    7. Step-by-step derivation
      1. associate-*r*N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto a \cdot a + {\left(\left(angle \cdot \color{blue}{\left(\frac{1}{180} \cdot \mathsf{PI}\left(\right)\right)}\right) \cdot b\right)}^{2} \]
      11. lower-PI.f6483.1

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

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

    if 1.00000000000000008e-5 < (/.f64 angle #s(literal 180 binary64))

    1. Initial program 57.3%

      \[{\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(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    4. Step-by-step derivation
      1. unpow2N/A

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

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

      \[\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. 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} \]
      3. lower-/.f64N/A

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(b \cdot \mathsf{fma}\left(-0.5, \cos \left(\pi \cdot \left(angle \cdot 0.011111111111111112\right)\right), 0.5\right), b, a \cdot a\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification75.9%

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

Alternative 8: 66.4% accurate, 3.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.2 \cdot 10^{-9}:\\
\;\;\;\;a \cdot a\\

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


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

    1. Initial program 76.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 \color{blue}{a \cdot a} \]
      2. lower-*.f6461.0

        \[\leadsto \color{blue}{a \cdot a} \]
    5. Applied rewrites61.0%

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

    if 3.20000000000000012e-9 < b

    1. Initial program 83.2%

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

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

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

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

      \[\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(\frac{1}{180} \cdot \left(angle \cdot \left(b \cdot \mathsf{PI}\left(\right)\right)\right)\right)}}^{2} \]
    7. Step-by-step derivation
      1. associate-*r*N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto a \cdot a + {\left(\left(angle \cdot \color{blue}{\left(\frac{1}{180} \cdot \mathsf{PI}\left(\right)\right)}\right) \cdot b\right)}^{2} \]
      11. lower-PI.f6480.2

        \[\leadsto a \cdot a + {\left(\left(angle \cdot \left(0.005555555555555556 \cdot \color{blue}{\pi}\right)\right) \cdot b\right)}^{2} \]
    8. Applied rewrites80.2%

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

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

Alternative 9: 65.9% accurate, 10.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 3.2 \cdot 10^{-9}:\\ \;\;\;\;a \cdot a\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\left(\pi \cdot \pi\right) \cdot \left(b \cdot \left(angle \cdot \left(b \cdot angle\right)\right)\right), 3.08641975308642 \cdot 10^{-5}, a \cdot a\right)\\ \end{array} \end{array} \]
(FPCore (a b angle)
 :precision binary64
 (if (<= b 3.2e-9)
   (* a a)
   (fma
    (* (* PI PI) (* b (* angle (* b angle))))
    3.08641975308642e-5
    (* a a))))
double code(double a, double b, double angle) {
	double tmp;
	if (b <= 3.2e-9) {
		tmp = a * a;
	} else {
		tmp = fma(((((double) M_PI) * ((double) M_PI)) * (b * (angle * (b * angle)))), 3.08641975308642e-5, (a * a));
	}
	return tmp;
}
function code(a, b, angle)
	tmp = 0.0
	if (b <= 3.2e-9)
		tmp = Float64(a * a);
	else
		tmp = fma(Float64(Float64(pi * pi) * Float64(b * Float64(angle * Float64(b * angle)))), 3.08641975308642e-5, Float64(a * a));
	end
	return tmp
end
code[a_, b_, angle_] := If[LessEqual[b, 3.2e-9], N[(a * a), $MachinePrecision], N[(N[(N[(Pi * Pi), $MachinePrecision] * N[(b * N[(angle * N[(b * angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 3.08641975308642e-5 + N[(a * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.2 \cdot 10^{-9}:\\
\;\;\;\;a \cdot a\\

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


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

    1. Initial program 76.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 \color{blue}{a \cdot a} \]
      2. lower-*.f6461.0

        \[\leadsto \color{blue}{a \cdot a} \]
    5. Applied rewrites61.0%

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

    if 3.20000000000000012e-9 < b

    1. Initial program 83.2%

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

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

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

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

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

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

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

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

        \[\leadsto \left({angle}^{2} \cdot {b}^{2}\right) \cdot \left({\mathsf{PI}\left(\right)}^{2} \cdot \color{blue}{\left(\mathsf{neg}\left(\frac{-1}{32400}\right)\right)}\right) + {a}^{2} \]
      5. distribute-rgt-neg-inN/A

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left({angle}^{2} \cdot {b}^{2}, \mathsf{neg}\left(\frac{-1}{32400} \cdot {\mathsf{PI}\left(\right)}^{2}\right), {a}^{2}\right)} \]
    8. Applied rewrites61.3%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\left(b \cdot b\right) \cdot \left(angle \cdot angle\right)\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right), \frac{1}{32400}, a \cdot a\right)} \]
    10. Applied rewrites78.9%

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

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

Alternative 10: 65.9% accurate, 10.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 3.2 \cdot 10^{-9}:\\ \;\;\;\;a \cdot a\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(b, \left(angle \cdot \left(b \cdot angle\right)\right) \cdot \left(\left(\pi \cdot \pi\right) \cdot 3.08641975308642 \cdot 10^{-5}\right), a \cdot a\right)\\ \end{array} \end{array} \]
(FPCore (a b angle)
 :precision binary64
 (if (<= b 3.2e-9)
   (* a a)
   (fma
    b
    (* (* angle (* b angle)) (* (* PI PI) 3.08641975308642e-5))
    (* a a))))
double code(double a, double b, double angle) {
	double tmp;
	if (b <= 3.2e-9) {
		tmp = a * a;
	} else {
		tmp = fma(b, ((angle * (b * angle)) * ((((double) M_PI) * ((double) M_PI)) * 3.08641975308642e-5)), (a * a));
	}
	return tmp;
}
function code(a, b, angle)
	tmp = 0.0
	if (b <= 3.2e-9)
		tmp = Float64(a * a);
	else
		tmp = fma(b, Float64(Float64(angle * Float64(b * angle)) * Float64(Float64(pi * pi) * 3.08641975308642e-5)), Float64(a * a));
	end
	return tmp
end
code[a_, b_, angle_] := If[LessEqual[b, 3.2e-9], N[(a * a), $MachinePrecision], N[(b * N[(N[(angle * N[(b * angle), $MachinePrecision]), $MachinePrecision] * N[(N[(Pi * Pi), $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.2 \cdot 10^{-9}:\\
\;\;\;\;a \cdot a\\

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


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

    1. Initial program 76.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 \color{blue}{a \cdot a} \]
      2. lower-*.f6461.0

        \[\leadsto \color{blue}{a \cdot a} \]
    5. Applied rewrites61.0%

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

    if 3.20000000000000012e-9 < b

    1. Initial program 83.2%

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

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

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

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

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

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

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

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

        \[\leadsto \left({angle}^{2} \cdot {b}^{2}\right) \cdot \left({\mathsf{PI}\left(\right)}^{2} \cdot \color{blue}{\left(\mathsf{neg}\left(\frac{-1}{32400}\right)\right)}\right) + {a}^{2} \]
      5. distribute-rgt-neg-inN/A

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left({angle}^{2} \cdot {b}^{2}, \mathsf{neg}\left(\frac{-1}{32400} \cdot {\mathsf{PI}\left(\right)}^{2}\right), {a}^{2}\right)} \]
    8. Applied rewrites61.3%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\color{blue}{\left(b \cdot b\right)} \cdot \left(angle \cdot angle\right)\right) \cdot \left(\frac{1}{32400} \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right) + a \cdot a \]
      11. associate-*l*N/A

        \[\leadsto \color{blue}{\left(b \cdot \left(b \cdot \left(angle \cdot angle\right)\right)\right)} \cdot \left(\frac{1}{32400} \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right) + a \cdot a \]
      12. associate-*l*N/A

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(b, \left(b \cdot \left(angle \cdot angle\right)\right) \cdot \left(\frac{1}{32400} \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right), a \cdot a\right)} \]
    10. Applied rewrites78.8%

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

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

Alternative 11: 64.2% accurate, 10.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 3.2 \cdot 10^{-9}:\\ \;\;\;\;a \cdot a\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(b, b \cdot \left(angle \cdot \left(angle \cdot \left(\left(\pi \cdot \pi\right) \cdot 3.08641975308642 \cdot 10^{-5}\right)\right)\right), a \cdot a\right)\\ \end{array} \end{array} \]
(FPCore (a b angle)
 :precision binary64
 (if (<= b 3.2e-9)
   (* a a)
   (fma
    b
    (* b (* angle (* angle (* (* PI PI) 3.08641975308642e-5))))
    (* a a))))
double code(double a, double b, double angle) {
	double tmp;
	if (b <= 3.2e-9) {
		tmp = a * a;
	} else {
		tmp = fma(b, (b * (angle * (angle * ((((double) M_PI) * ((double) M_PI)) * 3.08641975308642e-5)))), (a * a));
	}
	return tmp;
}
function code(a, b, angle)
	tmp = 0.0
	if (b <= 3.2e-9)
		tmp = Float64(a * a);
	else
		tmp = fma(b, Float64(b * Float64(angle * Float64(angle * Float64(Float64(pi * pi) * 3.08641975308642e-5)))), Float64(a * a));
	end
	return tmp
end
code[a_, b_, angle_] := If[LessEqual[b, 3.2e-9], N[(a * a), $MachinePrecision], N[(b * N[(b * N[(angle * N[(angle * N[(N[(Pi * Pi), $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.2 \cdot 10^{-9}:\\
\;\;\;\;a \cdot a\\

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


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

    1. Initial program 76.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 \color{blue}{a \cdot a} \]
      2. lower-*.f6461.0

        \[\leadsto \color{blue}{a \cdot a} \]
    5. Applied rewrites61.0%

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

    if 3.20000000000000012e-9 < b

    1. Initial program 83.2%

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

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

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

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

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

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

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

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

        \[\leadsto \left({angle}^{2} \cdot {b}^{2}\right) \cdot \left({\mathsf{PI}\left(\right)}^{2} \cdot \color{blue}{\left(\mathsf{neg}\left(\frac{-1}{32400}\right)\right)}\right) + {a}^{2} \]
      5. distribute-rgt-neg-inN/A

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left({angle}^{2} \cdot {b}^{2}, \mathsf{neg}\left(\frac{-1}{32400} \cdot {\mathsf{PI}\left(\right)}^{2}\right), {a}^{2}\right)} \]
    8. Applied rewrites61.3%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(\left(b \cdot b\right) \cdot \left(angle \cdot angle\right)\right)} \cdot \left(\frac{1}{32400} \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right) + a \cdot a \]
      10. associate-*l*N/A

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

        \[\leadsto \color{blue}{\left(b \cdot b\right)} \cdot \left(\left(angle \cdot angle\right) \cdot \left(\frac{1}{32400} \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)\right) + a \cdot a \]
      12. associate-*l*N/A

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

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

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

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

Alternative 12: 62.3% accurate, 12.1× speedup?

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

\\
\begin{array}{l}
t_0 := angle \cdot \left(b \cdot \pi\right)\\
\mathbf{if}\;b \leq 7.2 \cdot 10^{+152}:\\
\;\;\;\;a \cdot a\\

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


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

    1. Initial program 74.5%

      \[{\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 \color{blue}{a \cdot a} \]
      2. lower-*.f6457.8

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

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

    if 7.1999999999999998e152 < b

    1. Initial program 99.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(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    4. Step-by-step derivation
      1. unpow2N/A

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

        \[\leadsto \color{blue}{a \cdot a} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
    5. Applied rewrites99.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 \color{blue}{\frac{1}{32400} \cdot \left({angle}^{2} \cdot \left({b}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right) + {a}^{2}} \]
    7. Step-by-step derivation
      1. *-commutativeN/A

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

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

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

        \[\leadsto \left({angle}^{2} \cdot {b}^{2}\right) \cdot \left({\mathsf{PI}\left(\right)}^{2} \cdot \color{blue}{\left(\mathsf{neg}\left(\frac{-1}{32400}\right)\right)}\right) + {a}^{2} \]
      5. distribute-rgt-neg-inN/A

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left({angle}^{2} \cdot {b}^{2}, \mathsf{neg}\left(\frac{-1}{32400} \cdot {\mathsf{PI}\left(\right)}^{2}\right), {a}^{2}\right)} \]
    8. Applied rewrites62.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(b \cdot b\right) \cdot \left(angle \cdot angle\right), 3.08641975308642 \cdot 10^{-5} \cdot \left(\pi \cdot \pi\right), a \cdot a\right)} \]
    9. Taylor expanded in b around inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(b \cdot b\right) \cdot \left(angle \cdot \left(angle \cdot \left(\frac{1}{32400} \cdot \left(\color{blue}{\mathsf{PI}\left(\right)} \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
      19. lower-PI.f6462.5

        \[\leadsto \left(b \cdot b\right) \cdot \left(angle \cdot \left(angle \cdot \left(3.08641975308642 \cdot 10^{-5} \cdot \left(\pi \cdot \color{blue}{\pi}\right)\right)\right)\right) \]
    11. Applied rewrites62.5%

      \[\leadsto \color{blue}{\left(b \cdot b\right) \cdot \left(angle \cdot \left(angle \cdot \left(3.08641975308642 \cdot 10^{-5} \cdot \left(\pi \cdot \pi\right)\right)\right)\right)} \]
    12. Taylor expanded in b around 0

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

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

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

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

        \[\leadsto \frac{1}{32400} \cdot \left(\left(angle \cdot angle\right) \cdot \left(\left(b \cdot b\right) \cdot \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)}\right)\right) \]
      5. unswap-sqrN/A

        \[\leadsto \frac{1}{32400} \cdot \left(\left(angle \cdot angle\right) \cdot \color{blue}{\left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot \left(b \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \]
      6. unswap-sqrN/A

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{32400} \cdot \left(\left(angle \cdot \left(\mathsf{PI}\left(\right) \cdot b\right)\right) \cdot \left(angle \cdot \color{blue}{\left(\mathsf{PI}\left(\right) \cdot b\right)}\right)\right) \]
      15. lower-PI.f6484.2

        \[\leadsto 3.08641975308642 \cdot 10^{-5} \cdot \left(\left(angle \cdot \left(\pi \cdot b\right)\right) \cdot \left(angle \cdot \left(\color{blue}{\pi} \cdot b\right)\right)\right) \]
    14. Applied rewrites84.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 7.2 \cdot 10^{+152}:\\ \;\;\;\;a \cdot a\\ \mathbf{else}:\\ \;\;\;\;3.08641975308642 \cdot 10^{-5} \cdot \left(\left(angle \cdot \left(b \cdot \pi\right)\right) \cdot \left(angle \cdot \left(b \cdot \pi\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 55.9% accurate, 74.7× speedup?

\[\begin{array}{l} \\ a \cdot a \end{array} \]
(FPCore (a b angle) :precision binary64 (* a a))
double code(double a, double b, double angle) {
	return a * a;
}
real(8) function code(a, b, angle)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: angle
    code = a * a
end function
public static double code(double a, double b, double angle) {
	return a * a;
}
def code(a, b, angle):
	return a * a
function code(a, b, angle)
	return Float64(a * a)
end
function tmp = code(a, b, angle)
	tmp = a * a;
end
code[a_, b_, angle_] := N[(a * a), $MachinePrecision]
\begin{array}{l}

\\
a \cdot a
\end{array}
Derivation
  1. Initial program 78.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 \color{blue}{a \cdot a} \]
    2. lower-*.f6454.1

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

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

Reproduce

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