ab-angle->ABCF C

Percentage Accurate: 79.5% → 79.5%
Time: 19.0s
Alternatives: 12
Speedup: 2.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 12 alternatives:

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

Initial Program: 79.5% accurate, 1.0× speedup?

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

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

Alternative 1: 79.5% accurate, 0.8× speedup?

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

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

    \[{\left(a \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. unpow-prod-downN/A

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

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

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left({\cos \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)}^{2}\right), \left({a}^{2}\right)\right), \mathsf{pow.f64}\left(\color{blue}{\mathsf{*.f64}\left(b, \mathsf{sin.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right)}, 2\right)\right) \]
  4. Applied egg-rr79.7%

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

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\left(\sqrt{\mathsf{PI}\left(\right)} \cdot \sqrt{\mathsf{PI}\left(\right)}\right), angle\right), -180\right)\right)\right)\right)\right), \mathsf{*.f64}\left(a, a\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(b, \mathsf{sin.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right), 2\right)\right) \]
    2. pow2N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\left({\left(\sqrt{\mathsf{PI}\left(\right)}\right)}^{2}\right), angle\right), -180\right)\right)\right)\right)\right), \mathsf{*.f64}\left(a, a\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(b, \mathsf{sin.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right), 2\right)\right) \]
    3. pow-lowering-pow.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{pow.f64}\left(\left(\sqrt{\mathsf{PI}\left(\right)}\right), 2\right), angle\right), -180\right)\right)\right)\right)\right), \mathsf{*.f64}\left(a, a\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(b, \mathsf{sin.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right), 2\right)\right) \]
    4. sqrt-lowering-sqrt.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{pow.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{PI}\left(\right)\right), 2\right), angle\right), -180\right)\right)\right)\right)\right), \mathsf{*.f64}\left(a, a\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(b, \mathsf{sin.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right), 2\right)\right) \]
    5. PI-lowering-PI.f6479.8%

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{pow.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{PI.f64}\left(\right)\right), 2\right), angle\right), -180\right)\right)\right)\right)\right), \mathsf{*.f64}\left(a, a\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(b, \mathsf{sin.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right), 2\right)\right) \]
  6. Applied egg-rr79.8%

    \[\leadsto \left(0.5 + 0.5 \cdot \cos \left(2 \cdot \frac{\color{blue}{{\left(\sqrt{\pi}\right)}^{2}} \cdot angle}{-180}\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 2: 79.5% accurate, 1.3× speedup?

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

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

    \[{\left(a \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. unpow-prod-downN/A

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

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

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left({\cos \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)}^{2}\right), \left({a}^{2}\right)\right), \mathsf{pow.f64}\left(\color{blue}{\mathsf{*.f64}\left(b, \mathsf{sin.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right)}, 2\right)\right) \]
  4. Applied egg-rr79.7%

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

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(\left(2 \cdot \frac{1}{\frac{-180}{\mathsf{PI}\left(\right) \cdot angle}}\right)\right)\right)\right), \mathsf{*.f64}\left(a, a\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(b, \mathsf{sin.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right), 2\right)\right) \]
    2. un-div-invN/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(\left(\frac{2}{\frac{-180}{\mathsf{PI}\left(\right) \cdot angle}}\right)\right)\right)\right), \mathsf{*.f64}\left(a, a\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(b, \mathsf{sin.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right), 2\right)\right) \]
    3. /-lowering-/.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(\mathsf{/.f64}\left(2, \left(\frac{-180}{\mathsf{PI}\left(\right) \cdot angle}\right)\right)\right)\right)\right), \mathsf{*.f64}\left(a, a\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(b, \mathsf{sin.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right), 2\right)\right) \]
    4. /-lowering-/.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(-180, \left(\mathsf{PI}\left(\right) \cdot angle\right)\right)\right)\right)\right)\right), \mathsf{*.f64}\left(a, a\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(b, \mathsf{sin.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right), 2\right)\right) \]
    5. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(-180, \mathsf{*.f64}\left(\mathsf{PI}\left(\right), angle\right)\right)\right)\right)\right)\right), \mathsf{*.f64}\left(a, a\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(b, \mathsf{sin.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right), 2\right)\right) \]
    6. PI-lowering-PI.f6479.7%

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(-180, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), angle\right)\right)\right)\right)\right)\right), \mathsf{*.f64}\left(a, a\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(b, \mathsf{sin.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right), 2\right)\right) \]
  6. Applied egg-rr79.7%

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

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

