ab-angle->ABCF C

Percentage Accurate: 80.1% → 80.1%
Time: 5.7s
Alternatives: 12
Speedup: 1.0×

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.0))))
   (+ (pow (* a (cos t_0)) 2.0) (pow (* b (sin t_0)) 2.0))))
double code(double a, double b, double angle) {
	double t_0 = ((double) M_PI) * (angle / 180.0);
	return pow((a * cos(t_0)), 2.0) + pow((b * sin(t_0)), 2.0);
}
public static double code(double a, double b, double angle) {
	double t_0 = Math.PI * (angle / 180.0);
	return Math.pow((a * Math.cos(t_0)), 2.0) + Math.pow((b * Math.sin(t_0)), 2.0);
}
def code(a, b, angle):
	t_0 = math.pi * (angle / 180.0)
	return math.pow((a * math.cos(t_0)), 2.0) + math.pow((b * math.sin(t_0)), 2.0)
function code(a, b, angle)
	t_0 = Float64(pi * Float64(angle / 180.0))
	return Float64((Float64(a * cos(t_0)) ^ 2.0) + (Float64(b * sin(t_0)) ^ 2.0))
end
function tmp = code(a, b, angle)
	t_0 = pi * (angle / 180.0);
	tmp = ((a * cos(t_0)) ^ 2.0) + ((b * sin(t_0)) ^ 2.0);
end
code[a_, b_, angle_] := Block[{t$95$0 = N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]}, N[(N[Power[N[(a * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
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 12 alternatives:

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

Initial Program: 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.0))))
   (+ (pow (* a (cos t_0)) 2.0) (pow (* b (sin t_0)) 2.0))))
double code(double a, double b, double angle) {
	double t_0 = ((double) M_PI) * (angle / 180.0);
	return pow((a * cos(t_0)), 2.0) + pow((b * sin(t_0)), 2.0);
}
public static double code(double a, double b, double angle) {
	double t_0 = Math.PI * (angle / 180.0);
	return Math.pow((a * Math.cos(t_0)), 2.0) + Math.pow((b * Math.sin(t_0)), 2.0);
}
def code(a, b, angle):
	t_0 = math.pi * (angle / 180.0)
	return math.pow((a * math.cos(t_0)), 2.0) + math.pow((b * math.sin(t_0)), 2.0)
function code(a, b, angle)
	t_0 = Float64(pi * Float64(angle / 180.0))
	return Float64((Float64(a * cos(t_0)) ^ 2.0) + (Float64(b * sin(t_0)) ^ 2.0))
end
function tmp = code(a, b, angle)
	t_0 = pi * (angle / 180.0);
	tmp = ((a * cos(t_0)) ^ 2.0) + ((b * sin(t_0)) ^ 2.0);
