ab-angle->ABCF C

Percentage Accurate: 79.4% → 79.4%
Time: 16.0s
Alternatives: 12
Speedup: N/A×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 12 alternatives:

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

Initial Program: 79.4% accurate, 1.0× speedup?

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

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

Alternative 1: 79.4% accurate, 1.6× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 79.4% accurate, 1.9× speedup?

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

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

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

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

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

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

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

Alternative 3: 79.4% accurate, 2.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 76.0% accurate, 2.7× speedup?

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

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

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


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

    1. Initial program 88.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2e24 < (/.f64 angle #s(literal 180 binary64))

    1. Initial program 59.1%

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

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

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

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

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

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

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

Alternative 5: 76.9% accurate, 3.0× speedup?

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

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

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


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

    1. Initial program 88.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 61.3%

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

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

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

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

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

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

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

Alternative 6: 67.0% accurate, 3.4× speedup?

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

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

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


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

    1. Initial program 78.9%

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

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

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

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

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

    if 3.20000000000000028e-110 < b

    1. Initial program 85.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 62.5% accurate, 9.1× speedup?

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

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

\mathbf{elif}\;b \leq 1.1 \cdot 10^{+140}:\\
\;\;\;\;\mathsf{fma}\left(3.08641975308642 \cdot 10^{-5}, \left(b \cdot b\right) \cdot \left(angle \cdot \left(angle \cdot \left(\pi \cdot \pi\right)\right)\right), a \cdot a\right)\\

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


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

    1. Initial program 78.9%

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

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

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

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

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

    if 3.20000000000000028e-110 < b < 1.0999999999999999e140

    1. Initial program 72.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{1}{32400}, \left(b \cdot b\right) \cdot \left(angle \cdot \left(angle \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)\right), \color{blue}{a \cdot a}\right) \]
      17. lower-*.f6465.9

        \[\leadsto \mathsf{fma}\left(3.08641975308642 \cdot 10^{-5}, \left(b \cdot b\right) \cdot \left(angle \cdot \left(angle \cdot \left(\pi \cdot \pi\right)\right)\right), \color{blue}{a \cdot a}\right) \]
    8. Applied rewrites65.9%

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

    if 1.0999999999999999e140 < b

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{1}{32400}, \left(b \cdot b\right) \cdot \left(angle \cdot \left(angle \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)\right), \color{blue}{a \cdot a}\right) \]
      17. lower-*.f6456.0

        \[\leadsto \mathsf{fma}\left(3.08641975308642 \cdot 10^{-5}, \left(b \cdot b\right) \cdot \left(angle \cdot \left(angle \cdot \left(\pi \cdot \pi\right)\right)\right), \color{blue}{a \cdot a}\right) \]
    8. Applied rewrites56.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(b \cdot b\right) \cdot \color{blue}{\left({\mathsf{PI}\left(\right)}^{2} \cdot \left(\frac{1}{32400} \cdot {angle}^{2}\right)\right)} \]
    11. Applied rewrites56.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(b \cdot \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \left(\frac{1}{32400} \cdot \left(angle \cdot angle\right)\right)\right)\right) \cdot b} \]
    13. Applied rewrites66.2%

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

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

Alternative 8: 71.6% accurate, 10.4× speedup?

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

\\
\begin{array}{l}
t_0 := \pi \cdot \left(angle \cdot \pi\right)\\
\mathbf{if}\;b \leq 5 \cdot 10^{+110}:\\
\;\;\;\;\mathsf{fma}\left(angle \cdot \left(b \cdot b\right), t\_0 \cdot 3.08641975308642 \cdot 10^{-5}, a \cdot a\right)\\

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{1}{32400}, \left(b \cdot b\right) \cdot \left(angle \cdot \left(angle \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)\right), \color{blue}{a \cdot a}\right) \]
      17. lower-*.f6463.2

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

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

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

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

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

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

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

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

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

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

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

    if 4.99999999999999978e110 < b

    1. Initial program 94.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{1}{32400}, \left(b \cdot b\right) \cdot \left(angle \cdot \left(angle \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)\right), \color{blue}{a \cdot a}\right) \]
      17. lower-*.f6454.7

        \[\leadsto \mathsf{fma}\left(3.08641975308642 \cdot 10^{-5}, \left(b \cdot b\right) \cdot \left(angle \cdot \left(angle \cdot \left(\pi \cdot \pi\right)\right)\right), \color{blue}{a \cdot a}\right) \]
    8. Applied rewrites54.7%

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{1}{32400}, \color{blue}{\left(b \cdot \left(angle \cdot \left(angle \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \cdot b}, a \cdot a\right) \]
      9. lower-*.f6485.5

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{1}{32400}, \left(b \cdot \left(angle \cdot \left(\mathsf{PI}\left(\right) \cdot \color{blue}{\left(\mathsf{PI}\left(\right) \cdot angle\right)}\right)\right)\right) \cdot b, a \cdot a\right) \]
      15. lower-*.f6485.5

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

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

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