Alternative 3: 79.5% accurate, 1.3× speedup?

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

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

    \[{\left(a \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. unpow-prod-downN/A

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

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

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left({\cos \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)}^{2}\right), \left({a}^{2}\right)\right), \mathsf{pow.f64}\left(\color{blue}{\mathsf{*.f64}\left(b, \mathsf{sin.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right)}, 2\right)\right) \]
  4. Applied egg-rr79.7%

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

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\left(\sqrt{\mathsf{PI}\left(\right)} \cdot \sqrt{\mathsf{PI}\left(\right)}\right), angle\right), -180\right)\right)\right)\right)\right), \mathsf{*.f64}\left(a, a\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(b, \mathsf{sin.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right), 2\right)\right) \]
    2. pow2N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\left({\left(\sqrt{\mathsf{PI}\left(\right)}\right)}^{2}\right), angle\right), -180\right)\right)\right)\right)\right), \mathsf{*.f64}\left(a, a\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(b, \mathsf{sin.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right), 2\right)\right) \]
    3. pow-lowering-pow.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{pow.f64}\left(\left(\sqrt{\mathsf{PI}\left(\right)}\right), 2\right), angle\right), -180\right)\right)\right)\right)\right), \mathsf{*.f64}\left(a, a\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(b, \mathsf{sin.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right), 2\right)\right) \]
    4. sqrt-lowering-sqrt.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{pow.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{PI}\left(\right)\right), 2\right), angle\right), -180\right)\right)\right)\right)\right), \mathsf{*.f64}\left(a, a\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(b, \mathsf{sin.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right), 2\right)\right) \]
    5. PI-lowering-PI.f6479.8%

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{pow.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{PI.f64}\left(\right)\right), 2\right), angle\right), -180\right)\right)\right)\right)\right), \mathsf{*.f64}\left(a, a\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(b, \mathsf{sin.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right), 2\right)\right) \]
  6. Applied egg-rr79.8%

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

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(\left(\frac{{\left(\sqrt{\mathsf{PI}\left(\right)}\right)}^{2} \cdot angle}{-180} \cdot 2\right)\right)\right)\right), \mathsf{*.f64}\left(a, a\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(b, \mathsf{sin.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right), 2\right)\right) \]
    2. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(\left(\frac{{\left(\sqrt{\mathsf{PI}\left(\right)}\right)}^{2} \cdot angle}{-180}\right), 2\right)\right)\right)\right), \mathsf{*.f64}\left(a, a\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(b, \mathsf{sin.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right), 2\right)\right) \]
    3. unpow2N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(\left(\frac{\left(\sqrt{\mathsf{PI}\left(\right)} \cdot \sqrt{\mathsf{PI}\left(\right)}\right) \cdot angle}{-180}\right), 2\right)\right)\right)\right), \mathsf{*.f64}\left(a, a\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(b, \mathsf{sin.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right), 2\right)\right) \]
    4. add-sqr-sqrtN/A

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

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(\left(\mathsf{PI}\left(\right) \cdot \frac{angle}{-180}\right), 2\right)\right)\right)\right), \mathsf{*.f64}\left(a, a\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(b, \mathsf{sin.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right), 2\right)\right) \]
    6. clear-numN/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(\left(\mathsf{PI}\left(\right) \cdot \frac{1}{\frac{-180}{angle}}\right), 2\right)\right)\right)\right), \mathsf{*.f64}\left(a, a\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(b, \mathsf{sin.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right), 2\right)\right) \]
    7. un-div-invN/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(\left(\frac{\mathsf{PI}\left(\right)}{\frac{-180}{angle}}\right), 2\right)\right)\right)\right), \mathsf{*.f64}\left(a, a\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(b, \mathsf{sin.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right), 2\right)\right) \]
    8. metadata-evalN/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(\left(\frac{\mathsf{PI}\left(\right)}{\frac{\mathsf{neg}\left(180\right)}{angle}}\right), 2\right)\right)\right)\right), \mathsf{*.f64}\left(a, a\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(b, \mathsf{sin.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right), 2\right)\right) \]
    9. distribute-neg-fracN/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(\left(\frac{\mathsf{PI}\left(\right)}{\mathsf{neg}\left(\frac{180}{angle}\right)}\right), 2\right)\right)\right)\right), \mathsf{*.f64}\left(a, a\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(b, \mathsf{sin.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right), 2\right)\right) \]
    10. /-lowering-/.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{PI}\left(\right), \left(\mathsf{neg}\left(\frac{180}{angle}\right)\right)\right), 2\right)\right)\right)\right), \mathsf{*.f64}\left(a, a\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(b, \mathsf{sin.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right), 2\right)\right) \]
    11. PI-lowering-PI.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), \left(\mathsf{neg}\left(\frac{180}{angle}\right)\right)\right), 2\right)\right)\right)\right), \mathsf{*.f64}\left(a, a\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(b, \mathsf{sin.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right), 2\right)\right) \]
    12. distribute-neg-fracN/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), \left(\frac{\mathsf{neg}\left(180\right)}{angle}\right)\right), 2\right)\right)\right)\right), \mathsf{*.f64}\left(a, a\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(b, \mathsf{sin.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right), 2\right)\right) \]
    13. metadata-evalN/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), \left(\frac{-180}{angle}\right)\right), 2\right)\right)\right)\right), \mathsf{*.f64}\left(a, a\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(b, \mathsf{sin.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right), 2\right)\right) \]
    14. /-lowering-/.f6479.7%

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(-180, angle\right)\right), 2\right)\right)\right)\right), \mathsf{*.f64}\left(a, a\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(b, \mathsf{sin.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right), 2\right)\right) \]
  8. Applied egg-rr79.7%

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

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

