ab-angle->ABCF A

Percentage Accurate: 79.6% → 79.5%
Time: 15.2s
Alternatives: 10
Speedup: N/A×

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.6% 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.5% accurate, 1.0× speedup?

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

\\
{\left(a \cdot \sin \left(\frac{{\pi}^{0.6666666666666666}}{180} \cdot \frac{\sqrt[3]{\pi}}{\frac{1}{angle}}\right)\right)}^{2} + b \cdot b
\end{array}
Derivation
  1. Initial program 76.9%

    \[{\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 rewrites77.3%

      \[\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. clear-numN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 2: 77.1% accurate, 1.8× speedup?

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

      1. Initial program 86.6%

        \[{\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 rewrites86.6%

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

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

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

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

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

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

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

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

        if 5.00000000000000031e-10 < (/.f64 angle #s(literal 180 binary64))

        1. Initial program 58.9%

          \[{\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 rewrites58.7%

            \[\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. clear-numN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        Reproduce

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