Alternative 9: 65.0% accurate, 10.4× speedup?

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

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

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


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

    1. Initial program 78.9%

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

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

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

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

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

    if 3.20000000000000028e-110 < b

    1. Initial program 85.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{1}{32400}, \left(b \cdot b\right) \cdot \left(angle \cdot \left(angle \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)\right), \color{blue}{a \cdot a}\right) \]
      17. lower-*.f6461.3

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{1}{32400}, \color{blue}{\left(b \cdot \left(angle \cdot \left(angle \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \cdot b}, a \cdot a\right) \]
      9. lower-*.f6477.4

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{1}{32400}, \left(b \cdot \left(angle \cdot \left(\mathsf{PI}\left(\right) \cdot \color{blue}{\left(\mathsf{PI}\left(\right) \cdot angle\right)}\right)\right)\right) \cdot b, a \cdot a\right) \]
      15. lower-*.f6477.4

        \[\leadsto \mathsf{fma}\left(3.08641975308642 \cdot 10^{-5}, \left(b \cdot \left(angle \cdot \color{blue}{\left(\pi \cdot \left(\pi \cdot angle\right)\right)}\right)\right) \cdot b, a \cdot a\right) \]
    10. Applied rewrites77.4%

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

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

Alternative 10: 60.9% accurate, 12.1× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;b \cdot \left(\left(b \cdot \pi\right) \cdot \left(\left(angle \cdot angle\right) \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 < 1.5500000000000001e98

    1. Initial program 78.4%

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

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

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

        \[\leadsto \color{blue}{a \cdot a} \]
    5. Applied rewrites63.3%

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

    if 1.5500000000000001e98 < b

    1. Initial program 91.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{1}{32400}, \left(b \cdot b\right) \cdot \left(angle \cdot \left(angle \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)\right), \color{blue}{a \cdot a}\right) \]
      17. lower-*.f6454.5

        \[\leadsto \mathsf{fma}\left(3.08641975308642 \cdot 10^{-5}, \left(b \cdot b\right) \cdot \left(angle \cdot \left(angle \cdot \left(\pi \cdot \pi\right)\right)\right), \color{blue}{a \cdot a}\right) \]
    8. Applied rewrites54.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(b \cdot b\right) \cdot \color{blue}{\left({\mathsf{PI}\left(\right)}^{2} \cdot \left(\frac{1}{32400} \cdot {angle}^{2}\right)\right)} \]
    11. Applied rewrites54.5%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(b \cdot \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \left(\frac{1}{32400} \cdot \left(angle \cdot angle\right)\right)\right)\right) \cdot b} \]
    13. Applied rewrites62.4%

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

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

Alternative 11: 60.6% accurate, 12.1× speedup?

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

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

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


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

    1. Initial program 77.9%

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

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

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

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

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

    if 1.12e160 < b

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{1}{32400}, \left(b \cdot b\right) \cdot \left(angle \cdot \left(angle \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)\right), \color{blue}{a \cdot a}\right) \]
      17. lower-*.f6457.7

        \[\leadsto \mathsf{fma}\left(3.08641975308642 \cdot 10^{-5}, \left(b \cdot b\right) \cdot \left(angle \cdot \left(angle \cdot \left(\pi \cdot \pi\right)\right)\right), \color{blue}{a \cdot a}\right) \]
    8. Applied rewrites57.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(b \cdot b\right) \cdot \color{blue}{\left({\mathsf{PI}\left(\right)}^{2} \cdot \left(\frac{1}{32400} \cdot {angle}^{2}\right)\right)} \]
    11. Applied rewrites57.7%

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

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

Alternative 12: 57.5% accurate, 74.7× speedup?

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

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

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

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

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

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

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

Reproduce

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