ab-angle->ABCF A

Percentage Accurate: 79.4% → 79.4%
Time: 16.0s
Alternatives: 10
Speedup: 2.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 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.4% accurate, 1.0× speedup?

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

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

Alternative 1: 79.4% accurate, 2.7× speedup?

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

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

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


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

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      1. Initial program 63.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      Alternative 2: 79.5% accurate, 2.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        Reproduce

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