
(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:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(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}
(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}
Initial program 81.3%
(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}
if b < -3.19999999999999982e-28Initial program 82.7%
Taylor expanded in a around 0
Applied rewrites73.5%
if -3.19999999999999982e-28 < b < 7.19999999999999966e24Initial program 79.5%
Taylor expanded in a around 0
Applied rewrites65.1%
if 7.19999999999999966e24 < b Initial program 83.6%
Taylor expanded in a around 0
Applied rewrites76.2%
Taylor expanded in a around 0
Applied rewrites76.2%
(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}
if b < -3.25000000000000021e-28 or 7.19999999999999966e24 < b Initial program 83.1%
Taylor expanded in a around 0
Applied rewrites74.8%
Taylor expanded in a around 0
Applied rewrites74.7%
if -3.25000000000000021e-28 < b < 7.19999999999999966e24Initial program 79.5%
Taylor expanded in a around 0
Applied rewrites65.1%
(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}
if b < -3.3000000000000002e-28 or 1.00000000000000009e106 < b Initial program 86.8%
Taylor expanded in a around 0
Applied rewrites80.7%
Taylor expanded in a around 0
Applied rewrites80.6%
Taylor expanded in angle around 0
Applied rewrites80.0%
if -3.3000000000000002e-28 < b < 1.00000000000000009e106Initial program 76.9%
Taylor expanded in a around 0
Applied rewrites61.4%
(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}
if b < -2.30000000000000021e130 or 1.69999999999999998e192 < b Initial program 95.9%
Taylor expanded in a around 0
Applied rewrites95.9%
Taylor expanded in a around 0
Applied rewrites2.5%
Taylor expanded in angle around 0
Applied rewrites31.8%
if -2.30000000000000021e130 < b < 1.69999999999999998e192Initial program 76.8%
Taylor expanded in a around 0
Applied rewrites50.0%
(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}
Initial program 81.3%
Taylor expanded in a around 0
Applied rewrites48.8%
Taylor expanded in a around 0
Applied rewrites7.0%
Taylor expanded in angle around 0
Applied rewrites18.2%
(FPCore (a b angle) :precision binary64 (PI))
\begin{array}{l}
\\
\mathsf{PI}\left(\right)
\end{array}
Initial program 81.3%
Taylor expanded in a around 0
Applied rewrites48.8%
Taylor expanded in angle around 0
Applied rewrites4.2%
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)))