Alternative 4: 79.5% accurate, 1.3× speedup?

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

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

    \[{\left(a \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. unpow-prod-downN/A

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

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

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left({\cos \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)}^{2}\right), \left({a}^{2}\right)\right), \mathsf{pow.f64}\left(\color{blue}{\mathsf{*.f64}\left(b, \mathsf{sin.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right)}, 2\right)\right) \]
  4. Applied egg-rr79.7%

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

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

Alternative 5: 79.6% accurate, 2.0× speedup?

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

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

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

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

      \[\leadsto \mathsf{+.f64}\left(\left(a \cdot a\right), \mathsf{pow.f64}\left(\color{blue}{\mathsf{*.f64}\left(b, \mathsf{sin.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right)}, 2\right)\right) \]
    2. *-lowering-*.f6479.3%

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(a, a\right), \mathsf{pow.f64}\left(\color{blue}{\mathsf{*.f64}\left(b, \mathsf{sin.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right)}, 2\right)\right) \]
  5. Simplified79.3%

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

Alternative 6: 57.7% accurate, 3.3× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;a \cdot a + b \cdot \left(b \cdot \left(0.5 - 0.5 \cdot \cos \left(2 \cdot \frac{0.005555555555555556}{\frac{1}{\pi \cdot angle}}\right)\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < 4.2e-35

    1. Initial program 77.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(a, a\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(angle, angle\right), \left(\left(\left(\frac{-1}{32400} \cdot {a}^{2}\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \mathsf{PI}\left(\right) + \left(\left(\frac{1}{32400} \cdot {b}^{2}\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \color{blue}{\mathsf{PI}\left(\right)}\right)\right)\right) \]
      14. distribute-rgt-outN/A

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(a, a\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(angle, angle\right), \mathsf{*.f64}\left(\mathsf{PI}\left(\right), \color{blue}{\left(\left(\frac{-1}{32400} \cdot {a}^{2}\right) \cdot \mathsf{PI}\left(\right) + \left(\frac{1}{32400} \cdot {b}^{2}\right) \cdot \mathsf{PI}\left(\right)\right)}\right)\right)\right) \]
    5. Simplified44.6%

      \[\leadsto \color{blue}{a \cdot a + \left(angle \cdot angle\right) \cdot \left(\pi \cdot \left(\pi \cdot \left(\left(b \cdot b\right) \cdot 3.08641975308642 \cdot 10^{-5} + \left(a \cdot a\right) \cdot -3.08641975308642 \cdot 10^{-5}\right)\right)\right)} \]
    6. Step-by-step derivation
      1. associate-*l*N/A

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

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(a, a\right), \mathsf{*.f64}\left(\left(angle \cdot \left(\mathsf{PI}\left(\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \left(\left(b \cdot b\right) \cdot \frac{1}{32400} + \left(a \cdot a\right) \cdot \frac{-1}{32400}\right)\right)\right)\right), \color{blue}{angle}\right)\right) \]
    7. Applied egg-rr50.6%

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

    if 4.2e-35 < a

    1. Initial program 84.4%

      \[{\left(a \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. unpow2N/A

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

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{pow.f64}\left(\mathsf{*.f64}\left(a, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right), 2\right), \left(\left(\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right) \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right) \cdot \color{blue}{b}\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{pow.f64}\left(\mathsf{*.f64}\left(a, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right), 2\right), \mathsf{*.f64}\left(\left(\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right) \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right), \color{blue}{b}\right)\right) \]
    4. Applied egg-rr84.4%

      \[\leadsto {\left(a \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + \color{blue}{\left(b \cdot \left(0.5 - 0.5 \cdot \cos \left(2 \cdot \frac{\pi}{\frac{180}{angle}}\right)\right)\right) \cdot b} \]
    5. Step-by-step derivation
      1. associate-/r/N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{pow.f64}\left(\mathsf{*.f64}\left(a, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right), 2\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, \mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \left(\frac{\mathsf{PI}\left(\right)}{180} \cdot angle\right)\right)\right)\right)\right)\right), b\right)\right) \]
      2. associate-*l/N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{pow.f64}\left(\mathsf{*.f64}\left(a, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right), 2\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, \mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \left(\frac{\mathsf{PI}\left(\right) \cdot angle}{180}\right)\right)\right)\right)\right)\right), b\right)\right) \]
      3. clear-numN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{pow.f64}\left(\mathsf{*.f64}\left(a, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right), 2\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, \mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \left(\frac{1}{\frac{180}{\mathsf{PI}\left(\right) \cdot angle}}\right)\right)\right)\right)\right)\right), b\right)\right) \]
      4. div-invN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{pow.f64}\left(\mathsf{*.f64}\left(a, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right), 2\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, \mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \left(\frac{1}{180 \cdot \frac{1}{\mathsf{PI}\left(\right) \cdot angle}}\right)\right)\right)\right)\right)\right), b\right)\right) \]
      5. associate-/r*N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{pow.f64}\left(\mathsf{*.f64}\left(a, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right), 2\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, \mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \left(\frac{\frac{1}{180}}{\frac{1}{\mathsf{PI}\left(\right) \cdot angle}}\right)\right)\right)\right)\right)\right), b\right)\right) \]
      6. /-lowering-/.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{pow.f64}\left(\mathsf{*.f64}\left(a, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right), 2\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, \mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{/.f64}\left(\left(\frac{1}{180}\right), \left(\frac{1}{\mathsf{PI}\left(\right) \cdot angle}\right)\right)\right)\right)\right)\right)\right), b\right)\right) \]
      7. metadata-evalN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{pow.f64}\left(\mathsf{*.f64}\left(a, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right), 2\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, \mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{/.f64}\left(\frac{1}{180}, \left(\frac{1}{\mathsf{PI}\left(\right) \cdot angle}\right)\right)\right)\right)\right)\right)\right), b\right)\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{pow.f64}\left(\mathsf{*.f64}\left(a, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right), 2\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, \mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{/.f64}\left(\frac{1}{180}, \mathsf{/.f64}\left(1, \left(\mathsf{PI}\left(\right) \cdot angle\right)\right)\right)\right)\right)\right)\right)\right), b\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{pow.f64}\left(\mathsf{*.f64}\left(a, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right), 2\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, \mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{/.f64}\left(\frac{1}{180}, \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(\mathsf{PI}\left(\right), angle\right)\right)\right)\right)\right)\right)\right)\right), b\right)\right) \]
      10. PI-lowering-PI.f6484.4%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{pow.f64}\left(\mathsf{*.f64}\left(a, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right), 2\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, \mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{/.f64}\left(\frac{1}{180}, \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), angle\right)\right)\right)\right)\right)\right)\right)\right), b\right)\right) \]
    6. Applied egg-rr84.4%

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

      \[\leadsto \mathsf{+.f64}\left(\color{blue}{\left({a}^{2}\right)}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, \mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{/.f64}\left(\frac{1}{180}, \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), angle\right)\right)\right)\right)\right)\right)\right)\right), b\right)\right) \]
    8. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\left(a \cdot a\right), \mathsf{*.f64}\left(\color{blue}{\mathsf{*.f64}\left(b, \mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{/.f64}\left(\frac{1}{180}, \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), angle\right)\right)\right)\right)\right)\right)\right)\right)}, b\right)\right) \]
      2. *-lowering-*.f6483.2%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(a, a\right), \mathsf{*.f64}\left(\color{blue}{\mathsf{*.f64}\left(b, \mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{/.f64}\left(\frac{1}{180}, \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), angle\right)\right)\right)\right)\right)\right)\right)\right)}, b\right)\right) \]
    9. Simplified83.2%

      \[\leadsto \color{blue}{a \cdot a} + \left(b \cdot \left(0.5 - 0.5 \cdot \cos \left(2 \cdot \frac{0.005555555555555556}{\frac{1}{\pi \cdot angle}}\right)\right)\right) \cdot b \]
  3. Recombined 2 regimes into one program.
  4. Final simplification59.4%

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

