ab-angle->ABCF C

Percentage Accurate: 79.8% → 79.8%
Time: 4.9s
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.8% 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.8% accurate, 1.0× speedup?

\[\begin{array}{l} angle_m = \left|angle\right| \\ {\left(\sin \left(\mathsf{fma}\left(\mathsf{PI}\left(\right) \cdot angle\_m, 0.005555555555555556, 0.5 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot a\right)}^{2} + {\left(\sin \left(\left(0.005555555555555556 \cdot angle\_m\right) \cdot \mathsf{PI}\left(\right)\right) \cdot b\right)}^{2} \end{array} \]
angle_m = (fabs.f64 angle)
(FPCore (a b angle_m)
 :precision binary64
 (+
  (pow
   (* (sin (fma (* (PI) angle_m) 0.005555555555555556 (* 0.5 (PI)))) a)
   2.0)
  (pow (* (sin (* (* 0.005555555555555556 angle_m) (PI))) b) 2.0)))
\begin{array}{l}
angle_m = \left|angle\right|

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

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

      \[\leadsto {\left(a \cdot \color{blue}{\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. 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} \]
    3. 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} \]
    4. lift-PI.f64N/A

      \[\leadsto {\left(a \cdot \sin \left(\color{blue}{\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} \]
    5. lift-*.f64N/A

      \[\leadsto {\left(a \cdot \sin \left(\color{blue}{\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} \]
    6. lower-fma.f64N/A

      \[\leadsto {\left(a \cdot \sin \color{blue}{\left(\mathsf{fma}\left(\mathsf{PI}\left(\right), \frac{angle}{180}, \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. lift-PI.f64N/A

      \[\leadsto {\left(a \cdot \sin \left(\mathsf{fma}\left(\color{blue}{\mathsf{PI}\left(\right)}, \frac{angle}{180}, \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-/.f64N/A

      \[\leadsto {\left(a \cdot \sin \left(\mathsf{fma}\left(\mathsf{PI}\left(\right), \frac{angle}{180}, \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} \]
    9. lift-PI.f6479.7

      \[\leadsto {\left(a \cdot \sin \left(\mathsf{fma}\left(\mathsf{PI}\left(\right), \frac{angle}{180}, \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 rewrites79.7%

    \[\leadsto {\left(a \cdot \color{blue}{\sin \left(\mathsf{fma}\left(\mathsf{PI}\left(\right), \frac{angle}{180}, \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 angle around 0

    \[\leadsto {\left(a \cdot \sin \left(\mathsf{fma}\left(\mathsf{PI}\left(\right), \frac{angle}{180}, \frac{\mathsf{PI}\left(\right)}{2}\right)\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} \]
  6. Step-by-step derivation
    1. *-commutativeN/A

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{{\left(\sin \left(\mathsf{fma}\left(\mathsf{PI}\left(\right) \cdot angle, 0.005555555555555556, 0.5 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot a\right)}^{2} + {\left(\sin \left(\left(0.005555555555555556 \cdot angle\right) \cdot \mathsf{PI}\left(\right)\right) \cdot b\right)}^{2}} \]
  11. Final simplification79.8%

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

Alternative 2: 64.6% accurate, 2.0× speedup?

\[\begin{array}{l} angle_m = \left|angle\right| \\ \begin{array}{l} \mathbf{if}\;b \leq 1.15 \cdot 10^{-50}:\\ \;\;\;\;{\left(\sin \left(\mathsf{fma}\left(0.5, \mathsf{PI}\left(\right), \left(\mathsf{PI}\left(\right) \cdot angle\_m\right) \cdot 0.005555555555555556\right)\right) \cdot a\right)}^{2}\\ \mathbf{elif}\;b \leq 4.4 \cdot 10^{+153}:\\ \;\;\;\;\mathsf{fma}\left({\left(\mathsf{PI}\left(\right) \cdot b\right)}^{2} \cdot 3.08641975308642 \cdot 10^{-5}, angle\_m \cdot angle\_m, a \cdot a\right)\\ \mathbf{else}:\\ \;\;\;\;\left({\left(angle\_m \cdot b\right)}^{2} \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right) \cdot 3.08641975308642 \cdot 10^{-5}\\ \end{array} \end{array} \]
angle_m = (fabs.f64 angle)
(FPCore (a b angle_m)
 :precision binary64
 (if (<= b 1.15e-50)
   (pow
    (* (sin (fma 0.5 (PI) (* (* (PI) angle_m) 0.005555555555555556))) a)
    2.0)
   (if (<= b 4.4e+153)
     (fma
      (* (pow (* (PI) b) 2.0) 3.08641975308642e-5)
      (* angle_m angle_m)
      (* a a))
     (* (* (pow (* angle_m b) 2.0) (* (PI) (PI))) 3.08641975308642e-5))))
\begin{array}{l}
angle_m = \left|angle\right|

\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.15 \cdot 10^{-50}:\\
\;\;\;\;{\left(\sin \left(\mathsf{fma}\left(0.5, \mathsf{PI}\left(\right), \left(\mathsf{PI}\left(\right) \cdot angle\_m\right) \cdot 0.005555555555555556\right)\right) \cdot a\right)}^{2}\\

\mathbf{elif}\;b \leq 4.4 \cdot 10^{+153}:\\
\;\;\;\;\mathsf{fma}\left({\left(\mathsf{PI}\left(\right) \cdot b\right)}^{2} \cdot 3.08641975308642 \cdot 10^{-5}, angle\_m \cdot angle\_m, a \cdot a\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if b < 1.1500000000000001e-50

    1. Initial program 80.4%

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

        \[\leadsto {\left(a \cdot \color{blue}{\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. 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} \]
      3. 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} \]
      4. lift-PI.f64N/A

        \[\leadsto {\left(a \cdot \sin \left(\color{blue}{\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} \]
      5. lift-*.f64N/A

        \[\leadsto {\left(a \cdot \sin \left(\color{blue}{\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} \]
      6. lower-fma.f64N/A

        \[\leadsto {\left(a \cdot \sin \color{blue}{\left(\mathsf{fma}\left(\mathsf{PI}\left(\right), \frac{angle}{180}, \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. lift-PI.f64N/A

        \[\leadsto {\left(a \cdot \sin \left(\mathsf{fma}\left(\color{blue}{\mathsf{PI}\left(\right)}, \frac{angle}{180}, \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-/.f64N/A

        \[\leadsto {\left(a \cdot \sin \left(\mathsf{fma}\left(\mathsf{PI}\left(\right), \frac{angle}{180}, \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} \]
      9. lift-PI.f6480.6

        \[\leadsto {\left(a \cdot \sin \left(\mathsf{fma}\left(\mathsf{PI}\left(\right), \frac{angle}{180}, \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 rewrites80.6%

      \[\leadsto {\left(a \cdot \color{blue}{\sin \left(\mathsf{fma}\left(\mathsf{PI}\left(\right), \frac{angle}{180}, \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 {\sin \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right) + \frac{1}{2} \cdot \mathsf{PI}\left(\right)\right)}^{2}} \]
    6. Step-by-step derivation
      1. pow-prod-downN/A

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

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

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

    if 1.1500000000000001e-50 < b < 4.3999999999999999e153

    1. Initial program 67.5%

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

      \[\leadsto \color{blue}{{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 \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} + {\color{blue}{a}}^{2} \]
      2. lower-fma.f64N/A

        \[\leadsto \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), \color{blue}{{angle}^{2}}, {a}^{2}\right) \]
    5. Applied rewrites23.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left({\left(\mathsf{PI}\left(\right) \cdot b\right)}^{2}, 3.08641975308642 \cdot 10^{-5}, {\left(\mathsf{PI}\left(\right) \cdot a\right)}^{2} \cdot -3.08641975308642 \cdot 10^{-5}\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. *-commutativeN/A

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

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

        \[\leadsto \mathsf{fma}\left(\left({\mathsf{PI}\left(\right)}^{2} \cdot {b}^{2}\right) \cdot \frac{1}{32400}, angle \cdot angle, a \cdot a\right) \]
      4. unpow-prod-downN/A

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

        \[\leadsto \mathsf{fma}\left({\left(\mathsf{PI}\left(\right) \cdot b\right)}^{2} \cdot \frac{1}{32400}, angle \cdot angle, a \cdot a\right) \]
      6. lift-PI.f64N/A

        \[\leadsto \mathsf{fma}\left({\left(\mathsf{PI}\left(\right) \cdot b\right)}^{2} \cdot \frac{1}{32400}, angle \cdot angle, a \cdot a\right) \]
      7. lift-pow.f6462.5

        \[\leadsto \mathsf{fma}\left({\left(\mathsf{PI}\left(\right) \cdot b\right)}^{2} \cdot 3.08641975308642 \cdot 10^{-5}, angle \cdot angle, a \cdot a\right) \]
    8. Applied rewrites62.5%

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

    if 4.3999999999999999e153 < b

    1. Initial program 90.0%

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

      \[\leadsto \color{blue}{{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 \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} + {\color{blue}{a}}^{2} \]
      2. lower-fma.f64N/A

        \[\leadsto \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), \color{blue}{{angle}^{2}}, {a}^{2}\right) \]
    5. Applied rewrites52.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left({\left(\mathsf{PI}\left(\right) \cdot b\right)}^{2}, 3.08641975308642 \cdot 10^{-5}, {\left(\mathsf{PI}\left(\right) \cdot a\right)}^{2} \cdot -3.08641975308642 \cdot 10^{-5}\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. *-commutativeN/A

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

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

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

        \[\leadsto \left({angle}^{2} \cdot {\left(\mathsf{PI}\left(\right) \cdot b\right)}^{2}\right) \cdot \frac{1}{32400} \]
      5. pow-prod-downN/A

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

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

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

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

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

        \[\leadsto {\left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot angle\right)}^{2} \cdot \frac{1}{32400} \]
      11. lift-*.f64N/A

        \[\leadsto {\left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot angle\right)}^{2} \cdot \frac{1}{32400} \]
      12. lift-PI.f6480.3

        \[\leadsto {\left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot angle\right)}^{2} \cdot 3.08641975308642 \cdot 10^{-5} \]
    8. Applied rewrites80.3%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left({angle}^{2} \cdot {b}^{2}\right) \cdot {\mathsf{PI}\left(\right)}^{2}\right) \cdot \frac{1}{32400} \]
      11. pow-prod-downN/A

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

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

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

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

        \[\leadsto \left({\left(angle \cdot b\right)}^{2} \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \frac{1}{32400} \]
      16. lift-PI.f64N/A

        \[\leadsto \left({\left(angle \cdot b\right)}^{2} \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \frac{1}{32400} \]
      17. lift-PI.f6480.4

        \[\leadsto \left({\left(angle \cdot b\right)}^{2} \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right) \cdot 3.08641975308642 \cdot 10^{-5} \]
    10. Applied rewrites80.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 1.15 \cdot 10^{-50}:\\ \;\;\;\;{\left(\sin \left(\mathsf{fma}\left(0.5, \mathsf{PI}\left(\right), \left(\mathsf{PI}\left(\right) \cdot angle\right) \cdot 0.005555555555555556\right)\right) \cdot a\right)}^{2}\\ \mathbf{elif}\;b \leq 4.4 \cdot 10^{+153}:\\ \;\;\;\;\mathsf{fma}\left({\left(\mathsf{PI}\left(\right) \cdot b\right)}^{2} \cdot 3.08641975308642 \cdot 10^{-5}, angle \cdot angle, a \cdot a\right)\\ \mathbf{else}:\\ \;\;\;\;\left({\left(angle \cdot b\right)}^{2} \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right) \cdot 3.08641975308642 \cdot 10^{-5}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 79.8% accurate, 2.0× speedup?

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

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

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

    \[\leadsto {\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 \color{blue}{\left(\frac{1}{180} \cdot angle\right)}\right)\right)}^{2} \]
  4. Step-by-step derivation
    1. lower-*.f6479.6

      \[\leadsto {\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 \left(0.005555555555555556 \cdot \color{blue}{angle}\right)\right)\right)}^{2} \]
  5. Applied rewrites79.6%

    \[\leadsto {\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 \color{blue}{\left(0.005555555555555556 \cdot angle\right)}\right)\right)}^{2} \]
  6. Taylor expanded in angle around 0

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

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

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

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

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

Alternative 4: 64.6% accurate, 2.0× speedup?

\[\begin{array}{l} angle_m = \left|angle\right| \\ \begin{array}{l} \mathbf{if}\;b \leq 1.15 \cdot 10^{-50}:\\ \;\;\;\;{\left(\cos \left(\left(\mathsf{PI}\left(\right) \cdot angle\_m\right) \cdot 0.005555555555555556\right) \cdot a\right)}^{2}\\ \mathbf{elif}\;b \leq 4.4 \cdot 10^{+153}:\\ \;\;\;\;\mathsf{fma}\left({\left(\mathsf{PI}\left(\right) \cdot b\right)}^{2} \cdot 3.08641975308642 \cdot 10^{-5}, angle\_m \cdot angle\_m, a \cdot a\right)\\ \mathbf{else}:\\ \;\;\;\;\left({\left(angle\_m \cdot b\right)}^{2} \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right) \cdot 3.08641975308642 \cdot 10^{-5}\\ \end{array} \end{array} \]
angle_m = (fabs.f64 angle)
(FPCore (a b angle_m)
 :precision binary64
 (if (<= b 1.15e-50)
   (pow (* (cos (* (* (PI) angle_m) 0.005555555555555556)) a) 2.0)
   (if (<= b 4.4e+153)
     (fma
      (* (pow (* (PI) b) 2.0) 3.08641975308642e-5)
      (* angle_m angle_m)
      (* a a))
     (* (* (pow (* angle_m b) 2.0) (* (PI) (PI))) 3.08641975308642e-5))))
\begin{array}{l}
angle_m = \left|angle\right|

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

\mathbf{elif}\;b \leq 4.4 \cdot 10^{+153}:\\
\;\;\;\;\mathsf{fma}\left({\left(\mathsf{PI}\left(\right) \cdot b\right)}^{2} \cdot 3.08641975308642 \cdot 10^{-5}, angle\_m \cdot angle\_m, a \cdot a\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if b < 1.1500000000000001e-50

    1. Initial program 80.4%

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

      \[\leadsto \color{blue}{{a}^{2} \cdot {\cos \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(a \cdot \cos \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(a \cdot \cos \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)\right)}^{\color{blue}{2}} \]
      3. *-commutativeN/A

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

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

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

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

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

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

        \[\leadsto {\left(\cos \left(\left(\mathsf{PI}\left(\right) \cdot angle\right) \cdot \frac{1}{180}\right) \cdot a\right)}^{2} \]
      10. lift-PI.f6462.4

        \[\leadsto {\left(\cos \left(\left(\mathsf{PI}\left(\right) \cdot angle\right) \cdot 0.005555555555555556\right) \cdot a\right)}^{2} \]
    5. Applied rewrites62.4%

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

    if 1.1500000000000001e-50 < b < 4.3999999999999999e153

    1. Initial program 67.5%

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

      \[\leadsto \color{blue}{{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 \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} + {\color{blue}{a}}^{2} \]
      2. lower-fma.f64N/A

        \[\leadsto \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), \color{blue}{{angle}^{2}}, {a}^{2}\right) \]
    5. Applied rewrites23.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left({\left(\mathsf{PI}\left(\right) \cdot b\right)}^{2}, 3.08641975308642 \cdot 10^{-5}, {\left(\mathsf{PI}\left(\right) \cdot a\right)}^{2} \cdot -3.08641975308642 \cdot 10^{-5}\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. *-commutativeN/A

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

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

        \[\leadsto \mathsf{fma}\left(\left({\mathsf{PI}\left(\right)}^{2} \cdot {b}^{2}\right) \cdot \frac{1}{32400}, angle \cdot angle, a \cdot a\right) \]
      4. unpow-prod-downN/A

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

        \[\leadsto \mathsf{fma}\left({\left(\mathsf{PI}\left(\right) \cdot b\right)}^{2} \cdot \frac{1}{32400}, angle \cdot angle, a \cdot a\right) \]
      6. lift-PI.f64N/A

        \[\leadsto \mathsf{fma}\left({\left(\mathsf{PI}\left(\right) \cdot b\right)}^{2} \cdot \frac{1}{32400}, angle \cdot angle, a \cdot a\right) \]
      7. lift-pow.f6462.5

        \[\leadsto \mathsf{fma}\left({\left(\mathsf{PI}\left(\right) \cdot b\right)}^{2} \cdot 3.08641975308642 \cdot 10^{-5}, angle \cdot angle, a \cdot a\right) \]
    8. Applied rewrites62.5%

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

    if 4.3999999999999999e153 < b

    1. Initial program 90.0%

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

      \[\leadsto \color{blue}{{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 \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} + {\color{blue}{a}}^{2} \]
      2. lower-fma.f64N/A

        \[\leadsto \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), \color{blue}{{angle}^{2}}, {a}^{2}\right) \]
    5. Applied rewrites52.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left({\left(\mathsf{PI}\left(\right) \cdot b\right)}^{2}, 3.08641975308642 \cdot 10^{-5}, {\left(\mathsf{PI}\left(\right) \cdot a\right)}^{2} \cdot -3.08641975308642 \cdot 10^{-5}\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. *-commutativeN/A

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

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

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

        \[\leadsto \left({angle}^{2} \cdot {\left(\mathsf{PI}\left(\right) \cdot b\right)}^{2}\right) \cdot \frac{1}{32400} \]
      5. pow-prod-downN/A

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

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

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

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

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

        \[\leadsto {\left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot angle\right)}^{2} \cdot \frac{1}{32400} \]
      11. lift-*.f64N/A

        \[\leadsto {\left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot angle\right)}^{2} \cdot \frac{1}{32400} \]
      12. lift-PI.f6480.3

        \[\leadsto {\left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot angle\right)}^{2} \cdot 3.08641975308642 \cdot 10^{-5} \]
    8. Applied rewrites80.3%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left({angle}^{2} \cdot {b}^{2}\right) \cdot {\mathsf{PI}\left(\right)}^{2}\right) \cdot \frac{1}{32400} \]
      11. pow-prod-downN/A

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

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

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

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

        \[\leadsto \left({\left(angle \cdot b\right)}^{2} \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \frac{1}{32400} \]
      16. lift-PI.f64N/A

        \[\leadsto \left({\left(angle \cdot b\right)}^{2} \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \frac{1}{32400} \]
      17. lift-PI.f6480.4

        \[\leadsto \left({\left(angle \cdot b\right)}^{2} \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right) \cdot 3.08641975308642 \cdot 10^{-5} \]
    10. Applied rewrites80.4%

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

Alternative 5: 64.8% accurate, 3.2× speedup?

\[\begin{array}{l} angle_m = \left|angle\right| \\ \begin{array}{l} \mathbf{if}\;b \leq 1.65 \cdot 10^{-50}:\\ \;\;\;\;a \cdot a\\ \mathbf{elif}\;b \leq 4.4 \cdot 10^{+153}:\\ \;\;\;\;\mathsf{fma}\left({\left(\mathsf{PI}\left(\right) \cdot b\right)}^{2} \cdot 3.08641975308642 \cdot 10^{-5}, angle\_m \cdot angle\_m, a \cdot a\right)\\ \mathbf{else}:\\ \;\;\;\;\left({\left(angle\_m \cdot b\right)}^{2} \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right) \cdot 3.08641975308642 \cdot 10^{-5}\\ \end{array} \end{array} \]
angle_m = (fabs.f64 angle)
(FPCore (a b angle_m)
 :precision binary64
 (if (<= b 1.65e-50)
   (* a a)
   (if (<= b 4.4e+153)
     (fma
      (* (pow (* (PI) b) 2.0) 3.08641975308642e-5)
      (* angle_m angle_m)
      (* a a))
     (* (* (pow (* angle_m b) 2.0) (* (PI) (PI))) 3.08641975308642e-5))))
\begin{array}{l}
angle_m = \left|angle\right|

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

\mathbf{elif}\;b \leq 4.4 \cdot 10^{+153}:\\
\;\;\;\;\mathsf{fma}\left({\left(\mathsf{PI}\left(\right) \cdot b\right)}^{2} \cdot 3.08641975308642 \cdot 10^{-5}, angle\_m \cdot angle\_m, a \cdot a\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if b < 1.6499999999999999e-50

    1. Initial program 80.4%

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

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

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

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

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

    if 1.6499999999999999e-50 < b < 4.3999999999999999e153

    1. Initial program 67.5%

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

      \[\leadsto \color{blue}{{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 \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} + {\color{blue}{a}}^{2} \]
      2. lower-fma.f64N/A

        \[\leadsto \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), \color{blue}{{angle}^{2}}, {a}^{2}\right) \]
    5. Applied rewrites23.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left({\left(\mathsf{PI}\left(\right) \cdot b\right)}^{2}, 3.08641975308642 \cdot 10^{-5}, {\left(\mathsf{PI}\left(\right) \cdot a\right)}^{2} \cdot -3.08641975308642 \cdot 10^{-5}\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. *-commutativeN/A

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

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

        \[\leadsto \mathsf{fma}\left(\left({\mathsf{PI}\left(\right)}^{2} \cdot {b}^{2}\right) \cdot \frac{1}{32400}, angle \cdot angle, a \cdot a\right) \]
      4. unpow-prod-downN/A

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

        \[\leadsto \mathsf{fma}\left({\left(\mathsf{PI}\left(\right) \cdot b\right)}^{2} \cdot \frac{1}{32400}, angle \cdot angle, a \cdot a\right) \]
      6. lift-PI.f64N/A

        \[\leadsto \mathsf{fma}\left({\left(\mathsf{PI}\left(\right) \cdot b\right)}^{2} \cdot \frac{1}{32400}, angle \cdot angle, a \cdot a\right) \]
      7. lift-pow.f6462.5

        \[\leadsto \mathsf{fma}\left({\left(\mathsf{PI}\left(\right) \cdot b\right)}^{2} \cdot 3.08641975308642 \cdot 10^{-5}, angle \cdot angle, a \cdot a\right) \]
    8. Applied rewrites62.5%

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

    if 4.3999999999999999e153 < b

    1. Initial program 90.0%

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

      \[\leadsto \color{blue}{{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 \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} + {\color{blue}{a}}^{2} \]
      2. lower-fma.f64N/A

        \[\leadsto \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), \color{blue}{{angle}^{2}}, {a}^{2}\right) \]
    5. Applied rewrites52.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left({\left(\mathsf{PI}\left(\right) \cdot b\right)}^{2}, 3.08641975308642 \cdot 10^{-5}, {\left(\mathsf{PI}\left(\right) \cdot a\right)}^{2} \cdot -3.08641975308642 \cdot 10^{-5}\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. *-commutativeN/A

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

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

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

        \[\leadsto \left({angle}^{2} \cdot {\left(\mathsf{PI}\left(\right) \cdot b\right)}^{2}\right) \cdot \frac{1}{32400} \]
      5. pow-prod-downN/A

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

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

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

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

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

        \[\leadsto {\left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot angle\right)}^{2} \cdot \frac{1}{32400} \]
      11. lift-*.f64N/A

        \[\leadsto {\left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot angle\right)}^{2} \cdot \frac{1}{32400} \]
      12. lift-PI.f6480.3

        \[\leadsto {\left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot angle\right)}^{2} \cdot 3.08641975308642 \cdot 10^{-5} \]
    8. Applied rewrites80.3%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left({angle}^{2} \cdot {b}^{2}\right) \cdot {\mathsf{PI}\left(\right)}^{2}\right) \cdot \frac{1}{32400} \]
      11. pow-prod-downN/A

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

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

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

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

        \[\leadsto \left({\left(angle \cdot b\right)}^{2} \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \frac{1}{32400} \]
      16. lift-PI.f64N/A

        \[\leadsto \left({\left(angle \cdot b\right)}^{2} \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \frac{1}{32400} \]
      17. lift-PI.f6480.4

        \[\leadsto \left({\left(angle \cdot b\right)}^{2} \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right) \cdot 3.08641975308642 \cdot 10^{-5} \]
    10. Applied rewrites80.4%

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

Alternative 6: 62.5% accurate, 3.5× speedup?

\[\begin{array}{l} angle_m = \left|angle\right| \\ \begin{array}{l} \mathbf{if}\;b \leq 2.85 \cdot 10^{+170}:\\ \;\;\;\;a \cdot a\\ \mathbf{else}:\\ \;\;\;\;\left({\left(angle\_m \cdot b\right)}^{2} \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right) \cdot 3.08641975308642 \cdot 10^{-5}\\ \end{array} \end{array} \]
angle_m = (fabs.f64 angle)
(FPCore (a b angle_m)
 :precision binary64
 (if (<= b 2.85e+170)
   (* a a)
   (* (* (pow (* angle_m b) 2.0) (* (PI) (PI))) 3.08641975308642e-5)))
\begin{array}{l}
angle_m = \left|angle\right|

\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.85 \cdot 10^{+170}:\\
\;\;\;\;a \cdot a\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 2.84999999999999984e170

    1. Initial program 77.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 a \cdot \color{blue}{a} \]
      2. lower-*.f6461.6

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

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

    if 2.84999999999999984e170 < b

    1. Initial program 95.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}{{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 \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} + {\color{blue}{a}}^{2} \]
      2. lower-fma.f64N/A

        \[\leadsto \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), \color{blue}{{angle}^{2}}, {a}^{2}\right) \]
    5. Applied rewrites57.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left({\left(\mathsf{PI}\left(\right) \cdot b\right)}^{2}, 3.08641975308642 \cdot 10^{-5}, {\left(\mathsf{PI}\left(\right) \cdot a\right)}^{2} \cdot -3.08641975308642 \cdot 10^{-5}\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. *-commutativeN/A

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

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

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

        \[\leadsto \left({angle}^{2} \cdot {\left(\mathsf{PI}\left(\right) \cdot b\right)}^{2}\right) \cdot \frac{1}{32400} \]
      5. pow-prod-downN/A

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

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

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

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

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

        \[\leadsto {\left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot angle\right)}^{2} \cdot \frac{1}{32400} \]
      11. lift-*.f64N/A

        \[\leadsto {\left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot angle\right)}^{2} \cdot \frac{1}{32400} \]
      12. lift-PI.f6485.0

        \[\leadsto {\left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot angle\right)}^{2} \cdot 3.08641975308642 \cdot 10^{-5} \]
    8. Applied rewrites85.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left({angle}^{2} \cdot {b}^{2}\right) \cdot {\mathsf{PI}\left(\right)}^{2}\right) \cdot \frac{1}{32400} \]
      11. pow-prod-downN/A

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

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

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

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

        \[\leadsto \left({\left(angle \cdot b\right)}^{2} \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \frac{1}{32400} \]
      16. lift-PI.f64N/A

        \[\leadsto \left({\left(angle \cdot b\right)}^{2} \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \frac{1}{32400} \]
      17. lift-PI.f6485.0

        \[\leadsto \left({\left(angle \cdot b\right)}^{2} \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right) \cdot 3.08641975308642 \cdot 10^{-5} \]
    10. Applied rewrites85.0%

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

Alternative 7: 62.5% accurate, 12.1× speedup?

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

\\
\begin{array}{l}
t_0 := \left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\_m\\
\mathbf{if}\;b \leq 2.85 \cdot 10^{+170}:\\
\;\;\;\;a \cdot a\\

\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(t\_0 \cdot 3.08641975308642 \cdot 10^{-5}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 2.84999999999999984e170

    1. Initial program 77.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 a \cdot \color{blue}{a} \]
      2. lower-*.f6461.6

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

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

    if 2.84999999999999984e170 < b

    1. Initial program 95.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}{{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 \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} + {\color{blue}{a}}^{2} \]
      2. lower-fma.f64N/A

        \[\leadsto \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), \color{blue}{{angle}^{2}}, {a}^{2}\right) \]
    5. Applied rewrites57.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left({\left(\mathsf{PI}\left(\right) \cdot b\right)}^{2}, 3.08641975308642 \cdot 10^{-5}, {\left(\mathsf{PI}\left(\right) \cdot a\right)}^{2} \cdot -3.08641975308642 \cdot 10^{-5}\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. *-commutativeN/A

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

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

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

        \[\leadsto \left({angle}^{2} \cdot {\left(\mathsf{PI}\left(\right) \cdot b\right)}^{2}\right) \cdot \frac{1}{32400} \]
      5. pow-prod-downN/A

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

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

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

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

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

        \[\leadsto {\left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot angle\right)}^{2} \cdot \frac{1}{32400} \]
      11. lift-*.f64N/A

        \[\leadsto {\left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot angle\right)}^{2} \cdot \frac{1}{32400} \]
      12. lift-PI.f6485.0

        \[\leadsto {\left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot angle\right)}^{2} \cdot 3.08641975308642 \cdot 10^{-5} \]
    8. Applied rewrites85.0%

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

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

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

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

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

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

        \[\leadsto \left(\left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot angle\right) \cdot \left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot angle\right)\right) \cdot \frac{1}{32400} \]
      7. lift-*.f64N/A

        \[\leadsto \left(\left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot angle\right) \cdot \left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot angle\right)\right) \cdot \frac{1}{32400} \]
      8. lift-PI.f64N/A

        \[\leadsto \left(\left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot angle\right) \cdot \left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot angle\right)\right) \cdot \frac{1}{32400} \]
      9. lift-*.f64N/A

        \[\leadsto \left(\left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot angle\right) \cdot \left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot angle\right)\right) \cdot \frac{1}{32400} \]
      10. lift-*.f64N/A

        \[\leadsto \left(\left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot angle\right) \cdot \left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot angle\right)\right) \cdot \frac{1}{32400} \]
      11. lift-PI.f64N/A

        \[\leadsto \left(\left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot angle\right) \cdot \left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot angle\right)\right) \cdot \frac{1}{32400} \]
      12. lift-*.f6485.0

        \[\leadsto \left(\left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot angle\right) \cdot \left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot angle\right)\right) \cdot 3.08641975308642 \cdot 10^{-5} \]
    10. Applied rewrites85.0%

      \[\leadsto \left(\left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot angle\right) \cdot \left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot angle\right)\right) \cdot 3.08641975308642 \cdot 10^{-5} \]
    11. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \left(\left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot angle\right) \cdot \left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot angle\right)\right) \cdot \frac{1}{32400} \]
      2. lift-*.f64N/A

        \[\leadsto \left(\left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot angle\right) \cdot \left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot angle\right)\right) \cdot \frac{1}{32400} \]
      3. associate-*l*N/A

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

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

        \[\leadsto \left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot angle\right) \cdot \left(\left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot angle\right) \cdot \frac{1}{32400}\right) \]
      6. lift-*.f64N/A

        \[\leadsto \left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot angle\right) \cdot \left(\left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot angle\right) \cdot \frac{1}{32400}\right) \]
      7. *-commutativeN/A

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

        \[\leadsto \left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right) \cdot \left(\left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot angle\right) \cdot \frac{1}{32400}\right) \]
      9. lift-PI.f64N/A

        \[\leadsto \left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right) \cdot \left(\left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot angle\right) \cdot \frac{1}{32400}\right) \]
      10. lower-*.f6485.0

        \[\leadsto \left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right) \cdot \left(\left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot angle\right) \cdot 3.08641975308642 \cdot 10^{-5}\right) \]
      11. lift-PI.f64N/A

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

        \[\leadsto \left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right) \cdot \left(\left(\left(\mathsf{PI}\left(\right) \cdot b\right) \cdot angle\right) \cdot \frac{1}{32400}\right) \]
      13. *-commutativeN/A

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

        \[\leadsto \left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right) \cdot \left(\left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right) \cdot \frac{1}{32400}\right) \]
      15. lift-PI.f6485.0

        \[\leadsto \left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right) \cdot \left(\left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right) \cdot 3.08641975308642 \cdot 10^{-5}\right) \]
    12. Applied rewrites85.0%

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

Alternative 8: 57.0% accurate, 74.7× speedup?

\[\begin{array}{l} angle_m = \left|angle\right| \\ a \cdot a \end{array} \]
angle_m = (fabs.f64 angle)
(FPCore (a b angle_m) :precision binary64 (* a a))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
	return a * a;
}
angle_m =     private
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(a, b, angle_m)
use fmin_fmax_functions
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: angle_m
    code = a * a
end function
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
	return a * a;
}
angle_m = math.fabs(angle)
def code(a, b, angle_m):
	return a * a
angle_m = abs(angle)
function code(a, b, angle_m)
	return Float64(a * a)
end
angle_m = abs(angle);
function tmp = code(a, b, angle_m)
	tmp = a * a;
end
angle_m = N[Abs[angle], $MachinePrecision]
code[a_, b_, angle$95$m_] := N[(a * a), $MachinePrecision]
\begin{array}{l}
angle_m = \left|angle\right|

\\
a \cdot a
\end{array}
Derivation
  1. Initial program 79.5%

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

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

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

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

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

Reproduce

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