
(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 19 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 angle) (PI)))) 2.0)
(pow (* b (cos (* (* angle (/ t_0 180.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 angle\right) \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} + {\left(b \cdot \cos \left(\left(angle \cdot \frac{t\_0}{180}\right) \cdot t\_0\right)\right)}^{2}
\end{array}
\end{array}
Initial program 81.4%
lift-*.f64N/A
lift-PI.f64N/A
add-sqr-sqrtN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-PI.f64N/A
lower-sqrt.f64N/A
lift-PI.f64N/A
lower-sqrt.f6481.5
Applied rewrites81.5%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6481.5
Applied rewrites81.5%
Taylor expanded in angle around 0
lower-*.f6481.5
Applied rewrites81.5%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* (/ angle 180.0) (PI)))
(t_1 (+ (pow (* a (sin t_0)) 2.0) (pow (* b (cos t_0)) 2.0)))
(t_2 (* (* (PI) angle) a))
(t_3 (* (PI) (PI))))
(if (<= t_1 2e-99)
(fma
(* (* (* (- 3.08641975308642e-5) (- (* a a) (* b b))) t_3) angle)
(- angle)
(* b b))
(if (<= t_1 2e+299)
(*
(fma
-3.08641975308642e-5
(- (* (* t_3 angle) angle) (/ (* t_2 t_2) (* b b)))
1.0)
(* b b))
(fma
(* (* (* 3.08641975308642e-5 t_3) a) a)
(* angle angle)
(* b b))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{angle}{180} \cdot \mathsf{PI}\left(\right)\\
t_1 := {\left(a \cdot \sin t\_0\right)}^{2} + {\left(b \cdot \cos t\_0\right)}^{2}\\
t_2 := \left(\mathsf{PI}\left(\right) \cdot angle\right) \cdot a\\
t_3 := \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\\
\mathbf{if}\;t\_1 \leq 2 \cdot 10^{-99}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(\left(-3.08641975308642 \cdot 10^{-5}\right) \cdot \left(a \cdot a - b \cdot b\right)\right) \cdot t\_3\right) \cdot angle, -angle, b \cdot b\right)\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+299}:\\
\;\;\;\;\mathsf{fma}\left(-3.08641975308642 \cdot 10^{-5}, \left(t\_3 \cdot angle\right) \cdot angle - \frac{t\_2 \cdot t\_2}{b \cdot b}, 1\right) \cdot \left(b \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(3.08641975308642 \cdot 10^{-5} \cdot t\_3\right) \cdot a\right) \cdot a, angle \cdot angle, b \cdot b\right)\\
\end{array}
\end{array}
if (+.f64 (pow.f64 (*.f64 a (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64))) < 2e-99Initial program 79.8%
lift-*.f64N/A
*-commutativeN/A
lift-PI.f64N/A
add-cube-cbrtN/A
associate-*l*N/A
lower-*.f64N/A
pow2N/A
lower-pow.f64N/A
lift-PI.f64N/A
lower-cbrt.f64N/A
lower-*.f64N/A
lift-PI.f64N/A
lower-cbrt.f6479.9
Applied rewrites79.9%
Taylor expanded in angle around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites57.6%
Applied rewrites73.6%
if 2e-99 < (+.f64 (pow.f64 (*.f64 a (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64))) < 2.0000000000000001e299Initial program 67.2%
lift-*.f64N/A
*-commutativeN/A
lift-PI.f64N/A
add-cube-cbrtN/A
associate-*l*N/A
lower-*.f64N/A
pow2N/A
lower-pow.f64N/A
lift-PI.f64N/A
lower-cbrt.f64N/A
lower-*.f64N/A
lift-PI.f64N/A
lower-cbrt.f6467.4
Applied rewrites67.4%
Taylor expanded in angle around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites39.6%
Taylor expanded in b around inf
Applied rewrites47.0%
if 2.0000000000000001e299 < (+.f64 (pow.f64 (*.f64 a (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64))) Initial program 100.0%
lift-*.f64N/A
*-commutativeN/A
lift-PI.f64N/A
add-cube-cbrtN/A
associate-*l*N/A
lower-*.f64N/A
pow2N/A
lower-pow.f64N/A
lift-PI.f64N/A
lower-cbrt.f64N/A
lower-*.f64N/A
lift-PI.f64N/A
lower-cbrt.f64100.0
Applied rewrites100.0%
Taylor expanded in angle around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites33.0%
Taylor expanded in a around inf
Applied rewrites97.8%
Final simplification70.4%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* (/ angle 180.0) (PI))))
(if (<= (+ (pow (* a (sin t_0)) 2.0) (pow (* b (cos t_0)) 2.0)) 2e+299)
(+
(pow (* (- a) (sin (/ (* (PI) angle) -180.0))) 2.0)
(fma
(* (* (* (* (* b b) (PI)) (PI)) -3.08641975308642e-5) angle)
angle
(* b b)))
(fma
(* (* (* 3.08641975308642e-5 (* (PI) (PI))) a) a)
(* angle angle)
(* b b)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{angle}{180} \cdot \mathsf{PI}\left(\right)\\
\mathbf{if}\;{\left(a \cdot \sin t\_0\right)}^{2} + {\left(b \cdot \cos t\_0\right)}^{2} \leq 2 \cdot 10^{+299}:\\
\;\;\;\;{\left(\left(-a\right) \cdot \sin \left(\frac{\mathsf{PI}\left(\right) \cdot angle}{-180}\right)\right)}^{2} + \mathsf{fma}\left(\left(\left(\left(\left(b \cdot b\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \mathsf{PI}\left(\right)\right) \cdot -3.08641975308642 \cdot 10^{-5}\right) \cdot angle, angle, b \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(3.08641975308642 \cdot 10^{-5} \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right) \cdot a\right) \cdot a, angle \cdot angle, b \cdot b\right)\\
\end{array}
\end{array}
if (+.f64 (pow.f64 (*.f64 a (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64))) < 2.0000000000000001e299Initial program 71.2%
lift-*.f64N/A
*-commutativeN/A
lift-PI.f64N/A
add-cube-cbrtN/A
associate-*l*N/A
lower-*.f64N/A
pow2N/A
lower-pow.f64N/A
lift-PI.f64N/A
lower-cbrt.f64N/A
lower-*.f64N/A
lift-PI.f64N/A
lower-cbrt.f6471.3
Applied rewrites71.3%
Taylor expanded in angle around 0
*-commutativeN/A
associate-*r*N/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites66.2%
lift-sin.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-PI.f64N/A
*-commutativeN/A
associate-/l*N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
rem-square-sqrtN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
associate-*r*N/A
associate-*l/N/A
associate-*r/N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
Applied rewrites66.3%
if 2.0000000000000001e299 < (+.f64 (pow.f64 (*.f64 a (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64))) Initial program 100.0%
lift-*.f64N/A
*-commutativeN/A
lift-PI.f64N/A
add-cube-cbrtN/A
associate-*l*N/A
lower-*.f64N/A
pow2N/A
lower-pow.f64N/A
lift-PI.f64N/A
lower-cbrt.f64N/A
lower-*.f64N/A
lift-PI.f64N/A
lower-cbrt.f64100.0
Applied rewrites100.0%
Taylor expanded in angle around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites33.0%
Taylor expanded in a around inf
Applied rewrites97.8%
Final simplification77.5%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* (/ angle 180.0) (PI))) (t_1 (pow (* a (sin t_0)) 2.0)))
(if (<= (+ t_1 (pow (* b (cos t_0)) 2.0)) 2e+299)
(+
t_1
(fma
(* (* (* (* (* b b) (PI)) (PI)) -3.08641975308642e-5) angle)
angle
(* b b)))
(fma
(* (* (* 3.08641975308642e-5 (* (PI) (PI))) a) a)
(* angle angle)
(* b b)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{angle}{180} \cdot \mathsf{PI}\left(\right)\\
t_1 := {\left(a \cdot \sin t\_0\right)}^{2}\\
\mathbf{if}\;t\_1 + {\left(b \cdot \cos t\_0\right)}^{2} \leq 2 \cdot 10^{+299}:\\
\;\;\;\;t\_1 + \mathsf{fma}\left(\left(\left(\left(\left(b \cdot b\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \mathsf{PI}\left(\right)\right) \cdot -3.08641975308642 \cdot 10^{-5}\right) \cdot angle, angle, b \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(3.08641975308642 \cdot 10^{-5} \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right) \cdot a\right) \cdot a, angle \cdot angle, b \cdot b\right)\\
\end{array}
\end{array}
if (+.f64 (pow.f64 (*.f64 a (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64))) < 2.0000000000000001e299Initial program 71.2%
lift-*.f64N/A
*-commutativeN/A
lift-PI.f64N/A
add-cube-cbrtN/A
associate-*l*N/A
lower-*.f64N/A
pow2N/A
lower-pow.f64N/A
lift-PI.f64N/A
lower-cbrt.f64N/A
lower-*.f64N/A
lift-PI.f64N/A
lower-cbrt.f6471.3
Applied rewrites71.3%
Taylor expanded in angle around 0
*-commutativeN/A
associate-*r*N/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites66.2%
if 2.0000000000000001e299 < (+.f64 (pow.f64 (*.f64 a (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64))) Initial program 100.0%
lift-*.f64N/A
*-commutativeN/A
lift-PI.f64N/A
add-cube-cbrtN/A
associate-*l*N/A
lower-*.f64N/A
pow2N/A
lower-pow.f64N/A
lift-PI.f64N/A
lower-cbrt.f64N/A
lower-*.f64N/A
lift-PI.f64N/A
lower-cbrt.f64100.0
Applied rewrites100.0%
Taylor expanded in angle around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites33.0%
Taylor expanded in a around inf
Applied rewrites97.8%
Final simplification77.5%
(FPCore (a b angle) :precision binary64 (+ (pow (* a (sin (* (* 0.005555555555555556 angle) (PI)))) 2.0) (pow (* b (sin (fma (PI) (/ angle 180.0) (/ (PI) 2.0)))) 2.0)))
\begin{array}{l}
\\
{\left(a \cdot \sin \left(\left(0.005555555555555556 \cdot angle\right) \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{fma}\left(\mathsf{PI}\left(\right), \frac{angle}{180}, \frac{\mathsf{PI}\left(\right)}{2}\right)\right)\right)}^{2}
\end{array}
Initial program 81.4%
lift-*.f64N/A
lift-PI.f64N/A
add-sqr-sqrtN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-PI.f64N/A
lower-sqrt.f64N/A
lift-PI.f64N/A
lower-sqrt.f6481.5
Applied rewrites81.5%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6481.5
Applied rewrites81.5%
Taylor expanded in angle around 0
lower-*.f6481.5
Applied rewrites81.5%
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-/.f64N/A
associate-*l/N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
rem-square-sqrtN/A
associate-/l*N/A
associate-*l/N/A
lower-*.f64N/A
lift-/.f64N/A
sin-+PI/2-revN/A
lower-sin.f64N/A
Applied rewrites81.5%
(FPCore (a b angle) :precision binary64 (+ (pow (* a (sin (* (/ angle 180.0) (PI)))) 2.0) (pow (* b (sin (* (PI) (fma -0.005555555555555556 angle 0.5)))) 2.0)))
\begin{array}{l}
\\
{\left(a \cdot \sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(-0.005555555555555556, angle, 0.5\right)\right)\right)}^{2}
\end{array}
Initial program 81.4%
lift-cos.f64N/A
cos-neg-revN/A
sin-+PI/2-revN/A
lower-sin.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
lift-PI.f64N/A
lower-/.f6481.5
Applied rewrites81.5%
Taylor expanded in angle around 0
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f64N/A
lower-PI.f64N/A
lower-fma.f6481.5
Applied rewrites81.5%
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* (* 0.005555555555555556 angle) (PI)))) (+ (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 angle\right) \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.4%
lift-*.f64N/A
lift-PI.f64N/A
add-sqr-sqrtN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-PI.f64N/A
lower-sqrt.f64N/A
lift-PI.f64N/A
lower-sqrt.f6481.5
Applied rewrites81.5%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6481.5
Applied rewrites81.5%
Taylor expanded in angle around 0
lower-*.f6481.5
Applied rewrites81.5%
Taylor expanded in angle around inf
metadata-evalN/A
distribute-lft-neg-inN/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f6481.4
Applied rewrites81.4%
(FPCore (a b angle) :precision binary64 (+ (pow (* a (sin (* (* 0.005555555555555556 angle) (PI)))) 2.0) (pow (* b 1.0) 2.0)))
\begin{array}{l}
\\
{\left(a \cdot \sin \left(\left(0.005555555555555556 \cdot angle\right) \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} + {\left(b \cdot 1\right)}^{2}
\end{array}
Initial program 81.4%
lift-*.f64N/A
lift-PI.f64N/A
add-sqr-sqrtN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-PI.f64N/A
lower-sqrt.f64N/A
lift-PI.f64N/A
lower-sqrt.f6481.5
Applied rewrites81.5%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6481.5
Applied rewrites81.5%
Taylor expanded in angle around 0
lower-*.f6481.5
Applied rewrites81.5%
Taylor expanded in angle around 0
Applied rewrites81.3%
(FPCore (a b angle)
:precision binary64
(if (<= a 3.5e-156)
(* b b)
(if (<= a 4.2e+153)
(+
(* (* 3.08641975308642e-5 (* angle angle)) (* (* (* (PI) (PI)) a) a))
(pow (* b (cos (* (/ angle 180.0) (PI)))) 2.0))
(* (pow (* (* (PI) angle) a) 2.0) 3.08641975308642e-5))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 3.5 \cdot 10^{-156}:\\
\;\;\;\;b \cdot b\\
\mathbf{elif}\;a \leq 4.2 \cdot 10^{+153}:\\
\;\;\;\;\left(3.08641975308642 \cdot 10^{-5} \cdot \left(angle \cdot angle\right)\right) \cdot \left(\left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot a\right) \cdot a\right) + {\left(b \cdot \cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;{\left(\left(\mathsf{PI}\left(\right) \cdot angle\right) \cdot a\right)}^{2} \cdot 3.08641975308642 \cdot 10^{-5}\\
\end{array}
\end{array}
if a < 3.4999999999999999e-156Initial program 83.4%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6460.4
Applied rewrites60.4%
if 3.4999999999999999e-156 < a < 4.20000000000000033e153Initial program 69.0%
Taylor expanded in angle around 0
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
metadata-evalN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites62.2%
if 4.20000000000000033e153 < a Initial program 99.6%
lift-*.f64N/A
*-commutativeN/A
lift-PI.f64N/A
add-cube-cbrtN/A
associate-*l*N/A
lower-*.f64N/A
pow2N/A
lower-pow.f64N/A
lift-PI.f64N/A
lower-cbrt.f64N/A
lower-*.f64N/A
lift-PI.f64N/A
lower-cbrt.f6499.6
Applied rewrites99.6%
Taylor expanded in angle around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites42.8%
Taylor expanded in a around inf
Applied rewrites63.5%
Applied rewrites86.9%
Final simplification63.9%
(FPCore (a b angle) :precision binary64 (+ (pow (* a (sin (* (/ angle 180.0) (PI)))) 2.0) (fma (* (* (* (* (* (- b) b) (PI)) (PI)) -3.08641975308642e-5) angle) angle (* b b))))
\begin{array}{l}
\\
{\left(a \cdot \sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} + \mathsf{fma}\left(\left(\left(\left(\left(\left(-b\right) \cdot b\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \mathsf{PI}\left(\right)\right) \cdot -3.08641975308642 \cdot 10^{-5}\right) \cdot angle, angle, b \cdot b\right)
\end{array}
Initial program 81.4%
lift-*.f64N/A
*-commutativeN/A
lift-PI.f64N/A
add-cube-cbrtN/A
associate-*l*N/A
lower-*.f64N/A
pow2N/A
lower-pow.f64N/A
lift-PI.f64N/A
lower-cbrt.f64N/A
lower-*.f64N/A
lift-PI.f64N/A
lower-cbrt.f6481.5
Applied rewrites81.5%
Taylor expanded in angle around 0
*-commutativeN/A
associate-*r*N/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites47.8%
Applied rewrites78.8%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* (PI) (PI))) (t_1 (* (/ angle 180.0) (PI))))
(if (<= angle 1.2e-21)
(+
(pow (* a (sin t_1)) 2.0)
(* (fma (* (* t_0 -3.08641975308642e-5) angle) angle 1.0) (* b b)))
(+
(* (* 3.08641975308642e-5 (* angle angle)) (* (* t_0 a) a))
(pow (* b (cos t_1)) 2.0)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\\
t_1 := \frac{angle}{180} \cdot \mathsf{PI}\left(\right)\\
\mathbf{if}\;angle \leq 1.2 \cdot 10^{-21}:\\
\;\;\;\;{\left(a \cdot \sin t\_1\right)}^{2} + \mathsf{fma}\left(\left(t\_0 \cdot -3.08641975308642 \cdot 10^{-5}\right) \cdot angle, angle, 1\right) \cdot \left(b \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;\left(3.08641975308642 \cdot 10^{-5} \cdot \left(angle \cdot angle\right)\right) \cdot \left(\left(t\_0 \cdot a\right) \cdot a\right) + {\left(b \cdot \cos t\_1\right)}^{2}\\
\end{array}
\end{array}
if angle < 1.2e-21Initial program 86.9%
lift-*.f64N/A
*-commutativeN/A
lift-PI.f64N/A
add-cube-cbrtN/A
associate-*l*N/A
lower-*.f64N/A
pow2N/A
lower-pow.f64N/A
lift-PI.f64N/A
lower-cbrt.f64N/A
lower-*.f64N/A
lift-PI.f64N/A
lower-cbrt.f6487.1
Applied rewrites87.1%
Taylor expanded in angle around 0
*-commutativeN/A
associate-*r*N/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites57.8%
Taylor expanded in b around 0
Applied rewrites66.0%
if 1.2e-21 < angle Initial program 65.9%
Taylor expanded in angle around 0
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
metadata-evalN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites57.2%
(FPCore (a b angle)
:precision binary64
(if (<= a 2.1e-58)
(* (pow (sin (* (PI) (fma -0.005555555555555556 angle 0.5))) 2.0) (* b b))
(if (<= a 1.35e+154)
(fma
(* (* (PI) (PI)) (* 3.08641975308642e-5 (* a a)))
(* angle angle)
(* b b))
(* (pow (* (* (PI) angle) a) 2.0) 3.08641975308642e-5))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 2.1 \cdot 10^{-58}:\\
\;\;\;\;{\sin \left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(-0.005555555555555556, angle, 0.5\right)\right)}^{2} \cdot \left(b \cdot b\right)\\
\mathbf{elif}\;a \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\mathsf{fma}\left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \left(3.08641975308642 \cdot 10^{-5} \cdot \left(a \cdot a\right)\right), angle \cdot angle, b \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;{\left(\left(\mathsf{PI}\left(\right) \cdot angle\right) \cdot a\right)}^{2} \cdot 3.08641975308642 \cdot 10^{-5}\\
\end{array}
\end{array}
if a < 2.09999999999999988e-58Initial program 81.3%
lift-cos.f64N/A
cos-neg-revN/A
sin-+PI/2-revN/A
lower-sin.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
lift-PI.f64N/A
lower-/.f6481.4
Applied rewrites81.4%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f64N/A
lower-PI.f64N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6460.4
Applied rewrites60.4%
if 2.09999999999999988e-58 < a < 1.35000000000000003e154Initial program 70.4%
lift-*.f64N/A
*-commutativeN/A
lift-PI.f64N/A
add-cube-cbrtN/A
associate-*l*N/A
lower-*.f64N/A
pow2N/A
lower-pow.f64N/A
lift-PI.f64N/A
lower-cbrt.f64N/A
lower-*.f64N/A
lift-PI.f64N/A
lower-cbrt.f6470.4
Applied rewrites70.4%
Taylor expanded in angle around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites30.2%
Taylor expanded in a around inf
Applied rewrites62.9%
if 1.35000000000000003e154 < a Initial program 99.6%
lift-*.f64N/A
*-commutativeN/A
lift-PI.f64N/A
add-cube-cbrtN/A
associate-*l*N/A
lower-*.f64N/A
pow2N/A
lower-pow.f64N/A
lift-PI.f64N/A
lower-cbrt.f64N/A
lower-*.f64N/A
lift-PI.f64N/A
lower-cbrt.f6499.6
Applied rewrites99.6%
Taylor expanded in angle around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites42.8%
Taylor expanded in a around inf
Applied rewrites63.5%
Applied rewrites86.9%
Final simplification63.9%
(FPCore (a b angle)
:precision binary64
(if (<= a 2.1e-58)
(* (pow (cos (* (* 0.005555555555555556 angle) (PI))) 2.0) (* b b))
(if (<= a 1.35e+154)
(fma
(* (* (PI) (PI)) (* 3.08641975308642e-5 (* a a)))
(* angle angle)
(* b b))
(* (pow (* (* (PI) angle) a) 2.0) 3.08641975308642e-5))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 2.1 \cdot 10^{-58}:\\
\;\;\;\;{\cos \left(\left(0.005555555555555556 \cdot angle\right) \cdot \mathsf{PI}\left(\right)\right)}^{2} \cdot \left(b \cdot b\right)\\
\mathbf{elif}\;a \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\mathsf{fma}\left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \left(3.08641975308642 \cdot 10^{-5} \cdot \left(a \cdot a\right)\right), angle \cdot angle, b \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;{\left(\left(\mathsf{PI}\left(\right) \cdot angle\right) \cdot a\right)}^{2} \cdot 3.08641975308642 \cdot 10^{-5}\\
\end{array}
\end{array}
if a < 2.09999999999999988e-58Initial program 81.3%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-pow.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-cos.f64N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
unpow2N/A
lower-*.f6460.3
Applied rewrites60.3%
if 2.09999999999999988e-58 < a < 1.35000000000000003e154Initial program 70.4%
lift-*.f64N/A
*-commutativeN/A
lift-PI.f64N/A
add-cube-cbrtN/A
associate-*l*N/A
lower-*.f64N/A
pow2N/A
lower-pow.f64N/A
lift-PI.f64N/A
lower-cbrt.f64N/A
lower-*.f64N/A
lift-PI.f64N/A
lower-cbrt.f6470.4
Applied rewrites70.4%
Taylor expanded in angle around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites30.2%
Taylor expanded in a around inf
Applied rewrites62.9%
if 1.35000000000000003e154 < a Initial program 99.6%
lift-*.f64N/A
*-commutativeN/A
lift-PI.f64N/A
add-cube-cbrtN/A
associate-*l*N/A
lower-*.f64N/A
pow2N/A
lower-pow.f64N/A
lift-PI.f64N/A
lower-cbrt.f64N/A
lower-*.f64N/A
lift-PI.f64N/A
lower-cbrt.f6499.6
Applied rewrites99.6%
Taylor expanded in angle around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites42.8%
Taylor expanded in a around inf
Applied rewrites63.5%
Applied rewrites86.9%
Final simplification63.8%
(FPCore (a b angle)
:precision binary64
(if (<= a 2.6e-58)
(* b b)
(if (<= a 1.35e+154)
(fma
(* (* (PI) (PI)) (* 3.08641975308642e-5 (* a a)))
(* angle angle)
(* b b))
(* (pow (* (* (PI) angle) a) 2.0) 3.08641975308642e-5))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 2.6 \cdot 10^{-58}:\\
\;\;\;\;b \cdot b\\
\mathbf{elif}\;a \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\mathsf{fma}\left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \left(3.08641975308642 \cdot 10^{-5} \cdot \left(a \cdot a\right)\right), angle \cdot angle, b \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;{\left(\left(\mathsf{PI}\left(\right) \cdot angle\right) \cdot a\right)}^{2} \cdot 3.08641975308642 \cdot 10^{-5}\\
\end{array}
\end{array}
if a < 2.60000000000000007e-58Initial program 81.3%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6460.6
Applied rewrites60.6%
if 2.60000000000000007e-58 < a < 1.35000000000000003e154Initial program 70.4%
lift-*.f64N/A
*-commutativeN/A
lift-PI.f64N/A
add-cube-cbrtN/A
associate-*l*N/A
lower-*.f64N/A
pow2N/A
lower-pow.f64N/A
lift-PI.f64N/A
lower-cbrt.f64N/A
lower-*.f64N/A
lift-PI.f64N/A
lower-cbrt.f6470.4
Applied rewrites70.4%
Taylor expanded in angle around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites30.2%
Taylor expanded in a around inf
Applied rewrites62.9%
if 1.35000000000000003e154 < a Initial program 99.6%
lift-*.f64N/A
*-commutativeN/A
lift-PI.f64N/A
add-cube-cbrtN/A
associate-*l*N/A
lower-*.f64N/A
pow2N/A
lower-pow.f64N/A
lift-PI.f64N/A
lower-cbrt.f64N/A
lower-*.f64N/A
lift-PI.f64N/A
lower-cbrt.f6499.6
Applied rewrites99.6%
Taylor expanded in angle around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites42.8%
Taylor expanded in a around inf
Applied rewrites63.5%
Applied rewrites86.9%
Final simplification64.0%
(FPCore (a b angle)
:precision binary64
(if (<= a 2.6e-58)
(* b b)
(fma
(* (* (PI) (PI)) (* 3.08641975308642e-5 (* a a)))
(* angle angle)
(* b b))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 2.6 \cdot 10^{-58}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \left(3.08641975308642 \cdot 10^{-5} \cdot \left(a \cdot a\right)\right), angle \cdot angle, b \cdot b\right)\\
\end{array}
\end{array}
if a < 2.60000000000000007e-58Initial program 81.3%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6460.6
Applied rewrites60.6%
if 2.60000000000000007e-58 < a Initial program 81.7%
lift-*.f64N/A
*-commutativeN/A
lift-PI.f64N/A
add-cube-cbrtN/A
associate-*l*N/A
lower-*.f64N/A
pow2N/A
lower-pow.f64N/A
lift-PI.f64N/A
lower-cbrt.f64N/A
lower-*.f64N/A
lift-PI.f64N/A
lower-cbrt.f6481.7
Applied rewrites81.7%
Taylor expanded in angle around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites35.1%
Taylor expanded in a around inf
Applied rewrites63.1%
Final simplification61.3%
(FPCore (a b angle)
:precision binary64
(if (<= a 2.6e-58)
(* b b)
(fma
(* (* (* 3.08641975308642e-5 (* (PI) (PI))) a) a)
(* angle angle)
(* b b))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 2.6 \cdot 10^{-58}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(3.08641975308642 \cdot 10^{-5} \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right) \cdot a\right) \cdot a, angle \cdot angle, b \cdot b\right)\\
\end{array}
\end{array}
if a < 2.60000000000000007e-58Initial program 81.3%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6460.6
Applied rewrites60.6%
if 2.60000000000000007e-58 < a Initial program 81.7%
lift-*.f64N/A
*-commutativeN/A
lift-PI.f64N/A
add-cube-cbrtN/A
associate-*l*N/A
lower-*.f64N/A
pow2N/A
lower-pow.f64N/A
lift-PI.f64N/A
lower-cbrt.f64N/A
lower-*.f64N/A
lift-PI.f64N/A
lower-cbrt.f6481.7
Applied rewrites81.7%
Taylor expanded in angle around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites35.1%
Taylor expanded in a around inf
Applied rewrites63.1%
Final simplification61.3%
(FPCore (a b angle) :precision binary64 (if (<= a 5.5e+162) (* b b) (* (* (* (* a a) 3.08641975308642e-5) angle) (* (* (PI) (PI)) angle))))
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 5.5 \cdot 10^{+162}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\left(a \cdot a\right) \cdot 3.08641975308642 \cdot 10^{-5}\right) \cdot angle\right) \cdot \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right)\\
\end{array}
\end{array}
if a < 5.49999999999999966e162Initial program 79.2%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6459.1
Applied rewrites59.1%
if 5.49999999999999966e162 < a Initial program 99.6%
lift-*.f64N/A
*-commutativeN/A
lift-PI.f64N/A
add-cube-cbrtN/A
associate-*l*N/A
lower-*.f64N/A
pow2N/A
lower-pow.f64N/A
lift-PI.f64N/A
lower-cbrt.f64N/A
lower-*.f64N/A
lift-PI.f64N/A
lower-cbrt.f6499.6
Applied rewrites99.6%
Taylor expanded in angle around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites44.4%
Taylor expanded in a around inf
Applied rewrites65.8%
Applied rewrites66.5%
Final simplification59.9%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* (PI) angle)))
(if (<= a 5.8e+162)
(* b b)
(* (* 3.08641975308642e-5 (* a a)) (* t_0 t_0)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot angle\\
\mathbf{if}\;a \leq 5.8 \cdot 10^{+162}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;\left(3.08641975308642 \cdot 10^{-5} \cdot \left(a \cdot a\right)\right) \cdot \left(t\_0 \cdot t\_0\right)\\
\end{array}
\end{array}
if a < 5.80000000000000012e162Initial program 79.2%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6459.1
Applied rewrites59.1%
if 5.80000000000000012e162 < a Initial program 99.6%
lift-*.f64N/A
*-commutativeN/A
lift-PI.f64N/A
add-cube-cbrtN/A
associate-*l*N/A
lower-*.f64N/A
pow2N/A
lower-pow.f64N/A
lift-PI.f64N/A
lower-cbrt.f64N/A
lower-*.f64N/A
lift-PI.f64N/A
lower-cbrt.f6499.6
Applied rewrites99.6%
Taylor expanded in angle around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites44.4%
Taylor expanded in a around inf
Applied rewrites65.8%
Applied rewrites65.8%
Final simplification59.8%
(FPCore (a b angle) :precision binary64 (* b b))
double code(double a, double b, double angle) {
return b * b;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, angle)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: angle
code = 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 81.4%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6456.5
Applied rewrites56.5%
Final simplification56.5%
herbie shell --seed 2025017
(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)))