ab-angle->ABCF C

Percentage Accurate: 79.4% → 79.4%
Time: 16.0s
Alternatives: 12
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 12 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.4% 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.4% accurate, 1.6× speedup?

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

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

    \[{\left(a \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
  2. 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-*.f6481.4

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

    \[\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. rem-square-sqrtN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto a \cdot a + {\left(b \cdot \sin \left(\color{blue}{\left(\sqrt{\pi \cdot \sqrt{\pi}} \cdot \sqrt{\sqrt{\pi}}\right)} \cdot \frac{angle}{180}\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}{\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 81.0%

    \[{\left(a \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
  2. 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-*.f6481.4

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

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

      \[\leadsto a \cdot a + {\left(b \cdot \sin \color{blue}{\left(\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. 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} \]
    4. 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} \]
    5. 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} \]
    6. lower-/.f6481.4

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

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

Alternative 3: 79.4% accurate, 1.9× speedup?

\[\begin{array}{l} \\ a \cdot a + {\left(b \cdot \sin \left(\pi \cdot \frac{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(pi * Float64(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[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

    \[{\left(a \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
  2. 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-*.f6481.4

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

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

Alternative 4: 79.4% accurate, 2.0× speedup?

\[\begin{array}{l} \\ a \cdot a + {\left(b \cdot \sin \left(\left(angle \cdot \pi\right) \cdot 0.005555555555555556\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(Float64(angle * 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[(N[(angle * Pi), $MachinePrecision] * 0.005555555555555556), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

    \[{\left(a \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
  2. 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-*.f6481.4

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

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

      \[\leadsto a \cdot a + {\left(b \cdot \sin \color{blue}{\left(\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. div-invN/A

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

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

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

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

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

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

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

Alternative 5: 76.3% accurate, 2.7× speedup?

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

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

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


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

    1. Initial program 88.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-*.f6489.1

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

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

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

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

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

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

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

    if 1e-3 < (/.f64 angle #s(literal 180 binary64))

    1. Initial program 60.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-*.f6461.5

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

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

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

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

Alternative 6: 76.3% accurate, 2.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\frac{angle}{180} \leq 0.001:\\
\;\;\;\;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(\mathsf{fma}\left(\cos \left(\left(angle \cdot \pi\right) \cdot 0.011111111111111112\right), -0.5, 0.5\right), b \cdot b, a \cdot a\right)\\


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

    1. Initial program 88.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-*.f6489.1

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

      \[\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. rem-square-sqrtN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto a \cdot a + {\left(b \cdot \left(angle \cdot \left(\color{blue}{\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} \]
      10. 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} \]
      11. 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} \]
      12. 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} \]
      13. 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} \]
    10. Applied rewrites83.7%

      \[\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 1e-3 < (/.f64 angle #s(literal 180 binary64))

    1. Initial program 60.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-*.f6461.5

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

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

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

\\
\begin{array}{l}
\mathbf{if}\;\frac{angle}{180} \leq 2 \cdot 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(\cos \left(\left(angle \cdot \pi\right) \cdot 0.011111111111111112\right), -0.5, 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)) < 2.00000000000000016e-5

    1. Initial program 88.7%

      \[{\left(a \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
    2. 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-*.f6489.1

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

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

        \[\leadsto a \cdot a + {\left(b \cdot \sin \color{blue}{\left(\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. 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} \]
      4. 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} \]
      5. 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} \]
      6. lower-/.f6489.1

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

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

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

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

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

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

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

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

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

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

    1. Initial program 61.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-*.f6462.0

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{angle}{180} \leq 2 \cdot 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(\cos \left(\left(angle \cdot \pi\right) \cdot 0.011111111111111112\right), -0.5, 0.5\right), b, a \cdot a\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 67.0% accurate, 3.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 3.2 \cdot 10^{-110}:\\ \;\;\;\;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-110)
   (* 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-110) {
		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-110) {
		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-110:
		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-110)
		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-110)
		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-110], 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^{-110}:\\
\;\;\;\;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.20000000000000028e-110

    1. Initial program 78.9%

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

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

        \[\leadsto \color{blue}{a \cdot a} \]
      2. lower-*.f6462.6

        \[\leadsto \color{blue}{a \cdot a} \]
    5. Applied rewrites62.6%

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

    if 3.20000000000000028e-110 < b

    1. Initial program 85.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-*.f6485.3

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

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

        \[\leadsto a \cdot a + {\left(b \cdot \sin \color{blue}{\left(\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. 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} \]
      4. 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} \]
      5. 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} \]
      6. lower-/.f6485.2

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 3.2 \cdot 10^{-110}:\\ \;\;\;\;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: 67.0% accurate, 10.0× speedup?

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

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

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


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

    1. Initial program 78.9%

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

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

        \[\leadsto \color{blue}{a \cdot a} \]
      2. lower-*.f6462.6

        \[\leadsto \color{blue}{a \cdot a} \]
    5. Applied rewrites62.6%

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

    if 3.20000000000000028e-110 < b

    1. Initial program 85.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-*.f6485.3

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      Alternative 10: 65.1% accurate, 10.0× speedup?

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

        1. Initial program 78.9%

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

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

            \[\leadsto \color{blue}{a \cdot a} \]
          2. lower-*.f6462.6

            \[\leadsto \color{blue}{a \cdot a} \]
        5. Applied rewrites62.6%

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

        if 3.20000000000000028e-110 < b

        1. Initial program 85.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-*.f6485.3

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        Alternative 11: 60.6% accurate, 12.1× speedup?

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

          1. Initial program 77.9%

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

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

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

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

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

          if 2.7e160 < b

          1. Initial program 99.7%

            \[{\left(a \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
          2. 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.7

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

            \[\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. rem-square-sqrtN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \left(b \cdot b\right) \cdot {\sin \left(\frac{1}{180} \cdot \color{blue}{\left(angle \cdot \mathsf{PI}\left(\right)\right)}\right)}^{2} \]
            12. lower-PI.f6455.0

              \[\leadsto \left(b \cdot b\right) \cdot {\sin \left(0.005555555555555556 \cdot \left(angle \cdot \color{blue}{\pi}\right)\right)}^{2} \]
          10. Applied rewrites55.0%

            \[\leadsto \color{blue}{\left(b \cdot b\right) \cdot {\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2}} \]
          11. Taylor expanded in angle around 0

            \[\leadsto \left(b \cdot b\right) \cdot \left(\frac{1}{32400} \cdot \color{blue}{\left({angle}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)}\right) \]
          12. Step-by-step derivation
            1. Applied rewrites57.7%

              \[\leadsto \left(b \cdot b\right) \cdot \left(angle \cdot \color{blue}{\left(angle \cdot \left(\left(\pi \cdot \pi\right) \cdot 3.08641975308642 \cdot 10^{-5}\right)\right)}\right) \]
          13. Recombined 2 regimes into one program.
          14. Add Preprocessing

          Alternative 12: 57.5% 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 81.0%

            \[{\left(a \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
          2. 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.1

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

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

          Reproduce

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