
(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 15 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 (sqrt (PI))))
(+
(pow (* a (sin (* (* 0.005555555555555556 (PI)) angle))) 2.0)
(pow (* b (cos (* (pow (/ 180.0 angle) -1.0) (* t_0 t_0)))) 2.0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\mathsf{PI}\left(\right)}\\
{\left(a \cdot \sin \left(\left(0.005555555555555556 \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right)\right)}^{2} + {\left(b \cdot \cos \left({\left(\frac{180}{angle}\right)}^{-1} \cdot \left(t\_0 \cdot t\_0\right)\right)\right)}^{2}
\end{array}
\end{array}
Initial program 77.0%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
div-invN/A
*-commutativeN/A
lower-*.f64N/A
metadata-eval77.1
Applied rewrites77.1%
rem-square-sqrtN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
lower-*.f6477.2
Applied rewrites77.2%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6477.2
Applied rewrites77.2%
Final simplification77.2%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (sqrt (PI))))
(+
(pow (* a (sin (* (* 0.005555555555555556 (PI)) angle))) 2.0)
(pow (* b (cos (* (/ angle 180.0) (* t_0 t_0)))) 2.0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\mathsf{PI}\left(\right)}\\
{\left(a \cdot \sin \left(\left(0.005555555555555556 \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right)\right)}^{2} + {\left(b \cdot \cos \left(\frac{angle}{180} \cdot \left(t\_0 \cdot t\_0\right)\right)\right)}^{2}
\end{array}
\end{array}
Initial program 77.0%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
div-invN/A
*-commutativeN/A
lower-*.f64N/A
metadata-eval77.1
Applied rewrites77.1%
rem-square-sqrtN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
lower-*.f6477.2
Applied rewrites77.2%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (sqrt (PI))))
(+
(pow (* a (sin (* (* 0.005555555555555556 (PI)) angle))) 2.0)
(pow (* b (cos (* (* angle 0.005555555555555556) (* t_0 t_0)))) 2.0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\mathsf{PI}\left(\right)}\\
{\left(a \cdot \sin \left(\left(0.005555555555555556 \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right)\right)}^{2} + {\left(b \cdot \cos \left(\left(angle \cdot 0.005555555555555556\right) \cdot \left(t\_0 \cdot t\_0\right)\right)\right)}^{2}
\end{array}
\end{array}
Initial program 77.0%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
div-invN/A
*-commutativeN/A
lower-*.f64N/A
metadata-eval77.1
Applied rewrites77.1%
rem-square-sqrtN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
lower-*.f6477.2
Applied rewrites77.2%
lift-/.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f6477.2
Applied rewrites77.2%
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* (* angle (PI)) 0.005555555555555556))) (+ (pow (* (sin t_0) a) 2.0) (pow (* (cos t_0) b) 2.0))))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(angle \cdot \mathsf{PI}\left(\right)\right) \cdot 0.005555555555555556\\
{\left(\sin t\_0 \cdot a\right)}^{2} + {\left(\cos t\_0 \cdot b\right)}^{2}
\end{array}
\end{array}
Initial program 77.0%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
div-invN/A
*-commutativeN/A
lower-*.f64N/A
metadata-eval77.1
Applied rewrites77.1%
rem-square-sqrtN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
lower-*.f6477.2
Applied rewrites77.2%
Applied rewrites77.2%
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* (* 0.005555555555555556 (PI)) angle))) (+ (pow (* a (sin t_0)) 2.0) (pow (* b (cos t_0)) 2.0))))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(0.005555555555555556 \cdot \mathsf{PI}\left(\right)\right) \cdot angle\\
{\left(a \cdot \sin t\_0\right)}^{2} + {\left(b \cdot \cos t\_0\right)}^{2}
\end{array}
\end{array}
Initial program 77.0%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
div-invN/A
*-commutativeN/A
lower-*.f64N/A
metadata-eval77.1
Applied rewrites77.1%
Taylor expanded in angle around inf
*-commutativeN/A
associate-*r*N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f6477.2
Applied rewrites77.2%
(FPCore (a b angle) :precision binary64 (fma (* (fma (cos (* (* angle (PI)) -0.011111111111111112)) 0.5 0.5) b) b (pow (* (sin (* (PI) (* 0.005555555555555556 angle))) a) 2.0)))
\begin{array}{l}
\\
\mathsf{fma}\left(\mathsf{fma}\left(\cos \left(\left(angle \cdot \mathsf{PI}\left(\right)\right) \cdot -0.011111111111111112\right), 0.5, 0.5\right) \cdot b, b, {\left(\sin \left(\mathsf{PI}\left(\right) \cdot \left(0.005555555555555556 \cdot angle\right)\right) \cdot a\right)}^{2}\right)
\end{array}
Initial program 77.0%
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites77.0%
lift-pow.f64N/A
unpow2N/A
lift-cos.f64N/A
lift-cos.f64N/A
sqr-cos-aN/A
+-commutativeN/A
cos-2N/A
cos-sumN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites77.0%
(FPCore (a b angle) :precision binary64 (+ (pow (* a (sin (* (* 0.005555555555555556 (PI)) angle))) 2.0) (pow (* b 1.0) 2.0)))
\begin{array}{l}
\\
{\left(a \cdot \sin \left(\left(0.005555555555555556 \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right)\right)}^{2} + {\left(b \cdot 1\right)}^{2}
\end{array}
Initial program 77.0%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
div-invN/A
*-commutativeN/A
lower-*.f64N/A
metadata-eval77.1
Applied rewrites77.1%
rem-square-sqrtN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
lower-*.f6477.2
Applied rewrites77.2%
Taylor expanded in angle around 0
Applied rewrites76.6%
Final simplification76.6%
(FPCore (a b angle) :precision binary64 (fma (* 1.0 b) b (pow (* (sin (* (PI) (* 0.005555555555555556 angle))) a) 2.0)))
\begin{array}{l}
\\
\mathsf{fma}\left(1 \cdot b, b, {\left(\sin \left(\mathsf{PI}\left(\right) \cdot \left(0.005555555555555556 \cdot angle\right)\right) \cdot a\right)}^{2}\right)
\end{array}
Initial program 77.0%
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites77.0%
Taylor expanded in angle around 0
Applied rewrites76.4%
(FPCore (a b angle) :precision binary64 (if (<= a 1.96e+152) (fma (* (pow (* a (PI)) 2.0) angle) (* 3.08641975308642e-5 angle) (* b b)) (* (pow (* a (* angle (PI))) 2.0) 3.08641975308642e-5)))
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.96 \cdot 10^{+152}:\\
\;\;\;\;\mathsf{fma}\left({\left(a \cdot \mathsf{PI}\left(\right)\right)}^{2} \cdot angle, 3.08641975308642 \cdot 10^{-5} \cdot angle, b \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;{\left(a \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} \cdot 3.08641975308642 \cdot 10^{-5}\\
\end{array}
\end{array}
if a < 1.96e152Initial program 74.6%
rem-exp-logN/A
unpow1N/A
log-powN/A
lift-pow.f64N/A
log-powN/A
*-commutativeN/A
exp-prodN/A
lower-pow.f64N/A
exp-1-eN/A
lower-E.f64N/A
*-commutativeN/A
log-powN/A
lift-pow.f64N/A
lower-log.f6473.8
Applied rewrites73.8%
Taylor expanded in angle around 0
Applied rewrites60.9%
Applied rewrites67.3%
if 1.96e152 < a Initial program 96.8%
rem-exp-logN/A
unpow1N/A
log-powN/A
lift-pow.f64N/A
log-powN/A
*-commutativeN/A
exp-prodN/A
lower-pow.f64N/A
exp-1-eN/A
lower-E.f64N/A
*-commutativeN/A
log-powN/A
lift-pow.f64N/A
lower-log.f6495.6
Applied rewrites95.6%
Taylor expanded in angle around 0
Applied rewrites72.1%
Taylor expanded in a around inf
Applied rewrites72.1%
Applied rewrites86.5%
(FPCore (a b angle) :precision binary64 (if (<= a 1.02e+133) (* b b) (* (pow (* a (* angle (PI))) 2.0) 3.08641975308642e-5)))
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.02 \cdot 10^{+133}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;{\left(a \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} \cdot 3.08641975308642 \cdot 10^{-5}\\
\end{array}
\end{array}
if a < 1.02e133Initial program 74.7%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6458.2
Applied rewrites58.2%
if 1.02e133 < a Initial program 94.1%
rem-exp-logN/A
unpow1N/A
log-powN/A
lift-pow.f64N/A
log-powN/A
*-commutativeN/A
exp-prodN/A
lower-pow.f64N/A
exp-1-eN/A
lower-E.f64N/A
*-commutativeN/A
log-powN/A
lift-pow.f64N/A
lower-log.f6492.8
Applied rewrites92.8%
Taylor expanded in angle around 0
Applied rewrites67.8%
Taylor expanded in a around inf
Applied rewrites67.8%
Applied rewrites84.4%
(FPCore (a b angle)
:precision binary64
(if (<= a 5e-91)
(* b b)
(fma
(* (* (PI) (PI)) a)
(* a (* 3.08641975308642e-5 (* angle angle)))
(* b b))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 5 \cdot 10^{-91}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot a, a \cdot \left(3.08641975308642 \cdot 10^{-5} \cdot \left(angle \cdot angle\right)\right), b \cdot b\right)\\
\end{array}
\end{array}
if a < 4.99999999999999997e-91Initial program 77.2%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6459.0
Applied rewrites59.0%
if 4.99999999999999997e-91 < a Initial program 76.6%
rem-exp-logN/A
unpow1N/A
log-powN/A
lift-pow.f64N/A
log-powN/A
*-commutativeN/A
exp-prodN/A
lower-pow.f64N/A
exp-1-eN/A
lower-E.f64N/A
*-commutativeN/A
log-powN/A
lift-pow.f64N/A
lower-log.f6475.5
Applied rewrites75.5%
Taylor expanded in angle around 0
Applied rewrites62.7%
Applied rewrites66.9%
(FPCore (a b angle) :precision binary64 (if (<= a 1.02e+133) (* b b) (* (* (* 3.08641975308642e-5 a) (* a (* (* (PI) (PI)) angle))) angle)))
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.02 \cdot 10^{+133}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;\left(\left(3.08641975308642 \cdot 10^{-5} \cdot a\right) \cdot \left(a \cdot \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right)\right)\right) \cdot angle\\
\end{array}
\end{array}
if a < 1.02e133Initial program 74.7%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6458.2
Applied rewrites58.2%
if 1.02e133 < a Initial program 94.1%
rem-exp-logN/A
unpow1N/A
log-powN/A
lift-pow.f64N/A
log-powN/A
*-commutativeN/A
exp-prodN/A
lower-pow.f64N/A
exp-1-eN/A
lower-E.f64N/A
*-commutativeN/A
log-powN/A
lift-pow.f64N/A
lower-log.f6492.8
Applied rewrites92.8%
Taylor expanded in angle around 0
Applied rewrites67.8%
Taylor expanded in a around inf
Applied rewrites67.8%
Applied rewrites81.3%
(FPCore (a b angle) :precision binary64 (if (<= a 3.8e+177) (* b b) (* (* 3.08641975308642e-5 (* a a)) (* (* (* (PI) (PI)) angle) angle))))
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 3.8 \cdot 10^{+177}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;\left(3.08641975308642 \cdot 10^{-5} \cdot \left(a \cdot a\right)\right) \cdot \left(\left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right) \cdot angle\right)\\
\end{array}
\end{array}
if a < 3.7999999999999998e177Initial program 74.6%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6457.3
Applied rewrites57.3%
if 3.7999999999999998e177 < a Initial program 99.8%
rem-exp-logN/A
unpow1N/A
log-powN/A
lift-pow.f64N/A
log-powN/A
*-commutativeN/A
exp-prodN/A
lower-pow.f64N/A
exp-1-eN/A
lower-E.f64N/A
*-commutativeN/A
log-powN/A
lift-pow.f64N/A
lower-log.f6498.5
Applied rewrites98.5%
Taylor expanded in angle around 0
Applied rewrites79.4%
Taylor expanded in a around inf
Applied rewrites79.4%
(FPCore (a b angle) :precision binary64 (if (<= a 3.8e+177) (* b b) (* (* (* angle angle) 3.08641975308642e-5) (* (* (* (PI) (PI)) a) a))))
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 3.8 \cdot 10^{+177}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;\left(\left(angle \cdot angle\right) \cdot 3.08641975308642 \cdot 10^{-5}\right) \cdot \left(\left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot a\right) \cdot a\right)\\
\end{array}
\end{array}
if a < 3.7999999999999998e177Initial program 74.6%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6457.3
Applied rewrites57.3%
if 3.7999999999999998e177 < a Initial program 99.8%
rem-exp-logN/A
unpow1N/A
log-powN/A
lift-pow.f64N/A
log-powN/A
*-commutativeN/A
exp-prodN/A
lower-pow.f64N/A
exp-1-eN/A
lower-E.f64N/A
*-commutativeN/A
log-powN/A
lift-pow.f64N/A
lower-log.f6498.5
Applied rewrites98.5%
Taylor expanded in angle around 0
Applied rewrites79.4%
Taylor expanded in a around inf
Applied rewrites79.4%
Taylor expanded in a around 0
Applied rewrites79.4%
(FPCore (a b angle) :precision binary64 (* b b))
double code(double a, double b, double angle) {
return b * b;
}
real(8) function code(a, b, angle)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: angle
code = b * b
end function
public static double code(double a, double b, double angle) {
return b * b;
}
def code(a, b, angle): return b * b
function code(a, b, angle) return Float64(b * b) end
function tmp = code(a, b, angle) tmp = b * b; end
code[a_, b_, angle_] := N[(b * b), $MachinePrecision]
\begin{array}{l}
\\
b \cdot b
\end{array}
Initial program 77.0%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6454.9
Applied rewrites54.9%
herbie shell --seed 2024309
(FPCore (a b angle)
:name "ab-angle->ABCF A"
:precision binary64
(+ (pow (* a (sin (* (/ angle 180.0) (PI)))) 2.0) (pow (* b (cos (* (/ angle 180.0) (PI)))) 2.0)))