ab-angle->ABCF C

Percentage Accurate: 80.1% → 80.2%
Time: 20.6s
Alternatives: 8
Speedup: 1.3×

Specification

?
\[\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} \]
(FPCore (a b angle)
  :precision binary64
  (let* ((t_0 (* PI (/ angle 180))))
  (+ (pow (* a (cos t_0)) 2) (pow (* b (sin t_0)) 2))))
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), $MachinePrecision]), $MachinePrecision]}, N[(N[Power[N[(a * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision], 2], $MachinePrecision] + N[Power[N[(b * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision], 2], $MachinePrecision]), $MachinePrecision]]
\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}

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 8 alternatives:

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

Initial Program: 80.1% accurate, 1.0× speedup?

\[\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} \]
(FPCore (a b angle)
  :precision binary64
  (let* ((t_0 (* PI (/ angle 180))))
  (+ (pow (* a (cos t_0)) 2) (pow (* b (sin t_0)) 2))))
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), $MachinePrecision]), $MachinePrecision]}, N[(N[Power[N[(a * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision], 2], $MachinePrecision] + N[Power[N[(b * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision], 2], $MachinePrecision]), $MachinePrecision]]
\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}

Alternative 1: 80.2% accurate, 1.2× speedup?

\[\left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\frac{1}{90} \cdot \left(\pi \cdot \left|angle\right|\right) - \frac{-1}{2} \cdot \pi\right)\right) \cdot \left(a \cdot a\right) + {\left(b \cdot \sin \left(\left(\frac{1}{180} \cdot \pi\right) \cdot \left|angle\right|\right)\right)}^{2} \]
(FPCore (a b angle)
  :precision binary64
  (+
 (*
  (+ 1/2 (* 1/2 (sin (- (* 1/90 (* PI (fabs angle))) (* -1/2 PI)))))
  (* a a))
 (pow (* b (sin (* (* 1/180 PI) (fabs angle)))) 2)))
double code(double a, double b, double angle) {
	return ((0.5 + (0.5 * sin(((0.011111111111111112 * (((double) M_PI) * fabs(angle))) - (-0.5 * ((double) M_PI)))))) * (a * a)) + pow((b * sin(((0.005555555555555556 * ((double) M_PI)) * fabs(angle)))), 2.0);
}
public static double code(double a, double b, double angle) {
	return ((0.5 + (0.5 * Math.sin(((0.011111111111111112 * (Math.PI * Math.abs(angle))) - (-0.5 * Math.PI))))) * (a * a)) + Math.pow((b * Math.sin(((0.005555555555555556 * Math.PI) * Math.abs(angle)))), 2.0);
}
def code(a, b, angle):
	return ((0.5 + (0.5 * math.sin(((0.011111111111111112 * (math.pi * math.fabs(angle))) - (-0.5 * math.pi))))) * (a * a)) + math.pow((b * math.sin(((0.005555555555555556 * math.pi) * math.fabs(angle)))), 2.0)
function code(a, b, angle)
	return Float64(Float64(Float64(0.5 + Float64(0.5 * sin(Float64(Float64(0.011111111111111112 * Float64(pi * abs(angle))) - Float64(-0.5 * pi))))) * Float64(a * a)) + (Float64(b * sin(Float64(Float64(0.005555555555555556 * pi) * abs(angle)))) ^ 2.0))
end
function tmp = code(a, b, angle)
	tmp = ((0.5 + (0.5 * sin(((0.011111111111111112 * (pi * abs(angle))) - (-0.5 * pi))))) * (a * a)) + ((b * sin(((0.005555555555555556 * pi) * abs(angle)))) ^ 2.0);
