ab-angle->ABCF C

Percentage Accurate: 79.9% → 80.0%
Time: 4.7s
Alternatives: 8
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 8 alternatives:

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

Initial Program: 79.9% accurate, 1.0× speedup?

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

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

Alternative 1: 80.0% accurate, 1.9× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 80.0% accurate, 2.0× speedup?

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

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

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

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

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

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

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

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

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

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

Alternative 3: 58.9% accurate, 2.0× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot 0.005555555555555556\right) \cdot angle, \left(b \cdot \left(0.005555555555555556 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot angle, a \cdot a\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < 1.9499999999999999e-147

    1. Initial program 77.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {\left(\sin \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right) \cdot b\right)}^{2} \]
    10. Applied rewrites45.9%

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

    if 1.9499999999999999e-147 < a

    1. Initial program 81.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{180} \cdot \left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right), \frac{1}{180} \cdot \left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right), a \cdot a\right)} \]
    10. Applied rewrites79.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot 0.005555555555555556\right) \cdot angle, \left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot 0.005555555555555556\right) \cdot angle, a \cdot a\right)} \]
    11. Step-by-step derivation
      1. associate-*l*N/A

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

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

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

        \[\leadsto \mathsf{fma}\left(\left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot \frac{1}{180}\right) \cdot angle, \left(b \cdot \left(\frac{1}{180} \cdot \mathsf{PI}\left(\right)\right)\right) \cdot angle, a \cdot a\right) \]
      5. lower-PI.f6479.2

        \[\leadsto \mathsf{fma}\left(\left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot 0.005555555555555556\right) \cdot angle, \left(b \cdot \left(0.005555555555555556 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot angle, a \cdot a\right) \]
    12. Applied rewrites79.2%

      \[\leadsto \mathsf{fma}\left(\left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot 0.005555555555555556\right) \cdot angle, \left(b \cdot \left(0.005555555555555556 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot angle, a \cdot a\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification56.6%

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

Alternative 4: 58.9% accurate, 2.0× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot 0.005555555555555556\right) \cdot angle, \left(b \cdot \left(0.005555555555555556 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot angle, a \cdot a\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < 1.9499999999999999e-147

    1. Initial program 77.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 a around 0

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

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

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

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

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

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

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

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

        \[\leadsto {\left(\sin \left(\left(angle \cdot \mathsf{PI}\left(\right)\right) \cdot \frac{1}{180}\right) \cdot b\right)}^{2} \]
      9. lower-PI.f6446.0

        \[\leadsto {\left(\sin \left(\left(angle \cdot \mathsf{PI}\left(\right)\right) \cdot 0.005555555555555556\right) \cdot b\right)}^{2} \]
    5. Applied rewrites46.0%

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

    if 1.9499999999999999e-147 < a

    1. Initial program 81.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{180} \cdot \left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right), \frac{1}{180} \cdot \left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right), a \cdot a\right)} \]
    10. Applied rewrites79.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot 0.005555555555555556\right) \cdot angle, \left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot 0.005555555555555556\right) \cdot angle, a \cdot a\right)} \]
    11. Step-by-step derivation
      1. associate-*l*N/A

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

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

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

        \[\leadsto \mathsf{fma}\left(\left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot \frac{1}{180}\right) \cdot angle, \left(b \cdot \left(\frac{1}{180} \cdot \mathsf{PI}\left(\right)\right)\right) \cdot angle, a \cdot a\right) \]
      5. lower-PI.f6479.2

        \[\leadsto \mathsf{fma}\left(\left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot 0.005555555555555556\right) \cdot angle, \left(b \cdot \left(0.005555555555555556 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot angle, a \cdot a\right) \]
    12. Applied rewrites79.2%

      \[\leadsto \mathsf{fma}\left(\left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot 0.005555555555555556\right) \cdot angle, \left(b \cdot \left(0.005555555555555556 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot angle, a \cdot a\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 5: 67.0% accurate, 9.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 3.05 \cdot 10^{-86}:\\ \;\;\;\;a \cdot a\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot 0.005555555555555556\right) \cdot angle, \left(b \cdot \left(0.005555555555555556 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot angle, a \cdot a\right)\\ \end{array} \end{array} \]
(FPCore (a b angle)
 :precision binary64
 (if (<= b 3.05e-86)
   (* a a)
   (fma
    (* (* (* b (PI)) 0.005555555555555556) angle)
    (* (* b (* 0.005555555555555556 (PI))) angle)
    (* a a))))
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot 0.005555555555555556\right) \cdot angle, \left(b \cdot \left(0.005555555555555556 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot angle, a \cdot a\right)\\


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

    1. Initial program 79.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 a \cdot \color{blue}{a} \]
      2. lower-*.f6459.8

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

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

    if 3.05000000000000016e-86 < b

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{180} \cdot \left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right), \frac{1}{180} \cdot \left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right), a \cdot a\right)} \]
    10. Applied rewrites75.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot 0.005555555555555556\right) \cdot angle, \left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot 0.005555555555555556\right) \cdot angle, a \cdot a\right)} \]
    11. Step-by-step derivation
      1. associate-*l*N/A

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

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

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

        \[\leadsto \mathsf{fma}\left(\left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot \frac{1}{180}\right) \cdot angle, \left(b \cdot \left(\frac{1}{180} \cdot \mathsf{PI}\left(\right)\right)\right) \cdot angle, a \cdot a\right) \]
      5. lower-PI.f6475.3

        \[\leadsto \mathsf{fma}\left(\left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot 0.005555555555555556\right) \cdot angle, \left(b \cdot \left(0.005555555555555556 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot angle, a \cdot a\right) \]
    12. Applied rewrites75.3%

      \[\leadsto \mathsf{fma}\left(\left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot 0.005555555555555556\right) \cdot angle, \left(b \cdot \left(0.005555555555555556 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot angle, a \cdot a\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 6: 67.0% accurate, 9.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := b \cdot \mathsf{PI}\left(\right)\\ \mathbf{if}\;b \leq 3.05 \cdot 10^{-86}:\\ \;\;\;\;a \cdot a\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\left(t\_0 \cdot 0.005555555555555556\right) \cdot angle, t\_0 \cdot \left(0.005555555555555556 \cdot angle\right), a \cdot a\right)\\ \end{array} \end{array} \]
(FPCore (a b angle)
 :precision binary64
 (let* ((t_0 (* b (PI))))
   (if (<= b 3.05e-86)
     (* a a)
     (fma
      (* (* t_0 0.005555555555555556) angle)
      (* t_0 (* 0.005555555555555556 angle))
      (* a a)))))
\begin{array}{l}

\\
\begin{array}{l}
t_0 := b \cdot \mathsf{PI}\left(\right)\\
\mathbf{if}\;b \leq 3.05 \cdot 10^{-86}:\\
\;\;\;\;a \cdot a\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(t\_0 \cdot 0.005555555555555556\right) \cdot angle, t\_0 \cdot \left(0.005555555555555556 \cdot angle\right), a \cdot a\right)\\


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

    1. Initial program 79.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 a \cdot \color{blue}{a} \]
      2. lower-*.f6459.8

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

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

    if 3.05000000000000016e-86 < b

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{180} \cdot \left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right), \frac{1}{180} \cdot \left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right), a \cdot a\right)} \]
    10. Applied rewrites75.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot 0.005555555555555556\right) \cdot angle, \left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot 0.005555555555555556\right) \cdot angle, a \cdot a\right)} \]
    11. Step-by-step derivation
      1. associate-*l*N/A

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

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

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

        \[\leadsto \mathsf{fma}\left(\left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot \frac{1}{180}\right) \cdot angle, \left(b \cdot \mathsf{PI}\left(\right)\right) \cdot \left(\frac{1}{180} \cdot angle\right), a \cdot a\right) \]
      5. lower-*.f6475.3

        \[\leadsto \mathsf{fma}\left(\left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot 0.005555555555555556\right) \cdot angle, \left(b \cdot \mathsf{PI}\left(\right)\right) \cdot \left(0.005555555555555556 \cdot \color{blue}{angle}\right), a \cdot a\right) \]
    12. Applied rewrites75.3%

      \[\leadsto \mathsf{fma}\left(\left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot 0.005555555555555556\right) \cdot angle, \left(b \cdot \mathsf{PI}\left(\right)\right) \cdot \color{blue}{\left(0.005555555555555556 \cdot angle\right)}, a \cdot a\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 7: 67.0% accurate, 9.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := b \cdot \mathsf{PI}\left(\right)\\ \mathbf{if}\;b \leq 3.05 \cdot 10^{-86}:\\ \;\;\;\;a \cdot a\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\left(t\_0 \cdot 0.005555555555555556\right) \cdot angle, \left(t\_0 \cdot angle\right) \cdot 0.005555555555555556, a \cdot a\right)\\ \end{array} \end{array} \]