Alternative 7: 57.7% accurate, 3.4× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < 9.0000000000000002e-35

    1. Initial program 77.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(a, a\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(angle, angle\right), \left(\left(\left(\frac{-1}{32400} \cdot {a}^{2}\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \mathsf{PI}\left(\right) + \left(\left(\frac{1}{32400} \cdot {b}^{2}\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \color{blue}{\mathsf{PI}\left(\right)}\right)\right)\right) \]
      14. distribute-rgt-outN/A

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(a, a\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(angle, angle\right), \mathsf{*.f64}\left(\mathsf{PI}\left(\right), \color{blue}{\left(\left(\frac{-1}{32400} \cdot {a}^{2}\right) \cdot \mathsf{PI}\left(\right) + \left(\frac{1}{32400} \cdot {b}^{2}\right) \cdot \mathsf{PI}\left(\right)\right)}\right)\right)\right) \]
    5. Simplified44.6%

      \[\leadsto \color{blue}{a \cdot a + \left(angle \cdot angle\right) \cdot \left(\pi \cdot \left(\pi \cdot \left(\left(b \cdot b\right) \cdot 3.08641975308642 \cdot 10^{-5} + \left(a \cdot a\right) \cdot -3.08641975308642 \cdot 10^{-5}\right)\right)\right)} \]
    6. Step-by-step derivation
      1. associate-*l*N/A

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

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(a, a\right), \mathsf{*.f64}\left(\left(angle \cdot \left(\mathsf{PI}\left(\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \left(\left(b \cdot b\right) \cdot \frac{1}{32400} + \left(a \cdot a\right) \cdot \frac{-1}{32400}\right)\right)\right)\right), \color{blue}{angle}\right)\right) \]
    7. Applied egg-rr50.6%

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

    if 9.0000000000000002e-35 < a

    1. Initial program 84.4%

      \[{\left(a \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. unpow2N/A

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

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{pow.f64}\left(\mathsf{*.f64}\left(a, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right), 2\right), \left(\left(\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right) \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right) \cdot \color{blue}{b}\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{pow.f64}\left(\mathsf{*.f64}\left(a, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right), 2\right), \mathsf{*.f64}\left(\left(\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right) \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right), \color{blue}{b}\right)\right) \]
    4. Applied egg-rr84.4%

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

      \[\leadsto \mathsf{+.f64}\left(\color{blue}{\left({a}^{2}\right)}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, \mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(180, angle\right)\right)\right)\right)\right)\right)\right), b\right)\right) \]
    6. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\left(a \cdot a\right), \mathsf{*.f64}\left(\color{blue}{\mathsf{*.f64}\left(b, \mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(180, angle\right)\right)\right)\right)\right)\right)\right)}, b\right)\right) \]
      2. *-lowering-*.f6483.2%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(a, a\right), \mathsf{*.f64}\left(\color{blue}{\mathsf{*.f64}\left(b, \mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(180, angle\right)\right)\right)\right)\right)\right)\right)}, b\right)\right) \]
    7. Simplified83.2%

      \[\leadsto \color{blue}{a \cdot a} + \left(b \cdot \left(0.5 - 0.5 \cdot \cos \left(2 \cdot \frac{\pi}{\frac{180}{angle}}\right)\right)\right) \cdot b \]
  3. Recombined 2 regimes into one program.
  4. Final simplification59.4%

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

