ab-angle->ABCF C

Percentage Accurate: 80.1% → 80.0%
Time: 4.8s
Alternatives: 6
Speedup: N/A×

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 6 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: 80.1% 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: 80.0% accurate, 2.0× speedup?

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

\\
a \cdot a + {\left(b \cdot \sin \left(\left(angle \cdot \mathsf{PI}\left(\right)\right) \cdot 0.005555555555555556\right)\right)}^{2}
\end{array}
Derivation
  1. Initial program 77.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 rewrites78.4%

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

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

      Alternative 2: 80.0% accurate, 2.0× speedup?

      \[\begin{array}{l} \\ \mathsf{fma}\left(a, a, {\left(\sin \left(\left(0.005555555555555556 \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right) \cdot b\right)}^{2}\right) \end{array} \]
      (FPCore (a b angle)
       :precision binary64
       (fma a a (pow (* (sin (* (* 0.005555555555555556 (PI)) angle)) b) 2.0)))
      \begin{array}{l}
      
      \\
      \mathsf{fma}\left(a, a, {\left(\sin \left(\left(0.005555555555555556 \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right) \cdot b\right)}^{2}\right)
      \end{array}
      
      Derivation
      1. Initial program 77.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 {\left(a \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \sin \color{blue}{\left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}\right)}^{2} \]
      4. Step-by-step derivation
        1. Applied rewrites77.8%

          \[\leadsto {\left(a \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \sin \color{blue}{\left(\left(0.005555555555555556 \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right)}\right)}^{2} \]
        2. 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(\left(\frac{1}{180} \cdot \mathsf{PI}\left(\right)\right) \cdot angle\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(\left(\frac{1}{180} \cdot \mathsf{PI}\left(\right)\right) \cdot angle\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(\left(\frac{1}{180} \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right)\right)}^{2} \]
          4. unpow-prod-downN/A

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

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

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

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

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

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

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

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

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

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

          Alternative 3: 67.4% accurate, 10.0× speedup?

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

            1. Initial program 76.3%

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

              \[\leadsto \color{blue}{{a}^{2}} \]
            4. Step-by-step derivation
              1. Applied rewrites61.3%

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

              if 5.6999999999999996e-22 < b

              1. Initial program 83.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 rewrites83.7%

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

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

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

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

                    Alternative 4: 67.4% accurate, 10.0× speedup?

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

                      1. Initial program 76.3%

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

                        \[\leadsto \color{blue}{{a}^{2}} \]
                      4. Step-by-step derivation
                        1. Applied rewrites61.3%

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

                        if 5.6999999999999996e-22 < b

                        1. Initial program 83.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 rewrites83.7%

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

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

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

                            Alternative 5: 65.6% accurate, 10.4× speedup?

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

                              1. Initial program 76.3%

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

                                \[\leadsto \color{blue}{{a}^{2}} \]
                              4. Step-by-step derivation
                                1. Applied rewrites61.3%

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

                                if 5.6999999999999996e-22 < b

                                1. Initial program 83.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 {\left(a \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \sin \color{blue}{\left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}\right)}^{2} \]
                                4. Step-by-step derivation
                                  1. Applied rewrites83.6%

                                    \[\leadsto {\left(a \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \sin \color{blue}{\left(\left(0.005555555555555556 \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right)}\right)}^{2} \]
                                  2. 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(\left(\frac{1}{180} \cdot \mathsf{PI}\left(\right)\right) \cdot angle\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(\left(\frac{1}{180} \cdot \mathsf{PI}\left(\right)\right) \cdot angle\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(\left(\frac{1}{180} \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right)\right)}^{2} \]
                                    4. unpow-prod-downN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

                                    Alternative 6: 57.6% accurate, 74.7× speedup?

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

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

                                      Reproduce

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