(FPCore (a b angle)
 :precision binary64
 (let* ((t_0 (* b (PI))))
   (if (<= b 3.05e-86)
     (* a a)
     (fma
      (* (* t_0 0.005555555555555556) angle)
      (* (* t_0 angle) 0.005555555555555556)
      (* a a)))))
\begin{array}{l}

\\
\begin{array}{l}
t_0 := b \cdot \mathsf{PI}\left(\right)\\
\mathbf{if}\;b \leq 3.05 \cdot 10^{-86}:\\
\;\;\;\;a \cdot a\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(t\_0 \cdot 0.005555555555555556\right) \cdot angle, \left(t\_0 \cdot angle\right) \cdot 0.005555555555555556, a \cdot a\right)\\


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

    1. Initial program 79.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 a \cdot \color{blue}{a} \]
      2. lower-*.f6459.8

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

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

    if 3.05000000000000016e-86 < b

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{180} \cdot \left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right), \frac{1}{180} \cdot \left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right), a \cdot a\right)} \]
    10. Applied rewrites75.3%

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot \frac{1}{180}\right) \cdot angle, \left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right) \cdot \frac{1}{180}, a \cdot a\right) \]
      6. lower-PI.f6475.3

        \[\leadsto \mathsf{fma}\left(\left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot 0.005555555555555556\right) \cdot angle, \left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right) \cdot 0.005555555555555556, a \cdot a\right) \]
    13. Applied rewrites75.3%

      \[\leadsto \mathsf{fma}\left(\left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot 0.005555555555555556\right) \cdot angle, \left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right) \cdot \color{blue}{0.005555555555555556}, a \cdot a\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 8: 56.8% 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 78.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 a \cdot \color{blue}{a} \]
    2. lower-*.f6453.1

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

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

Reproduce

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