Alternative 8: 62.1% accurate, 3.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq 4 \cdot 10^{-35}:\\
\;\;\;\;\left(1 + \cos \left(\left(\pi \cdot angle\right) \cdot -0.011111111111111112\right)\right) \cdot \left(0.5 \cdot \left(a \cdot a\right)\right)\\

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


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

    1. Initial program 79.9%

      \[{\left(a \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. unpow-prod-downN/A

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

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left({\cos \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)}^{2}\right), \left({a}^{2}\right)\right), \mathsf{pow.f64}\left(\color{blue}{\mathsf{*.f64}\left(b, \mathsf{sin.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(angle, 180\right)\right)\right)\right)}, 2\right)\right) \]
    4. Applied egg-rr79.9%

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

      \[\leadsto \color{blue}{{a}^{2} \cdot \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\frac{-1}{90} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)\right)} \]
    6. Step-by-step derivation
      1. distribute-lft-inN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{-1}{90}, \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)\right), 1\right), \left({a}^{2} \cdot \frac{1}{2}\right)\right) \]
      11. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{-1}{90}, \mathsf{*.f64}\left(angle, \mathsf{PI}\left(\right)\right)\right)\right), 1\right), \left({a}^{2} \cdot \frac{1}{2}\right)\right) \]
      12. PI-lowering-PI.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{-1}{90}, \mathsf{*.f64}\left(angle, \mathsf{PI.f64}\left(\right)\right)\right)\right), 1\right), \left({a}^{2} \cdot \frac{1}{2}\right)\right) \]
      13. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{-1}{90}, \mathsf{*.f64}\left(angle, \mathsf{PI.f64}\left(\right)\right)\right)\right), 1\right), \mathsf{*.f64}\left(\left({a}^{2}\right), \color{blue}{\frac{1}{2}}\right)\right) \]
      14. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{-1}{90}, \mathsf{*.f64}\left(angle, \mathsf{PI.f64}\left(\right)\right)\right)\right), 1\right), \mathsf{*.f64}\left(\left(a \cdot a\right), \frac{1}{2}\right)\right) \]
      15. *-lowering-*.f6467.5%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{-1}{90}, \mathsf{*.f64}\left(angle, \mathsf{PI.f64}\left(\right)\right)\right)\right), 1\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, a\right), \frac{1}{2}\right)\right) \]
    7. Simplified67.5%

      \[\leadsto \color{blue}{\left(\cos \left(-0.011111111111111112 \cdot \left(angle \cdot \pi\right)\right) + 1\right) \cdot \left(\left(a \cdot a\right) \cdot 0.5\right)} \]

    if 4.00000000000000003e-35 < b

    1. Initial program 79.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(a, a\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(angle, angle\right), \left(\left(\left(\frac{-1}{32400} \cdot {a}^{2}\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \mathsf{PI}\left(\right) + \left(\left(\frac{1}{32400} \cdot {b}^{2}\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \color{blue}{\mathsf{PI}\left(\right)}\right)\right)\right) \]
      14. distribute-rgt-outN/A

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(a, a\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(angle, angle\right), \mathsf{*.f64}\left(\mathsf{PI}\left(\right), \color{blue}{\left(\left(\frac{-1}{32400} \cdot {a}^{2}\right) \cdot \mathsf{PI}\left(\right) + \left(\frac{1}{32400} \cdot {b}^{2}\right) \cdot \mathsf{PI}\left(\right)\right)}\right)\right)\right) \]
    5. Simplified43.9%

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

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

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(a, a\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(angle, angle\right), \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(\frac{1}{32400}, \left(b \cdot \color{blue}{b}\right)\right)\right)\right)\right)\right) \]
      3. *-lowering-*.f6462.0%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(a, a\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(angle, angle\right), \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(\frac{1}{32400}, \mathsf{*.f64}\left(b, \color{blue}{b}\right)\right)\right)\right)\right)\right) \]
    8. Simplified62.0%

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

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

