ab-angle->ABCF C

Percentage Accurate: 79.0% → 79.0%
Time: 9.1s
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: 79.0% accurate, 1.0× speedup?

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

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

Alternative 1: 79.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 83.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 2: 64.1% accurate, 3.5× speedup?

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

      1. Initial program 87.9%

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

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

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

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

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

      if 3.89999999999999977e-100 < b < 5.4000000000000001e157

      1. Initial program 64.6%

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

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

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

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

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

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

        if 5.4000000000000001e157 < b

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

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

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

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

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

            \[\leadsto \left(\left(angle \cdot angle\right) \cdot 3.08641975308642 \cdot 10^{-5}\right) \cdot \color{blue}{\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 rewrites90.7%

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

          Alternative 3: 62.8% accurate, 9.1× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\\ \mathbf{if}\;b \leq 3.9 \cdot 10^{-100}:\\ \;\;\;\;a \cdot a\\ \mathbf{elif}\;b \leq 5.4 \cdot 10^{+157}:\\ \;\;\;\;\mathsf{fma}\left(\left(\left(t\_0 \cdot 3.08641975308642 \cdot 10^{-5}\right) \cdot b\right) \cdot b, angle \cdot angle, a \cdot a\right)\\ \mathbf{else}:\\ \;\;\;\;\left(t\_0 \cdot b\right) \cdot \left(b \cdot \left(3.08641975308642 \cdot 10^{-5} \cdot \left(angle \cdot angle\right)\right)\right)\\ \end{array} \end{array} \]
          (FPCore (a b angle)
           :precision binary64
           (let* ((t_0 (* (PI) (PI))))
             (if (<= b 3.9e-100)
               (* a a)
               (if (<= b 5.4e+157)
                 (fma (* (* (* t_0 3.08641975308642e-5) b) b) (* angle angle) (* a a))
                 (* (* t_0 b) (* b (* 3.08641975308642e-5 (* angle angle))))))))
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          t_0 := \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\\
          \mathbf{if}\;b \leq 3.9 \cdot 10^{-100}:\\
          \;\;\;\;a \cdot a\\
          
          \mathbf{elif}\;b \leq 5.4 \cdot 10^{+157}:\\
          \;\;\;\;\mathsf{fma}\left(\left(\left(t\_0 \cdot 3.08641975308642 \cdot 10^{-5}\right) \cdot b\right) \cdot b, angle \cdot angle, a \cdot a\right)\\
          
          \mathbf{else}:\\
          \;\;\;\;\left(t\_0 \cdot b\right) \cdot \left(b \cdot \left(3.08641975308642 \cdot 10^{-5} \cdot \left(angle \cdot angle\right)\right)\right)\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 3 regimes
          2. if b < 3.89999999999999977e-100

            1. Initial program 87.9%

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

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

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

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

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

            if 3.89999999999999977e-100 < b < 5.4000000000000001e157

            1. Initial program 64.6%

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

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

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

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

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

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

              if 5.4000000000000001e157 < b

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

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

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

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

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

                  \[\leadsto \left(\left(angle \cdot angle\right) \cdot 3.08641975308642 \cdot 10^{-5}\right) \cdot \color{blue}{\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 rewrites82.2%

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

                Alternative 4: 60.9% accurate, 12.1× speedup?

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

                  1. Initial program 81.6%

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

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

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

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

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

                  if 5.4000000000000001e157 < b

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

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

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

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

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

                      \[\leadsto \left(\left(angle \cdot angle\right) \cdot 3.08641975308642 \cdot 10^{-5}\right) \cdot \color{blue}{\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 rewrites82.2%

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

                    Alternative 5: 60.2% accurate, 12.1× speedup?

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

                      1. Initial program 82.1%

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

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

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

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

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

                      if 2.40000000000000003e150 < b

                      1. Initial program 95.1%

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

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

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

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

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

                          \[\leadsto \left(\left(angle \cdot angle\right) \cdot 3.08641975308642 \cdot 10^{-5}\right) \cdot \color{blue}{\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 rewrites65.2%

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

                        Alternative 6: 56.7% accurate, 74.7× speedup?

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

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

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

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

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

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

                        Reproduce

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