
(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:
Herbie found 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(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}
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (cbrt (PI))))
(+
(pow (* a (cos (* (pow t_0 2.0) (* t_0 (/ angle 180.0))))) 2.0)
(pow (* b (sin (* (* (PI) 0.005555555555555556) angle))) 2.0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{\mathsf{PI}\left(\right)}\\
{\left(a \cdot \cos \left({t\_0}^{2} \cdot \left(t\_0 \cdot \frac{angle}{180}\right)\right)\right)}^{2} + {\left(b \cdot \sin \left(\left(\mathsf{PI}\left(\right) \cdot 0.005555555555555556\right) \cdot angle\right)\right)}^{2}
\end{array}
\end{array}
Initial program 81.2%
Taylor expanded in angle around inf
*-commutativeN/A
associate-*r*N/A
lower-sin.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6481.3
Applied rewrites81.3%
lift-*.f64N/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.3
Applied rewrites81.3%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* (PI) (/ angle 180.0)))
(t_1 (* (PI) (PI)))
(t_2 (+ (pow (* a (cos t_0)) 2.0) (pow (* b (sin t_0)) 2.0)))
(t_3 (* (PI) a)))
(if (<= t_2 2e-309)
(* (pow (sin (* (* (PI) angle) 0.005555555555555556)) 2.0) (* b b))
(if (<= t_2 1e+302)
(+
(fma (* (* angle angle) -3.08641975308642e-5) (* t_3 t_3) (* a a))
(pow
(*
(*
b
(*
(PI)
(fma
(* -2.8577960676726107e-8 (* angle angle))
t_1
0.005555555555555556)))
angle)
2.0))
(fma
(* (* (* t_1 3.08641975308642e-5) b) b)
(* angle angle)
(* a a))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot \frac{angle}{180}\\
t_1 := \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\\
t_2 := {\left(a \cdot \cos t\_0\right)}^{2} + {\left(b \cdot \sin t\_0\right)}^{2}\\
t_3 := \mathsf{PI}\left(\right) \cdot a\\
\mathbf{if}\;t\_2 \leq 2 \cdot 10^{-309}:\\
\;\;\;\;{\sin \left(\left(\mathsf{PI}\left(\right) \cdot angle\right) \cdot 0.005555555555555556\right)}^{2} \cdot \left(b \cdot b\right)\\
\mathbf{elif}\;t\_2 \leq 10^{+302}:\\
\;\;\;\;\mathsf{fma}\left(\left(angle \cdot angle\right) \cdot -3.08641975308642 \cdot 10^{-5}, t\_3 \cdot t\_3, a \cdot a\right) + {\left(\left(b \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(-2.8577960676726107 \cdot 10^{-8} \cdot \left(angle \cdot angle\right), t\_1, 0.005555555555555556\right)\right)\right) \cdot angle\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(t\_1 \cdot 3.08641975308642 \cdot 10^{-5}\right) \cdot b\right) \cdot b, angle \cdot angle, a \cdot a\right)\\
\end{array}
\end{array}
if (+.f64 (pow.f64 (*.f64 a (cos.f64 (*.f64 (PI.f64) (/.f64 angle #s(literal 180 binary64))))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (sin.f64 (*.f64 (PI.f64) (/.f64 angle #s(literal 180 binary64))))) #s(literal 2 binary64))) < 1.9999999999999988e-309Initial program 95.0%
Taylor expanded in angle around inf
*-commutativeN/A
associate-*r*N/A
lower-sin.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6495.0
Applied rewrites95.0%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f64N/A
unpow2N/A
lower-*.f6495.3
Applied rewrites95.3%
if 1.9999999999999988e-309 < (+.f64 (pow.f64 (*.f64 a (cos.f64 (*.f64 (PI.f64) (/.f64 angle #s(literal 180 binary64))))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (sin.f64 (*.f64 (PI.f64) (/.f64 angle #s(literal 180 binary64))))) #s(literal 2 binary64))) < 1.0000000000000001e302Initial program 66.7%
Taylor expanded in angle around 0
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
+-commutativeN/A
lower-*.f64N/A
Applied rewrites62.1%
Taylor expanded in angle around 0
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
unpow2N/A
unswap-sqrN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f64N/A
unpow2N/A
lower-*.f6459.8
Applied rewrites59.8%
if 1.0000000000000001e302 < (+.f64 (pow.f64 (*.f64 a (cos.f64 (*.f64 (PI.f64) (/.f64 angle #s(literal 180 binary64))))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (sin.f64 (*.f64 (PI.f64) (/.f64 angle #s(literal 180 binary64))))) #s(literal 2 binary64))) Initial program 99.0%
Taylor expanded in angle around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites34.3%
Taylor expanded in a around 0
Applied rewrites93.7%
Final simplification75.6%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* (PI) (/ angle 180.0)))
(t_1 (* (PI) (PI)))
(t_2 (+ (pow (* a (cos t_0)) 2.0) (pow (* b (sin t_0)) 2.0)))
(t_3 (* (PI) a)))
(if (<= t_2 2e-309)
(* (pow (sin (* (* (PI) 0.005555555555555556) angle)) 2.0) (* b b))
(if (<= t_2 1e+302)
(+
(fma (* (* angle angle) -3.08641975308642e-5) (* t_3 t_3) (* a a))
(pow
(*
(*
b
(*
(PI)
(fma
(* -2.8577960676726107e-8 (* angle angle))
t_1
0.005555555555555556)))
angle)
2.0))
(fma
(* (* (* t_1 3.08641975308642e-5) b) b)
(* angle angle)
(* a a))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot \frac{angle}{180}\\
t_1 := \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\\
t_2 := {\left(a \cdot \cos t\_0\right)}^{2} + {\left(b \cdot \sin t\_0\right)}^{2}\\
t_3 := \mathsf{PI}\left(\right) \cdot a\\
\mathbf{if}\;t\_2 \leq 2 \cdot 10^{-309}:\\
\;\;\;\;{\sin \left(\left(\mathsf{PI}\left(\right) \cdot 0.005555555555555556\right) \cdot angle\right)}^{2} \cdot \left(b \cdot b\right)\\
\mathbf{elif}\;t\_2 \leq 10^{+302}:\\
\;\;\;\;\mathsf{fma}\left(\left(angle \cdot angle\right) \cdot -3.08641975308642 \cdot 10^{-5}, t\_3 \cdot t\_3, a \cdot a\right) + {\left(\left(b \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(-2.8577960676726107 \cdot 10^{-8} \cdot \left(angle \cdot angle\right), t\_1, 0.005555555555555556\right)\right)\right) \cdot angle\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(t\_1 \cdot 3.08641975308642 \cdot 10^{-5}\right) \cdot b\right) \cdot b, angle \cdot angle, a \cdot a\right)\\
\end{array}
\end{array}
if (+.f64 (pow.f64 (*.f64 a (cos.f64 (*.f64 (PI.f64) (/.f64 angle #s(literal 180 binary64))))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (sin.f64 (*.f64 (PI.f64) (/.f64 angle #s(literal 180 binary64))))) #s(literal 2 binary64))) < 1.9999999999999988e-309Initial program 95.0%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-pow.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-sin.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f64N/A
unpow2N/A
lower-*.f6495.2
Applied rewrites95.2%
if 1.9999999999999988e-309 < (+.f64 (pow.f64 (*.f64 a (cos.f64 (*.f64 (PI.f64) (/.f64 angle #s(literal 180 binary64))))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (sin.f64 (*.f64 (PI.f64) (/.f64 angle #s(literal 180 binary64))))) #s(literal 2 binary64))) < 1.0000000000000001e302Initial program 66.7%
Taylor expanded in angle around 0
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
+-commutativeN/A
lower-*.f64N/A
Applied rewrites62.1%
Taylor expanded in angle around 0
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
unpow2N/A
unswap-sqrN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f64N/A
unpow2N/A
lower-*.f6459.8
Applied rewrites59.8%
if 1.0000000000000001e302 < (+.f64 (pow.f64 (*.f64 a (cos.f64 (*.f64 (PI.f64) (/.f64 angle #s(literal 180 binary64))))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (sin.f64 (*.f64 (PI.f64) (/.f64 angle #s(literal 180 binary64))))) #s(literal 2 binary64))) Initial program 99.0%
Taylor expanded in angle around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites34.3%
Taylor expanded in a around 0
Applied rewrites93.7%
Final simplification75.6%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* (PI) (/ angle 180.0)))
(t_1 (* (PI) (PI)))
(t_2 (+ (pow (* a (cos t_0)) 2.0) (pow (* b (sin t_0)) 2.0)))
(t_3 (* (PI) a)))
(if (<= t_2 2e-309)
(* (pow (cos (* -0.005555555555555556 (* (PI) angle))) 2.0) (* a a))
(if (<= t_2 1e+302)
(+
(fma (* (* angle angle) -3.08641975308642e-5) (* t_3 t_3) (* a a))
(pow
(*
(*
b
(*
(PI)
(fma
(* -2.8577960676726107e-8 (* angle angle))
t_1
0.005555555555555556)))
angle)
2.0))
(fma
(* (* (* t_1 3.08641975308642e-5) b) b)
(* angle angle)
(* a a))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot \frac{angle}{180}\\
t_1 := \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\\
t_2 := {\left(a \cdot \cos t\_0\right)}^{2} + {\left(b \cdot \sin t\_0\right)}^{2}\\
t_3 := \mathsf{PI}\left(\right) \cdot a\\
\mathbf{if}\;t\_2 \leq 2 \cdot 10^{-309}:\\
\;\;\;\;{\cos \left(-0.005555555555555556 \cdot \left(\mathsf{PI}\left(\right) \cdot angle\right)\right)}^{2} \cdot \left(a \cdot a\right)\\
\mathbf{elif}\;t\_2 \leq 10^{+302}:\\
\;\;\;\;\mathsf{fma}\left(\left(angle \cdot angle\right) \cdot -3.08641975308642 \cdot 10^{-5}, t\_3 \cdot t\_3, a \cdot a\right) + {\left(\left(b \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(-2.8577960676726107 \cdot 10^{-8} \cdot \left(angle \cdot angle\right), t\_1, 0.005555555555555556\right)\right)\right) \cdot angle\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(t\_1 \cdot 3.08641975308642 \cdot 10^{-5}\right) \cdot b\right) \cdot b, angle \cdot angle, a \cdot a\right)\\
\end{array}
\end{array}
if (+.f64 (pow.f64 (*.f64 a (cos.f64 (*.f64 (PI.f64) (/.f64 angle #s(literal 180 binary64))))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (sin.f64 (*.f64 (PI.f64) (/.f64 angle #s(literal 180 binary64))))) #s(literal 2 binary64))) < 1.9999999999999988e-309Initial program 95.0%
Taylor expanded in angle around inf
*-commutativeN/A
associate-*r*N/A
lower-sin.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6495.0
Applied rewrites95.0%
Taylor expanded in angle around 0
Applied rewrites53.0%
Applied rewrites52.9%
Taylor expanded in a around inf
*-commutativeN/A
unpow2N/A
associate-*l*N/A
cos-neg-revN/A
sin-+PI/2-revN/A
distribute-lft-neg-inN/A
metadata-evalN/A
sin-+PI/2-revN/A
cos-neg-revN/A
sin-+PI/2-revN/A
distribute-lft-neg-inN/A
metadata-evalN/A
sin-+PI/2-revN/A
Applied rewrites95.0%
if 1.9999999999999988e-309 < (+.f64 (pow.f64 (*.f64 a (cos.f64 (*.f64 (PI.f64) (/.f64 angle #s(literal 180 binary64))))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (sin.f64 (*.f64 (PI.f64) (/.f64 angle #s(literal 180 binary64))))) #s(literal 2 binary64))) < 1.0000000000000001e302Initial program 66.7%
Taylor expanded in angle around 0
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
+-commutativeN/A
lower-*.f64N/A
Applied rewrites62.1%
Taylor expanded in angle around 0
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
unpow2N/A
unswap-sqrN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f64N/A
unpow2N/A
lower-*.f6459.8
Applied rewrites59.8%
if 1.0000000000000001e302 < (+.f64 (pow.f64 (*.f64 a (cos.f64 (*.f64 (PI.f64) (/.f64 angle #s(literal 180 binary64))))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (sin.f64 (*.f64 (PI.f64) (/.f64 angle #s(literal 180 binary64))))) #s(literal 2 binary64))) Initial program 99.0%
Taylor expanded in angle around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites34.3%
Taylor expanded in a around 0
Applied rewrites93.7%
Final simplification75.6%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* (PI) (PI)))
(t_1 (* (PI) (/ angle 180.0)))
(t_2 (+ (pow (* a (cos t_1)) 2.0) (pow (* b (sin t_1)) 2.0)))
(t_3 (* (PI) a)))
(if (<= t_2 2e-309)
(* a a)
(if (<= t_2 1e+302)
(+
(fma (* (* angle angle) -3.08641975308642e-5) (* t_3 t_3) (* a a))
(pow
(*
(*
b
(*
(PI)
(fma
(* -2.8577960676726107e-8 (* angle angle))
t_0
0.005555555555555556)))
angle)
2.0))
(fma
(* (* (* t_0 3.08641975308642e-5) b) b)
(* angle angle)
(* a a))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\\
t_1 := \mathsf{PI}\left(\right) \cdot \frac{angle}{180}\\
t_2 := {\left(a \cdot \cos t\_1\right)}^{2} + {\left(b \cdot \sin t\_1\right)}^{2}\\
t_3 := \mathsf{PI}\left(\right) \cdot a\\
\mathbf{if}\;t\_2 \leq 2 \cdot 10^{-309}:\\
\;\;\;\;a \cdot a\\
\mathbf{elif}\;t\_2 \leq 10^{+302}:\\
\;\;\;\;\mathsf{fma}\left(\left(angle \cdot angle\right) \cdot -3.08641975308642 \cdot 10^{-5}, t\_3 \cdot t\_3, a \cdot a\right) + {\left(\left(b \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(-2.8577960676726107 \cdot 10^{-8} \cdot \left(angle \cdot angle\right), t\_0, 0.005555555555555556\right)\right)\right) \cdot angle\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(t\_0 \cdot 3.08641975308642 \cdot 10^{-5}\right) \cdot b\right) \cdot b, angle \cdot angle, a \cdot a\right)\\
\end{array}
\end{array}
if (+.f64 (pow.f64 (*.f64 a (cos.f64 (*.f64 (PI.f64) (/.f64 angle #s(literal 180 binary64))))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (sin.f64 (*.f64 (PI.f64) (/.f64 angle #s(literal 180 binary64))))) #s(literal 2 binary64))) < 1.9999999999999988e-309Initial program 95.0%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6494.9
Applied rewrites94.9%
if 1.9999999999999988e-309 < (+.f64 (pow.f64 (*.f64 a (cos.f64 (*.f64 (PI.f64) (/.f64 angle #s(literal 180 binary64))))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (sin.f64 (*.f64 (PI.f64) (/.f64 angle #s(literal 180 binary64))))) #s(literal 2 binary64))) < 1.0000000000000001e302Initial program 66.7%
Taylor expanded in angle around 0
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
+-commutativeN/A
lower-*.f64N/A
Applied rewrites62.1%
Taylor expanded in angle around 0
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
unpow2N/A
unswap-sqrN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f64N/A
unpow2N/A
lower-*.f6459.8
Applied rewrites59.8%
if 1.0000000000000001e302 < (+.f64 (pow.f64 (*.f64 a (cos.f64 (*.f64 (PI.f64) (/.f64 angle #s(literal 180 binary64))))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (sin.f64 (*.f64 (PI.f64) (/.f64 angle #s(literal 180 binary64))))) #s(literal 2 binary64))) Initial program 99.0%
Taylor expanded in angle around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites34.3%
Taylor expanded in a around 0
Applied rewrites93.7%
Final simplification75.6%
(FPCore (a b angle) :precision binary64 (fma (* (pow (sin (* (fma 0.005555555555555556 angle 0.5) (PI))) 2.0) a) a (pow (* b (sin (* (* 0.005555555555555556 (PI)) angle))) 2.0)))
\begin{array}{l}
\\
\mathsf{fma}\left({\sin \left(\mathsf{fma}\left(0.005555555555555556, angle, 0.5\right) \cdot \mathsf{PI}\left(\right)\right)}^{2} \cdot a, a, {\left(b \cdot \sin \left(\left(0.005555555555555556 \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right)\right)}^{2}\right)
\end{array}
Initial program 81.2%
lift-cos.f64N/A
sin-+PI/2-revN/A
lower-sin.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-PI.f64N/A
lower-/.f6481.1
Applied rewrites81.1%
Taylor expanded in a around 0
*-commutativeN/A
lower-fma.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-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites72.7%
Applied rewrites81.3%
(FPCore (a b angle) :precision binary64 (+ (pow (* a (cos (* -0.005555555555555556 (* (PI) angle)))) 2.0) (pow (* b (sin (* (* (PI) 0.005555555555555556) angle))) 2.0)))
\begin{array}{l}
\\
{\left(a \cdot \cos \left(-0.005555555555555556 \cdot \left(\mathsf{PI}\left(\right) \cdot angle\right)\right)\right)}^{2} + {\left(b \cdot \sin \left(\left(\mathsf{PI}\left(\right) \cdot 0.005555555555555556\right) \cdot angle\right)\right)}^{2}
\end{array}
Initial program 81.2%
Taylor expanded in angle around inf
*-commutativeN/A
associate-*r*N/A
lower-sin.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6481.3
Applied rewrites81.3%
Taylor expanded in angle around inf
cos-neg-revN/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6481.2
Applied rewrites81.2%
(FPCore (a b angle) :precision binary64 (+ (pow (* a 1.0) 2.0) (pow (* b (sin (* (* (PI) 0.005555555555555556) angle))) 2.0)))
\begin{array}{l}
\\
{\left(a \cdot 1\right)}^{2} + {\left(b \cdot \sin \left(\left(\mathsf{PI}\left(\right) \cdot 0.005555555555555556\right) \cdot angle\right)\right)}^{2}
\end{array}
Initial program 81.2%
Taylor expanded in angle around inf
*-commutativeN/A
associate-*r*N/A
lower-sin.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6481.3
Applied rewrites81.3%
Taylor expanded in angle around 0
Applied rewrites81.0%
(FPCore (a b angle) :precision binary64 (fma (* (* 1.0 a) 1.0) a (pow (* (sin (* (/ angle 180.0) (PI))) b) 2.0)))
\begin{array}{l}
\\
\mathsf{fma}\left(\left(1 \cdot a\right) \cdot 1, a, {\left(\sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right) \cdot b\right)}^{2}\right)
\end{array}
Initial program 81.2%
unpow1N/A
pow-to-expN/A
lower-exp.f64N/A
lower-*.f64N/A
lower-log.f6443.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6443.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6443.3
Applied rewrites43.3%
Taylor expanded in angle around 0
Applied rewrites43.3%
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-pow.f64N/A
lift-exp.f64N/A
Applied rewrites80.9%
(FPCore (a b angle)
:precision binary64
(if (<= b 1.9e-67)
(* (pow (sin (* (fma 0.005555555555555556 angle 0.5) (PI))) 2.0) (* a a))
(+
(pow (* a 1.0) 2.0)
(pow (* b (* (* (PI) angle) 0.005555555555555556)) 2.0))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.9 \cdot 10^{-67}:\\
\;\;\;\;{\sin \left(\mathsf{fma}\left(0.005555555555555556, angle, 0.5\right) \cdot \mathsf{PI}\left(\right)\right)}^{2} \cdot \left(a \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;{\left(a \cdot 1\right)}^{2} + {\left(b \cdot \left(\left(\mathsf{PI}\left(\right) \cdot angle\right) \cdot 0.005555555555555556\right)\right)}^{2}\\
\end{array}
\end{array}
if b < 1.89999999999999994e-67Initial program 80.7%
lift-cos.f64N/A
sin-+PI/2-revN/A
lower-sin.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-PI.f64N/A
lower-/.f6480.8
Applied rewrites80.8%
Taylor expanded in a around 0
*-commutativeN/A
lower-fma.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-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites75.1%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-PI.f64N/A
unpow2N/A
lower-*.f6462.6
Applied rewrites62.6%
if 1.89999999999999994e-67 < b Initial program 82.1%
Taylor expanded in angle around inf
*-commutativeN/A
associate-*r*N/A
lower-sin.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6482.1
Applied rewrites82.1%
Taylor expanded in angle around 0
Applied rewrites79.9%
Taylor expanded in angle around 0
Applied rewrites79.9%
(FPCore (a b angle)
:precision binary64
(if (<= a 3.6e-155)
(* angle (* angle (* (pow (* b (PI)) 2.0) 3.08641975308642e-5)))
(if (<= a 2.5e+142)
(fma
(* (* -3.08641975308642e-5 (* (PI) (PI))) (* (- b) b))
(* angle angle)
(* a a))
(* a a))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 3.6 \cdot 10^{-155}:\\
\;\;\;\;angle \cdot \left(angle \cdot \left({\left(b \cdot \mathsf{PI}\left(\right)\right)}^{2} \cdot 3.08641975308642 \cdot 10^{-5}\right)\right)\\
\mathbf{elif}\;a \leq 2.5 \cdot 10^{+142}:\\
\;\;\;\;\mathsf{fma}\left(\left(-3.08641975308642 \cdot 10^{-5} \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \left(\left(-b\right) \cdot b\right), angle \cdot angle, a \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;a \cdot a\\
\end{array}
\end{array}
if a < 3.59999999999999989e-155Initial program 80.4%
Taylor expanded in angle around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites45.8%
Taylor expanded in a around 0
Applied rewrites37.6%
Applied rewrites48.2%
if 3.59999999999999989e-155 < a < 2.5000000000000001e142Initial program 72.8%
Taylor expanded in angle around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites62.0%
Taylor expanded in a around 0
Applied rewrites63.7%
if 2.5000000000000001e142 < a Initial program 100.0%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f64100.0
Applied rewrites100.0%
Final simplification58.5%
(FPCore (a b angle)
:precision binary64
(if (<= b 1.9e-67)
(* a a)
(fma
(* (* -3.08641975308642e-5 (* (PI) (PI))) (* (- b) b))
(* angle angle)
(* a a))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.9 \cdot 10^{-67}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(-3.08641975308642 \cdot 10^{-5} \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \left(\left(-b\right) \cdot b\right), angle \cdot angle, a \cdot a\right)\\
\end{array}
\end{array}
if b < 1.89999999999999994e-67Initial program 80.7%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6462.1
Applied rewrites62.1%
if 1.89999999999999994e-67 < b Initial program 82.1%
Taylor expanded in angle around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites45.2%
Taylor expanded in a around 0
Applied rewrites65.8%
Final simplification63.4%
(FPCore (a b angle)
:precision binary64
(if (<= b 1.9e-67)
(* a a)
(fma
(* (* (* (* (PI) (PI)) 3.08641975308642e-5) b) b)
(* angle angle)
(* a a))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.9 \cdot 10^{-67}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot 3.08641975308642 \cdot 10^{-5}\right) \cdot b\right) \cdot b, angle \cdot angle, a \cdot a\right)\\
\end{array}
\end{array}
if b < 1.89999999999999994e-67Initial program 80.7%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6462.1
Applied rewrites62.1%
if 1.89999999999999994e-67 < b Initial program 82.1%
Taylor expanded in angle around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites45.2%
Taylor expanded in a around 0
Applied rewrites65.8%
Final simplification63.4%
(FPCore (a b angle) :precision binary64 (if (<= b 8e+125) (* a a) (* (* 3.08641975308642e-5 (* (* (* angle angle) b) b)) (* (PI) (PI)))))
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 8 \cdot 10^{+125}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;\left(3.08641975308642 \cdot 10^{-5} \cdot \left(\left(\left(angle \cdot angle\right) \cdot b\right) \cdot b\right)\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\\
\end{array}
\end{array}
if b < 7.9999999999999994e125Initial program 80.1%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6461.3
Applied rewrites61.3%
if 7.9999999999999994e125 < b Initial program 86.8%
Taylor expanded in angle around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites44.3%
Taylor expanded in a around 0
Applied rewrites59.3%
Taylor expanded in a around 0
Applied rewrites69.0%
Final simplification62.5%
(FPCore (a b angle) :precision binary64 (* a a))
double code(double a, double b, double angle) {
return a * a;
}
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 = a * a
end function
public static double code(double a, double b, double angle) {
return a * a;
}
def code(a, b, angle): return a * a
function code(a, b, angle) return Float64(a * a) end
function tmp = code(a, b, angle) tmp = a * a; end
code[a_, b_, angle_] := N[(a * a), $MachinePrecision]
\begin{array}{l}
\\
a \cdot a
\end{array}
Initial program 81.2%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6456.0
Applied rewrites56.0%
Final simplification56.0%
herbie shell --seed 2025010
(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)))