
(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 17 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 (log (PI))) (t_1 (* (/ angle 180.0) (sinh t_0))) (t_2 (cosh t_0)))
(+
(pow
(*
a
(-
(* (cos (/ (* t_2 angle) -180.0)) (cos t_1))
(* (sin (* (/ angle 180.0) t_2)) (sin t_1))))
2.0)
(pow (* b (sin (* (PI) (/ angle 180.0)))) 2.0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \mathsf{PI}\left(\right)\\
t_1 := \frac{angle}{180} \cdot \sinh t\_0\\
t_2 := \cosh t\_0\\
{\left(a \cdot \left(\cos \left(\frac{t\_2 \cdot angle}{-180}\right) \cdot \cos t\_1 - \sin \left(\frac{angle}{180} \cdot t\_2\right) \cdot \sin t\_1\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2}
\end{array}
\end{array}
Initial program 77.0%
lift-cos.f64N/A
cos-neg-revN/A
cos-neg-revN/A
remove-double-negN/A
lift-*.f64N/A
*-commutativeN/A
lift-PI.f64N/A
add-exp-logN/A
sinh-+-cosh-revN/A
distribute-lft-inN/A
cos-sumN/A
lower--.f64N/A
Applied rewrites77.2%
lift-cos.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
distribute-neg-frac2N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
metadata-eval77.2
Applied rewrites77.2%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (log (PI)))
(t_1 (* (/ angle 180.0) (sinh t_0)))
(t_2 (* (/ angle 180.0) (cosh t_0))))
(+
(pow (* a (- (* (cos t_2) (cos t_1)) (* (sin t_2) (sin t_1)))) 2.0)
(pow (* b (sin (* (PI) (/ angle 180.0)))) 2.0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \mathsf{PI}\left(\right)\\
t_1 := \frac{angle}{180} \cdot \sinh t\_0\\
t_2 := \frac{angle}{180} \cdot \cosh t\_0\\
{\left(a \cdot \left(\cos t\_2 \cdot \cos t\_1 - \sin t\_2 \cdot \sin t\_1\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2}
\end{array}
\end{array}
Initial program 77.0%
lift-cos.f64N/A
cos-neg-revN/A
cos-neg-revN/A
remove-double-negN/A
lift-*.f64N/A
*-commutativeN/A
lift-PI.f64N/A
add-exp-logN/A
sinh-+-cosh-revN/A
distribute-lft-inN/A
cos-sumN/A
lower--.f64N/A
Applied rewrites77.2%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (log (PI))) (t_1 (cosh t_0)))
(+
(pow
(*
a
(-
(* (cos (/ (* t_1 angle) -180.0)) (cos (* (/ angle 180.0) (sinh t_0))))
(*
(sin (* (/ angle 180.0) t_1))
(sin (* (* (- (PI) (pow (PI) -1.0)) 0.002777777777777778) angle)))))
2.0)
(pow (* b (sin (* (PI) (/ angle 180.0)))) 2.0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \mathsf{PI}\left(\right)\\
t_1 := \cosh t\_0\\
{\left(a \cdot \left(\cos \left(\frac{t\_1 \cdot angle}{-180}\right) \cdot \cos \left(\frac{angle}{180} \cdot \sinh t\_0\right) - \sin \left(\frac{angle}{180} \cdot t\_1\right) \cdot \sin \left(\left(\left(\mathsf{PI}\left(\right) - {\mathsf{PI}\left(\right)}^{-1}\right) \cdot 0.002777777777777778\right) \cdot angle\right)\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2}
\end{array}
\end{array}
Initial program 77.0%
lift-cos.f64N/A
cos-neg-revN/A
cos-neg-revN/A
remove-double-negN/A
lift-*.f64N/A
*-commutativeN/A
lift-PI.f64N/A
add-exp-logN/A
sinh-+-cosh-revN/A
distribute-lft-inN/A
cos-sumN/A
lower--.f64N/A
Applied rewrites77.2%
lift-cos.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
distribute-neg-frac2N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
metadata-eval77.2
Applied rewrites77.2%
Taylor expanded in angle around inf
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-sin.f64N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-PI.f64N/A
lower-/.f64N/A
lower-PI.f6477.2
Applied rewrites77.2%
Final simplification77.2%
(FPCore (a b angle)
:precision binary64
(+
(pow
(*
a
(cos
(*
(* (/ (* (sqrt (PI)) angle) 180.0) (cbrt (PI)))
(pow (PI) 0.16666666666666666))))
2.0)
(pow (* b (sin (* (PI) (/ angle 180.0)))) 2.0)))\begin{array}{l}
\\
{\left(a \cdot \cos \left(\left(\frac{\sqrt{\mathsf{PI}\left(\right)} \cdot angle}{180} \cdot \sqrt[3]{\mathsf{PI}\left(\right)}\right) \cdot {\mathsf{PI}\left(\right)}^{0.16666666666666666}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2}
\end{array}
Initial program 77.0%
lift-*.f64N/A
*-commutativeN/A
lift-PI.f64N/A
add-sqr-sqrtN/A
associate-*r*N/A
add-cube-cbrtN/A
sqrt-prodN/A
pow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites77.2%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (sqrt (PI))))
(+
(pow (* a (cos (* (* angle (/ t_0 180.0)) t_0))) 2.0)
(pow (* b (sin (* (PI) (/ angle 180.0)))) 2.0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\mathsf{PI}\left(\right)}\\
{\left(a \cdot \cos \left(\left(angle \cdot \frac{t\_0}{180}\right) \cdot t\_0\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2}
\end{array}
\end{array}
Initial program 77.0%
lift-*.f64N/A
*-commutativeN/A
lift-PI.f64N/A
add-sqr-sqrtN/A
sqr-neg-revN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lift-PI.f64N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lift-PI.f64N/A
lower-sqrt.f6477.1
Applied rewrites77.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6477.1
Applied rewrites77.1%
Final simplification77.1%
(FPCore (a b angle) :precision binary64 (+ (pow (* a (cos (* (* (PI) 0.005555555555555556) angle))) 2.0) (pow (* b (sin (* (PI) (/ angle 180.0)))) 2.0)))
\begin{array}{l}
\\
{\left(a \cdot \cos \left(\left(\mathsf{PI}\left(\right) \cdot 0.005555555555555556\right) \cdot angle\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2}
\end{array}
Initial program 77.0%
Taylor expanded in angle around inf
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6477.1
Applied rewrites77.1%
(FPCore (a b angle) :precision binary64 (+ (pow (* a (cos (* -0.005555555555555556 (* (PI) angle)))) 2.0) (pow (* b (sin (* (* 0.005555555555555556 (PI)) 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(0.005555555555555556 \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right)\right)}^{2}
\end{array}
Initial program 77.0%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6477.0
Applied rewrites77.0%
Taylor expanded in angle around inf
*-commutativeN/A
associate-*r*N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f6477.0
Applied rewrites77.0%
Taylor expanded in angle around inf
cos-neg-revN/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6477.1
Applied rewrites77.1%
Final simplification77.1%
(FPCore (a b angle) :precision binary64 (+ (pow (* a 1.0) 2.0) (pow (* b (sin (* (PI) (/ angle 180.0)))) 2.0)))
\begin{array}{l}
\\
{\left(a \cdot 1\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2}
\end{array}
Initial program 77.0%
Taylor expanded in angle around 0
Applied rewrites77.0%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* (* (* (PI) (PI)) angle) angle)))
(if (<= angle 3.9)
(+
(* (fma -3.08641975308642e-5 t_0 1.0) (* a a))
(pow (* b (sin (* (PI) (/ angle 180.0)))) 2.0))
(if (<= angle 1.5e+172)
(+
(pow (* a (cos (/ (* angle (PI)) 180.0))) 2.0)
(* (* 3.08641975308642e-5 (* b b)) t_0))
(exp (* (log a) 2.0))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right) \cdot angle\\
\mathbf{if}\;angle \leq 3.9:\\
\;\;\;\;\mathsf{fma}\left(-3.08641975308642 \cdot 10^{-5}, t\_0, 1\right) \cdot \left(a \cdot a\right) + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2}\\
\mathbf{elif}\;angle \leq 1.5 \cdot 10^{+172}:\\
\;\;\;\;{\left(a \cdot \cos \left(\frac{angle \cdot \mathsf{PI}\left(\right)}{180}\right)\right)}^{2} + \left(3.08641975308642 \cdot 10^{-5} \cdot \left(b \cdot b\right)\right) \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;e^{\log a \cdot 2}\\
\end{array}
\end{array}
if angle < 3.89999999999999991Initial program 84.4%
Taylor expanded in angle around 0
*-commutativeN/A
associate-*r*N/A
distribute-lft1-inN/A
lower-*.f64N/A
lower-fma.f64N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-PI.f64N/A
lower-PI.f64N/A
unpow2N/A
lower-*.f6465.2
Applied rewrites65.2%
if 3.89999999999999991 < angle < 1.5e172Initial program 51.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6451.6
Applied rewrites51.6%
Taylor expanded in angle around 0
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-PI.f64N/A
lower-PI.f6445.8
Applied rewrites45.8%
if 1.5e172 < angle Initial program 56.9%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6446.5
Applied rewrites46.5%
Applied rewrites12.8%
(FPCore (a b angle) :precision binary64 (if (<= b 5.5e+96) (* a a) (* (pow (* (* b (PI)) angle) 2.0) 3.08641975308642e-5)))
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 5.5 \cdot 10^{+96}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;{\left(\left(b \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right)}^{2} \cdot 3.08641975308642 \cdot 10^{-5}\\
\end{array}
\end{array}
if b < 5.5000000000000002e96Initial program 75.9%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6468.8
Applied rewrites68.8%
if 5.5000000000000002e96 < b Initial program 82.2%
Taylor expanded in angle around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites44.8%
Taylor expanded in a around 0
Applied rewrites53.8%
Applied rewrites69.0%
(FPCore (a b angle)
:precision binary64
(if (<= a 4.6e+95)
(fma
(*
(* (* (- a b) (+ b a)) (* (* (PI) (PI)) -3.08641975308642e-5))
(- angle))
(- angle)
(* a a))
(* a a)))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 4.6 \cdot 10^{+95}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(\left(a - b\right) \cdot \left(b + a\right)\right) \cdot \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot -3.08641975308642 \cdot 10^{-5}\right)\right) \cdot \left(-angle\right), -angle, a \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;a \cdot a\\
\end{array}
\end{array}
if a < 4.59999999999999994e95Initial program 75.6%
Taylor expanded in angle around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites43.6%
Applied rewrites48.9%
if 4.59999999999999994e95 < a Initial program 85.4%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6485.0
Applied rewrites85.0%
(FPCore (a b angle)
:precision binary64
(if (<= a 4.6e+95)
(fma
(* (* (- a b) (+ b a)) (* (* (* (PI) (PI)) -3.08641975308642e-5) angle))
angle
(* a a))
(* a a)))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 4.6 \cdot 10^{+95}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(a - b\right) \cdot \left(b + a\right)\right) \cdot \left(\left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot -3.08641975308642 \cdot 10^{-5}\right) \cdot angle\right), angle, a \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;a \cdot a\\
\end{array}
\end{array}
if a < 4.59999999999999994e95Initial program 75.6%
Taylor expanded in angle around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites43.6%
Applied rewrites48.9%
if 4.59999999999999994e95 < a Initial program 85.4%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6485.0
Applied rewrites85.0%
(FPCore (a b angle)
:precision binary64
(if (<= b 1.7e-54)
(* 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.7 \cdot 10^{-54}:\\
\;\;\;\;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.69999999999999994e-54Initial program 75.2%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6468.0
Applied rewrites68.0%
if 1.69999999999999994e-54 < b Initial program 81.8%
Taylor expanded in angle around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites46.3%
Taylor expanded in a around 0
Applied rewrites65.6%
(FPCore (a b angle)
:precision binary64
(if (<= b 1.7e-54)
(* a a)
(fma
(* (* (* 3.08641975308642e-5 (* b b)) (PI)) (PI))
(* angle angle)
(* a a))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.7 \cdot 10^{-54}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(3.08641975308642 \cdot 10^{-5} \cdot \left(b \cdot b\right)\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \mathsf{PI}\left(\right), angle \cdot angle, a \cdot a\right)\\
\end{array}
\end{array}
if b < 1.69999999999999994e-54Initial program 75.2%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6468.0
Applied rewrites68.0%
if 1.69999999999999994e-54 < b Initial program 81.8%
Taylor expanded in angle around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites46.3%
Taylor expanded in a around 0
Applied rewrites65.6%
(FPCore (a b angle) :precision binary64 (if (<= b 9e+96) (* a a) (* (* (* (* 3.08641975308642e-5 (* angle angle)) b) (* (PI) (PI))) b)))
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 9 \cdot 10^{+96}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\left(3.08641975308642 \cdot 10^{-5} \cdot \left(angle \cdot angle\right)\right) \cdot b\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right) \cdot b\\
\end{array}
\end{array}
if b < 8.99999999999999914e96Initial program 75.9%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6468.8
Applied rewrites68.8%
if 8.99999999999999914e96 < b Initial program 82.2%
Taylor expanded in angle around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites44.8%
Taylor expanded in a around 0
Applied rewrites53.8%
Applied rewrites54.3%
(FPCore (a b angle) :precision binary64 (if (<= b 9e+96) (* a a) (* (* 3.08641975308642e-5 (* b b)) (* (* (* (PI) (PI)) angle) angle))))
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 9 \cdot 10^{+96}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;\left(3.08641975308642 \cdot 10^{-5} \cdot \left(b \cdot b\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 b < 8.99999999999999914e96Initial program 75.9%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6468.8
Applied rewrites68.8%
if 8.99999999999999914e96 < b Initial program 82.2%
Taylor expanded in angle around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites44.8%
Taylor expanded in a around 0
Applied rewrites53.8%
Taylor expanded in a around 0
Applied rewrites55.9%
(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 77.0%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6460.0
Applied rewrites60.0%
herbie shell --seed 2024353
(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)))