Alternative 9: 62.4% accurate, 18.9× speedup?

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

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

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


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

    1. Initial program 79.8%

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

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

        \[\leadsto a \cdot \color{blue}{a} \]
      2. *-lowering-*.f6467.3%

        \[\leadsto \mathsf{*.f64}\left(a, \color{blue}{a}\right) \]
    5. Simplified67.3%

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

    if 6.9999999999999995e-44 < b

    1. Initial program 79.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(a, a\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(angle, angle\right), \left(\left(\left(\frac{-1}{32400} \cdot {a}^{2}\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \mathsf{PI}\left(\right) + \left(\left(\frac{1}{32400} \cdot {b}^{2}\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \color{blue}{\mathsf{PI}\left(\right)}\right)\right)\right) \]
      14. distribute-rgt-outN/A

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(a, a\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(angle, angle\right), \mathsf{*.f64}\left(\mathsf{PI}\left(\right), \color{blue}{\left(\left(\frac{-1}{32400} \cdot {a}^{2}\right) \cdot \mathsf{PI}\left(\right) + \left(\frac{1}{32400} \cdot {b}^{2}\right) \cdot \mathsf{PI}\left(\right)\right)}\right)\right)\right) \]
    5. Simplified45.1%

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

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

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(a, a\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(angle, angle\right), \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(\frac{1}{32400}, \left(b \cdot \color{blue}{b}\right)\right)\right)\right)\right)\right) \]
      3. *-lowering-*.f6463.7%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(a, a\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(angle, angle\right), \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(\frac{1}{32400}, \mathsf{*.f64}\left(b, \color{blue}{b}\right)\right)\right)\right)\right)\right) \]
    8. Simplified63.7%

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

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

