ab-angle->ABCF C

Percentage Accurate: 79.9% → 79.9%
Time: 8.1s
Alternatives: 9
Speedup: 1.2×

Specification

?
\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{PI}\left(\right) \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))))
\begin{array}{l}

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

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

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{PI}\left(\right) \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))))
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \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.9% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{\mathsf{PI}\left(\right)}\\ {\left(a \cdot \cos \left(\left(t\_0 \cdot t\_0\right) \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \end{array} \end{array} \]
(FPCore (a b angle)
 :precision binary64
 (let* ((t_0 (sqrt (PI))))
   (+
    (pow (* a (cos (* (* t_0 t_0) (/ angle 180.0)))) 2.0)
    (pow (* b (sin (* (PI) (/ angle 180.0)))) 2.0))))
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sqrt{\mathsf{PI}\left(\right)}\\
{\left(a \cdot \cos \left(\left(t\_0 \cdot t\_0\right) \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2}
\end{array}
\end{array}
Derivation
  1. Initial program 83.4%

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

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

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

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

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

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

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

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

    \[\leadsto {\left(a \cdot \cos \left(\color{blue}{\left(\sqrt{\mathsf{PI}\left(\right)} \cdot \sqrt{\mathsf{PI}\left(\right)}\right)} \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
  5. Add Preprocessing

Alternative 2: 79.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ {\left(a \cdot \sin \left(\mathsf{fma}\left(\frac{angle}{180}, \mathsf{PI}\left(\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \end{array} \]
(FPCore (a b angle)
 :precision binary64
 (+
  (pow (* a (sin (fma (/ angle 180.0) (PI) (/ (PI) 2.0)))) 2.0)
  (pow (* b (sin (* (PI) (/ angle 180.0)))) 2.0)))
\begin{array}{l}

\\
{\left(a \cdot \sin \left(\mathsf{fma}\left(\frac{angle}{180}, \mathsf{PI}\left(\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2}
\end{array}
Derivation
  1. Initial program 83.4%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto {\left(a \cdot \color{blue}{\sin \left(\mathsf{fma}\left(\frac{angle}{180}, \mathsf{PI}\left(\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\right)}\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
  5. Add Preprocessing

Alternative 3: 79.9% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(\left(0.5 - 0.5 \cdot \cos \left(2 \cdot \mathsf{fma}\left(\frac{angle}{180}, \mathsf{PI}\left(\right), \frac{\mathsf{PI}\left(\right)}{-2}\right)\right)\right) \cdot a, a, {\left(\sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right) \cdot b\right)}^{2}\right) \end{array} \]
(FPCore (a b angle)
 :precision binary64
 (fma
  (* (- 0.5 (* 0.5 (cos (* 2.0 (fma (/ angle 180.0) (PI) (/ (PI) -2.0)))))) a)
  a
  (pow (* (sin (* (/ angle 180.0) (PI))) b) 2.0)))
\begin{array}{l}

\\
\mathsf{fma}\left(\left(0.5 - 0.5 \cdot \cos \left(2 \cdot \mathsf{fma}\left(\frac{angle}{180}, \mathsf{PI}\left(\right), \frac{\mathsf{PI}\left(\right)}{-2}\right)\right)\right) \cdot a, a, {\left(\sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right) \cdot b\right)}^{2}\right)
\end{array}
Derivation
  1. Initial program 83.4%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(a \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right), a, {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2}\right)} \]
  4. Applied rewrites83.4%

    \[\leadsto \color{blue}{\mathsf{fma}\left({\cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)}^{2} \cdot a, a, {\left(\sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right) \cdot b\right)}^{2}\right)} \]
  5. Applied rewrites83.4%

    \[\leadsto \mathsf{fma}\left(\color{blue}{\left(0.5 - 0.5 \cdot \cos \left(2 \cdot \mathsf{fma}\left(\frac{angle}{180}, \mathsf{PI}\left(\right), \frac{\mathsf{PI}\left(\right)}{-2}\right)\right)\right)} \cdot a, a, {\left(\sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right) \cdot b\right)}^{2}\right) \]
  6. Add Preprocessing

Alternative 4: 79.9% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{angle}{180} \cdot \mathsf{PI}\left(\right)\\ \mathsf{fma}\left(\left(0.5 - -0.5 \cdot \cos \left(2 \cdot t\_0\right)\right) \cdot a, a, {\left(\sin t\_0 \cdot b\right)}^{2}\right) \end{array} \end{array} \]
(FPCore (a b angle)
 :precision binary64
 (let* ((t_0 (* (/ angle 180.0) (PI))))
   (fma (* (- 0.5 (* -0.5 (cos (* 2.0 t_0)))) a) a (pow (* (sin t_0) b) 2.0))))
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{angle}{180} \cdot \mathsf{PI}\left(\right)\\
\mathsf{fma}\left(\left(0.5 - -0.5 \cdot \cos \left(2 \cdot t\_0\right)\right) \cdot a, a, {\left(\sin t\_0 \cdot b\right)}^{2}\right)
\end{array}
\end{array}
Derivation
  1. Initial program 83.4%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(a \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right), a, {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2}\right)} \]
  4. Applied rewrites83.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\left(\frac{1}{2} + \frac{1}{2} \cdot \color{blue}{\cos \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180} + \mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)}\right) \cdot a, a, {\left(\sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right) \cdot b\right)}^{2}\right) \]
    14. fp-cancel-sign-sub-invN/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\frac{1}{2} - \left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180} + \mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)} \cdot a, a, {\left(\sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right) \cdot b\right)}^{2}\right) \]
  6. Applied rewrites83.4%

    \[\leadsto \mathsf{fma}\left(\color{blue}{\left(0.5 - -0.5 \cdot \cos \left(2 \cdot \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)\right)} \cdot a, a, {\left(\sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right) \cdot b\right)}^{2}\right) \]
  7. Add Preprocessing

