ab-angle->ABCF C

Percentage Accurate: 79.4% → 79.4%
Time: 10.5s
Alternatives: 9
Speedup: 2.0×

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto a \cdot a + {\left(b \cdot \sin \color{blue}{\left(\frac{\mathsf{PI}\left(\right)}{\frac{180}{angle}}\right)}\right)}^{2} \]
  8. Final simplification78.0%

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

Alternative 2: 66.8% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 7.2 \cdot 10^{-66}:\\ \;\;\;\;{\cos \left(\left(-0.005555555555555556 \cdot angle\right) \cdot \mathsf{PI}\left(\right)\right)}^{2} \cdot \left(a \cdot a\right)\\ \mathbf{else}:\\ \;\;\;\;{\left(\left(\left(0.005555555555555556 \cdot angle\right) \cdot \mathsf{PI}\left(\right)\right) \cdot b\right)}^{2} + a \cdot a\\ \end{array} \end{array} \]
(FPCore (a b angle)
 :precision binary64
 (if (<= b 7.2e-66)
   (* (pow (cos (* (* -0.005555555555555556 angle) (PI))) 2.0) (* a a))
   (+ (pow (* (* (* 0.005555555555555556 angle) (PI)) b) 2.0) (* a a))))
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq 7.2 \cdot 10^{-66}:\\
\;\;\;\;{\cos \left(\left(-0.005555555555555556 \cdot angle\right) \cdot \mathsf{PI}\left(\right)\right)}^{2} \cdot \left(a \cdot a\right)\\

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{{\cos \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} \cdot {a}^{2}} \]
    10. Applied rewrites56.5%

      \[\leadsto \color{blue}{{\cos \left(\left(-0.005555555555555556 \cdot angle\right) \cdot \mathsf{PI}\left(\right)\right)}^{2} \cdot \left(a \cdot a\right)} \]

    if 7.20000000000000025e-66 < b

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto a \cdot a + {\left(b \cdot \left(\left(0.005555555555555556 \cdot angle\right) \cdot \color{blue}{\mathsf{PI}\left(\right)}\right)\right)}^{2} \]
    10. Applied rewrites83.9%

      \[\leadsto a \cdot a + {\left(b \cdot \color{blue}{\left(\left(0.005555555555555556 \cdot angle\right) \cdot \mathsf{PI}\left(\right)\right)}\right)}^{2} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification66.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 7.2 \cdot 10^{-66}:\\ \;\;\;\;{\cos \left(\left(-0.005555555555555556 \cdot angle\right) \cdot \mathsf{PI}\left(\right)\right)}^{2} \cdot \left(a \cdot a\right)\\ \mathbf{else}:\\ \;\;\;\;{\left(\left(\left(0.005555555555555556 \cdot angle\right) \cdot \mathsf{PI}\left(\right)\right) \cdot b\right)}^{2} + a \cdot a\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 66.8% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 7.2 \cdot 10^{-66}:\\ \;\;\;\;{\cos \left(\left(\mathsf{PI}\left(\right) \cdot angle\right) \cdot -0.005555555555555556\right)}^{2} \cdot \left(a \cdot a\right)\\ \mathbf{else}:\\ \;\;\;\;{\left(\left(\left(0.005555555555555556 \cdot angle\right) \cdot \mathsf{PI}\left(\right)\right) \cdot b\right)}^{2} + a \cdot a\\ \end{array} \end{array} \]