Alternative 10: 61.5% accurate, 23.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq 5.6 \cdot 10^{+162}:\\
\;\;\;\;a \cdot a\\

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


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

    1. Initial program 78.2%

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

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

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

        \[\leadsto \mathsf{*.f64}\left(a, \color{blue}{a}\right) \]
    5. Simplified62.6%

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

    if 5.59999999999999981e162 < b

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(a, a\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(angle, angle\right), \left(\left(\left(\frac{-1}{32400} \cdot {a}^{2}\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \mathsf{PI}\left(\right) + \left(\left(\frac{1}{32400} \cdot {b}^{2}\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \color{blue}{\mathsf{PI}\left(\right)}\right)\right)\right) \]
      14. distribute-rgt-outN/A

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(a, a\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(angle, angle\right), \mathsf{*.f64}\left(\mathsf{PI}\left(\right), \color{blue}{\left(\left(\frac{-1}{32400} \cdot {a}^{2}\right) \cdot \mathsf{PI}\left(\right) + \left(\frac{1}{32400} \cdot {b}^{2}\right) \cdot \mathsf{PI}\left(\right)\right)}\right)\right)\right) \]
    5. Simplified67.6%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(angle, angle\right), \left({b}^{2} \cdot \left(\left(\mathsf{neg}\left(\frac{-1}{32400}\right)\right) \cdot {\color{blue}{\mathsf{PI}\left(\right)}}^{2}\right)\right)\right) \]
      11. distribute-lft-neg-inN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(angle, angle\right), \left({b}^{2} \cdot \left(\mathsf{neg}\left(\frac{-1}{32400} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)\right)\right) \]
      12. *-lowering-*.f64N/A

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(angle, angle\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, b\right), \left({\mathsf{PI}\left(\right)}^{2} \cdot \frac{1}{32400}\right)\right)\right) \]
      18. *-lowering-*.f64N/A

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(angle, angle\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, b\right), \mathsf{*.f64}\left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right), \frac{1}{32400}\right)\right)\right) \]
      20. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(angle, angle\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, b\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{PI}\left(\right), \mathsf{PI}\left(\right)\right), \frac{1}{32400}\right)\right)\right) \]
      21. PI-lowering-PI.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(angle, angle\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, b\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{PI}\left(\right)\right), \frac{1}{32400}\right)\right)\right) \]
      22. PI-lowering-PI.f6478.7%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(angle, angle\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, b\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{PI.f64}\left(\right)\right), \frac{1}{32400}\right)\right)\right) \]
    8. Simplified78.7%

      \[\leadsto \color{blue}{\left(angle \cdot angle\right) \cdot \left(\left(b \cdot b\right) \cdot \left(\left(\pi \cdot \pi\right) \cdot 3.08641975308642 \cdot 10^{-5}\right)\right)} \]
    9. Step-by-step derivation
      1. associate-*l*N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(angle, angle\right), b\right), \mathsf{*.f64}\left(b, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(\mathsf{PI}\left(\right), \color{blue}{\frac{1}{32400}}\right)\right)\right)\right) \]
      11. PI-lowering-PI.f6478.8%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(angle, angle\right), b\right), \mathsf{*.f64}\left(b, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \frac{1}{32400}\right)\right)\right)\right) \]
    10. Applied egg-rr78.8%

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

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