Alternative 5: 79.8% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(\frac{2}{2} \cdot a, a, {\left(\sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right) \cdot b\right)}^{2}\right) \end{array} \]
(FPCore (a b angle)
 :precision binary64
 (fma (* (/ 2.0 2.0) a) a (pow (* (sin (* (/ angle 180.0) (PI))) b) 2.0)))
\begin{array}{l}

\\
\mathsf{fma}\left(\frac{2}{2} \cdot a, a, {\left(\sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right) \cdot b\right)}^{2}\right)
\end{array}
Derivation
  1. Initial program 83.4%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(a \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right), a, {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2}\right)} \]
  4. Applied rewrites83.4%

    \[\leadsto \color{blue}{\mathsf{fma}\left({\cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)}^{2} \cdot a, a, {\left(\sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right) \cdot b\right)}^{2}\right)} \]
  5. Applied rewrites74.9%

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

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

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

    Alternative 6: 56.0% accurate, 8.3× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq 1.5 \cdot 10^{+74}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(3.08641975308642 \cdot 10^{-5} \cdot b, b, \left(-3.08641975308642 \cdot 10^{-5} \cdot a\right) \cdot a\right) \cdot \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right), angle, a \cdot a\right)\\ \mathbf{else}:\\ \;\;\;\;a \cdot a\\ \end{array} \end{array} \]
    (FPCore (a b angle)
     :precision binary64
     (if (<= a 1.5e+74)
       (fma
        (*
         (fma (* 3.08641975308642e-5 b) b (* (* -3.08641975308642e-5 a) a))
         (* (* (PI) (PI)) angle))
        angle
        (* a a))
       (* a a)))
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;a \leq 1.5 \cdot 10^{+74}:\\
    \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(3.08641975308642 \cdot 10^{-5} \cdot b, b, \left(-3.08641975308642 \cdot 10^{-5} \cdot a\right) \cdot a\right) \cdot \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right), angle, a \cdot a\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;a \cdot a\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if a < 1.5e74

      1. Initial program 81.4%

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-1}{32400} \cdot \left({a}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right) + \frac{1}{32400} \cdot \left({b}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right), {angle}^{2}, {a}^{2}\right)} \]
      7. Applied rewrites49.3%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \mathsf{fma}\left(3.08641975308642 \cdot 10^{-5}, b \cdot b, \left(-3.08641975308642 \cdot 10^{-5} \cdot a\right) \cdot a\right), angle \cdot angle, a \cdot a\right)} \]
      8. Step-by-step derivation
        1. Applied rewrites53.0%

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

        if 1.5e74 < a

        1. Initial program 89.9%

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

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

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

            \[\leadsto \color{blue}{a \cdot a} \]
        5. Applied rewrites88.7%

          \[\leadsto \color{blue}{a \cdot a} \]
      9. Recombined 2 regimes into one program.
      10. Final simplification61.2%

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

      Alternative 7: 62.6% accurate, 10.4× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 2.8 \cdot 10^{-95}:\\ \;\;\;\;a \cdot a\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \left(3.08641975308642 \cdot 10^{-5} \cdot \left(b \cdot b\right)\right), angle \cdot angle, a \cdot a\right)\\ \end{array} \end{array} \]
      (FPCore (a b angle)
       :precision binary64
       (if (<= b 2.8e-95)
         (* a a)
         (fma
          (* (* (PI) (PI)) (* 3.08641975308642e-5 (* b b)))
          (* angle angle)
          (* a a))))
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;b \leq 2.8 \cdot 10^{-95}:\\
      \;\;\;\;a \cdot a\\
      
      \mathbf{else}:\\
      \;\;\;\;\mathsf{fma}\left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \left(3.08641975308642 \cdot 10^{-5} \cdot \left(b \cdot b\right)\right), angle \cdot angle, a \cdot a\right)\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if b < 2.7999999999999999e-95

        1. Initial program 83.3%

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

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

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

            \[\leadsto \color{blue}{a \cdot a} \]
        5. Applied rewrites67.8%

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

        if 2.7999999999999999e-95 < b

        1. Initial program 83.4%

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-1}{32400} \cdot \left({a}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right) + \frac{1}{32400} \cdot \left({b}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right), {angle}^{2}, {a}^{2}\right)} \]
        7. Applied rewrites43.0%

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

          \[\leadsto \mathsf{fma}\left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \left(\frac{1}{32400} \cdot {b}^{2}\right), angle \cdot angle, a \cdot a\right) \]
        9. Step-by-step derivation
          1. Applied rewrites72.1%

            \[\leadsto \mathsf{fma}\left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \left(3.08641975308642 \cdot 10^{-5} \cdot \left(b \cdot b\right)\right), angle \cdot angle, a \cdot a\right) \]
        10. Recombined 2 regimes into one program.
        11. Final simplification69.3%

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

        Alternative 8: 60.9% accurate, 12.1× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{PI}\left(\right) \cdot b\\ \mathbf{if}\;b \leq 8.5 \cdot 10^{+147}:\\ \;\;\;\;a \cdot a\\ \mathbf{else}:\\ \;\;\;\;\left(3.08641975308642 \cdot 10^{-5} \cdot \left(angle \cdot angle\right)\right) \cdot \left(t\_0 \cdot t\_0\right)\\ \end{array} \end{array} \]
        (FPCore (a b angle)
         :precision binary64
         (let* ((t_0 (* (PI) b)))
           (if (<= b 8.5e+147)
             (* a a)
             (* (* 3.08641975308642e-5 (* angle angle)) (* t_0 t_0)))))
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_0 := \mathsf{PI}\left(\right) \cdot b\\
        \mathbf{if}\;b \leq 8.5 \cdot 10^{+147}:\\
        \;\;\;\;a \cdot a\\
        
        \mathbf{else}:\\
        \;\;\;\;\left(3.08641975308642 \cdot 10^{-5} \cdot \left(angle \cdot angle\right)\right) \cdot \left(t\_0 \cdot t\_0\right)\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if b < 8.5000000000000007e147

          1. Initial program 81.2%

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

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

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

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

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

          if 8.5000000000000007e147 < b

          1. Initial program 97.2%

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-1}{32400} \cdot \left({a}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right) + \frac{1}{32400} \cdot \left({b}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right), {angle}^{2}, {a}^{2}\right)} \]
          7. Applied rewrites45.9%

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

            \[\leadsto \frac{1}{32400} \cdot \color{blue}{\left({angle}^{2} \cdot \left({b}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)} \]
          9. Step-by-step derivation
            1. Applied rewrites83.0%

              \[\leadsto \left(3.08641975308642 \cdot 10^{-5} \cdot \left(angle \cdot angle\right)\right) \cdot \color{blue}{\left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot \left(\mathsf{PI}\left(\right) \cdot b\right)\right)} \]
          10. Recombined 2 regimes into one program.
          11. Final simplification67.0%

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

          Alternative 9: 57.5% accurate, 74.7× speedup?

          \[\begin{array}{l} \\ a \cdot a \end{array} \]
          (FPCore (a b angle) :precision binary64 (* a a))
          double code(double a, double b, double angle) {
          	return a * a;
          }
          
          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)
          use fmin_fmax_functions
              real(8), intent (in) :: a
              real(8), intent (in) :: b
              real(8), intent (in) :: angle
              code = a * a
          end function
          
          public static double code(double a, double b, double angle) {
          	return a * a;
          }
          
          def code(a, b, angle):
          	return a * a
          
          function code(a, b, angle)
          	return Float64(a * a)
          end
          
          function tmp = code(a, b, angle)
          	tmp = a * a;
          end
          
          code[a_, b_, angle_] := N[(a * a), $MachinePrecision]
          
          \begin{array}{l}
          
          \\
          a \cdot a
          \end{array}
          
          Derivation
          1. Initial program 83.4%

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

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

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

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

            \[\leadsto \color{blue}{a \cdot a} \]
          6. Final simplification62.2%

            \[\leadsto a \cdot a \]
          7. Add Preprocessing

          Reproduce

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