(FPCore (a b angle)
 :precision binary64
 (if (<= b 7.2e-66)
   (* (pow (cos (* (* (PI) angle) -0.005555555555555556)) 2.0) (* a a))
   (+ (pow (* (* (* 0.005555555555555556 angle) (PI)) b) 2.0) (* a a))))
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq 7.2 \cdot 10^{-66}:\\
\;\;\;\;{\cos \left(\left(\mathsf{PI}\left(\right) \cdot angle\right) \cdot -0.005555555555555556\right)}^{2} \cdot \left(a \cdot a\right)\\

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


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

    1. Initial program 72.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. 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. 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} \]
      4. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {\cos \left(\frac{-1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} \cdot \color{blue}{\left(a \cdot a\right)} \]
      9. lower-*.f6456.6

        \[\leadsto {\cos \left(-0.005555555555555556 \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} \cdot \color{blue}{\left(a \cdot a\right)} \]
    7. Applied rewrites56.6%

      \[\leadsto \color{blue}{{\cos \left(-0.005555555555555556 \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} \cdot \left(a \cdot a\right)} \]

    if 7.20000000000000025e-66 < b

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto a \cdot a + {\left(b \cdot \left(\left(0.005555555555555556 \cdot angle\right) \cdot \color{blue}{\mathsf{PI}\left(\right)}\right)\right)}^{2} \]
    10. Applied rewrites83.9%

      \[\leadsto a \cdot a + {\left(b \cdot \color{blue}{\left(\left(0.005555555555555556 \cdot angle\right) \cdot \mathsf{PI}\left(\right)\right)}\right)}^{2} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification66.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 7.2 \cdot 10^{-66}:\\ \;\;\;\;{\cos \left(\left(\mathsf{PI}\left(\right) \cdot angle\right) \cdot -0.005555555555555556\right)}^{2} \cdot \left(a \cdot a\right)\\ \mathbf{else}:\\ \;\;\;\;{\left(\left(\left(0.005555555555555556 \cdot angle\right) \cdot \mathsf{PI}\left(\right)\right) \cdot b\right)}^{2} + a \cdot a\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 79.4% accurate, 2.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 66.9% accurate, 3.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 7.8 \cdot 10^{-66}:\\ \;\;\;\;a \cdot a\\ \mathbf{else}:\\ \;\;\;\;{\left(\left(\left(0.005555555555555556 \cdot angle\right) \cdot \mathsf{PI}\left(\right)\right) \cdot b\right)}^{2} + a \cdot a\\ \end{array} \end{array} \]
(FPCore (a b angle)
 :precision binary64
 (if (<= b 7.8e-66)
   (* a a)
   (+ (pow (* (* (* 0.005555555555555556 angle) (PI)) b) 2.0) (* a a))))
\begin{array}{l}

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

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


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

    1. Initial program 72.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-*.f6457.1

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

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

    if 7.79999999999999965e-66 < b

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto a \cdot a + {\left(b \cdot \left(\left(0.005555555555555556 \cdot angle\right) \cdot \color{blue}{\mathsf{PI}\left(\right)}\right)\right)}^{2} \]
    10. Applied rewrites83.9%

      \[\leadsto a \cdot a + {\left(b \cdot \color{blue}{\left(\left(0.005555555555555556 \cdot angle\right) \cdot \mathsf{PI}\left(\right)\right)}\right)}^{2} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification66.4%

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

Alternative 6: 66.9% accurate, 3.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 7.8 \cdot 10^{-66}:\\ \;\;\;\;a \cdot a\\ \mathbf{else}:\\ \;\;\;\;{\left(\left(\left(0.005555555555555556 \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right) \cdot b\right)}^{2} + a \cdot a\\ \end{array} \end{array} \]
(FPCore (a b angle)
 :precision binary64
 (if (<= b 7.8e-66)
   (* a a)
   (+ (pow (* (* (* 0.005555555555555556 (PI)) angle) b) 2.0) (* a a))))
\begin{array}{l}

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

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


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

    1. Initial program 72.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-*.f6457.1

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

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

    if 7.79999999999999965e-66 < b

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

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

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

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

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

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

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

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

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

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

      \[\leadsto a \cdot a + {\left(b \cdot \color{blue}{\left(\left(0.005555555555555556 \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right)}\right)}^{2} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification66.4%

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

Alternative 7: 61.8% accurate, 8.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{angle}{180} \leq 2 \cdot 10^{-166}:\\ \;\;\;\;a \cdot a\\ \mathbf{else}:\\ \;\;\;\;\left(\left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot b\right) \cdot b\right) \cdot \left(\left(angle \cdot angle\right) \cdot 3.08641975308642 \cdot 10^{-5}\right) + a \cdot a\\ \end{array} \end{array} \]
(FPCore (a b angle)
 :precision binary64
 (if (<= (/ angle 180.0) 2e-166)
   (* a a)
   (+
    (* (* (* (* (PI) (PI)) b) b) (* (* angle angle) 3.08641975308642e-5))
    (* a a))))
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\frac{angle}{180} \leq 2 \cdot 10^{-166}:\\
\;\;\;\;a \cdot a\\

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


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

    1. Initial program 83.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-*.f6460.0

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

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

    if 2.00000000000000008e-166 < (/.f64 angle #s(literal 180 binary64))

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto a \cdot a + \left(\frac{1}{32400} \cdot \left(angle \cdot angle\right)\right) \cdot \left(\left(\left(\color{blue}{\mathsf{PI}\left(\right)} \cdot \mathsf{PI}\left(\right)\right) \cdot b\right) \cdot b\right) \]
      14. lower-PI.f6458.8

        \[\leadsto a \cdot a + \left(3.08641975308642 \cdot 10^{-5} \cdot \left(angle \cdot angle\right)\right) \cdot \left(\left(\left(\mathsf{PI}\left(\right) \cdot \color{blue}{\mathsf{PI}\left(\right)}\right) \cdot b\right) \cdot b\right) \]
    8. Applied rewrites58.8%

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

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

Alternative 8: 66.4% accurate, 10.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 7.8 \cdot 10^{-66}:\\ \;\;\;\;a \cdot a\\ \mathbf{else}:\\ \;\;\;\;\left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot b\right) \cdot \left(\left(\left(3.08641975308642 \cdot 10^{-5} \cdot angle\right) \cdot b\right) \cdot angle\right) + a \cdot a\\ \end{array} \end{array} \]
(FPCore (a b angle)
 :precision binary64
 (if (<= b 7.8e-66)
   (* a a)
   (+
    (* (* (* (PI) (PI)) b) (* (* (* 3.08641975308642e-5 angle) b) angle))
    (* a a))))
\begin{array}{l}

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

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


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

    1. Initial program 72.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-*.f6457.1

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

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

    if 7.79999999999999965e-66 < b

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto a \cdot a + \left(\frac{1}{32400} \cdot \left(angle \cdot angle\right)\right) \cdot \left(\left(\left(\color{blue}{\mathsf{PI}\left(\right)} \cdot \mathsf{PI}\left(\right)\right) \cdot b\right) \cdot b\right) \]
      14. lower-PI.f6466.4

        \[\leadsto a \cdot a + \left(3.08641975308642 \cdot 10^{-5} \cdot \left(angle \cdot angle\right)\right) \cdot \left(\left(\left(\mathsf{PI}\left(\right) \cdot \color{blue}{\mathsf{PI}\left(\right)}\right) \cdot b\right) \cdot b\right) \]
    8. Applied rewrites66.4%

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

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

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

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

      Alternative 9: 57.0% accurate, 74.7× speedup?

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

        \[{\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-*.f6454.9

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

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

      Reproduce

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