Alternative 11: 61.5% accurate, 23.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq 5.5 \cdot 10^{+162}:\\
\;\;\;\;a \cdot a\\

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


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

    1. Initial program 78.2%

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

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

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

        \[\leadsto \mathsf{*.f64}\left(a, \color{blue}{a}\right) \]
    5. Simplified62.6%

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

    if 5.49999999999999966e162 < b

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(a, a\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(angle, angle\right), \left(\left(\left(\frac{-1}{32400} \cdot {a}^{2}\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \mathsf{PI}\left(\right) + \left(\left(\frac{1}{32400} \cdot {b}^{2}\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \color{blue}{\mathsf{PI}\left(\right)}\right)\right)\right) \]
      14. distribute-rgt-outN/A

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(a, a\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(angle, angle\right), \mathsf{*.f64}\left(\mathsf{PI}\left(\right), \color{blue}{\left(\left(\frac{-1}{32400} \cdot {a}^{2}\right) \cdot \mathsf{PI}\left(\right) + \left(\frac{1}{32400} \cdot {b}^{2}\right) \cdot \mathsf{PI}\left(\right)\right)}\right)\right)\right) \]
    5. Simplified67.6%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(angle, angle\right), \left({b}^{2} \cdot \left(\left(\mathsf{neg}\left(\frac{-1}{32400}\right)\right) \cdot {\color{blue}{\mathsf{PI}\left(\right)}}^{2}\right)\right)\right) \]
      11. distribute-lft-neg-inN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(angle, angle\right), \left({b}^{2} \cdot \left(\mathsf{neg}\left(\frac{-1}{32400} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)\right)\right) \]
      12. *-lowering-*.f64N/A

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(angle, angle\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, b\right), \left({\mathsf{PI}\left(\right)}^{2} \cdot \frac{1}{32400}\right)\right)\right) \]
      18. *-lowering-*.f64N/A

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(angle, angle\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, b\right), \mathsf{*.f64}\left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right), \frac{1}{32400}\right)\right)\right) \]
      20. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(angle, angle\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, b\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{PI}\left(\right), \mathsf{PI}\left(\right)\right), \frac{1}{32400}\right)\right)\right) \]
      21. PI-lowering-PI.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(angle, angle\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, b\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{PI}\left(\right)\right), \frac{1}{32400}\right)\right)\right) \]
      22. PI-lowering-PI.f6478.7%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(angle, angle\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, b\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{PI.f64}\left(\right)\right), \frac{1}{32400}\right)\right)\right) \]
    8. Simplified78.7%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(b, \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(\mathsf{PI}\left(\right), \frac{1}{32400}\right)\right)\right), \left(angle \cdot angle\right)\right)\right) \]
      11. PI-lowering-PI.f64N/A

        \[\leadsto \mathsf{*.f64}\left(b, \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \frac{1}{32400}\right)\right)\right), \left(angle \cdot angle\right)\right)\right) \]
      12. *-lowering-*.f6478.8%

        \[\leadsto \mathsf{*.f64}\left(b, \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \frac{1}{32400}\right)\right)\right), \mathsf{*.f64}\left(angle, \color{blue}{angle}\right)\right)\right) \]
    10. Applied egg-rr78.8%

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

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

Alternative 12: 57.3% accurate, 139.0× speedup?

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

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

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

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

      \[\leadsto a \cdot \color{blue}{a} \]
    2. *-lowering-*.f6459.6%

      \[\leadsto \mathsf{*.f64}\left(a, \color{blue}{a}\right) \]
  5. Simplified59.6%

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

Reproduce

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