ab-angle->ABCF C

Percentage Accurate: 79.1% → 79.0%
Time: 5.0s
Alternatives: 10
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}

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 10 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.1% 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.0% accurate, 1.9× speedup?

\[\begin{array}{l} angle_m = \left|angle\right| \\ \begin{array}{l} \mathbf{if}\;angle\_m \leq 3.2 \cdot 10^{-18}:\\ \;\;\;\;a \cdot a + \left(\left(\left(b \cdot \pi\right) \cdot angle\_m\right) \cdot \left(\left(angle\_m \cdot b\right) \cdot \pi\right)\right) \cdot 3.08641975308642 \cdot 10^{-5}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left({\sin \left(\left(angle\_m \cdot \pi\right) \cdot 0.005555555555555556\right)}^{2}, b \cdot b, a \cdot a\right)\\ \end{array} \end{array} \]
angle_m = (fabs.f64 angle)
(FPCore (a b angle_m)
 :precision binary64
 (if (<= angle_m 3.2e-18)
   (+
    (* a a)
    (* (* (* (* b PI) angle_m) (* (* angle_m b) PI)) 3.08641975308642e-5))
   (fma
    (pow (sin (* (* angle_m PI) 0.005555555555555556)) 2.0)
    (* b b)
    (* a a))))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
	double tmp;
	if (angle_m <= 3.2e-18) {
		tmp = (a * a) + ((((b * ((double) M_PI)) * angle_m) * ((angle_m * b) * ((double) M_PI))) * 3.08641975308642e-5);
	} else {
		tmp = fma(pow(sin(((angle_m * ((double) M_PI)) * 0.005555555555555556)), 2.0), (b * b), (a * a));
	}
	return tmp;
}
angle_m = abs(angle)
function code(a, b, angle_m)
	tmp = 0.0
	if (angle_m <= 3.2e-18)
		tmp = Float64(Float64(a * a) + Float64(Float64(Float64(Float64(b * pi) * angle_m) * Float64(Float64(angle_m * b) * pi)) * 3.08641975308642e-5));
	else
		tmp = fma((sin(Float64(Float64(angle_m * pi) * 0.005555555555555556)) ^ 2.0), Float64(b * b), Float64(a * a));
	end
	return tmp