end
code[a_, b_, angle_] := N[(N[(N[(1/2 + N[(1/2 * N[Sin[N[(N[(1/90 * N[(Pi * N[Abs[angle], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(-1/2 * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision] + N[Power[N[(b * N[Sin[N[(N[(1/180 * Pi), $MachinePrecision] * N[Abs[angle], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2], $MachinePrecision]), $MachinePrecision]
\left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\frac{1}{90} \cdot \left(\pi \cdot \left|angle\right|\right) - \frac{-1}{2} \cdot \pi\right)\right) \cdot \left(a \cdot a\right) + {\left(b \cdot \sin \left(\left(\frac{1}{180} \cdot \pi\right) \cdot \left|angle\right|\right)\right)}^{2}
Derivation
  1. Initial program 80.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. Step-by-step derivation
    1. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \color{blue}{\cos \left(2 \cdot \left(\frac{-1}{180} \cdot \left(angle \cdot \pi\right)\right)\right)}\right) \cdot \left(a \cdot a\right) + {\left(b \cdot \sin \left(\left(\frac{1}{180} \cdot \pi\right) \cdot angle\right)\right)}^{2} \]
    2. cos-neg-revN/A

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90} - \left(\mathsf{neg}\left(\frac{\color{blue}{\pi}}{2}\right)\right)\right)\right) \cdot \left(a \cdot a\right) + {\left(b \cdot \sin \left(\left(\frac{1}{180} \cdot \pi\right) \cdot angle\right)\right)}^{2} \]
    15. mult-flipN/A

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

      \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90} - \left(\mathsf{neg}\left(\pi \cdot \color{blue}{\frac{1}{2}}\right)\right)\right)\right) \cdot \left(a \cdot a\right) + {\left(b \cdot \sin \left(\left(\frac{1}{180} \cdot \pi\right) \cdot angle\right)\right)}^{2} \]
    17. distribute-lft-neg-outN/A

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

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

Alternative 2: 80.1% accurate, 1.3× speedup?

\[\left(1 - \left(\frac{1}{2} - \cos \left(\frac{1}{90} \cdot \left(\pi \cdot angle\right)\right) \cdot \frac{1}{2}\right)\right) \cdot \left(a \cdot a\right) + {\left(b \cdot \sin \left(\left(\frac{1}{180} \cdot \pi\right) \cdot angle\right)\right)}^{2} \]
(FPCore (a b angle)
  :precision binary64
  (+
 (* (- 1 (- 1/2 (* (cos (* 1/90 (* PI angle))) 1/2))) (* a a))
 (pow (* b (sin (* (* 1/180 PI) angle))) 2)))
double code(double a, double b, double angle) {
	return ((1.0 - (0.5 - (cos((0.011111111111111112 * (((double) M_PI) * angle))) * 0.5))) * (a * a)) + pow((b * sin(((0.005555555555555556 * ((double) M_PI)) * angle))), 2.0);
}
public static double code(double a, double b, double angle) {
	return ((1.0 - (0.5 - (Math.cos((0.011111111111111112 * (Math.PI * angle))) * 0.5))) * (a * a)) + Math.pow((b * Math.sin(((0.005555555555555556 * Math.PI) * angle))), 2.0);
}
def code(a, b, angle):
	return ((1.0 - (0.5 - (math.cos((0.011111111111111112 * (math.pi * angle))) * 0.5))) * (a * a)) + math.pow((b * math.sin(((0.005555555555555556 * math.pi) * angle))), 2.0)
function code(a, b, angle)
	return Float64(Float64(Float64(1.0 - Float64(0.5 - Float64(cos(Float64(0.011111111111111112 * Float64(pi * angle))) * 0.5))) * Float64(a * a)) + (Float64(b * sin(Float64(Float64(0.005555555555555556 * pi) * angle))) ^ 2.0))
end
function tmp = code(a, b, angle)
	tmp = ((1.0 - (0.5 - (cos((0.011111111111111112 * (pi * angle))) * 0.5))) * (a * a)) + ((b * sin(((0.005555555555555556 * pi) * angle))) ^ 2.0);
end
code[a_, b_, angle_] := N[(N[(N[(1 - N[(1/2 - N[(N[Cos[N[(1/90 * N[(Pi * angle), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 1/2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision] + N[Power[N[(b * N[Sin[N[(N[(1/180 * Pi), $MachinePrecision] * angle), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2], $MachinePrecision]), $MachinePrecision]
\left(1 - \left(\frac{1}{2} - \cos \left(\frac{1}{90} \cdot \left(\pi \cdot angle\right)\right) \cdot \frac{1}{2}\right)\right) \cdot \left(a \cdot a\right) + {\left(b \cdot \sin \left(\left(\frac{1}{180} \cdot \pi\right) \cdot angle\right)\right)}^{2}
Derivation
  1. Initial program 80.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. Step-by-step derivation
    1. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 80.1% accurate, 1.9× speedup?

\[\left(\frac{1}{2} + \frac{1}{2}\right) \cdot \left(a \cdot a\right) + {\left(b \cdot \sin \left(\left(\frac{1}{180} \cdot \pi\right) \cdot angle\right)\right)}^{2} \]
(FPCore (a b angle)
  :precision binary64
  (+ (* (+ 1/2 1/2) (* a a)) (pow (* b (sin (* (* 1/180 PI) angle))) 2)))
double code(double a, double b, double angle) {
	return ((0.5 + 0.5) * (a * a)) + pow((b * sin(((0.005555555555555556 * ((double) M_PI)) * angle))), 2.0);
}
public static double code(double a, double b, double angle) {
	return ((0.5 + 0.5) * (a * a)) + Math.pow((b * Math.sin(((0.005555555555555556 * Math.PI) * angle))), 2.0);
}
def code(a, b, angle):
	return ((0.5 + 0.5) * (a * a)) + math.pow((b * math.sin(((0.005555555555555556 * math.pi) * angle))), 2.0)
function code(a, b, angle)
	return Float64(Float64(Float64(0.5 + 0.5) * Float64(a * a)) + (Float64(b * sin(Float64(Float64(0.005555555555555556 * pi) * angle))) ^ 2.0))
end
function tmp = code(a, b, angle)
	tmp = ((0.5 + 0.5) * (a * a)) + ((b * sin(((0.005555555555555556 * pi) * angle))) ^ 2.0);
end
code[a_, b_, angle_] := N[(N[(N[(1/2 + 1/2), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision] + N[Power[N[(b * N[Sin[N[(N[(1/180 * Pi), $MachinePrecision] * angle), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2], $MachinePrecision]), $MachinePrecision]
\left(\frac{1}{2} + \frac{1}{2}\right) \cdot \left(a \cdot a\right) + {\left(b \cdot \sin \left(\left(\frac{1}{180} \cdot \pi\right) \cdot angle\right)\right)}^{2}
Derivation
  1. Initial program 80.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. Step-by-step derivation
    1. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 4: 71.6% accurate, 1.9× speedup?

    \[\begin{array}{l} \mathbf{if}\;\left|a\right| \leq \frac{3950954765291961}{253266331108459042877954581524118722595974501479640924072000569439126758509088631982403994686712878069348015540240526683495797795130113239006767262824338603946605334680267915264}:\\ \;\;\;\;\left(b \cdot b\right) \cdot {\sin \left(\frac{1}{180} \cdot \left(angle \cdot \pi\right)\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(\frac{1}{90} \cdot \left(angle \cdot \pi\right)\right)\right) \cdot b\right) \cdot b + \left(\left(\frac{1}{2} + \frac{1}{2}\right) \cdot \left|a\right|\right) \cdot \left|a\right|\\ \end{array} \]
    (FPCore (a b angle)
      :precision binary64
      (if (<=
         (fabs a)
         3950954765291961/253266331108459042877954581524118722595974501479640924072000569439126758509088631982403994686712878069348015540240526683495797795130113239006767262824338603946605334680267915264)
      (* (* b b) (pow (sin (* 1/180 (* angle PI))) 2))
      (+
       (* (* (- 1/2 (* 1/2 (cos (* 1/90 (* angle PI))))) b) b)
       (* (* (+ 1/2 1/2) (fabs a)) (fabs a)))))
    double code(double a, double b, double angle) {
    	double tmp;
    	if (fabs(a) <= 1.56e-161) {
    		tmp = (b * b) * pow(sin((0.005555555555555556 * (angle * ((double) M_PI)))), 2.0);
    	} else {
    		tmp = (((0.5 - (0.5 * cos((0.011111111111111112 * (angle * ((double) M_PI)))))) * b) * b) + (((0.5 + 0.5) * fabs(a)) * fabs(a));
    	}
    	return tmp;
    }
    
    public static double code(double a, double b, double angle) {
    	double tmp;
    	if (Math.abs(a) <= 1.56e-161) {
    		tmp = (b * b) * Math.pow(Math.sin((0.005555555555555556 * (angle * Math.PI))), 2.0);
    	} else {
    		tmp = (((0.5 - (0.5 * Math.cos((0.011111111111111112 * (angle * Math.PI))))) * b) * b) + (((0.5 + 0.5) * Math.abs(a)) * Math.abs(a));
    	}
    	return tmp;
    }
    
    def code(a, b, angle):
    	tmp = 0
    	if math.fabs(a) <= 1.56e-161:
    		tmp = (b * b) * math.pow(math.sin((0.005555555555555556 * (angle * math.pi))), 2.0)
    	else:
    		tmp = (((0.5 - (0.5 * math.cos((0.011111111111111112 * (angle * math.pi))))) * b) * b) + (((0.5 + 0.5) * math.fabs(a)) * math.fabs(a))
    	return tmp
    
    function code(a, b, angle)
    	tmp = 0.0
    	if (abs(a) <= 1.56e-161)
    		tmp = Float64(Float64(b * b) * (sin(Float64(0.005555555555555556 * Float64(angle * pi))) ^ 2.0));
    	else
    		tmp = Float64(Float64(Float64(Float64(0.5 - Float64(0.5 * cos(Float64(0.011111111111111112 * Float64(angle * pi))))) * b) * b) + Float64(Float64(Float64(0.5 + 0.5) * abs(a)) * abs(a)));
    	end
    	return tmp
    end
    
    function tmp_2 = code(a, b, angle)
    	tmp = 0.0;
    	if (abs(a) <= 1.56e-161)
    		tmp = (b * b) * (sin((0.005555555555555556 * (angle * pi))) ^ 2.0);
    	else
    		tmp = (((0.5 - (0.5 * cos((0.011111111111111112 * (angle * pi))))) * b) * b) + (((0.5 + 0.5) * abs(a)) * abs(a));
    	end
    	tmp_2 = tmp;
    end
    
    code[a_, b_, angle_] := If[LessEqual[N[Abs[a], $MachinePrecision], 3950954765291961/253266331108459042877954581524118722595974501479640924072000569439126758509088631982403994686712878069348015540240526683495797795130113239006767262824338603946605334680267915264], N[(N[(b * b), $MachinePrecision] * N[Power[N[Sin[N[(1/180 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2], $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(1/2 - N[(1/2 * N[Cos[N[(1/90 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision] * b), $MachinePrecision] + N[(N[(N[(1/2 + 1/2), $MachinePrecision] * N[Abs[a], $MachinePrecision]), $MachinePrecision] * N[Abs[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
    
    \begin{array}{l}
    \mathbf{if}\;\left|a\right| \leq \frac{3950954765291961}{253266331108459042877954581524118722595974501479640924072000569439126758509088631982403994686712878069348015540240526683495797795130113239006767262824338603946605334680267915264}:\\
    \;\;\;\;\left(b \cdot b\right) \cdot {\sin \left(\frac{1}{180} \cdot \left(angle \cdot \pi\right)\right)}^{2}\\
    
    \mathbf{else}:\\
    \;\;\;\;\left(\left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(\frac{1}{90} \cdot \left(angle \cdot \pi\right)\right)\right) \cdot b\right) \cdot b + \left(\left(\frac{1}{2} + \frac{1}{2}\right) \cdot \left|a\right|\right) \cdot \left|a\right|\\
    
    
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if a < 1.56e-161

      1. Initial program 80.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. Step-by-step derivation
        1. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto {b}^{2} \cdot {\sin \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} \]
        7. lower-PI.f6434.6%

          \[\leadsto {b}^{2} \cdot {\sin \left(\frac{1}{180} \cdot \left(angle \cdot \pi\right)\right)}^{2} \]
      8. Applied rewrites34.6%

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

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

          \[\leadsto \left(b \cdot b\right) \cdot {\color{blue}{\sin \left(\frac{1}{180} \cdot \left(angle \cdot \pi\right)\right)}}^{2} \]
        3. lower-*.f6434.6%

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

        \[\leadsto \left(b \cdot b\right) \cdot {\color{blue}{\sin \left(\frac{1}{180} \cdot \left(angle \cdot \pi\right)\right)}}^{2} \]

      if 1.56e-161 < a

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

        \[\leadsto \color{blue}{\left(\left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right) \cdot b\right) \cdot b + \left(\left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right) \cdot a\right) \cdot a} \]
      3. Taylor expanded in angle around 0

        \[\leadsto \left(\left(\frac{1}{2} - \color{blue}{\frac{1}{2}}\right) \cdot b\right) \cdot b + \left(\left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right) \cdot a\right) \cdot a \]
      4. Step-by-step derivation
        1. Applied rewrites57.3%

          \[\leadsto \left(\left(\frac{1}{2} - \color{blue}{\frac{1}{2}}\right) \cdot b\right) \cdot b + \left(\left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right) \cdot a\right) \cdot a \]
        2. Taylor expanded in angle around 0

          \[\leadsto \left(\left(\frac{1}{2} - \frac{1}{2}\right) \cdot b\right) \cdot b + \left(\left(\frac{1}{2} + \color{blue}{\frac{1}{2}}\right) \cdot a\right) \cdot a \]
        3. Step-by-step derivation
          1. Applied rewrites57.4%

            \[\leadsto \left(\left(\frac{1}{2} - \frac{1}{2}\right) \cdot b\right) \cdot b + \left(\left(\frac{1}{2} + \color{blue}{\frac{1}{2}}\right) \cdot a\right) \cdot a \]
          2. Taylor expanded in angle around inf

            \[\leadsto \left(\color{blue}{\left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(\frac{1}{90} \cdot \left(angle \cdot \pi\right)\right)\right)} \cdot b\right) \cdot b + \left(\left(\frac{1}{2} + \frac{1}{2}\right) \cdot a\right) \cdot a \]
          3. Step-by-step derivation
            1. lower--.f64N/A

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

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

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

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

              \[\leadsto \left(\left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(\frac{1}{90} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot b\right) \cdot b + \left(\left(\frac{1}{2} + \frac{1}{2}\right) \cdot a\right) \cdot a \]
            6. lower-PI.f6468.6%

              \[\leadsto \left(\left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(\frac{1}{90} \cdot \left(angle \cdot \pi\right)\right)\right) \cdot b\right) \cdot b + \left(\left(\frac{1}{2} + \frac{1}{2}\right) \cdot a\right) \cdot a \]
          4. Applied rewrites68.6%

            \[\leadsto \left(\color{blue}{\left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(\frac{1}{90} \cdot \left(angle \cdot \pi\right)\right)\right)} \cdot b\right) \cdot b + \left(\left(\frac{1}{2} + \frac{1}{2}\right) \cdot a\right) \cdot a \]
        4. Recombined 2 regimes into one program.
        5. Add Preprocessing

        Alternative 5: 68.6% accurate, 3.1× speedup?

        \[\left(\left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(\frac{1}{90} \cdot \left(angle \cdot \pi\right)\right)\right) \cdot b\right) \cdot b + \left(\left(\frac{1}{2} + \frac{1}{2}\right) \cdot a\right) \cdot a \]
        (FPCore (a b angle)
          :precision binary64
          (+
         (* (* (- 1/2 (* 1/2 (cos (* 1/90 (* angle PI))))) b) b)
         (* (* (+ 1/2 1/2) a) a)))
        double code(double a, double b, double angle) {
        	return (((0.5 - (0.5 * cos((0.011111111111111112 * (angle * ((double) M_PI)))))) * b) * b) + (((0.5 + 0.5) * a) * a);
        }
        
        public static double code(double a, double b, double angle) {
        	return (((0.5 - (0.5 * Math.cos((0.011111111111111112 * (angle * Math.PI))))) * b) * b) + (((0.5 + 0.5) * a) * a);
        }
        
        def code(a, b, angle):
        	return (((0.5 - (0.5 * math.cos((0.011111111111111112 * (angle * math.pi))))) * b) * b) + (((0.5 + 0.5) * a) * a)
        
        function code(a, b, angle)
        	return Float64(Float64(Float64(Float64(0.5 - Float64(0.5 * cos(Float64(0.011111111111111112 * Float64(angle * pi))))) * b) * b) + Float64(Float64(Float64(0.5 + 0.5) * a) * a))
        end
        
        function tmp = code(a, b, angle)
        	tmp = (((0.5 - (0.5 * cos((0.011111111111111112 * (angle * pi))))) * b) * b) + (((0.5 + 0.5) * a) * a);
        end
        
        code[a_, b_, angle_] := N[(N[(N[(N[(1/2 - N[(1/2 * N[Cos[N[(1/90 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision] * b), $MachinePrecision] + N[(N[(N[(1/2 + 1/2), $MachinePrecision] * a), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]
        
        \left(\left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(\frac{1}{90} \cdot \left(angle \cdot \pi\right)\right)\right) \cdot b\right) \cdot b + \left(\left(\frac{1}{2} + \frac{1}{2}\right) \cdot a\right) \cdot a
        
        Derivation
        1. Initial program 80.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. Applied rewrites68.7%

          \[\leadsto \color{blue}{\left(\left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right) \cdot b\right) \cdot b + \left(\left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right) \cdot a\right) \cdot a} \]
        3. Taylor expanded in angle around 0

          \[\leadsto \left(\left(\frac{1}{2} - \color{blue}{\frac{1}{2}}\right) \cdot b\right) \cdot b + \left(\left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right) \cdot a\right) \cdot a \]
        4. Step-by-step derivation
          1. Applied rewrites57.3%

            \[\leadsto \left(\left(\frac{1}{2} - \color{blue}{\frac{1}{2}}\right) \cdot b\right) \cdot b + \left(\left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right) \cdot a\right) \cdot a \]
          2. Taylor expanded in angle around 0

            \[\leadsto \left(\left(\frac{1}{2} - \frac{1}{2}\right) \cdot b\right) \cdot b + \left(\left(\frac{1}{2} + \color{blue}{\frac{1}{2}}\right) \cdot a\right) \cdot a \]
          3. Step-by-step derivation
            1. Applied rewrites57.4%

              \[\leadsto \left(\left(\frac{1}{2} - \frac{1}{2}\right) \cdot b\right) \cdot b + \left(\left(\frac{1}{2} + \color{blue}{\frac{1}{2}}\right) \cdot a\right) \cdot a \]
            2. Taylor expanded in angle around inf

              \[\leadsto \left(\color{blue}{\left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(\frac{1}{90} \cdot \left(angle \cdot \pi\right)\right)\right)} \cdot b\right) \cdot b + \left(\left(\frac{1}{2} + \frac{1}{2}\right) \cdot a\right) \cdot a \]
            3. Step-by-step derivation
              1. lower--.f64N/A

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

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

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

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

                \[\leadsto \left(\left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(\frac{1}{90} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot b\right) \cdot b + \left(\left(\frac{1}{2} + \frac{1}{2}\right) \cdot a\right) \cdot a \]
              6. lower-PI.f6468.6%

                \[\leadsto \left(\left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(\frac{1}{90} \cdot \left(angle \cdot \pi\right)\right)\right) \cdot b\right) \cdot b + \left(\left(\frac{1}{2} + \frac{1}{2}\right) \cdot a\right) \cdot a \]
            4. Applied rewrites68.6%

              \[\leadsto \left(\color{blue}{\left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(\frac{1}{90} \cdot \left(angle \cdot \pi\right)\right)\right)} \cdot b\right) \cdot b + \left(\left(\frac{1}{2} + \frac{1}{2}\right) \cdot a\right) \cdot a \]
            5. Add Preprocessing

            Alternative 6: 60.1% accurate, 3.0× speedup?

            \[\begin{array}{l} \mathbf{if}\;\left|b\right| \leq 45000000000000001093790020844307659491309099240666167757791051529882576298935378714552136028009316752614990502760270500706746399264931364234169536023864079809685017457168411131102292168329892380638610266183315693802356736:\\ \;\;\;\;\left(\left(\frac{1}{2} - \frac{1}{2}\right) \cdot \left|b\right|\right) \cdot \left|b\right| + \left(\left(\frac{1}{2} + \frac{1}{2}\right) \cdot a\right) \cdot a\\ \mathbf{else}:\\ \;\;\;\;\left|b\right| \cdot \left(\frac{-1}{2} \cdot \left(\left|b\right| \cdot \cos \left(\frac{-1}{90} \cdot \left(angle \cdot \pi\right)\right)\right) + \frac{1}{2} \cdot \left|b\right|\right)\\ \end{array} \]
            (FPCore (a b angle)
              :precision binary64
              (if (<=
                 (fabs b)
                 45000000000000001093790020844307659491309099240666167757791051529882576298935378714552136028009316752614990502760270500706746399264931364234169536023864079809685017457168411131102292168329892380638610266183315693802356736)
              (+ (* (* (- 1/2 1/2) (fabs b)) (fabs b)) (* (* (+ 1/2 1/2) a) a))
              (*
               (fabs b)
               (+
                (* -1/2 (* (fabs b) (cos (* -1/90 (* angle PI)))))
                (* 1/2 (fabs b))))))
            double code(double a, double b, double angle) {
            	double tmp;
            	if (fabs(b) <= 4.5e+220) {
            		tmp = (((0.5 - 0.5) * fabs(b)) * fabs(b)) + (((0.5 + 0.5) * a) * a);
            	} else {
            		tmp = fabs(b) * ((-0.5 * (fabs(b) * cos((-0.011111111111111112 * (angle * ((double) M_PI)))))) + (0.5 * fabs(b)));
            	}
            	return tmp;
            }
            
            public static double code(double a, double b, double angle) {
            	double tmp;
            	if (Math.abs(b) <= 4.5e+220) {
            		tmp = (((0.5 - 0.5) * Math.abs(b)) * Math.abs(b)) + (((0.5 + 0.5) * a) * a);
            	} else {
            		tmp = Math.abs(b) * ((-0.5 * (Math.abs(b) * Math.cos((-0.011111111111111112 * (angle * Math.PI))))) + (0.5 * Math.abs(b)));
            	}
            	return tmp;
            }
            
            def code(a, b, angle):
            	tmp = 0
            	if math.fabs(b) <= 4.5e+220:
            		tmp = (((0.5 - 0.5) * math.fabs(b)) * math.fabs(b)) + (((0.5 + 0.5) * a) * a)
            	else:
            		tmp = math.fabs(b) * ((-0.5 * (math.fabs(b) * math.cos((-0.011111111111111112 * (angle * math.pi))))) + (0.5 * math.fabs(b)))
            	return tmp
            
            function code(a, b, angle)
            	tmp = 0.0
            	if (abs(b) <= 4.5e+220)
            		tmp = Float64(Float64(Float64(Float64(0.5 - 0.5) * abs(b)) * abs(b)) + Float64(Float64(Float64(0.5 + 0.5) * a) * a));
            	else
            		tmp = Float64(abs(b) * Float64(Float64(-0.5 * Float64(abs(b) * cos(Float64(-0.011111111111111112 * Float64(angle * pi))))) + Float64(0.5 * abs(b))));
            	end
            	return tmp
            end
            
            function tmp_2 = code(a, b, angle)
            	tmp = 0.0;
            	if (abs(b) <= 4.5e+220)
            		tmp = (((0.5 - 0.5) * abs(b)) * abs(b)) + (((0.5 + 0.5) * a) * a);
            	else
            		tmp = abs(b) * ((-0.5 * (abs(b) * cos((-0.011111111111111112 * (angle * pi))))) + (0.5 * abs(b)));
            	end
            	tmp_2 = tmp;
            end
            
            code[a_, b_, angle_] := If[LessEqual[N[Abs[b], $MachinePrecision], 45000000000000001093790020844307659491309099240666167757791051529882576298935378714552136028009316752614990502760270500706746399264931364234169536023864079809685017457168411131102292168329892380638610266183315693802356736], N[(N[(N[(N[(1/2 - 1/2), $MachinePrecision] * N[Abs[b], $MachinePrecision]), $MachinePrecision] * N[Abs[b], $MachinePrecision]), $MachinePrecision] + N[(N[(N[(1/2 + 1/2), $MachinePrecision] * a), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision], N[(N[Abs[b], $MachinePrecision] * N[(N[(-1/2 * N[(N[Abs[b], $MachinePrecision] * N[Cos[N[(-1/90 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(1/2 * N[Abs[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
            
            \begin{array}{l}
            \mathbf{if}\;\left|b\right| \leq 45000000000000001093790020844307659491309099240666167757791051529882576298935378714552136028009316752614990502760270500706746399264931364234169536023864079809685017457168411131102292168329892380638610266183315693802356736:\\
            \;\;\;\;\left(\left(\frac{1}{2} - \frac{1}{2}\right) \cdot \left|b\right|\right) \cdot \left|b\right| + \left(\left(\frac{1}{2} + \frac{1}{2}\right) \cdot a\right) \cdot a\\
            
            \mathbf{else}:\\
            \;\;\;\;\left|b\right| \cdot \left(\frac{-1}{2} \cdot \left(\left|b\right| \cdot \cos \left(\frac{-1}{90} \cdot \left(angle \cdot \pi\right)\right)\right) + \frac{1}{2} \cdot \left|b\right|\right)\\
            
            
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if b < 4.5000000000000001e220

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

                \[\leadsto \color{blue}{\left(\left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right) \cdot b\right) \cdot b + \left(\left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right) \cdot a\right) \cdot a} \]
              3. Taylor expanded in angle around 0

                \[\leadsto \left(\left(\frac{1}{2} - \color{blue}{\frac{1}{2}}\right) \cdot b\right) \cdot b + \left(\left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right) \cdot a\right) \cdot a \]
              4. Step-by-step derivation
                1. Applied rewrites57.3%

                  \[\leadsto \left(\left(\frac{1}{2} - \color{blue}{\frac{1}{2}}\right) \cdot b\right) \cdot b + \left(\left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right) \cdot a\right) \cdot a \]
                2. Taylor expanded in angle around 0

                  \[\leadsto \left(\left(\frac{1}{2} - \frac{1}{2}\right) \cdot b\right) \cdot b + \left(\left(\frac{1}{2} + \color{blue}{\frac{1}{2}}\right) \cdot a\right) \cdot a \]
                3. Step-by-step derivation
                  1. Applied rewrites57.4%

                    \[\leadsto \left(\left(\frac{1}{2} - \frac{1}{2}\right) \cdot b\right) \cdot b + \left(\left(\frac{1}{2} + \color{blue}{\frac{1}{2}}\right) \cdot a\right) \cdot a \]

                  if 4.5000000000000001e220 < b

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

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

                      \[\leadsto \color{blue}{\left(\left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right) \cdot b\right)} \cdot b + \left(\left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right) \cdot a\right) \cdot a \]
                    2. *-commutativeN/A

                      \[\leadsto \color{blue}{\left(b \cdot \left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right)\right)} \cdot b + \left(\left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right) \cdot a\right) \cdot a \]
                    3. lift--.f64N/A

                      \[\leadsto \left(b \cdot \color{blue}{\left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right)}\right) \cdot b + \left(\left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right) \cdot a\right) \cdot a \]
                    4. lift-*.f64N/A

                      \[\leadsto \left(b \cdot \left(\frac{1}{2} - \color{blue}{\frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)}\right)\right) \cdot b + \left(\left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right) \cdot a\right) \cdot a \]
                    5. fp-cancel-sub-sign-invN/A

                      \[\leadsto \left(b \cdot \color{blue}{\left(\frac{1}{2} + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right)}\right) \cdot b + \left(\left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right) \cdot a\right) \cdot a \]
                    6. distribute-lft-inN/A

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

                      \[\leadsto \color{blue}{\left(b \cdot \frac{1}{2} + b \cdot \left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right)\right)} \cdot b + \left(\left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right) \cdot a\right) \cdot a \]
                    8. lower-*.f64N/A

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

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

                      \[\leadsto \left(b \cdot \frac{1}{2} + b \cdot \color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right)}\right) \cdot b + \left(\left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right) \cdot a\right) \cdot a \]
                    11. metadata-eval68.6%

                      \[\leadsto \left(b \cdot \frac{1}{2} + b \cdot \left(\color{blue}{\frac{-1}{2}} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right)\right) \cdot b + \left(\left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right) \cdot a\right) \cdot a \]
                    12. lift-cos.f64N/A

                      \[\leadsto \left(b \cdot \frac{1}{2} + b \cdot \left(\frac{-1}{2} \cdot \color{blue}{\cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)}\right)\right) \cdot b + \left(\left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right) \cdot a\right) \cdot a \]
                    13. cos-neg-revN/A

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

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

                      \[\leadsto \left(b \cdot \frac{1}{2} + b \cdot \left(\frac{-1}{2} \cdot \cos \left(\mathsf{neg}\left(\color{blue}{\left(angle \cdot \pi\right) \cdot \frac{1}{90}}\right)\right)\right)\right) \cdot b + \left(\left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right) \cdot a\right) \cdot a \]
                    16. *-commutativeN/A

                      \[\leadsto \left(b \cdot \frac{1}{2} + b \cdot \left(\frac{-1}{2} \cdot \cos \left(\mathsf{neg}\left(\color{blue}{\frac{1}{90} \cdot \left(angle \cdot \pi\right)}\right)\right)\right)\right) \cdot b + \left(\left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right) \cdot a\right) \cdot a \]
                    17. distribute-lft-neg-inN/A

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

                      \[\leadsto \left(b \cdot \frac{1}{2} + b \cdot \left(\frac{-1}{2} \cdot \cos \color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{90}\right)\right) \cdot \left(angle \cdot \pi\right)\right)}\right)\right) \cdot b + \left(\left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right) \cdot a\right) \cdot a \]
                    19. metadata-eval68.6%

                      \[\leadsto \left(b \cdot \frac{1}{2} + b \cdot \left(\frac{-1}{2} \cdot \cos \left(\color{blue}{\frac{-1}{90}} \cdot \left(angle \cdot \pi\right)\right)\right)\right) \cdot b + \left(\left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right) \cdot a\right) \cdot a \]
                  4. Applied rewrites68.6%

                    \[\leadsto \color{blue}{\left(b \cdot \frac{1}{2} + b \cdot \left(\frac{-1}{2} \cdot \cos \left(\frac{-1}{90} \cdot \left(angle \cdot \pi\right)\right)\right)\right)} \cdot b + \left(\left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right) \cdot a\right) \cdot a \]
                  5. Taylor expanded in a around 0

                    \[\leadsto \color{blue}{b \cdot \left(\frac{-1}{2} \cdot \left(b \cdot \cos \left(\frac{-1}{90} \cdot \left(angle \cdot \pi\right)\right)\right) + \frac{1}{2} \cdot b\right)} \]
                  6. Step-by-step derivation
                    1. lower-*.f64N/A

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

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

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

                      \[\leadsto b \cdot \left(\frac{-1}{2} \cdot \left(b \cdot \cos \left(\frac{-1}{90} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)\right) + \frac{1}{2} \cdot b\right) \]
                    5. lower-cos.f64N/A

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

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

                      \[\leadsto b \cdot \left(\frac{-1}{2} \cdot \left(b \cdot \cos \left(\frac{-1}{90} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)\right) + \frac{1}{2} \cdot b\right) \]
                    8. lower-PI.f64N/A

                      \[\leadsto b \cdot \left(\frac{-1}{2} \cdot \left(b \cdot \cos \left(\frac{-1}{90} \cdot \left(angle \cdot \pi\right)\right)\right) + \frac{1}{2} \cdot b\right) \]
                    9. lower-*.f6427.1%

                      \[\leadsto b \cdot \left(\frac{-1}{2} \cdot \left(b \cdot \cos \left(\frac{-1}{90} \cdot \left(angle \cdot \pi\right)\right)\right) + \frac{1}{2} \cdot \color{blue}{b}\right) \]
                  7. Applied rewrites27.1%

                    \[\leadsto \color{blue}{b \cdot \left(\frac{-1}{2} \cdot \left(b \cdot \cos \left(\frac{-1}{90} \cdot \left(angle \cdot \pi\right)\right)\right) + \frac{1}{2} \cdot b\right)} \]
                4. Recombined 2 regimes into one program.
                5. Add Preprocessing

                Alternative 7: 60.0% accurate, 3.2× speedup?

                \[\begin{array}{l} \mathbf{if}\;\left|b\right| \leq 45000000000000001093790020844307659491309099240666167757791051529882576298935378714552136028009316752614990502760270500706746399264931364234169536023864079809685017457168411131102292168329892380638610266183315693802356736:\\ \;\;\;\;\left(\left(\frac{1}{2} - \frac{1}{2}\right) \cdot \left|b\right|\right) \cdot \left|b\right| + \left(\left(\frac{1}{2} + \frac{1}{2}\right) \cdot a\right) \cdot a\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{2} - \cos \left(\frac{1}{90} \cdot \left(\pi \cdot angle\right)\right) \cdot \frac{1}{2}\right) \cdot \left(\left|b\right| \cdot \left|b\right|\right)\\ \end{array} \]
                (FPCore (a b angle)
                  :precision binary64
                  (if (<=
                     (fabs b)
                     45000000000000001093790020844307659491309099240666167757791051529882576298935378714552136028009316752614990502760270500706746399264931364234169536023864079809685017457168411131102292168329892380638610266183315693802356736)
                  (+ (* (* (- 1/2 1/2) (fabs b)) (fabs b)) (* (* (+ 1/2 1/2) a) a))
                  (*
                   (- 1/2 (* (cos (* 1/90 (* PI angle))) 1/2))
                   (* (fabs b) (fabs b)))))
                double code(double a, double b, double angle) {
                	double tmp;
                	if (fabs(b) <= 4.5e+220) {
                		tmp = (((0.5 - 0.5) * fabs(b)) * fabs(b)) + (((0.5 + 0.5) * a) * a);
                	} else {
                		tmp = (0.5 - (cos((0.011111111111111112 * (((double) M_PI) * angle))) * 0.5)) * (fabs(b) * fabs(b));
                	}
                	return tmp;
                }
                
                public static double code(double a, double b, double angle) {
                	double tmp;
                	if (Math.abs(b) <= 4.5e+220) {
                		tmp = (((0.5 - 0.5) * Math.abs(b)) * Math.abs(b)) + (((0.5 + 0.5) * a) * a);
                	} else {
                		tmp = (0.5 - (Math.cos((0.011111111111111112 * (Math.PI * angle))) * 0.5)) * (Math.abs(b) * Math.abs(b));
                	}
                	return tmp;
                }
                
                def code(a, b, angle):
                	tmp = 0
                	if math.fabs(b) <= 4.5e+220:
                		tmp = (((0.5 - 0.5) * math.fabs(b)) * math.fabs(b)) + (((0.5 + 0.5) * a) * a)
                	else:
                		tmp = (0.5 - (math.cos((0.011111111111111112 * (math.pi * angle))) * 0.5)) * (math.fabs(b) * math.fabs(b))
                	return tmp
                
                function code(a, b, angle)
                	tmp = 0.0
                	if (abs(b) <= 4.5e+220)
                		tmp = Float64(Float64(Float64(Float64(0.5 - 0.5) * abs(b)) * abs(b)) + Float64(Float64(Float64(0.5 + 0.5) * a) * a));
                	else
                		tmp = Float64(Float64(0.5 - Float64(cos(Float64(0.011111111111111112 * Float64(pi * angle))) * 0.5)) * Float64(abs(b) * abs(b)));
                	end
                	return tmp
                end
                
                function tmp_2 = code(a, b, angle)
                	tmp = 0.0;
                	if (abs(b) <= 4.5e+220)
                		tmp = (((0.5 - 0.5) * abs(b)) * abs(b)) + (((0.5 + 0.5) * a) * a);
                	else
                		tmp = (0.5 - (cos((0.011111111111111112 * (pi * angle))) * 0.5)) * (abs(b) * abs(b));
                	end
                	tmp_2 = tmp;
                end
                
                code[a_, b_, angle_] := If[LessEqual[N[Abs[b], $MachinePrecision], 45000000000000001093790020844307659491309099240666167757791051529882576298935378714552136028009316752614990502760270500706746399264931364234169536023864079809685017457168411131102292168329892380638610266183315693802356736], N[(N[(N[(N[(1/2 - 1/2), $MachinePrecision] * N[Abs[b], $MachinePrecision]), $MachinePrecision] * N[Abs[b], $MachinePrecision]), $MachinePrecision] + N[(N[(N[(1/2 + 1/2), $MachinePrecision] * a), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision], N[(N[(1/2 - N[(N[Cos[N[(1/90 * N[(Pi * angle), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 1/2), $MachinePrecision]), $MachinePrecision] * N[(N[Abs[b], $MachinePrecision] * N[Abs[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
                
                \begin{array}{l}
                \mathbf{if}\;\left|b\right| \leq 45000000000000001093790020844307659491309099240666167757791051529882576298935378714552136028009316752614990502760270500706746399264931364234169536023864079809685017457168411131102292168329892380638610266183315693802356736:\\
                \;\;\;\;\left(\left(\frac{1}{2} - \frac{1}{2}\right) \cdot \left|b\right|\right) \cdot \left|b\right| + \left(\left(\frac{1}{2} + \frac{1}{2}\right) \cdot a\right) \cdot a\\
                
                \mathbf{else}:\\
                \;\;\;\;\left(\frac{1}{2} - \cos \left(\frac{1}{90} \cdot \left(\pi \cdot angle\right)\right) \cdot \frac{1}{2}\right) \cdot \left(\left|b\right| \cdot \left|b\right|\right)\\
                
                
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if b < 4.5000000000000001e220

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

                    \[\leadsto \color{blue}{\left(\left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right) \cdot b\right) \cdot b + \left(\left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right) \cdot a\right) \cdot a} \]
                  3. Taylor expanded in angle around 0

                    \[\leadsto \left(\left(\frac{1}{2} - \color{blue}{\frac{1}{2}}\right) \cdot b\right) \cdot b + \left(\left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right) \cdot a\right) \cdot a \]
                  4. Step-by-step derivation
                    1. Applied rewrites57.3%

                      \[\leadsto \left(\left(\frac{1}{2} - \color{blue}{\frac{1}{2}}\right) \cdot b\right) \cdot b + \left(\left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right) \cdot a\right) \cdot a \]
                    2. Taylor expanded in angle around 0

                      \[\leadsto \left(\left(\frac{1}{2} - \frac{1}{2}\right) \cdot b\right) \cdot b + \left(\left(\frac{1}{2} + \color{blue}{\frac{1}{2}}\right) \cdot a\right) \cdot a \]
                    3. Step-by-step derivation
                      1. Applied rewrites57.4%

                        \[\leadsto \left(\left(\frac{1}{2} - \frac{1}{2}\right) \cdot b\right) \cdot b + \left(\left(\frac{1}{2} + \color{blue}{\frac{1}{2}}\right) \cdot a\right) \cdot a \]

                      if 4.5000000000000001e220 < b

                      1. Initial program 80.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. Step-by-step derivation
                        1. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                          \[\leadsto {b}^{2} \cdot {\sin \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} \]
                        7. lower-PI.f6434.6%

                          \[\leadsto {b}^{2} \cdot {\sin \left(\frac{1}{180} \cdot \left(angle \cdot \pi\right)\right)}^{2} \]
                      8. Applied rewrites34.6%

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

                        \[\leadsto \color{blue}{\left(\frac{1}{2} - \cos \left(\frac{1}{90} \cdot \left(\pi \cdot angle\right)\right) \cdot \frac{1}{2}\right) \cdot \left(b \cdot b\right)} \]
                    4. Recombined 2 regimes into one program.
                    5. Add Preprocessing

                    Alternative 8: 57.4% accurate, 14.9× speedup?

                    \[\left(\left(\frac{1}{2} - \frac{1}{2}\right) \cdot b\right) \cdot b + \left(\left(\frac{1}{2} + \frac{1}{2}\right) \cdot a\right) \cdot a \]
                    (FPCore (a b angle)
                      :precision binary64
                      (+ (* (* (- 1/2 1/2) b) b) (* (* (+ 1/2 1/2) a) a)))
                    double code(double a, double b, double angle) {
                    	return (((0.5 - 0.5) * b) * b) + (((0.5 + 0.5) * a) * a);
                    }
                    
                    module fmin_fmax_functions
                        implicit none
                        private
                        public fmax
                        public fmin
                    
                        interface fmax
                            module procedure fmax88
                            module procedure fmax44
                            module procedure fmax84
                            module procedure fmax48
                        end interface
                        interface fmin
                            module procedure fmin88
                            module procedure fmin44
                            module procedure fmin84
                            module procedure fmin48
                        end interface
                    contains
                        real(8) function fmax88(x, y) result (res)
                            real(8), intent (in) :: x
                            real(8), intent (in) :: y
                            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                        end function
                        real(4) function fmax44(x, y) result (res)
                            real(4), intent (in) :: x
                            real(4), intent (in) :: y
                            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                        end function
                        real(8) function fmax84(x, y) result(res)
                            real(8), intent (in) :: x
                            real(4), intent (in) :: y
                            res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                        end function
                        real(8) function fmax48(x, y) result(res)
                            real(4), intent (in) :: x
                            real(8), intent (in) :: y
                            res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                        end function
                        real(8) function fmin88(x, y) result (res)
                            real(8), intent (in) :: x
                            real(8), intent (in) :: y
                            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                        end function
                        real(4) function fmin44(x, y) result (res)
                            real(4), intent (in) :: x
                            real(4), intent (in) :: y
                            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                        end function
                        real(8) function fmin84(x, y) result(res)
                            real(8), intent (in) :: x
                            real(4), intent (in) :: y
                            res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                        end function
                        real(8) function fmin48(x, y) result(res)
                            real(4), intent (in) :: x
                            real(8), intent (in) :: y
                            res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                        end function
                    end module
                    
                    real(8) function code(a, b, angle)
                    use fmin_fmax_functions
                        real(8), intent (in) :: a
                        real(8), intent (in) :: b
                        real(8), intent (in) :: angle
                        code = (((0.5d0 - 0.5d0) * b) * b) + (((0.5d0 + 0.5d0) * a) * a)
                    end function
                    
                    public static double code(double a, double b, double angle) {
                    	return (((0.5 - 0.5) * b) * b) + (((0.5 + 0.5) * a) * a);
                    }
                    
                    def code(a, b, angle):
                    	return (((0.5 - 0.5) * b) * b) + (((0.5 + 0.5) * a) * a)
                    
                    function code(a, b, angle)
                    	return Float64(Float64(Float64(Float64(0.5 - 0.5) * b) * b) + Float64(Float64(Float64(0.5 + 0.5) * a) * a))
                    end
                    
                    function tmp = code(a, b, angle)
                    	tmp = (((0.5 - 0.5) * b) * b) + (((0.5 + 0.5) * a) * a);
                    end
                    
                    code[a_, b_, angle_] := N[(N[(N[(N[(1/2 - 1/2), $MachinePrecision] * b), $MachinePrecision] * b), $MachinePrecision] + N[(N[(N[(1/2 + 1/2), $MachinePrecision] * a), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]
                    
                    \left(\left(\frac{1}{2} - \frac{1}{2}\right) \cdot b\right) \cdot b + \left(\left(\frac{1}{2} + \frac{1}{2}\right) \cdot a\right) \cdot a
                    
                    Derivation
                    1. Initial program 80.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. Applied rewrites68.7%

                      \[\leadsto \color{blue}{\left(\left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right) \cdot b\right) \cdot b + \left(\left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right) \cdot a\right) \cdot a} \]
                    3. Taylor expanded in angle around 0

                      \[\leadsto \left(\left(\frac{1}{2} - \color{blue}{\frac{1}{2}}\right) \cdot b\right) \cdot b + \left(\left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right) \cdot a\right) \cdot a \]
                    4. Step-by-step derivation
                      1. Applied rewrites57.3%

                        \[\leadsto \left(\left(\frac{1}{2} - \color{blue}{\frac{1}{2}}\right) \cdot b\right) \cdot b + \left(\left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right) \cdot a\right) \cdot a \]
                      2. Taylor expanded in angle around 0

                        \[\leadsto \left(\left(\frac{1}{2} - \frac{1}{2}\right) \cdot b\right) \cdot b + \left(\left(\frac{1}{2} + \color{blue}{\frac{1}{2}}\right) \cdot a\right) \cdot a \]
                      3. Step-by-step derivation
                        1. Applied rewrites57.4%

                          \[\leadsto \left(\left(\frac{1}{2} - \frac{1}{2}\right) \cdot b\right) \cdot b + \left(\left(\frac{1}{2} + \color{blue}{\frac{1}{2}}\right) \cdot a\right) \cdot a \]
                        2. Add Preprocessing

                        Reproduce

                        ?
                        herbie shell --seed 2025271 -o generate:evaluate
                        (FPCore (a b angle)
                          :name "ab-angle->ABCF C"
                          :precision binary64
                          (+ (pow (* a (cos (* PI (/ angle 180)))) 2) (pow (* b (sin (* PI (/ angle 180)))) 2)))