ab-angle->ABCF C

Percentage Accurate: 79.5% → 77.8%
Time: 6.8s
Alternatives: 10
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 10 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 79.5% 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: 77.8% accurate, 2.9× speedup?

\[\begin{array}{l} angle_m = \left|angle\right| \\ \begin{array}{l} \mathbf{if}\;angle\_m \leq 7.6 \cdot 10^{-27}:\\ \;\;\;\;a \cdot a + {\left(b \cdot \left(\left(0.005555555555555556 \cdot \mathsf{PI}\left(\right)\right) \cdot angle\_m\right)\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(\frac{angle\_m}{180} \cdot \mathsf{PI}\left(\right)\right)\right), b \cdot b, a \cdot a\right)\\ \end{array} \end{array} \]
angle_m = (fabs.f64 angle)
(FPCore (a b angle_m)
 :precision binary64
 (if (<= angle_m 7.6e-27)
   (+ (* a a) (pow (* b (* (* 0.005555555555555556 (PI)) angle_m)) 2.0))
   (fma
    (- 0.5 (* 0.5 (cos (* 2.0 (* (/ angle_m 180.0) (PI))))))
    (* b b)
    (* a a))))
\begin{array}{l}
angle_m = \left|angle\right|

\\
\begin{array}{l}
\mathbf{if}\;angle\_m \leq 7.6 \cdot 10^{-27}:\\
\;\;\;\;a \cdot a + {\left(b \cdot \left(\left(0.005555555555555556 \cdot \mathsf{PI}\left(\right)\right) \cdot angle\_m\right)\right)}^{2}\\

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


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

    1. Initial program 85.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. Applied rewrites86.6%

        \[\leadsto \color{blue}{a \cdot a} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
      2. 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} \]
      3. Step-by-step derivation
        1. Applied rewrites84.6%

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

        if 7.60000000000000001e-27 < angle

        1. Initial program 56.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{fma}\left({\sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)}^{2}, \color{blue}{b \cdot b}, a \cdot a\right) \]
            13. lower-*.f6456.6

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(2 \cdot \color{blue}{\left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)}\right), b \cdot b, a \cdot a\right) \]
          5. Applied rewrites56.6%

            \[\leadsto \mathsf{fma}\left(\color{blue}{0.5 - 0.5 \cdot \cos \left(2 \cdot \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}, b \cdot b, a \cdot a\right) \]
        5. Recombined 2 regimes into one program.
        6. Add Preprocessing

        Alternative 2: 79.5% accurate, 1.9× speedup?

        \[\begin{array}{l} angle_m = \left|angle\right| \\ a \cdot a + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle\_m}{180}\right)\right)}^{2} \end{array} \]
        angle_m = (fabs.f64 angle)
        (FPCore (a b angle_m)
         :precision binary64
         (+ (* a a) (pow (* b (sin (* (PI) (/ angle_m 180.0)))) 2.0)))
        \begin{array}{l}
        angle_m = \left|angle\right|
        
        \\
        a \cdot a + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle\_m}{180}\right)\right)}^{2}
        \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. Applied rewrites78.1%

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

          Alternative 3: 79.6% accurate, 2.0× speedup?

          \[\begin{array}{l} angle_m = \left|angle\right| \\ a \cdot a + {\left(b \cdot \sin \left(\left(0.005555555555555556 \cdot \mathsf{PI}\left(\right)\right) \cdot angle\_m\right)\right)}^{2} \end{array} \]
          angle_m = (fabs.f64 angle)
          (FPCore (a b angle_m)
           :precision binary64
           (+ (* a a) (pow (* b (sin (* (* 0.005555555555555556 (PI)) angle_m))) 2.0)))
          \begin{array}{l}
          angle_m = \left|angle\right|
          
          \\
          a \cdot a + {\left(b \cdot \sin \left(\left(0.005555555555555556 \cdot \mathsf{PI}\left(\right)\right) \cdot angle\_m\right)\right)}^{2}
          \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. Applied rewrites78.1%

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

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

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

              Alternative 4: 67.0% accurate, 3.4× speedup?

              \[\begin{array}{l} angle_m = \left|angle\right| \\ \begin{array}{l} \mathbf{if}\;b \leq 5 \cdot 10^{-56}:\\ \;\;\;\;a \cdot a\\ \mathbf{else}:\\ \;\;\;\;a \cdot a + {\left(b \cdot \left(\left(0.005555555555555556 \cdot \mathsf{PI}\left(\right)\right) \cdot angle\_m\right)\right)}^{2}\\ \end{array} \end{array} \]
              angle_m = (fabs.f64 angle)
              (FPCore (a b angle_m)
               :precision binary64
               (if (<= b 5e-56)
                 (* a a)
                 (+ (* a a) (pow (* b (* (* 0.005555555555555556 (PI)) angle_m)) 2.0))))
              \begin{array}{l}
              angle_m = \left|angle\right|
              
              \\
              \begin{array}{l}
              \mathbf{if}\;b \leq 5 \cdot 10^{-56}:\\
              \;\;\;\;a \cdot a\\
              
              \mathbf{else}:\\
              \;\;\;\;a \cdot a + {\left(b \cdot \left(\left(0.005555555555555556 \cdot \mathsf{PI}\left(\right)\right) \cdot angle\_m\right)\right)}^{2}\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if b < 4.99999999999999997e-56

                1. Initial program 74.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. Applied rewrites59.7%

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

                  if 4.99999999999999997e-56 < b

                  1. Initial program 85.0%

                    \[{\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. Applied rewrites85.0%

                      \[\leadsto \color{blue}{a \cdot a} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
                    2. 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} \]
                    3. Step-by-step derivation
                      1. Applied rewrites81.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} \]
                    4. Recombined 2 regimes into one program.
                    5. Add Preprocessing

                    Alternative 5: 71.7% accurate, 10.0× speedup?

                    \[\begin{array}{l} angle_m = \left|angle\right| \\ \begin{array}{l} \mathbf{if}\;b \leq 5 \cdot 10^{+128}:\\ \;\;\;\;a \cdot a + \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \left(\left(\left(b \cdot b\right) \cdot angle\_m\right) \cdot \left(3.08641975308642 \cdot 10^{-5} \cdot angle\_m\right)\right)\\ \mathbf{else}:\\ \;\;\;\;a \cdot a + \left(\left(\left(\left(angle\_m \cdot angle\_m\right) \cdot 3.08641975308642 \cdot 10^{-5}\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \left(\mathsf{PI}\left(\right) \cdot b\right)\right) \cdot b\\ \end{array} \end{array} \]
                    angle_m = (fabs.f64 angle)
                    (FPCore (a b angle_m)
                     :precision binary64
                     (if (<= b 5e+128)
                       (+
                        (* a a)
                        (* (* (PI) (PI)) (* (* (* b b) angle_m) (* 3.08641975308642e-5 angle_m))))
                       (+
                        (* a a)
                        (*
                         (* (* (* (* angle_m angle_m) 3.08641975308642e-5) (PI)) (* (PI) b))
                         b))))
                    \begin{array}{l}
                    angle_m = \left|angle\right|
                    
                    \\
                    \begin{array}{l}
                    \mathbf{if}\;b \leq 5 \cdot 10^{+128}:\\
                    \;\;\;\;a \cdot a + \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \left(\left(\left(b \cdot b\right) \cdot angle\_m\right) \cdot \left(3.08641975308642 \cdot 10^{-5} \cdot angle\_m\right)\right)\\
                    
                    \mathbf{else}:\\
                    \;\;\;\;a \cdot a + \left(\left(\left(\left(angle\_m \cdot angle\_m\right) \cdot 3.08641975308642 \cdot 10^{-5}\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \left(\mathsf{PI}\left(\right) \cdot b\right)\right) \cdot b\\
                    
                    
                    \end{array}
                    \end{array}
                    
                    Derivation
                    1. Split input into 2 regimes
                    2. if b < 5e128

                      1. Initial program 73.8%

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

                          \[\leadsto \color{blue}{a \cdot a} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
                        2. 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)} \]
                        3. Step-by-step derivation
                          1. Applied rewrites62.9%

                            \[\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)} \]
                          2. Step-by-step derivation
                            1. Applied rewrites63.4%

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

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

                              if 5e128 < b

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

                                  \[\leadsto \color{blue}{a \cdot a} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
                                2. 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)} \]
                                3. Step-by-step derivation
                                  1. Applied rewrites63.3%

                                    \[\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)} \]
                                  2. Step-by-step derivation
                                    1. Applied rewrites91.1%

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

                                  Alternative 6: 71.7% accurate, 10.0× speedup?

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

                                    1. Initial program 73.8%

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

                                        \[\leadsto \color{blue}{a \cdot a} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
                                      2. 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)} \]
                                      3. Step-by-step derivation
                                        1. Applied rewrites62.9%

                                          \[\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)} \]
                                        2. Step-by-step derivation
                                          1. Applied rewrites63.4%

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

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

                                            if 5e128 < b

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

                                                \[\leadsto \color{blue}{a \cdot a} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
                                              2. 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)} \]
                                              3. Step-by-step derivation
                                                1. Applied rewrites63.3%

                                                  \[\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)} \]
                                                2. Step-by-step derivation
                                                  1. Applied rewrites63.3%

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

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

                                                  Alternative 7: 71.7% accurate, 10.0× speedup?

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

                                                    1. Initial program 73.8%

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

                                                        \[\leadsto \color{blue}{a \cdot a} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
                                                      2. 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)} \]
                                                      3. Step-by-step derivation
                                                        1. Applied rewrites62.9%

                                                          \[\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)} \]
                                                        2. Step-by-step derivation
                                                          1. Applied rewrites63.4%

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

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

                                                            if 5e128 < b

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

                                                                \[\leadsto \color{blue}{a \cdot a} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
                                                              2. 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)} \]
                                                              3. Step-by-step derivation
                                                                1. Applied rewrites63.3%

                                                                  \[\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)} \]
                                                                2. Step-by-step derivation
                                                                  1. Applied rewrites63.3%

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

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

                                                                  Alternative 8: 67.4% accurate, 10.4× speedup?

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

                                                                    1. Initial program 84.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. Applied rewrites61.8%

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

                                                                      if 3.6999999999999998e-157 < angle

                                                                      1. Initial program 64.7%

                                                                        \[{\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. Applied rewrites65.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                            \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\left(angle \cdot angle\right) \cdot 3.08641975308642 \cdot 10^{-5}\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)}, b \cdot b, a \cdot a\right) \]
                                                                        6. Recombined 2 regimes into one program.
                                                                        7. Add Preprocessing

                                                                        Alternative 9: 70.1% accurate, 11.5× speedup?

                                                                        \[\begin{array}{l} angle_m = \left|angle\right| \\ a \cdot a + \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \left(angle\_m \cdot \left(\left(3.08641975308642 \cdot 10^{-5} \cdot angle\_m\right) \cdot \left(b \cdot b\right)\right)\right) \end{array} \]
                                                                        angle_m = (fabs.f64 angle)
                                                                        (FPCore (a b angle_m)
                                                                         :precision binary64
                                                                         (+
                                                                          (* a a)
                                                                          (* (* (PI) (PI)) (* angle_m (* (* 3.08641975308642e-5 angle_m) (* b b))))))
                                                                        \begin{array}{l}
                                                                        angle_m = \left|angle\right|
                                                                        
                                                                        \\
                                                                        a \cdot a + \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \left(angle\_m \cdot \left(\left(3.08641975308642 \cdot 10^{-5} \cdot angle\_m\right) \cdot \left(b \cdot b\right)\right)\right)
                                                                        \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. Applied rewrites78.1%

                                                                            \[\leadsto \color{blue}{a \cdot a} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
                                                                          2. 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)} \]
                                                                          3. Step-by-step derivation
                                                                            1. Applied rewrites63.0%

                                                                              \[\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)} \]
                                                                            2. Step-by-step derivation
                                                                              1. Applied rewrites63.4%

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

                                                                                  \[\leadsto a \cdot a + \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \left(angle \cdot \color{blue}{\left(\left(3.08641975308642 \cdot 10^{-5} \cdot angle\right) \cdot \left(b \cdot b\right)\right)}\right) \]
                                                                                2. Add Preprocessing

                                                                                Alternative 10: 57.1% accurate, 74.7× speedup?

                                                                                \[\begin{array}{l} angle_m = \left|angle\right| \\ a \cdot a \end{array} \]
                                                                                angle_m = (fabs.f64 angle)
                                                                                (FPCore (a b angle_m) :precision binary64 (* a a))
                                                                                angle_m = fabs(angle);
                                                                                double code(double a, double b, double angle_m) {
                                                                                	return a * a;
                                                                                }
                                                                                
                                                                                angle_m =     private
                                                                                module fmin_fmax_functions
                                                                                    implicit none
                                                                                    private
                                                                                    public fmax
                                                                                    public fmin
                                                                                
                                                                                    interface fmax
                                                                                        module procedure fmax88
                                                                                        module procedure fmax44
                                                                                        module procedure fmax84
                                                                                        module procedure fmax48
                                                                                    end interface
                                                                                    interface fmin
                                                                                        module procedure fmin88
                                                                                        module procedure fmin44
                                                                                        module procedure fmin84
                                                                                        module procedure fmin48
                                                                                    end interface
                                                                                contains
                                                                                    real(8) function fmax88(x, y) result (res)
                                                                                        real(8), intent (in) :: x
                                                                                        real(8), intent (in) :: y
                                                                                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                                                    end function
                                                                                    real(4) function fmax44(x, y) result (res)
                                                                                        real(4), intent (in) :: x
                                                                                        real(4), intent (in) :: y
                                                                                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                                                    end function
                                                                                    real(8) function fmax84(x, y) result(res)
                                                                                        real(8), intent (in) :: x
                                                                                        real(4), intent (in) :: y
                                                                                        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                                                                    end function
                                                                                    real(8) function fmax48(x, y) result(res)
                                                                                        real(4), intent (in) :: x
                                                                                        real(8), intent (in) :: y
                                                                                        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                                                                    end function
                                                                                    real(8) function fmin88(x, y) result (res)
                                                                                        real(8), intent (in) :: x
                                                                                        real(8), intent (in) :: y
                                                                                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                                                    end function
                                                                                    real(4) function fmin44(x, y) result (res)
                                                                                        real(4), intent (in) :: x
                                                                                        real(4), intent (in) :: y
                                                                                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                                                    end function
                                                                                    real(8) function fmin84(x, y) result(res)
                                                                                        real(8), intent (in) :: x
                                                                                        real(4), intent (in) :: y
                                                                                        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                                                                    end function
                                                                                    real(8) function fmin48(x, y) result(res)
                                                                                        real(4), intent (in) :: x
                                                                                        real(8), intent (in) :: y
                                                                                        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                                                                    end function
                                                                                end module
                                                                                
                                                                                real(8) function code(a, b, angle_m)
                                                                                use fmin_fmax_functions
                                                                                    real(8), intent (in) :: a
                                                                                    real(8), intent (in) :: b
                                                                                    real(8), intent (in) :: angle_m
                                                                                    code = a * a
                                                                                end function
                                                                                
                                                                                angle_m = Math.abs(angle);
                                                                                public static double code(double a, double b, double angle_m) {
                                                                                	return a * a;
                                                                                }
                                                                                
                                                                                angle_m = math.fabs(angle)
                                                                                def code(a, b, angle_m):
                                                                                	return a * a
                                                                                
                                                                                angle_m = abs(angle)
                                                                                function code(a, b, angle_m)
                                                                                	return Float64(a * a)
                                                                                end
                                                                                
                                                                                angle_m = abs(angle);
                                                                                function tmp = code(a, b, angle_m)
                                                                                	tmp = a * a;
                                                                                end
                                                                                
                                                                                angle_m = N[Abs[angle], $MachinePrecision]
                                                                                code[a_, b_, angle$95$m_] := N[(a * a), $MachinePrecision]
                                                                                
                                                                                \begin{array}{l}
                                                                                angle_m = \left|angle\right|
                                                                                
                                                                                \\
                                                                                a \cdot a
                                                                                \end{array}
                                                                                
                                                                                Derivation
                                                                                1. Initial program 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. Applied rewrites54.4%

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

                                                                                  Reproduce

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