end
code[a_, b_, angle_] := Block[{t$95$0 = N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]}, N[(N[Power[N[(a * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
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.1% accurate, 0.9× speedup?

\[{\sin \left(\mathsf{fma}\left(-0.005555555555555556, \left|angle\right| \cdot \pi, 0.5 \cdot \pi\right) + \pi\right)}^{2} \cdot \left(a \cdot a\right) + {\left(b \cdot \sin \left(\pi \cdot \frac{\left|angle\right|}{180}\right)\right)}^{2} \]
(FPCore (a b angle)
 :precision binary64
 (+
  (*
   (pow
    (sin (+ (fma -0.005555555555555556 (* (fabs angle) PI) (* 0.5 PI)) PI))
    2.0)
   (* a a))
  (pow (* b (sin (* PI (/ (fabs angle) 180.0)))) 2.0)))
double code(double a, double b, double angle) {
	return (pow(sin((fma(-0.005555555555555556, (fabs(angle) * ((double) M_PI)), (0.5 * ((double) M_PI))) + ((double) M_PI))), 2.0) * (a * a)) + pow((b * sin((((double) M_PI) * (fabs(angle) / 180.0)))), 2.0);
}
function code(a, b, angle)
	return Float64(Float64((sin(Float64(fma(-0.005555555555555556, Float64(abs(angle) * pi), Float64(0.5 * pi)) + pi)) ^ 2.0) * Float64(a * a)) + (Float64(b * sin(Float64(pi * Float64(abs(angle) / 180.0)))) ^ 2.0))
end
code[a_, b_, angle_] := N[(N[(N[Power[N[Sin[N[(N[(-0.005555555555555556 * N[(N[Abs[angle], $MachinePrecision] * Pi), $MachinePrecision] + N[(0.5 * Pi), $MachinePrecision]), $MachinePrecision] + Pi), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision] + N[Power[N[(b * N[Sin[N[(Pi * N[(N[Abs[angle], $MachinePrecision] / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
{\sin \left(\mathsf{fma}\left(-0.005555555555555556, \left|angle\right| \cdot \pi, 0.5 \cdot \pi\right) + \pi\right)}^{2} \cdot \left(a \cdot a\right) + {\left(b \cdot \sin \left(\pi \cdot \frac{\left|angle\right|}{180}\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-pow.f64N/A

      \[\leadsto \color{blue}{{\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. unpow2N/A

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

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

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

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

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

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

      \[\leadsto \color{blue}{{\left(\mathsf{neg}\left(\cos \left(\pi \cdot \frac{angle}{180}\right)\right)\right)}^{2} \cdot {a}^{2}} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
    9. lower-unsound-pow.f32N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 80.1% accurate, 1.0× speedup?

\[\left(0.5 - 0.5 \cdot \cos \left(2 \cdot \mathsf{fma}\left(\pi \cdot 0.005555555555555556, angle, 0.5 \cdot \pi\right)\right)\right) \cdot \left(a \cdot a\right) + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
(FPCore (a b angle)
 :precision binary64
 (+
  (*
   (-
    0.5
    (* 0.5 (cos (* 2.0 (fma (* PI 0.005555555555555556) angle (* 0.5 PI))))))
   (* a a))
  (pow (* b (sin (* PI (/ angle 180.0)))) 2.0)))
double code(double a, double b, double angle) {
	return ((0.5 - (0.5 * cos((2.0 * fma((((double) M_PI) * 0.005555555555555556), angle, (0.5 * ((double) M_PI))))))) * (a * a)) + pow((b * sin((((double) M_PI) * (angle / 180.0)))), 2.0);
}
function code(a, b, angle)
	return Float64(Float64(Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * fma(Float64(pi * 0.005555555555555556), angle, Float64(0.5 * pi)))))) * Float64(a * a)) + (Float64(b * sin(Float64(pi * Float64(angle / 180.0)))) ^ 2.0))
end
code[a_, b_, angle_] := N[(N[(N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(N[(Pi * 0.005555555555555556), $MachinePrecision] * angle + N[(0.5 * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision] + N[Power[N[(b * N[Sin[N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\left(0.5 - 0.5 \cdot \cos \left(2 \cdot \mathsf{fma}\left(\pi \cdot 0.005555555555555556, angle, 0.5 \cdot \pi\right)\right)\right) \cdot \left(a \cdot a\right) + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\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-pow.f64N/A

      \[\leadsto \color{blue}{{\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. unpow2N/A

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

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

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

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

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

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

      \[\leadsto \color{blue}{{\left(\mathsf{neg}\left(\cos \left(\pi \cdot \frac{angle}{180}\right)\right)\right)}^{2} \cdot {a}^{2}} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
    9. lower-unsound-pow.f32N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\left(\mathsf{neg}\left(\sin \left(\mathsf{fma}\left(\frac{1}{180}, \pi \cdot angle, \frac{1}{2} \cdot \pi\right)\right)\right)\right) \cdot \color{blue}{\left(\mathsf{neg}\left(\sin \left(\mathsf{fma}\left(\frac{1}{180}, \pi \cdot angle, \frac{1}{2} \cdot \pi\right)\right)\right)\right)}\right) \cdot \left(a \cdot a\right) + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
    9. sqr-negN/A

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

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

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

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

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

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

Alternative 3: 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.0))))
   (+ (pow (* a (cos t_0)) 2.0) (pow (* b (sin t_0)) 2.0))))
double code(double a, double b, double angle) {
	double t_0 = ((double) M_PI) * (angle / 180.0);
	return pow((a * cos(t_0)), 2.0) + pow((b * sin(t_0)), 2.0);
}
public static double code(double a, double b, double angle) {
	double t_0 = Math.PI * (angle / 180.0);
	return Math.pow((a * Math.cos(t_0)), 2.0) + Math.pow((b * Math.sin(t_0)), 2.0);
}
def code(a, b, angle):
	t_0 = math.pi * (angle / 180.0)
	return math.pow((a * math.cos(t_0)), 2.0) + math.pow((b * math.sin(t_0)), 2.0)
function code(a, b, angle)
	t_0 = Float64(pi * Float64(angle / 180.0))
	return Float64((Float64(a * cos(t_0)) ^ 2.0) + (Float64(b * sin(t_0)) ^ 2.0))
end
function tmp = code(a, b, angle)
	t_0 = pi * (angle / 180.0);
	tmp = ((a * cos(t_0)) ^ 2.0) + ((b * sin(t_0)) ^ 2.0);
end
code[a_, b_, angle_] := Block[{t$95$0 = N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]}, N[(N[Power[N[(a * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
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}
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. Add Preprocessing

Alternative 4: 80.0% accurate, 1.0× speedup?

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

      \[\leadsto \color{blue}{{\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. unpow2N/A

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

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

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

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

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

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

      \[\leadsto \color{blue}{{\left(\mathsf{neg}\left(\cos \left(\pi \cdot \frac{angle}{180}\right)\right)\right)}^{2} \cdot {a}^{2}} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
    9. lower-unsound-pow.f32N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 80.0% accurate, 1.0× speedup?

\[\begin{array}{l} t_0 := \pi \cdot \left|angle\right|\\ \mathsf{fma}\left(0.5 + 0.5 \cdot \cos \left(2 \cdot \mathsf{fma}\left(0.005555555555555556, t\_0, \pi\right)\right), a \cdot a, {\left(\sin \left(0.005555555555555556 \cdot t\_0\right) \cdot b\right)}^{2}\right) \end{array} \]
(FPCore (a b angle)
 :precision binary64
 (let* ((t_0 (* PI (fabs angle))))
   (fma
    (+ 0.5 (* 0.5 (cos (* 2.0 (fma 0.005555555555555556 t_0 PI)))))
    (* a a)
    (pow (* (sin (* 0.005555555555555556 t_0)) b) 2.0))))
double code(double a, double b, double angle) {
	double t_0 = ((double) M_PI) * fabs(angle);
	return fma((0.5 + (0.5 * cos((2.0 * fma(0.005555555555555556, t_0, ((double) M_PI)))))), (a * a), pow((sin((0.005555555555555556 * t_0)) * b), 2.0));
}
function code(a, b, angle)
	t_0 = Float64(pi * abs(angle))
	return fma(Float64(0.5 + Float64(0.5 * cos(Float64(2.0 * fma(0.005555555555555556, t_0, pi))))), Float64(a * a), (Float64(sin(Float64(0.005555555555555556 * t_0)) * b) ^ 2.0))
end
code[a_, b_, angle_] := Block[{t$95$0 = N[(Pi * N[Abs[angle], $MachinePrecision]), $MachinePrecision]}, N[(N[(0.5 + N[(0.5 * N[Cos[N[(2.0 * N[(0.005555555555555556 * t$95$0 + Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(a * a), $MachinePrecision] + N[Power[N[(N[Sin[N[(0.005555555555555556 * t$95$0), $MachinePrecision]], $MachinePrecision] * b), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
t_0 := \pi \cdot \left|angle\right|\\
\mathsf{fma}\left(0.5 + 0.5 \cdot \cos \left(2 \cdot \mathsf{fma}\left(0.005555555555555556, t\_0, \pi\right)\right), a \cdot a, {\left(\sin \left(0.005555555555555556 \cdot t\_0\right) \cdot b\right)}^{2}\right)
\end{array}
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-cos.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(0.5 + 0.5 \cdot \cos \left(2 \cdot \mathsf{fma}\left(0.005555555555555556, \pi \cdot angle, \pi\right)\right), a \cdot a, {\left(\sin \left(0.005555555555555556 \cdot \left(\pi \cdot angle\right)\right) \cdot b\right)}^{2}\right)} \]
  5. Add Preprocessing

Alternative 6: 79.9% accurate, 1.4× speedup?

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

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

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

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

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

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

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

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

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

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

    Alternative 7: 79.8% accurate, 1.5× speedup?

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

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

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

      Alternative 8: 79.0% accurate, 1.5× speedup?

      \[\begin{array}{l} t_0 := 0.5 \cdot \cos \left(\left(\left|angle\right| \cdot \pi\right) \cdot 0.011111111111111112\right)\\ \mathbf{if}\;\left|angle\right| \leq 175000:\\ \;\;\;\;\mathsf{fma}\left(\left(0.5 + t\_0\right) \cdot a, a, \left(3.08641975308642 \cdot 10^{-5} \cdot \left(\left(\left(\left(\pi \cdot \pi\right) \cdot b\right) \cdot \left|angle\right|\right) \cdot \left|angle\right|\right)\right) \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(1 \cdot a, a, \left(\left(0.5 - t\_0\right) \cdot b\right) \cdot b\right)\\ \end{array} \]
      (FPCore (a b angle)
       :precision binary64
       (let* ((t_0 (* 0.5 (cos (* (* (fabs angle) PI) 0.011111111111111112)))))
         (if (<= (fabs angle) 175000.0)
           (fma
            (* (+ 0.5 t_0) a)
            a
            (*
             (*
              3.08641975308642e-5
              (* (* (* (* PI PI) b) (fabs angle)) (fabs angle)))
             b))
           (fma (* 1.0 a) a (* (* (- 0.5 t_0) b) b)))))
      double code(double a, double b, double angle) {
      	double t_0 = 0.5 * cos(((fabs(angle) * ((double) M_PI)) * 0.011111111111111112));
      	double tmp;
      	if (fabs(angle) <= 175000.0) {
      		tmp = fma(((0.5 + t_0) * a), a, ((3.08641975308642e-5 * ((((((double) M_PI) * ((double) M_PI)) * b) * fabs(angle)) * fabs(angle))) * b));
      	} else {
      		tmp = fma((1.0 * a), a, (((0.5 - t_0) * b) * b));
      	}
      	return tmp;
      }
      
      function code(a, b, angle)
      	t_0 = Float64(0.5 * cos(Float64(Float64(abs(angle) * pi) * 0.011111111111111112)))
      	tmp = 0.0
      	if (abs(angle) <= 175000.0)
      		tmp = fma(Float64(Float64(0.5 + t_0) * a), a, Float64(Float64(3.08641975308642e-5 * Float64(Float64(Float64(Float64(pi * pi) * b) * abs(angle)) * abs(angle))) * b));
      	else
      		tmp = fma(Float64(1.0 * a), a, Float64(Float64(Float64(0.5 - t_0) * b) * b));
      	end
      	return tmp
      end
      
      code[a_, b_, angle_] := Block[{t$95$0 = N[(0.5 * N[Cos[N[(N[(N[Abs[angle], $MachinePrecision] * Pi), $MachinePrecision] * 0.011111111111111112), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Abs[angle], $MachinePrecision], 175000.0], N[(N[(N[(0.5 + t$95$0), $MachinePrecision] * a), $MachinePrecision] * a + N[(N[(3.08641975308642e-5 * N[(N[(N[(N[(Pi * Pi), $MachinePrecision] * b), $MachinePrecision] * N[Abs[angle], $MachinePrecision]), $MachinePrecision] * N[Abs[angle], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 * a), $MachinePrecision] * a + N[(N[(N[(0.5 - t$95$0), $MachinePrecision] * b), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]]]
      
      \begin{array}{l}
      t_0 := 0.5 \cdot \cos \left(\left(\left|angle\right| \cdot \pi\right) \cdot 0.011111111111111112\right)\\
      \mathbf{if}\;\left|angle\right| \leq 175000:\\
      \;\;\;\;\mathsf{fma}\left(\left(0.5 + t\_0\right) \cdot a, a, \left(3.08641975308642 \cdot 10^{-5} \cdot \left(\left(\left(\left(\pi \cdot \pi\right) \cdot b\right) \cdot \left|angle\right|\right) \cdot \left|angle\right|\right)\right) \cdot b\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;\mathsf{fma}\left(1 \cdot a, a, \left(\left(0.5 - t\_0\right) \cdot b\right) \cdot b\right)\\
      
      
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if angle < 175000

        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.3%

          \[\leadsto \color{blue}{\mathsf{fma}\left(\left(0.5 + 0.5 \cdot \cos \left(\left(angle \cdot \pi\right) \cdot 0.011111111111111112\right)\right) \cdot a, a, \left(\left(0.5 - 0.5 \cdot \cos \left(\left(angle \cdot \pi\right) \cdot 0.011111111111111112\right)\right) \cdot b\right) \cdot b\right)} \]
        3. Taylor expanded in angle around 0

          \[\leadsto \mathsf{fma}\left(\left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right) \cdot a, a, \color{blue}{\left(\frac{1}{32400} \cdot \left({angle}^{2} \cdot \left(b \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)\right)} \cdot b\right) \]
        4. Step-by-step derivation
          1. lower-*.f64N/A

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

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

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

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

            \[\leadsto \mathsf{fma}\left(\left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right) \cdot a, a, \left(\frac{1}{32400} \cdot \left({angle}^{2} \cdot \left(b \cdot {\mathsf{PI}\left(\right)}^{\color{blue}{2}}\right)\right)\right) \cdot b\right) \]
          6. lower-PI.f6471.1

            \[\leadsto \mathsf{fma}\left(\left(0.5 + 0.5 \cdot \cos \left(\left(angle \cdot \pi\right) \cdot 0.011111111111111112\right)\right) \cdot a, a, \left(3.08641975308642 \cdot 10^{-5} \cdot \left({angle}^{2} \cdot \left(b \cdot {\pi}^{2}\right)\right)\right) \cdot b\right) \]
        5. Applied rewrites71.1%

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

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

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

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

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

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

            \[\leadsto \mathsf{fma}\left(\left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right) \cdot a, a, \left(\frac{1}{32400} \cdot \left(\left(\left(b \cdot {\pi}^{2}\right) \cdot angle\right) \cdot \color{blue}{angle}\right)\right) \cdot b\right) \]
          7. lower-*.f6474.2

            \[\leadsto \mathsf{fma}\left(\left(0.5 + 0.5 \cdot \cos \left(\left(angle \cdot \pi\right) \cdot 0.011111111111111112\right)\right) \cdot a, a, \left(3.08641975308642 \cdot 10^{-5} \cdot \left(\left(\left(b \cdot {\pi}^{2}\right) \cdot angle\right) \cdot angle\right)\right) \cdot b\right) \]
          8. lift-*.f64N/A

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

            \[\leadsto \mathsf{fma}\left(\left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right) \cdot a, a, \left(\frac{1}{32400} \cdot \left(\left(\left({\pi}^{2} \cdot b\right) \cdot angle\right) \cdot angle\right)\right) \cdot b\right) \]
          10. lower-*.f6474.2

            \[\leadsto \mathsf{fma}\left(\left(0.5 + 0.5 \cdot \cos \left(\left(angle \cdot \pi\right) \cdot 0.011111111111111112\right)\right) \cdot a, a, \left(3.08641975308642 \cdot 10^{-5} \cdot \left(\left(\left({\pi}^{2} \cdot b\right) \cdot angle\right) \cdot angle\right)\right) \cdot b\right) \]
          11. lift-pow.f64N/A

            \[\leadsto \mathsf{fma}\left(\left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right) \cdot a, a, \left(\frac{1}{32400} \cdot \left(\left(\left({\pi}^{2} \cdot b\right) \cdot angle\right) \cdot angle\right)\right) \cdot b\right) \]
          12. unpow2N/A

            \[\leadsto \mathsf{fma}\left(\left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right) \cdot a, a, \left(\frac{1}{32400} \cdot \left(\left(\left(\left(\pi \cdot \pi\right) \cdot b\right) \cdot angle\right) \cdot angle\right)\right) \cdot b\right) \]
          13. lower-*.f6474.2

            \[\leadsto \mathsf{fma}\left(\left(0.5 + 0.5 \cdot \cos \left(\left(angle \cdot \pi\right) \cdot 0.011111111111111112\right)\right) \cdot a, a, \left(3.08641975308642 \cdot 10^{-5} \cdot \left(\left(\left(\left(\pi \cdot \pi\right) \cdot b\right) \cdot angle\right) \cdot angle\right)\right) \cdot b\right) \]
        7. Applied rewrites74.2%

          \[\leadsto \mathsf{fma}\left(\left(0.5 + 0.5 \cdot \cos \left(\left(angle \cdot \pi\right) \cdot 0.011111111111111112\right)\right) \cdot a, a, \left(3.08641975308642 \cdot 10^{-5} \cdot \left(\left(\left(\left(\pi \cdot \pi\right) \cdot b\right) \cdot angle\right) \cdot \color{blue}{angle}\right)\right) \cdot b\right) \]

        if 175000 < angle

        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.3%

          \[\leadsto \color{blue}{\mathsf{fma}\left(\left(0.5 + 0.5 \cdot \cos \left(\left(angle \cdot \pi\right) \cdot 0.011111111111111112\right)\right) \cdot a, a, \left(\left(0.5 - 0.5 \cdot \cos \left(\left(angle \cdot \pi\right) \cdot 0.011111111111111112\right)\right) \cdot b\right) \cdot b\right)} \]
        3. Taylor expanded in angle around 0

          \[\leadsto \mathsf{fma}\left(\color{blue}{1} \cdot a, a, \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\right) \]
        4. Step-by-step derivation
          1. Applied rewrites68.1%

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

        Alternative 9: 76.1% accurate, 1.5× speedup?

        \[\begin{array}{l} t_0 := \left|angle\right| \cdot \pi\\ \mathbf{if}\;\left|angle\right| \leq 175000:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\cos \left(-0.011111111111111112 \cdot t\_0\right), 0.5, 0.5\right) \cdot a, a, \left(\left(\left(\left(\left|angle\right| \cdot \left|angle\right|\right) \cdot 3.08641975308642 \cdot 10^{-5}\right) \cdot b\right) \cdot \left(\pi \cdot \pi\right)\right) \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(1 \cdot a, a, \left(\left(0.5 - 0.5 \cdot \cos \left(t\_0 \cdot 0.011111111111111112\right)\right) \cdot b\right) \cdot b\right)\\ \end{array} \]
        (FPCore (a b angle)
         :precision binary64
         (let* ((t_0 (* (fabs angle) PI)))
           (if (<= (fabs angle) 175000.0)
             (fma
              (* (fma (cos (* -0.011111111111111112 t_0)) 0.5 0.5) a)
              a
              (*
               (*
                (* (* (* (fabs angle) (fabs angle)) 3.08641975308642e-5) b)
                (* PI PI))
               b))
             (fma
              (* 1.0 a)
              a
              (* (* (- 0.5 (* 0.5 (cos (* t_0 0.011111111111111112)))) b) b)))))
        double code(double a, double b, double angle) {
        	double t_0 = fabs(angle) * ((double) M_PI);
        	double tmp;
        	if (fabs(angle) <= 175000.0) {
        		tmp = fma((fma(cos((-0.011111111111111112 * t_0)), 0.5, 0.5) * a), a, (((((fabs(angle) * fabs(angle)) * 3.08641975308642e-5) * b) * (((double) M_PI) * ((double) M_PI))) * b));
        	} else {
        		tmp = fma((1.0 * a), a, (((0.5 - (0.5 * cos((t_0 * 0.011111111111111112)))) * b) * b));
        	}
        	return tmp;
        }
        
        function code(a, b, angle)
        	t_0 = Float64(abs(angle) * pi)
        	tmp = 0.0
        	if (abs(angle) <= 175000.0)
        		tmp = fma(Float64(fma(cos(Float64(-0.011111111111111112 * t_0)), 0.5, 0.5) * a), a, Float64(Float64(Float64(Float64(Float64(abs(angle) * abs(angle)) * 3.08641975308642e-5) * b) * Float64(pi * pi)) * b));
        	else
        		tmp = fma(Float64(1.0 * a), a, Float64(Float64(Float64(0.5 - Float64(0.5 * cos(Float64(t_0 * 0.011111111111111112)))) * b) * b));
        	end
        	return tmp
        end
        
        code[a_, b_, angle_] := Block[{t$95$0 = N[(N[Abs[angle], $MachinePrecision] * Pi), $MachinePrecision]}, If[LessEqual[N[Abs[angle], $MachinePrecision], 175000.0], N[(N[(N[(N[Cos[N[(-0.011111111111111112 * t$95$0), $MachinePrecision]], $MachinePrecision] * 0.5 + 0.5), $MachinePrecision] * a), $MachinePrecision] * a + N[(N[(N[(N[(N[(N[Abs[angle], $MachinePrecision] * N[Abs[angle], $MachinePrecision]), $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision] * b), $MachinePrecision] * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 * a), $MachinePrecision] * a + N[(N[(N[(0.5 - N[(0.5 * N[Cos[N[(t$95$0 * 0.011111111111111112), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]]]
        
        \begin{array}{l}
        t_0 := \left|angle\right| \cdot \pi\\
        \mathbf{if}\;\left|angle\right| \leq 175000:\\
        \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\cos \left(-0.011111111111111112 \cdot t\_0\right), 0.5, 0.5\right) \cdot a, a, \left(\left(\left(\left(\left|angle\right| \cdot \left|angle\right|\right) \cdot 3.08641975308642 \cdot 10^{-5}\right) \cdot b\right) \cdot \left(\pi \cdot \pi\right)\right) \cdot b\right)\\
        
        \mathbf{else}:\\
        \;\;\;\;\mathsf{fma}\left(1 \cdot a, a, \left(\left(0.5 - 0.5 \cdot \cos \left(t\_0 \cdot 0.011111111111111112\right)\right) \cdot b\right) \cdot b\right)\\
        
        
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if angle < 175000

          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.3%

            \[\leadsto \color{blue}{\mathsf{fma}\left(\left(0.5 + 0.5 \cdot \cos \left(\left(angle \cdot \pi\right) \cdot 0.011111111111111112\right)\right) \cdot a, a, \left(\left(0.5 - 0.5 \cdot \cos \left(\left(angle \cdot \pi\right) \cdot 0.011111111111111112\right)\right) \cdot b\right) \cdot b\right)} \]
          3. Taylor expanded in angle around 0

            \[\leadsto \mathsf{fma}\left(\left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right) \cdot a, a, \color{blue}{\left(\frac{1}{32400} \cdot \left({angle}^{2} \cdot \left(b \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)\right)} \cdot b\right) \]
          4. Step-by-step derivation
            1. lower-*.f64N/A

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

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

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

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

              \[\leadsto \mathsf{fma}\left(\left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right) \cdot a, a, \left(\frac{1}{32400} \cdot \left({angle}^{2} \cdot \left(b \cdot {\mathsf{PI}\left(\right)}^{\color{blue}{2}}\right)\right)\right) \cdot b\right) \]
            6. lower-PI.f6471.1

              \[\leadsto \mathsf{fma}\left(\left(0.5 + 0.5 \cdot \cos \left(\left(angle \cdot \pi\right) \cdot 0.011111111111111112\right)\right) \cdot a, a, \left(3.08641975308642 \cdot 10^{-5} \cdot \left({angle}^{2} \cdot \left(b \cdot {\pi}^{2}\right)\right)\right) \cdot b\right) \]
          5. Applied rewrites71.1%

            \[\leadsto \mathsf{fma}\left(\left(0.5 + 0.5 \cdot \cos \left(\left(angle \cdot \pi\right) \cdot 0.011111111111111112\right)\right) \cdot a, a, \color{blue}{\left(3.08641975308642 \cdot 10^{-5} \cdot \left({angle}^{2} \cdot \left(b \cdot {\pi}^{2}\right)\right)\right)} \cdot b\right) \]
          6. Step-by-step derivation
            1. Applied rewrites71.0%

              \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(\cos \left(-0.011111111111111112 \cdot \left(angle \cdot \pi\right)\right), 0.5, 0.5\right) \cdot a, a, \left(\left(\left(\left(angle \cdot angle\right) \cdot 3.08641975308642 \cdot 10^{-5}\right) \cdot b\right) \cdot \left(\pi \cdot \pi\right)\right) \cdot b\right)} \]

            if 175000 < angle

            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.3%

              \[\leadsto \color{blue}{\mathsf{fma}\left(\left(0.5 + 0.5 \cdot \cos \left(\left(angle \cdot \pi\right) \cdot 0.011111111111111112\right)\right) \cdot a, a, \left(\left(0.5 - 0.5 \cdot \cos \left(\left(angle \cdot \pi\right) \cdot 0.011111111111111112\right)\right) \cdot b\right) \cdot b\right)} \]
            3. Taylor expanded in angle around 0

              \[\leadsto \mathsf{fma}\left(\color{blue}{1} \cdot a, a, \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\right) \]
            4. Step-by-step derivation
              1. Applied rewrites68.1%

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

            Alternative 10: 76.1% accurate, 1.8× speedup?

            \[\begin{array}{l} \mathbf{if}\;\left|angle\right| \leq 0.0028:\\ \;\;\;\;\mathsf{fma}\left(1 \cdot a, a, \left(3.08641975308642 \cdot 10^{-5} \cdot \left({\left(\left|angle\right|\right)}^{2} \cdot \left(b \cdot {\pi}^{2}\right)\right)\right) \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(1 \cdot a, a, \left(\left(0.5 - 0.5 \cdot \cos \left(\left(\left|angle\right| \cdot \pi\right) \cdot 0.011111111111111112\right)\right) \cdot b\right) \cdot b\right)\\ \end{array} \]
            (FPCore (a b angle)
             :precision binary64
             (if (<= (fabs angle) 0.0028)
               (fma
                (* 1.0 a)
                a
                (*
                 (* 3.08641975308642e-5 (* (pow (fabs angle) 2.0) (* b (pow PI 2.0))))
                 b))
               (fma
                (* 1.0 a)
                a
                (*
                 (* (- 0.5 (* 0.5 (cos (* (* (fabs angle) PI) 0.011111111111111112)))) b)
                 b))))
            double code(double a, double b, double angle) {
            	double tmp;
            	if (fabs(angle) <= 0.0028) {
            		tmp = fma((1.0 * a), a, ((3.08641975308642e-5 * (pow(fabs(angle), 2.0) * (b * pow(((double) M_PI), 2.0)))) * b));
            	} else {
            		tmp = fma((1.0 * a), a, (((0.5 - (0.5 * cos(((fabs(angle) * ((double) M_PI)) * 0.011111111111111112)))) * b) * b));
            	}
            	return tmp;
            }
            
            function code(a, b, angle)
            	tmp = 0.0
            	if (abs(angle) <= 0.0028)
            		tmp = fma(Float64(1.0 * a), a, Float64(Float64(3.08641975308642e-5 * Float64((abs(angle) ^ 2.0) * Float64(b * (pi ^ 2.0)))) * b));
            	else
            		tmp = fma(Float64(1.0 * a), a, Float64(Float64(Float64(0.5 - Float64(0.5 * cos(Float64(Float64(abs(angle) * pi) * 0.011111111111111112)))) * b) * b));
            	end
            	return tmp
            end
            
            code[a_, b_, angle_] := If[LessEqual[N[Abs[angle], $MachinePrecision], 0.0028], N[(N[(1.0 * a), $MachinePrecision] * a + N[(N[(3.08641975308642e-5 * N[(N[Power[N[Abs[angle], $MachinePrecision], 2.0], $MachinePrecision] * N[(b * N[Power[Pi, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 * a), $MachinePrecision] * a + N[(N[(N[(0.5 - N[(0.5 * N[Cos[N[(N[(N[Abs[angle], $MachinePrecision] * Pi), $MachinePrecision] * 0.011111111111111112), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]]
            
            \begin{array}{l}
            \mathbf{if}\;\left|angle\right| \leq 0.0028:\\
            \;\;\;\;\mathsf{fma}\left(1 \cdot a, a, \left(3.08641975308642 \cdot 10^{-5} \cdot \left({\left(\left|angle\right|\right)}^{2} \cdot \left(b \cdot {\pi}^{2}\right)\right)\right) \cdot b\right)\\
            
            \mathbf{else}:\\
            \;\;\;\;\mathsf{fma}\left(1 \cdot a, a, \left(\left(0.5 - 0.5 \cdot \cos \left(\left(\left|angle\right| \cdot \pi\right) \cdot 0.011111111111111112\right)\right) \cdot b\right) \cdot b\right)\\
            
            
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if angle < 0.00279999999999999997

              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.3%

                \[\leadsto \color{blue}{\mathsf{fma}\left(\left(0.5 + 0.5 \cdot \cos \left(\left(angle \cdot \pi\right) \cdot 0.011111111111111112\right)\right) \cdot a, a, \left(\left(0.5 - 0.5 \cdot \cos \left(\left(angle \cdot \pi\right) \cdot 0.011111111111111112\right)\right) \cdot b\right) \cdot b\right)} \]
              3. Taylor expanded in angle around 0

                \[\leadsto \mathsf{fma}\left(\left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right) \cdot a, a, \color{blue}{\left(\frac{1}{32400} \cdot \left({angle}^{2} \cdot \left(b \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)\right)} \cdot b\right) \]
              4. Step-by-step derivation
                1. lower-*.f64N/A

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

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

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

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

                  \[\leadsto \mathsf{fma}\left(\left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right) \cdot a, a, \left(\frac{1}{32400} \cdot \left({angle}^{2} \cdot \left(b \cdot {\mathsf{PI}\left(\right)}^{\color{blue}{2}}\right)\right)\right) \cdot b\right) \]
                6. lower-PI.f6471.1

                  \[\leadsto \mathsf{fma}\left(\left(0.5 + 0.5 \cdot \cos \left(\left(angle \cdot \pi\right) \cdot 0.011111111111111112\right)\right) \cdot a, a, \left(3.08641975308642 \cdot 10^{-5} \cdot \left({angle}^{2} \cdot \left(b \cdot {\pi}^{2}\right)\right)\right) \cdot b\right) \]
              5. Applied rewrites71.1%

                \[\leadsto \mathsf{fma}\left(\left(0.5 + 0.5 \cdot \cos \left(\left(angle \cdot \pi\right) \cdot 0.011111111111111112\right)\right) \cdot a, a, \color{blue}{\left(3.08641975308642 \cdot 10^{-5} \cdot \left({angle}^{2} \cdot \left(b \cdot {\pi}^{2}\right)\right)\right)} \cdot b\right) \]
              6. Taylor expanded in angle around 0

                \[\leadsto \mathsf{fma}\left(\color{blue}{1} \cdot a, a, \left(\frac{1}{32400} \cdot \left({angle}^{2} \cdot \left(b \cdot {\pi}^{2}\right)\right)\right) \cdot b\right) \]
              7. Step-by-step derivation
                1. Applied rewrites70.8%

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

                if 0.00279999999999999997 < angle

                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.3%

                  \[\leadsto \color{blue}{\mathsf{fma}\left(\left(0.5 + 0.5 \cdot \cos \left(\left(angle \cdot \pi\right) \cdot 0.011111111111111112\right)\right) \cdot a, a, \left(\left(0.5 - 0.5 \cdot \cos \left(\left(angle \cdot \pi\right) \cdot 0.011111111111111112\right)\right) \cdot b\right) \cdot b\right)} \]
                3. Taylor expanded in angle around 0

                  \[\leadsto \mathsf{fma}\left(\color{blue}{1} \cdot a, a, \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\right) \]
                4. Step-by-step derivation
                  1. Applied rewrites68.1%

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

                Alternative 11: 70.8% accurate, 2.2× speedup?

                \[\mathsf{fma}\left(1 \cdot a, a, \left(3.08641975308642 \cdot 10^{-5} \cdot \left({angle}^{2} \cdot \left(b \cdot {\pi}^{2}\right)\right)\right) \cdot b\right) \]
                (FPCore (a b angle)
                 :precision binary64
                 (fma
                  (* 1.0 a)
                  a
                  (* (* 3.08641975308642e-5 (* (pow angle 2.0) (* b (pow PI 2.0)))) b)))
                double code(double a, double b, double angle) {
                	return fma((1.0 * a), a, ((3.08641975308642e-5 * (pow(angle, 2.0) * (b * pow(((double) M_PI), 2.0)))) * b));
                }
                
                function code(a, b, angle)
                	return fma(Float64(1.0 * a), a, Float64(Float64(3.08641975308642e-5 * Float64((angle ^ 2.0) * Float64(b * (pi ^ 2.0)))) * b))
                end
                
                code[a_, b_, angle_] := N[(N[(1.0 * a), $MachinePrecision] * a + N[(N[(3.08641975308642e-5 * N[(N[Power[angle, 2.0], $MachinePrecision] * N[(b * N[Power[Pi, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
                
                \mathsf{fma}\left(1 \cdot a, a, \left(3.08641975308642 \cdot 10^{-5} \cdot \left({angle}^{2} \cdot \left(b \cdot {\pi}^{2}\right)\right)\right) \cdot b\right)
                
                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.3%

                  \[\leadsto \color{blue}{\mathsf{fma}\left(\left(0.5 + 0.5 \cdot \cos \left(\left(angle \cdot \pi\right) \cdot 0.011111111111111112\right)\right) \cdot a, a, \left(\left(0.5 - 0.5 \cdot \cos \left(\left(angle \cdot \pi\right) \cdot 0.011111111111111112\right)\right) \cdot b\right) \cdot b\right)} \]
                3. Taylor expanded in angle around 0

                  \[\leadsto \mathsf{fma}\left(\left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right) \cdot a, a, \color{blue}{\left(\frac{1}{32400} \cdot \left({angle}^{2} \cdot \left(b \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)\right)} \cdot b\right) \]
                4. Step-by-step derivation
                  1. lower-*.f64N/A

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(\left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right) \cdot a, a, \left(\frac{1}{32400} \cdot \left({angle}^{2} \cdot \left(b \cdot {\mathsf{PI}\left(\right)}^{\color{blue}{2}}\right)\right)\right) \cdot b\right) \]
                  6. lower-PI.f6471.1

                    \[\leadsto \mathsf{fma}\left(\left(0.5 + 0.5 \cdot \cos \left(\left(angle \cdot \pi\right) \cdot 0.011111111111111112\right)\right) \cdot a, a, \left(3.08641975308642 \cdot 10^{-5} \cdot \left({angle}^{2} \cdot \left(b \cdot {\pi}^{2}\right)\right)\right) \cdot b\right) \]
                5. Applied rewrites71.1%

                  \[\leadsto \mathsf{fma}\left(\left(0.5 + 0.5 \cdot \cos \left(\left(angle \cdot \pi\right) \cdot 0.011111111111111112\right)\right) \cdot a, a, \color{blue}{\left(3.08641975308642 \cdot 10^{-5} \cdot \left({angle}^{2} \cdot \left(b \cdot {\pi}^{2}\right)\right)\right)} \cdot b\right) \]
                6. Taylor expanded in angle around 0

                  \[\leadsto \mathsf{fma}\left(\color{blue}{1} \cdot a, a, \left(\frac{1}{32400} \cdot \left({angle}^{2} \cdot \left(b \cdot {\pi}^{2}\right)\right)\right) \cdot b\right) \]
                7. Step-by-step derivation
                  1. Applied rewrites70.8%

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

                  Alternative 12: 57.1% accurate, 29.7× speedup?

                  \[a \cdot a \]
                  (FPCore (a b angle) :precision binary64 (* a a))
                  double code(double a, double b, double angle) {
                  	return 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 = a * a
                  end function
                  
                  public static double code(double a, double b, double angle) {
                  	return a * a;
                  }
                  
                  def code(a, b, angle):
                  	return a * a
                  
                  function code(a, b, angle)
                  	return Float64(a * a)
                  end
                  
                  function tmp = code(a, b, angle)
                  	tmp = a * a;
                  end
                  
                  code[a_, b_, angle_] := N[(a * a), $MachinePrecision]
                  
                  a \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. Taylor expanded in angle around 0

                    \[\leadsto \color{blue}{{a}^{2}} \]
                  3. Step-by-step derivation
                    1. lower-pow.f6457.1

                      \[\leadsto {a}^{\color{blue}{2}} \]
                  4. Applied rewrites57.1%

                    \[\leadsto \color{blue}{{a}^{2}} \]
                  5. Step-by-step derivation
                    1. lift-pow.f64N/A

                      \[\leadsto {a}^{\color{blue}{2}} \]
                    2. unpow2N/A

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

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

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

                  Reproduce

                  ?
                  herbie shell --seed 2025171 
                  (FPCore (a b angle)
                    :name "ab-angle->ABCF C"
                    :precision binary64
                    (+ (pow (* a (cos (* PI (/ angle 180.0)))) 2.0) (pow (* b (sin (* PI (/ angle 180.0)))) 2.0)))