end
angle_m = N[Abs[angle], $MachinePrecision]
code[a_, b_, angle$95$m_] := If[LessEqual[angle$95$m, 3.2e-18], N[(N[(a * a), $MachinePrecision] + N[(N[(N[(N[(b * Pi), $MachinePrecision] * angle$95$m), $MachinePrecision] * N[(N[(angle$95$m * b), $MachinePrecision] * Pi), $MachinePrecision]), $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision], N[(N[Power[N[Sin[N[(N[(angle$95$m * Pi), $MachinePrecision] * 0.005555555555555556), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] * N[(b * b), $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
angle_m = \left|angle\right|

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left({\sin \left(\left(angle\_m \cdot \pi\right) \cdot 0.005555555555555556\right)}^{2}, b \cdot b, a \cdot a\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if angle < 3.1999999999999999e-18

    1. Initial program 87.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(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
    4. Step-by-step derivation
      1. unpow2N/A

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

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

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

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

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

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

        \[\leadsto a \cdot a + \left({angle}^{2} \cdot {\left(b \cdot \mathsf{PI}\left(\right)\right)}^{2}\right) \cdot \frac{1}{32400} \]
      4. pow-prod-downN/A

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

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

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

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

        \[\leadsto a \cdot a + {\left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right)}^{2} \cdot \frac{1}{32400} \]
      9. lift-PI.f6484.0

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

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

        \[\leadsto a \cdot a + {\left(\left(b \cdot \pi\right) \cdot angle\right)}^{2} \cdot \frac{1}{32400} \]
      2. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto a \cdot a + \left(\left(\left(b \cdot \pi\right) \cdot angle\right) \cdot \left(\left(b \cdot \pi\right) \cdot angle\right)\right) \cdot \frac{1}{32400} \]
      12. lift-*.f6484.0

        \[\leadsto a \cdot a + \left(\left(\left(b \cdot \pi\right) \cdot angle\right) \cdot \left(\left(b \cdot \pi\right) \cdot angle\right)\right) \cdot 3.08641975308642 \cdot 10^{-5} \]
    10. Applied rewrites84.0%

      \[\leadsto a \cdot a + \left(\left(\left(b \cdot \pi\right) \cdot angle\right) \cdot \left(\left(b \cdot \pi\right) \cdot angle\right)\right) \cdot 3.08641975308642 \cdot 10^{-5} \]
    11. Step-by-step derivation
      1. lift-*.f64N/A

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

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

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

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

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

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

        \[\leadsto a \cdot a + \left(\left(\left(b \cdot \pi\right) \cdot angle\right) \cdot \left(\left(angle \cdot b\right) \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \frac{1}{32400} \]
      8. lift-PI.f6484.1

        \[\leadsto a \cdot a + \left(\left(\left(b \cdot \pi\right) \cdot angle\right) \cdot \left(\left(angle \cdot b\right) \cdot \pi\right)\right) \cdot 3.08641975308642 \cdot 10^{-5} \]
    12. Applied rewrites84.1%

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

    if 3.1999999999999999e-18 < angle

    1. Initial program 61.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(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
    4. Step-by-step derivation
      1. unpow2N/A

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto a \cdot a + {\left(b \cdot \frac{1}{{\sin \left(\color{blue}{\pi} \cdot \frac{angle}{180}\right)}^{-1}}\right)}^{2} \]
      13. lift-sin.f6461.7

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

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

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

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

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

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

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

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

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

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

        \[\leadsto a \cdot a + {\left(b \cdot \frac{1}{{\sin \left(\left(angle \cdot \mathsf{PI}\left(\right)\right) \cdot \frac{1}{180}\right)}^{-1}}\right)}^{2} \]
      4. lift-PI.f6462.1

        \[\leadsto a \cdot a + {\left(b \cdot \frac{1}{{\sin \left(\left(angle \cdot \pi\right) \cdot 0.005555555555555556\right)}^{-1}}\right)}^{2} \]
    10. Applied rewrites62.1%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left({\sin \left(\left(angle \cdot \pi\right) \cdot 0.005555555555555556\right)}^{2}, b \cdot b, a \cdot a\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification79.0%

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

Alternative 2: 79.1% accurate, 1.3× speedup?

\[\begin{array}{l} angle_m = \left|angle\right| \\ a \cdot a + {\left(b \cdot \frac{1}{{\sin \left(angle\_m \cdot \left(0.005555555555555556 \cdot \pi\right)\right)}^{-1}}\right)}^{2} \end{array} \]
angle_m = (fabs.f64 angle)
(FPCore (a b angle_m)
 :precision binary64
 (+
  (* a a)
  (pow
   (* b (/ 1.0 (pow (sin (* angle_m (* 0.005555555555555556 PI))) -1.0)))
   2.0)))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
	return (a * a) + pow((b * (1.0 / pow(sin((angle_m * (0.005555555555555556 * ((double) M_PI)))), -1.0))), 2.0);
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
	return (a * a) + Math.pow((b * (1.0 / Math.pow(Math.sin((angle_m * (0.005555555555555556 * Math.PI))), -1.0))), 2.0);
}
angle_m = math.fabs(angle)
def code(a, b, angle_m):
	return (a * a) + math.pow((b * (1.0 / math.pow(math.sin((angle_m * (0.005555555555555556 * math.pi))), -1.0))), 2.0)
angle_m = abs(angle)
function code(a, b, angle_m)
	return Float64(Float64(a * a) + (Float64(b * Float64(1.0 / (sin(Float64(angle_m * Float64(0.005555555555555556 * pi))) ^ -1.0))) ^ 2.0))
end
angle_m = abs(angle);
function tmp = code(a, b, angle_m)
	tmp = (a * a) + ((b * (1.0 / (sin((angle_m * (0.005555555555555556 * pi))) ^ -1.0))) ^ 2.0);
end
angle_m = N[Abs[angle], $MachinePrecision]
code[a_, b_, angle$95$m_] := N[(N[(a * a), $MachinePrecision] + N[Power[N[(b * N[(1.0 / N[Power[N[Sin[N[(angle$95$m * N[(0.005555555555555556 * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], -1.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
angle_m = \left|angle\right|

\\
a \cdot a + {\left(b \cdot \frac{1}{{\sin \left(angle\_m \cdot \left(0.005555555555555556 \cdot \pi\right)\right)}^{-1}}\right)}^{2}
\end{array}
Derivation
  1. Initial program 81.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(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
  4. Step-by-step derivation
    1. unpow2N/A

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

      \[\leadsto a \cdot \color{blue}{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-sin.f64N/A

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

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

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

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

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

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

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

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

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

      \[\leadsto a \cdot a + {\left(b \cdot \frac{1}{{\sin \left(\color{blue}{\pi} \cdot \frac{angle}{180}\right)}^{-1}}\right)}^{2} \]
    13. lift-sin.f6481.4

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

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

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

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

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

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

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

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

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

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

      \[\leadsto a \cdot a + {\left(b \cdot \frac{1}{{\sin \left(\left(angle \cdot \mathsf{PI}\left(\right)\right) \cdot \frac{1}{180}\right)}^{-1}}\right)}^{2} \]
    4. lift-PI.f6481.5

      \[\leadsto a \cdot a + {\left(b \cdot \frac{1}{{\sin \left(\left(angle \cdot \pi\right) \cdot 0.005555555555555556\right)}^{-1}}\right)}^{2} \]
  10. Applied rewrites81.5%

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

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

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

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

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

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

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

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

      \[\leadsto a \cdot a + {\left(b \cdot \frac{1}{{\sin \left(angle \cdot \left(0.005555555555555556 \cdot \pi\right)\right)}^{-1}}\right)}^{2} \]
  12. Applied rewrites81.5%

    \[\leadsto a \cdot a + {\left(b \cdot \frac{1}{{\sin \left(angle \cdot \color{blue}{\left(0.005555555555555556 \cdot \pi\right)}\right)}^{-1}}\right)}^{2} \]
  13. Final simplification81.5%

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

Alternative 3: 79.0% accurate, 1.8× speedup?

\[\begin{array}{l} angle_m = \left|angle\right| \\ a \cdot a + {\left(b \cdot \frac{1}{\frac{1}{\sin \left(\left(angle\_m \cdot \pi\right) \cdot 0.005555555555555556\right)}}\right)}^{2} \end{array} \]
angle_m = (fabs.f64 angle)
(FPCore (a b angle_m)
 :precision binary64
 (+
  (* a a)
  (pow
   (* b (/ 1.0 (/ 1.0 (sin (* (* angle_m PI) 0.005555555555555556)))))
   2.0)))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
	return (a * a) + pow((b * (1.0 / (1.0 / sin(((angle_m * ((double) M_PI)) * 0.005555555555555556))))), 2.0);
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
	return (a * a) + Math.pow((b * (1.0 / (1.0 / Math.sin(((angle_m * Math.PI) * 0.005555555555555556))))), 2.0);
}
angle_m = math.fabs(angle)
def code(a, b, angle_m):
	return (a * a) + math.pow((b * (1.0 / (1.0 / math.sin(((angle_m * math.pi) * 0.005555555555555556))))), 2.0)
angle_m = abs(angle)
function code(a, b, angle_m)
	return Float64(Float64(a * a) + (Float64(b * Float64(1.0 / Float64(1.0 / sin(Float64(Float64(angle_m * pi) * 0.005555555555555556))))) ^ 2.0))
end
angle_m = abs(angle);
function tmp = code(a, b, angle_m)
	tmp = (a * a) + ((b * (1.0 / (1.0 / sin(((angle_m * pi) * 0.005555555555555556))))) ^ 2.0);
end
angle_m = N[Abs[angle], $MachinePrecision]
code[a_, b_, angle$95$m_] := N[(N[(a * a), $MachinePrecision] + N[Power[N[(b * N[(1.0 / N[(1.0 / N[Sin[N[(N[(angle$95$m * Pi), $MachinePrecision] * 0.005555555555555556), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
angle_m = \left|angle\right|

\\
a \cdot a + {\left(b \cdot \frac{1}{\frac{1}{\sin \left(\left(angle\_m \cdot \pi\right) \cdot 0.005555555555555556\right)}}\right)}^{2}
\end{array}
Derivation
  1. Initial program 81.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(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
  4. Step-by-step derivation
    1. unpow2N/A

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

      \[\leadsto a \cdot \color{blue}{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-sin.f64N/A

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

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

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

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

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

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

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

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

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

      \[\leadsto a \cdot a + {\left(b \cdot \frac{1}{{\sin \left(\color{blue}{\pi} \cdot \frac{angle}{180}\right)}^{-1}}\right)}^{2} \]
    13. lift-sin.f6481.4

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

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

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

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

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

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

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

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

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

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

      \[\leadsto a \cdot a + {\left(b \cdot \frac{1}{{\sin \left(\left(angle \cdot \mathsf{PI}\left(\right)\right) \cdot \frac{1}{180}\right)}^{-1}}\right)}^{2} \]
    4. lift-PI.f6481.5

      \[\leadsto a \cdot a + {\left(b \cdot \frac{1}{{\sin \left(\left(angle \cdot \pi\right) \cdot 0.005555555555555556\right)}^{-1}}\right)}^{2} \]
  10. Applied rewrites81.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 79.1% accurate, 1.9× speedup?

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

\\
a \cdot a + {\left(b \cdot \sin \left(\pi \cdot \frac{angle\_m}{180}\right)\right)}^{2}
\end{array}
Derivation
  1. Initial program 81.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(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
  4. Step-by-step derivation
    1. unpow2N/A

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

      \[\leadsto a \cdot \color{blue}{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. Final simplification81.4%

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

Alternative 5: 79.0% accurate, 2.9× speedup?

\[\begin{array}{l} angle_m = \left|angle\right| \\ \begin{array}{l} \mathbf{if}\;angle\_m \leq 0.00036:\\ \;\;\;\;a \cdot a + \left(\left(\left(b \cdot \pi\right) \cdot angle\_m\right) \cdot \left(\left(angle\_m \cdot b\right) \cdot \pi\right)\right) \cdot 3.08641975308642 \cdot 10^{-5}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(\frac{angle\_m}{180} \cdot \pi\right)\right)\right) \cdot b, b, a \cdot a\right)\\ \end{array} \end{array} \]
angle_m = (fabs.f64 angle)
(FPCore (a b angle_m)
 :precision binary64
 (if (<= angle_m 0.00036)
   (+
    (* a a)
    (* (* (* (* b PI) angle_m) (* (* angle_m b) PI)) 3.08641975308642e-5))
   (fma
    (* (- 0.5 (* 0.5 (cos (* 2.0 (* (/ angle_m 180.0) PI))))) b)
    b
    (* a a))))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
	double tmp;
	if (angle_m <= 0.00036) {
		tmp = (a * a) + ((((b * ((double) M_PI)) * angle_m) * ((angle_m * b) * ((double) M_PI))) * 3.08641975308642e-5);
	} else {
		tmp = fma(((0.5 - (0.5 * cos((2.0 * ((angle_m / 180.0) * ((double) M_PI)))))) * b), b, (a * a));
	}
	return tmp;
}
angle_m = abs(angle)
function code(a, b, angle_m)
	tmp = 0.0
	if (angle_m <= 0.00036)
		tmp = Float64(Float64(a * a) + Float64(Float64(Float64(Float64(b * pi) * angle_m) * Float64(Float64(angle_m * b) * pi)) * 3.08641975308642e-5));
	else
		tmp = fma(Float64(Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(Float64(angle_m / 180.0) * pi))))) * b), b, Float64(a * a));
	end
	return tmp
end
angle_m = N[Abs[angle], $MachinePrecision]
code[a_, b_, angle$95$m_] := If[LessEqual[angle$95$m, 0.00036], N[(N[(a * a), $MachinePrecision] + N[(N[(N[(N[(b * Pi), $MachinePrecision] * angle$95$m), $MachinePrecision] * N[(N[(angle$95$m * b), $MachinePrecision] * Pi), $MachinePrecision]), $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision], N[(N[(N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(N[(angle$95$m / 180.0), $MachinePrecision] * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision] * b + N[(a * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
angle_m = \left|angle\right|

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if angle < 3.60000000000000023e-4

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

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

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

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

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

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

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

        \[\leadsto a \cdot a + \left({angle}^{2} \cdot {\left(b \cdot \mathsf{PI}\left(\right)\right)}^{2}\right) \cdot \frac{1}{32400} \]
      4. pow-prod-downN/A

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

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

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

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

        \[\leadsto a \cdot a + {\left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right)}^{2} \cdot \frac{1}{32400} \]
      9. lift-PI.f6484.2

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

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

        \[\leadsto a \cdot a + {\left(\left(b \cdot \pi\right) \cdot angle\right)}^{2} \cdot \frac{1}{32400} \]
      2. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto a \cdot a + \left(\left(\left(b \cdot \pi\right) \cdot angle\right) \cdot \left(\left(b \cdot \pi\right) \cdot angle\right)\right) \cdot \frac{1}{32400} \]
      12. lift-*.f6484.2

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

      \[\leadsto a \cdot a + \left(\left(\left(b \cdot \pi\right) \cdot angle\right) \cdot \left(\left(b \cdot \pi\right) \cdot angle\right)\right) \cdot 3.08641975308642 \cdot 10^{-5} \]
    11. Step-by-step derivation
      1. lift-*.f64N/A

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

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

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

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

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

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

        \[\leadsto a \cdot a + \left(\left(\left(b \cdot \pi\right) \cdot angle\right) \cdot \left(\left(angle \cdot b\right) \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \frac{1}{32400} \]
      8. lift-PI.f6484.2

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

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

    if 3.60000000000000023e-4 < angle

    1. Initial program 59.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(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
    4. Step-by-step derivation
      1. unpow2N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right) \cdot \sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)} \cdot b, b, a \cdot a\right) \]
      7. sqr-sin-aN/A

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(2 \cdot \color{blue}{\left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)}\right)\right) \cdot b, b, a \cdot a\right) \]
      14. lift-PI.f6460.4

        \[\leadsto \mathsf{fma}\left(\left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(\frac{angle}{180} \cdot \color{blue}{\pi}\right)\right)\right) \cdot b, b, a \cdot a\right) \]
    9. Applied rewrites60.4%

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

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

Alternative 6: 73.9% accurate, 11.5× speedup?

\[\begin{array}{l} angle_m = \left|angle\right| \\ a \cdot a + \left(\left(\left(b \cdot \pi\right) \cdot angle\_m\right) \cdot \left(\left(angle\_m \cdot b\right) \cdot \pi\right)\right) \cdot 3.08641975308642 \cdot 10^{-5} \end{array} \]
angle_m = (fabs.f64 angle)
(FPCore (a b angle_m)
 :precision binary64
 (+
  (* a a)
  (* (* (* (* b PI) angle_m) (* (* angle_m b) PI)) 3.08641975308642e-5)))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
	return (a * a) + ((((b * ((double) M_PI)) * angle_m) * ((angle_m * b) * ((double) M_PI))) * 3.08641975308642e-5);
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
	return (a * a) + ((((b * Math.PI) * angle_m) * ((angle_m * b) * Math.PI)) * 3.08641975308642e-5);
}
angle_m = math.fabs(angle)
def code(a, b, angle_m):
	return (a * a) + ((((b * math.pi) * angle_m) * ((angle_m * b) * math.pi)) * 3.08641975308642e-5)
angle_m = abs(angle)
function code(a, b, angle_m)
	return Float64(Float64(a * a) + Float64(Float64(Float64(Float64(b * pi) * angle_m) * Float64(Float64(angle_m * b) * pi)) * 3.08641975308642e-5))
end
angle_m = abs(angle);
function tmp = code(a, b, angle_m)
	tmp = (a * a) + ((((b * pi) * angle_m) * ((angle_m * b) * pi)) * 3.08641975308642e-5);
end
angle_m = N[Abs[angle], $MachinePrecision]
code[a_, b_, angle$95$m_] := N[(N[(a * a), $MachinePrecision] + N[(N[(N[(N[(b * Pi), $MachinePrecision] * angle$95$m), $MachinePrecision] * N[(N[(angle$95$m * b), $MachinePrecision] * Pi), $MachinePrecision]), $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
angle_m = \left|angle\right|

\\
a \cdot a + \left(\left(\left(b \cdot \pi\right) \cdot angle\_m\right) \cdot \left(\left(angle\_m \cdot b\right) \cdot \pi\right)\right) \cdot 3.08641975308642 \cdot 10^{-5}
\end{array}
Derivation
  1. Initial program 81.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(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
  4. Step-by-step derivation
    1. unpow2N/A

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

      \[\leadsto a \cdot \color{blue}{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. Taylor expanded in angle around 0

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

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

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

      \[\leadsto a \cdot a + \left({angle}^{2} \cdot {\left(b \cdot \mathsf{PI}\left(\right)\right)}^{2}\right) \cdot \frac{1}{32400} \]
    4. pow-prod-downN/A

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

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

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

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

      \[\leadsto a \cdot a + {\left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right)}^{2} \cdot \frac{1}{32400} \]
    9. lift-PI.f6477.7

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

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

      \[\leadsto a \cdot a + {\left(\left(b \cdot \pi\right) \cdot angle\right)}^{2} \cdot \frac{1}{32400} \]
    2. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

      \[\leadsto a \cdot a + \left(\left(\left(b \cdot \pi\right) \cdot angle\right) \cdot \left(\left(b \cdot \pi\right) \cdot angle\right)\right) \cdot \frac{1}{32400} \]
    12. lift-*.f6477.7

      \[\leadsto a \cdot a + \left(\left(\left(b \cdot \pi\right) \cdot angle\right) \cdot \left(\left(b \cdot \pi\right) \cdot angle\right)\right) \cdot 3.08641975308642 \cdot 10^{-5} \]
  10. Applied rewrites77.7%

    \[\leadsto a \cdot a + \left(\left(\left(b \cdot \pi\right) \cdot angle\right) \cdot \left(\left(b \cdot \pi\right) \cdot angle\right)\right) \cdot 3.08641975308642 \cdot 10^{-5} \]
  11. Step-by-step derivation
    1. lift-*.f64N/A

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

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

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

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

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

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

      \[\leadsto a \cdot a + \left(\left(\left(b \cdot \pi\right) \cdot angle\right) \cdot \left(\left(angle \cdot b\right) \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \frac{1}{32400} \]
    8. lift-PI.f6477.8

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

    \[\leadsto a \cdot a + \left(\left(\left(b \cdot \pi\right) \cdot angle\right) \cdot \left(\left(angle \cdot b\right) \cdot \pi\right)\right) \cdot 3.08641975308642 \cdot 10^{-5} \]
  13. Final simplification77.8%

    \[\leadsto a \cdot a + \left(\left(\left(b \cdot \pi\right) \cdot angle\right) \cdot \left(\left(angle \cdot b\right) \cdot \pi\right)\right) \cdot 3.08641975308642 \cdot 10^{-5} \]
  14. Add Preprocessing

Alternative 7: 73.9% accurate, 11.5× speedup?

\[\begin{array}{l} angle_m = \left|angle\right| \\ \begin{array}{l} t_0 := \left(angle\_m \cdot b\right) \cdot \pi\\ a \cdot a + \left(t\_0 \cdot t\_0\right) \cdot 3.08641975308642 \cdot 10^{-5} \end{array} \end{array} \]
angle_m = (fabs.f64 angle)
(FPCore (a b angle_m)
 :precision binary64
 (let* ((t_0 (* (* angle_m b) PI)))
   (+ (* a a) (* (* t_0 t_0) 3.08641975308642e-5))))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
	double t_0 = (angle_m * b) * ((double) M_PI);
	return (a * a) + ((t_0 * t_0) * 3.08641975308642e-5);
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
	double t_0 = (angle_m * b) * Math.PI;
	return (a * a) + ((t_0 * t_0) * 3.08641975308642e-5);
}
angle_m = math.fabs(angle)
def code(a, b, angle_m):
	t_0 = (angle_m * b) * math.pi
	return (a * a) + ((t_0 * t_0) * 3.08641975308642e-5)
angle_m = abs(angle)
function code(a, b, angle_m)
	t_0 = Float64(Float64(angle_m * b) * pi)
	return Float64(Float64(a * a) + Float64(Float64(t_0 * t_0) * 3.08641975308642e-5))
end
angle_m = abs(angle);
function tmp = code(a, b, angle_m)
	t_0 = (angle_m * b) * pi;
	tmp = (a * a) + ((t_0 * t_0) * 3.08641975308642e-5);
end
angle_m = N[Abs[angle], $MachinePrecision]
code[a_, b_, angle$95$m_] := Block[{t$95$0 = N[(N[(angle$95$m * b), $MachinePrecision] * Pi), $MachinePrecision]}, N[(N[(a * a), $MachinePrecision] + N[(N[(t$95$0 * t$95$0), $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
angle_m = \left|angle\right|

\\
\begin{array}{l}
t_0 := \left(angle\_m \cdot b\right) \cdot \pi\\
a \cdot a + \left(t\_0 \cdot t\_0\right) \cdot 3.08641975308642 \cdot 10^{-5}
\end{array}
\end{array}
Derivation
  1. Initial program 81.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(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
  4. Step-by-step derivation
    1. unpow2N/A

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

      \[\leadsto a \cdot \color{blue}{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. Taylor expanded in angle around 0

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

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

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

      \[\leadsto a \cdot a + \left({angle}^{2} \cdot {\left(b \cdot \mathsf{PI}\left(\right)\right)}^{2}\right) \cdot \frac{1}{32400} \]
    4. pow-prod-downN/A

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

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

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

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

      \[\leadsto a \cdot a + {\left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right)}^{2} \cdot \frac{1}{32400} \]
    9. lift-PI.f6477.7

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

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

      \[\leadsto a \cdot a + {\left(\left(b \cdot \pi\right) \cdot angle\right)}^{2} \cdot \frac{1}{32400} \]
    2. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

      \[\leadsto a \cdot a + \left(\left(\left(b \cdot \pi\right) \cdot angle\right) \cdot \left(\left(b \cdot \pi\right) \cdot angle\right)\right) \cdot \frac{1}{32400} \]
    12. lift-*.f6477.7

      \[\leadsto a \cdot a + \left(\left(\left(b \cdot \pi\right) \cdot angle\right) \cdot \left(\left(b \cdot \pi\right) \cdot angle\right)\right) \cdot 3.08641975308642 \cdot 10^{-5} \]
  10. Applied rewrites77.7%

    \[\leadsto a \cdot a + \left(\left(\left(b \cdot \pi\right) \cdot angle\right) \cdot \left(\left(b \cdot \pi\right) \cdot angle\right)\right) \cdot 3.08641975308642 \cdot 10^{-5} \]
  11. Step-by-step derivation
    1. lift-*.f64N/A

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

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

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

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

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

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

      \[\leadsto a \cdot a + \left(\left(\left(angle \cdot b\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \left(\left(b \cdot \pi\right) \cdot angle\right)\right) \cdot \frac{1}{32400} \]
    8. lift-PI.f6477.8

      \[\leadsto a \cdot a + \left(\left(\left(angle \cdot b\right) \cdot \pi\right) \cdot \left(\left(b \cdot \pi\right) \cdot angle\right)\right) \cdot 3.08641975308642 \cdot 10^{-5} \]
    9. lift-*.f64N/A

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

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

      \[\leadsto a \cdot a + \left(\left(\left(angle \cdot b\right) \cdot \pi\right) \cdot \left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right)\right) \cdot \frac{1}{32400} \]
    12. *-commutativeN/A

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

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

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

      \[\leadsto a \cdot a + \left(\left(\left(angle \cdot b\right) \cdot \pi\right) \cdot \left(\left(angle \cdot b\right) \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \frac{1}{32400} \]
    16. lift-PI.f6477.8

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

    \[\leadsto a \cdot a + \left(\left(\left(angle \cdot b\right) \cdot \pi\right) \cdot \left(\left(angle \cdot b\right) \cdot \pi\right)\right) \cdot 3.08641975308642 \cdot 10^{-5} \]
  13. Final simplification77.8%

    \[\leadsto a \cdot a + \left(\left(\left(angle \cdot b\right) \cdot \pi\right) \cdot \left(\left(angle \cdot b\right) \cdot \pi\right)\right) \cdot 3.08641975308642 \cdot 10^{-5} \]
  14. Add Preprocessing

Alternative 8: 74.0% accurate, 11.5× speedup?

\[\begin{array}{l} angle_m = \left|angle\right| \\ \begin{array}{l} t_0 := \left(angle\_m \cdot b\right) \cdot \pi\\ a \cdot a + t\_0 \cdot \left(t\_0 \cdot 3.08641975308642 \cdot 10^{-5}\right) \end{array} \end{array} \]
angle_m = (fabs.f64 angle)
(FPCore (a b angle_m)
 :precision binary64
 (let* ((t_0 (* (* angle_m b) PI)))
   (+ (* a a) (* t_0 (* t_0 3.08641975308642e-5)))))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
	double t_0 = (angle_m * b) * ((double) M_PI);
	return (a * a) + (t_0 * (t_0 * 3.08641975308642e-5));
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
	double t_0 = (angle_m * b) * Math.PI;
	return (a * a) + (t_0 * (t_0 * 3.08641975308642e-5));
}
angle_m = math.fabs(angle)
def code(a, b, angle_m):
	t_0 = (angle_m * b) * math.pi
	return (a * a) + (t_0 * (t_0 * 3.08641975308642e-5))
angle_m = abs(angle)
function code(a, b, angle_m)
	t_0 = Float64(Float64(angle_m * b) * pi)
	return Float64(Float64(a * a) + Float64(t_0 * Float64(t_0 * 3.08641975308642e-5)))
end
angle_m = abs(angle);
function tmp = code(a, b, angle_m)
	t_0 = (angle_m * b) * pi;
	tmp = (a * a) + (t_0 * (t_0 * 3.08641975308642e-5));
end
angle_m = N[Abs[angle], $MachinePrecision]
code[a_, b_, angle$95$m_] := Block[{t$95$0 = N[(N[(angle$95$m * b), $MachinePrecision] * Pi), $MachinePrecision]}, N[(N[(a * a), $MachinePrecision] + N[(t$95$0 * N[(t$95$0 * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
angle_m = \left|angle\right|

\\
\begin{array}{l}
t_0 := \left(angle\_m \cdot b\right) \cdot \pi\\
a \cdot a + t\_0 \cdot \left(t\_0 \cdot 3.08641975308642 \cdot 10^{-5}\right)
\end{array}
\end{array}
Derivation
  1. Initial program 81.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(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
  4. Step-by-step derivation
    1. unpow2N/A

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

      \[\leadsto a \cdot \color{blue}{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. Taylor expanded in angle around 0

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

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

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

      \[\leadsto a \cdot a + \left({angle}^{2} \cdot {\left(b \cdot \mathsf{PI}\left(\right)\right)}^{2}\right) \cdot \frac{1}{32400} \]
    4. pow-prod-downN/A

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

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

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

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

      \[\leadsto a \cdot a + {\left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right)}^{2} \cdot \frac{1}{32400} \]
    9. lift-PI.f6477.7

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

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

      \[\leadsto a \cdot a + {\left(\left(b \cdot \pi\right) \cdot angle\right)}^{2} \cdot \frac{1}{32400} \]
    2. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

      \[\leadsto a \cdot a + \left(\left(\left(b \cdot \pi\right) \cdot angle\right) \cdot \left(\left(b \cdot \pi\right) \cdot angle\right)\right) \cdot \frac{1}{32400} \]
    12. lift-*.f6477.7

      \[\leadsto a \cdot a + \left(\left(\left(b \cdot \pi\right) \cdot angle\right) \cdot \left(\left(b \cdot \pi\right) \cdot angle\right)\right) \cdot 3.08641975308642 \cdot 10^{-5} \]
  10. Applied rewrites77.7%

    \[\leadsto a \cdot a + \left(\left(\left(b \cdot \pi\right) \cdot angle\right) \cdot \left(\left(b \cdot \pi\right) \cdot angle\right)\right) \cdot 3.08641975308642 \cdot 10^{-5} \]
  11. Step-by-step derivation
    1. lift-*.f64N/A

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

      \[\leadsto a \cdot a + \left(\left(\left(b \cdot \pi\right) \cdot angle\right) \cdot \left(\left(b \cdot \pi\right) \cdot angle\right)\right) \cdot \frac{1}{32400} \]
    3. associate-*l*N/A

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

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

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

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

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

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

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

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

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

      \[\leadsto a \cdot a + \left(\left(angle \cdot b\right) \cdot \pi\right) \cdot \left(\left(\left(b \cdot \pi\right) \cdot \color{blue}{angle}\right) \cdot \frac{1}{32400}\right) \]
    13. lower-*.f6477.8

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

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

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

      \[\leadsto a \cdot a + \left(\left(angle \cdot b\right) \cdot \pi\right) \cdot \left(\left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right) \cdot \frac{1}{32400}\right) \]
    17. *-commutativeN/A

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

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

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

      \[\leadsto a \cdot a + \left(\left(angle \cdot b\right) \cdot \pi\right) \cdot \left(\left(\left(angle \cdot b\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \frac{1}{32400}\right) \]
    21. lift-PI.f6477.8

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

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

    \[\leadsto a \cdot a + \left(\left(angle \cdot b\right) \cdot \pi\right) \cdot \left(\left(\left(angle \cdot b\right) \cdot \pi\right) \cdot 3.08641975308642 \cdot 10^{-5}\right) \]
  14. Add Preprocessing

Alternative 9: 69.9% accurate, 12.1× speedup?

\[\begin{array}{l} angle_m = \left|angle\right| \\ \mathsf{fma}\left(\left(3.08641975308642 \cdot 10^{-5} \cdot \left(angle\_m \cdot angle\_m\right)\right) \cdot \left(\left(\pi \cdot \pi\right) \cdot b\right), b, a \cdot a\right) \end{array} \]
angle_m = (fabs.f64 angle)
(FPCore (a b angle_m)
 :precision binary64
 (fma
  (* (* 3.08641975308642e-5 (* angle_m angle_m)) (* (* PI PI) b))
  b
  (* a a)))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
	return fma(((3.08641975308642e-5 * (angle_m * angle_m)) * ((((double) M_PI) * ((double) M_PI)) * b)), b, (a * a));
}
angle_m = abs(angle)
function code(a, b, angle_m)
	return fma(Float64(Float64(3.08641975308642e-5 * Float64(angle_m * angle_m)) * Float64(Float64(pi * pi) * b)), b, Float64(a * a))
end
angle_m = N[Abs[angle], $MachinePrecision]
code[a_, b_, angle$95$m_] := N[(N[(N[(3.08641975308642e-5 * N[(angle$95$m * angle$95$m), $MachinePrecision]), $MachinePrecision] * N[(N[(Pi * Pi), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision] * b + N[(a * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
angle_m = \left|angle\right|

\\
\mathsf{fma}\left(\left(3.08641975308642 \cdot 10^{-5} \cdot \left(angle\_m \cdot angle\_m\right)\right) \cdot \left(\left(\pi \cdot \pi\right) \cdot b\right), b, a \cdot a\right)
\end{array}
Derivation
  1. Initial program 81.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(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
  4. Step-by-step derivation
    1. unpow2N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\left(\frac{1}{32400} \cdot \left(angle \cdot angle\right)\right) \cdot \left(\left(\pi \cdot \mathsf{PI}\left(\right)\right) \cdot b\right), b, a \cdot a\right) \]
    11. lift-PI.f6473.5

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

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

Alternative 10: 56.7% accurate, 74.7× speedup?

\[\begin{array}{l} angle_m = \left|angle\right| \\ a \cdot a \end{array} \]
angle_m = (fabs.f64 angle)
(FPCore (a b angle_m) :precision binary64 (* a a))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
	return a * a;
}
angle_m =     private
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(a, b, angle_m)
use fmin_fmax_functions
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: angle_m
    code = a * a
end function
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
	return a * a;
}
angle_m = math.fabs(angle)
def code(a, b, angle_m):
	return a * a
angle_m = abs(angle)
function code(a, b, angle_m)
	return Float64(a * a)
end
angle_m = abs(angle);
function tmp = code(a, b, angle_m)
	tmp = a * a;
end
angle_m = N[Abs[angle], $MachinePrecision]
code[a_, b_, angle$95$m_] := N[(a * a), $MachinePrecision]
\begin{array}{l}
angle_m = \left|angle\right|

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

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

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

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

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

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

Reproduce

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