ab-angle->ABCF A

Percentage Accurate: 79.7% → 79.7%
Time: 2.3s
Alternatives: 7
Speedup: 1.0×

Specification

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

\\
\begin{array}{l}
t_0 := \frac{angle}{180} \cdot \mathsf{PI}\left(\right)\\
{\left(a \cdot \sin t\_0\right)}^{2} + {\left(b \cdot \cos 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 7 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.7% accurate, 1.0× speedup?

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

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

Alternative 1: 79.7% accurate, 1.0× speedup?

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

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

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

Alternative 2: 66.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{angle}{180} \cdot \mathsf{PI}\left(\right)\\ t_1 := {\left(b \cdot \cos t\_0\right)}^{2}\\ t_2 := \sin t\_0\\ \mathbf{if}\;b \leq -3.2 \cdot 10^{-28}:\\ \;\;\;\;{t\_2}^{2} + t\_1\\ \mathbf{elif}\;b \leq 7.2 \cdot 10^{+24}:\\ \;\;\;\;{\left(a \cdot t\_2\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;t\_2 + t\_1\\ \end{array} \end{array} \]
(FPCore (a b angle)
 :precision binary64
 (let* ((t_0 (* (/ angle 180.0) (PI)))
        (t_1 (pow (* b (cos t_0)) 2.0))
        (t_2 (sin t_0)))
   (if (<= b -3.2e-28)
     (+ (pow t_2 2.0) t_1)
     (if (<= b 7.2e+24) (pow (* a t_2) 2.0) (+ t_2 t_1)))))
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{angle}{180} \cdot \mathsf{PI}\left(\right)\\
t_1 := {\left(b \cdot \cos t\_0\right)}^{2}\\
t_2 := \sin t\_0\\
\mathbf{if}\;b \leq -3.2 \cdot 10^{-28}:\\
\;\;\;\;{t\_2}^{2} + t\_1\\

\mathbf{elif}\;b \leq 7.2 \cdot 10^{+24}:\\
\;\;\;\;{\left(a \cdot t\_2\right)}^{2}\\

\mathbf{else}:\\
\;\;\;\;t\_2 + t\_1\\


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

    1. Initial program 82.7%

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

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

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

    if -3.19999999999999982e-28 < b < 7.19999999999999966e24

    1. Initial program 79.5%

      \[{\left(a \cdot \sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} + {\left(b \cdot \cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} \]
    2. Add Preprocessing
    3. 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)\right)}^{2} + {b}^{2} \cdot {\cos \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{2}} \]
    4. Applied rewrites65.1%

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

    if 7.19999999999999966e24 < b

    1. Initial program 83.6%

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

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

      \[\leadsto {\color{blue}{\sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)}}^{2} + {\left(b \cdot \cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} \]
    5. 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)\right)}^{2}} + {\left(b \cdot \cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} \]
    6. Applied rewrites76.2%

      \[\leadsto \color{blue}{\sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)} + {\left(b \cdot \cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 3: 66.5% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{angle}{180} \cdot \mathsf{PI}\left(\right)\\ t_1 := \sin t\_0\\ t_2 := t\_1 + {\left(b \cdot \cos t\_0\right)}^{2}\\ \mathbf{if}\;b \leq -3.25 \cdot 10^{-28}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;b \leq 7.2 \cdot 10^{+24}:\\ \;\;\;\;{\left(a \cdot t\_1\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \]
(FPCore (a b angle)
 :precision binary64
 (let* ((t_0 (* (/ angle 180.0) (PI)))
        (t_1 (sin t_0))
        (t_2 (+ t_1 (pow (* b (cos t_0)) 2.0))))
   (if (<= b -3.25e-28) t_2 (if (<= b 7.2e+24) (pow (* a t_1) 2.0) t_2))))
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{angle}{180} \cdot \mathsf{PI}\left(\right)\\
t_1 := \sin t\_0\\
t_2 := t\_1 + {\left(b \cdot \cos t\_0\right)}^{2}\\
\mathbf{if}\;b \leq -3.25 \cdot 10^{-28}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;b \leq 7.2 \cdot 10^{+24}:\\
\;\;\;\;{\left(a \cdot t\_1\right)}^{2}\\

\mathbf{else}:\\
\;\;\;\;t\_2\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -3.25000000000000021e-28 or 7.19999999999999966e24 < b

    1. Initial program 83.1%

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

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

      \[\leadsto {\color{blue}{\sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)}}^{2} + {\left(b \cdot \cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} \]
    5. 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)\right)}^{2}} + {\left(b \cdot \cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} \]
    6. Applied rewrites74.7%

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

    if -3.25000000000000021e-28 < b < 7.19999999999999966e24

    1. Initial program 79.5%

      \[{\left(a \cdot \sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} + {\left(b \cdot \cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} \]
    2. Add Preprocessing
    3. 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)\right)}^{2} + {b}^{2} \cdot {\cos \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{2}} \]
    4. Applied rewrites65.1%

      \[\leadsto \color{blue}{{\left(a \cdot \sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 4: 64.6% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{angle}{180} \cdot \mathsf{PI}\left(\right)\\ t_1 := t\_0 + {\left(b \cdot \cos t\_0\right)}^{2}\\ \mathbf{if}\;b \leq -3.3 \cdot 10^{-28}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;b \leq 10^{+106}:\\ \;\;\;\;{\left(a \cdot \sin t\_0\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (a b angle)
 :precision binary64
 (let* ((t_0 (* (/ angle 180.0) (PI))) (t_1 (+ t_0 (pow (* b (cos t_0)) 2.0))))
   (if (<= b -3.3e-28) t_1 (if (<= b 1e+106) (pow (* a (sin t_0)) 2.0) t_1))))
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{angle}{180} \cdot \mathsf{PI}\left(\right)\\
t_1 := t\_0 + {\left(b \cdot \cos t\_0\right)}^{2}\\
\mathbf{if}\;b \leq -3.3 \cdot 10^{-28}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;b \leq 10^{+106}:\\
\;\;\;\;{\left(a \cdot \sin t\_0\right)}^{2}\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -3.3000000000000002e-28 or 1.00000000000000009e106 < b

    1. Initial program 86.8%

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

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

      \[\leadsto {\color{blue}{\sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)}}^{2} + {\left(b \cdot \cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} \]
    5. 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)\right)}^{2}} + {\left(b \cdot \cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} \]
    6. Applied rewrites80.6%

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

      \[\leadsto angle \cdot \color{blue}{\left(\frac{-1}{34992000} \cdot \left(a \cdot \left({angle}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right)\right) + \frac{1}{180} \cdot \left(a \cdot \mathsf{PI}\left(\right)\right)\right)} + {\left(b \cdot \cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} \]
    8. Applied rewrites80.0%

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

    if -3.3000000000000002e-28 < b < 1.00000000000000009e106

    1. Initial program 76.9%

      \[{\left(a \cdot \sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} + {\left(b \cdot \cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} \]
    2. Add Preprocessing
    3. 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)\right)}^{2} + {b}^{2} \cdot {\cos \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{2}} \]
    4. Applied rewrites61.4%

      \[\leadsto \color{blue}{{\left(a \cdot \sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 5: 40.4% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{angle}{180} \cdot \mathsf{PI}\left(\right)\\ t_1 := {t\_0}^{2}\\ \mathbf{if}\;b \leq -2.3 \cdot 10^{+130}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;b \leq 1.7 \cdot 10^{+192}:\\ \;\;\;\;{\left(a \cdot \sin t\_0\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (a b angle)
 :precision binary64
 (let* ((t_0 (* (/ angle 180.0) (PI))) (t_1 (pow t_0 2.0)))
   (if (<= b -2.3e+130)
     t_1
     (if (<= b 1.7e+192) (pow (* a (sin t_0)) 2.0) t_1))))
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{angle}{180} \cdot \mathsf{PI}\left(\right)\\
t_1 := {t\_0}^{2}\\
\mathbf{if}\;b \leq -2.3 \cdot 10^{+130}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;b \leq 1.7 \cdot 10^{+192}:\\
\;\;\;\;{\left(a \cdot \sin t\_0\right)}^{2}\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -2.30000000000000021e130 or 1.69999999999999998e192 < b

    1. Initial program 95.9%

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

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

      \[\leadsto {\color{blue}{\sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)}}^{2} + {\left(b \cdot \cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} \]
    5. 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)\right)}^{2} + {b}^{2} \cdot {\cos \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{2}} \]
    6. Applied rewrites2.5%

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

      \[\leadsto {\left(angle \cdot \left(\frac{-1}{34992000} \cdot \left(a \cdot \left({angle}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right)\right) + \frac{1}{180} \cdot \left(a \cdot \mathsf{PI}\left(\right)\right)\right)\right)}^{2} \]
    8. Applied rewrites31.8%

      \[\leadsto {\left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)}^{2} \]

    if -2.30000000000000021e130 < b < 1.69999999999999998e192

    1. Initial program 76.8%

      \[{\left(a \cdot \sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} + {\left(b \cdot \cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} \]
    2. Add Preprocessing
    3. 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)\right)}^{2} + {b}^{2} \cdot {\cos \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{2}} \]
    4. Applied rewrites50.0%

      \[\leadsto \color{blue}{{\left(a \cdot \sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 6: 17.9% accurate, 3.8× speedup?

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

\\
{\left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)}^{2}
\end{array}
Derivation
  1. Initial program 81.3%

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

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

    \[\leadsto {\color{blue}{\sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)}}^{2} + {\left(b \cdot \cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} \]
  5. 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)\right)}^{2} + {b}^{2} \cdot {\cos \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{2}} \]
  6. Applied rewrites7.0%

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

    \[\leadsto {\left(angle \cdot \left(\frac{-1}{34992000} \cdot \left(a \cdot \left({angle}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right)\right) + \frac{1}{180} \cdot \left(a \cdot \mathsf{PI}\left(\right)\right)\right)\right)}^{2} \]
  8. Applied rewrites18.2%

    \[\leadsto {\left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)}^{2} \]
  9. Add Preprocessing

Alternative 7: 4.4% accurate, 448.0× speedup?

\[\begin{array}{l} \\ \mathsf{PI}\left(\right) \end{array} \]
(FPCore (a b angle) :precision binary64 (PI))
\begin{array}{l}

\\
\mathsf{PI}\left(\right)
\end{array}
Derivation
  1. Initial program 81.3%

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

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

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

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

    \[\leadsto \color{blue}{\mathsf{PI}\left(\right)} \]
  7. Add Preprocessing

Reproduce

?
herbie shell --seed 2024321 
(FPCore (a b angle)
  :name "ab-angle->ABCF A"
  :precision binary64
  :pre (TRUE)
  (+ (pow (* a (sin (* (/ angle 180.0) (PI)))) 2.0) (pow (* b (cos (* (/ angle 180.0) (PI)))) 2.0)))