
(FPCore (kx ky th) :precision binary64 (* (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) (sin th)))
double code(double kx, double ky, double th) {
return (sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) * sin(th);
}
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(kx, ky, th)
use fmin_fmax_functions
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = (sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))) * sin(th)
end function
public static double code(double kx, double ky, double th) {
return (Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))) * Math.sin(th);
}
def code(kx, ky, th): return (math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))) * math.sin(th)
function code(kx, ky, th) return Float64(Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th)) end
function tmp = code(kx, ky, th) tmp = (sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th); end
code[kx_, ky_, th_] := N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th
\end{array}
Herbie found 16 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (kx ky th) :precision binary64 (* (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) (sin th)))
double code(double kx, double ky, double th) {
return (sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) * sin(th);
}
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(kx, ky, th)
use fmin_fmax_functions
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = (sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))) * sin(th)
end function
public static double code(double kx, double ky, double th) {
return (Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))) * Math.sin(th);
}
def code(kx, ky, th): return (math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))) * math.sin(th)
function code(kx, ky, th) return Float64(Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th)) end
function tmp = code(kx, ky, th) tmp = (sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th); end
code[kx_, ky_, th_] := N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th
\end{array}
(FPCore (kx ky th) :precision binary64 (* (/ (sin ky) (hypot (sin ky) (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
return (sin(ky) / hypot(sin(ky), sin(kx))) * sin(th);
}
public static double code(double kx, double ky, double th) {
return (Math.sin(ky) / Math.hypot(Math.sin(ky), Math.sin(kx))) * Math.sin(th);
}
def code(kx, ky, th): return (math.sin(ky) / math.hypot(math.sin(ky), math.sin(kx))) * math.sin(th)
function code(kx, ky, th) return Float64(Float64(sin(ky) / hypot(sin(ky), sin(kx))) * sin(th)) end
function tmp = code(kx, ky, th) tmp = (sin(ky) / hypot(sin(ky), sin(kx))) * sin(th); end
code[kx_, ky_, th_] := N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \sin th
\end{array}
Initial program 94.1%
lift-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.7
Applied rewrites99.7%
(FPCore (kx ky th) :precision binary64 (* (sin ky) (/ (sin th) (hypot (sin kx) (sin ky)))))
double code(double kx, double ky, double th) {
return sin(ky) * (sin(th) / hypot(sin(kx), sin(ky)));
}
public static double code(double kx, double ky, double th) {
return Math.sin(ky) * (Math.sin(th) / Math.hypot(Math.sin(kx), Math.sin(ky)));
}
def code(kx, ky, th): return math.sin(ky) * (math.sin(th) / math.hypot(math.sin(kx), math.sin(ky)))
function code(kx, ky, th) return Float64(sin(ky) * Float64(sin(th) / hypot(sin(kx), sin(ky)))) end
function tmp = code(kx, ky, th) tmp = sin(ky) * (sin(th) / hypot(sin(kx), sin(ky))); end
code[kx_, ky_, th_] := N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin kx, \sin ky\right)}
\end{array}
Initial program 94.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6494.1
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.6
Applied rewrites99.6%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))))
(t_2 (cos (+ kx kx))))
(if (<= t_1 -0.99)
(* (/ (sin ky) (sqrt (fma (sin ky) (sin ky) (- 0.5 0.5)))) (sin th))
(if (<= t_1 -0.4)
(/
(* th (sin ky))
(sqrt (- 0.5 (- (* (cos (+ ky ky)) 0.5) (- 0.5 (* t_2 0.5))))))
(if (<= t_1 0.7)
(* (/ (sin ky) (sqrt (- 0.5 (* 0.5 t_2)))) (sin th))
(if (<= t_1 2.0) (sin th) (* (/ (sin ky) (sin kx)) (sin th))))))))
double code(double kx, double ky, double th) {
double t_1 = sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)));
double t_2 = cos((kx + kx));
double tmp;
if (t_1 <= -0.99) {
tmp = (sin(ky) / sqrt(fma(sin(ky), sin(ky), (0.5 - 0.5)))) * sin(th);
} else if (t_1 <= -0.4) {
tmp = (th * sin(ky)) / sqrt((0.5 - ((cos((ky + ky)) * 0.5) - (0.5 - (t_2 * 0.5)))));
} else if (t_1 <= 0.7) {
tmp = (sin(ky) / sqrt((0.5 - (0.5 * t_2)))) * sin(th);
} else if (t_1 <= 2.0) {
tmp = sin(th);
} else {
tmp = (sin(ky) / sin(kx)) * sin(th);
}
return tmp;
}
function code(kx, ky, th) t_1 = Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) t_2 = cos(Float64(kx + kx)) tmp = 0.0 if (t_1 <= -0.99) tmp = Float64(Float64(sin(ky) / sqrt(fma(sin(ky), sin(ky), Float64(0.5 - 0.5)))) * sin(th)); elseif (t_1 <= -0.4) tmp = Float64(Float64(th * sin(ky)) / sqrt(Float64(0.5 - Float64(Float64(cos(Float64(ky + ky)) * 0.5) - Float64(0.5 - Float64(t_2 * 0.5)))))); elseif (t_1 <= 0.7) tmp = Float64(Float64(sin(ky) / sqrt(Float64(0.5 - Float64(0.5 * t_2)))) * sin(th)); elseif (t_1 <= 2.0) tmp = sin(th); else tmp = Float64(Float64(sin(ky) / sin(kx)) * sin(th)); end return tmp end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$1, -0.99], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Sin[ky], $MachinePrecision] * N[Sin[ky], $MachinePrecision] + N[(0.5 - 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -0.4], N[(N[(th * N[Sin[ky], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(0.5 - N[(N[(N[Cos[N[(ky + ky), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision] - N[(0.5 - N[(t$95$2 * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.7], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(0.5 - N[(0.5 * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2.0], N[Sin[th], $MachinePrecision], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\
t_2 := \cos \left(kx + kx\right)\\
\mathbf{if}\;t\_1 \leq -0.99:\\
\;\;\;\;\frac{\sin ky}{\sqrt{\mathsf{fma}\left(\sin ky, \sin ky, 0.5 - 0.5\right)}} \cdot \sin th\\
\mathbf{elif}\;t\_1 \leq -0.4:\\
\;\;\;\;\frac{th \cdot \sin ky}{\sqrt{0.5 - \left(\cos \left(ky + ky\right) \cdot 0.5 - \left(0.5 - t\_2 \cdot 0.5\right)\right)}}\\
\mathbf{elif}\;t\_1 \leq 0.7:\\
\;\;\;\;\frac{\sin ky}{\sqrt{0.5 - 0.5 \cdot t\_2}} \cdot \sin th\\
\mathbf{elif}\;t\_1 \leq 2:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\sin kx} \cdot \sin th\\
\end{array}
\end{array}
if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.98999999999999999Initial program 86.2%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6486.2
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6465.3
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6464.9
Applied rewrites64.9%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
sqr-sin-a-revN/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-fma.f6486.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6486.0
lift-*.f64N/A
count-2-revN/A
lower-+.f6486.0
Applied rewrites86.0%
Taylor expanded in kx around 0
Applied rewrites83.8%
if -0.98999999999999999 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.40000000000000002Initial program 99.3%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.3
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.3
Applied rewrites99.3%
lift-hypot.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-a-revN/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-a-revN/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift--.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+l-N/A
Applied rewrites98.9%
Taylor expanded in th around 0
Applied rewrites51.0%
if -0.40000000000000002 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.69999999999999996Initial program 99.2%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.2
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6499.0
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6478.4
Applied rewrites78.4%
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lower--.f6478.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6478.4
lift-*.f64N/A
count-2-revN/A
lower-+.f6478.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6478.4
lift-*.f64N/A
count-2-revN/A
lower-+.f6478.4
Applied rewrites78.4%
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-+.f64N/A
count-2-revN/A
sqr-sin-a-revN/A
lift-sin.f64N/A
lift-sin.f64N/A
pow2N/A
pow-to-expN/A
lower-exp.f64N/A
lower-*.f64N/A
lower-log.f6439.5
Applied rewrites39.5%
Taylor expanded in ky around 0
pow2N/A
sqr-sin-a-revN/A
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f6463.8
lift-*.f64N/A
count-2-revN/A
lift-+.f6463.8
Applied rewrites63.8%
if 0.69999999999999996 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 2Initial program 99.6%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.6
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6480.0
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6479.5
Applied rewrites79.5%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
sqr-sin-a-revN/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-fma.f6499.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.2
lift-*.f64N/A
count-2-revN/A
lower-+.f6499.2
Applied rewrites99.2%
Taylor expanded in kx around 0
lift-sin.f6478.7
Applied rewrites78.7%
if 2 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 2.6%
lift-+.f64N/A
+-commutativeN/A
lower-+.f642.6
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f642.6
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f642.6
Applied rewrites2.6%
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lower--.f642.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f642.6
lift-*.f64N/A
count-2-revN/A
lower-+.f642.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f642.6
lift-*.f64N/A
count-2-revN/A
lower-+.f642.6
Applied rewrites2.6%
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-+.f64N/A
count-2-revN/A
sqr-sin-a-revN/A
lift-sin.f64N/A
lift-sin.f64N/A
pow2N/A
pow-to-expN/A
lower-exp.f64N/A
lower-*.f64N/A
lower-log.f641.5
Applied rewrites1.5%
Taylor expanded in ky around 0
lift-sin.f6429.8
Applied rewrites29.8%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))))
(t_2 (cos (+ kx kx)))
(t_3 (cos (+ ky ky))))
(if (<= t_1 -0.99)
(* (/ (sin ky) (sqrt (fma kx kx (- 0.5 (* 0.5 t_3))))) (sin th))
(if (<= t_1 -0.4)
(/ (* th (sin ky)) (sqrt (- 0.5 (- (* t_3 0.5) (- 0.5 (* t_2 0.5))))))
(if (<= t_1 0.7)
(* (/ (sin ky) (sqrt (- 0.5 (* 0.5 t_2)))) (sin th))
(if (<= t_1 2.0) (sin th) (* (/ (sin ky) (sin kx)) (sin th))))))))
double code(double kx, double ky, double th) {
double t_1 = sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)));
double t_2 = cos((kx + kx));
double t_3 = cos((ky + ky));
double tmp;
if (t_1 <= -0.99) {
tmp = (sin(ky) / sqrt(fma(kx, kx, (0.5 - (0.5 * t_3))))) * sin(th);
} else if (t_1 <= -0.4) {
tmp = (th * sin(ky)) / sqrt((0.5 - ((t_3 * 0.5) - (0.5 - (t_2 * 0.5)))));
} else if (t_1 <= 0.7) {
tmp = (sin(ky) / sqrt((0.5 - (0.5 * t_2)))) * sin(th);
} else if (t_1 <= 2.0) {
tmp = sin(th);
} else {
tmp = (sin(ky) / sin(kx)) * sin(th);
}
return tmp;
}
function code(kx, ky, th) t_1 = Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) t_2 = cos(Float64(kx + kx)) t_3 = cos(Float64(ky + ky)) tmp = 0.0 if (t_1 <= -0.99) tmp = Float64(Float64(sin(ky) / sqrt(fma(kx, kx, Float64(0.5 - Float64(0.5 * t_3))))) * sin(th)); elseif (t_1 <= -0.4) tmp = Float64(Float64(th * sin(ky)) / sqrt(Float64(0.5 - Float64(Float64(t_3 * 0.5) - Float64(0.5 - Float64(t_2 * 0.5)))))); elseif (t_1 <= 0.7) tmp = Float64(Float64(sin(ky) / sqrt(Float64(0.5 - Float64(0.5 * t_2)))) * sin(th)); elseif (t_1 <= 2.0) tmp = sin(th); else tmp = Float64(Float64(sin(ky) / sin(kx)) * sin(th)); end return tmp end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Cos[N[(ky + ky), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$1, -0.99], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(kx * kx + N[(0.5 - N[(0.5 * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -0.4], N[(N[(th * N[Sin[ky], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(0.5 - N[(N[(t$95$3 * 0.5), $MachinePrecision] - N[(0.5 - N[(t$95$2 * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.7], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(0.5 - N[(0.5 * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2.0], N[Sin[th], $MachinePrecision], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\
t_2 := \cos \left(kx + kx\right)\\
t_3 := \cos \left(ky + ky\right)\\
\mathbf{if}\;t\_1 \leq -0.99:\\
\;\;\;\;\frac{\sin ky}{\sqrt{\mathsf{fma}\left(kx, kx, 0.5 - 0.5 \cdot t\_3\right)}} \cdot \sin th\\
\mathbf{elif}\;t\_1 \leq -0.4:\\
\;\;\;\;\frac{th \cdot \sin ky}{\sqrt{0.5 - \left(t\_3 \cdot 0.5 - \left(0.5 - t\_2 \cdot 0.5\right)\right)}}\\
\mathbf{elif}\;t\_1 \leq 0.7:\\
\;\;\;\;\frac{\sin ky}{\sqrt{0.5 - 0.5 \cdot t\_2}} \cdot \sin th\\
\mathbf{elif}\;t\_1 \leq 2:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\sin kx} \cdot \sin th\\
\end{array}
\end{array}
if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.98999999999999999Initial program 86.2%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6486.2
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6465.3
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6464.9
Applied rewrites64.9%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
sqr-sin-a-revN/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-fma.f6486.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6486.0
lift-*.f64N/A
count-2-revN/A
lower-+.f6486.0
Applied rewrites86.0%
Taylor expanded in kx around 0
unpow2N/A
pow2N/A
sqr-sin-a-revN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f6462.7
lift-*.f64N/A
count-2-revN/A
lift-+.f6462.7
Applied rewrites62.7%
if -0.98999999999999999 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.40000000000000002Initial program 99.3%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.3
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.3
Applied rewrites99.3%
lift-hypot.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-a-revN/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-a-revN/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift--.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+l-N/A
Applied rewrites98.9%
Taylor expanded in th around 0
Applied rewrites51.0%
if -0.40000000000000002 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.69999999999999996Initial program 99.2%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.2
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6499.0
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6478.4
Applied rewrites78.4%
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lower--.f6478.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6478.4
lift-*.f64N/A
count-2-revN/A
lower-+.f6478.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6478.4
lift-*.f64N/A
count-2-revN/A
lower-+.f6478.4
Applied rewrites78.4%
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-+.f64N/A
count-2-revN/A
sqr-sin-a-revN/A
lift-sin.f64N/A
lift-sin.f64N/A
pow2N/A
pow-to-expN/A
lower-exp.f64N/A
lower-*.f64N/A
lower-log.f6439.5
Applied rewrites39.5%
Taylor expanded in ky around 0
pow2N/A
sqr-sin-a-revN/A
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f6463.8
lift-*.f64N/A
count-2-revN/A
lift-+.f6463.8
Applied rewrites63.8%
if 0.69999999999999996 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 2Initial program 99.6%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.6
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6480.0
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6479.5
Applied rewrites79.5%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
sqr-sin-a-revN/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-fma.f6499.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.2
lift-*.f64N/A
count-2-revN/A
lower-+.f6499.2
Applied rewrites99.2%
Taylor expanded in kx around 0
lift-sin.f6478.7
Applied rewrites78.7%
if 2 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 2.6%
lift-+.f64N/A
+-commutativeN/A
lower-+.f642.6
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f642.6
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f642.6
Applied rewrites2.6%
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lower--.f642.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f642.6
lift-*.f64N/A
count-2-revN/A
lower-+.f642.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f642.6
lift-*.f64N/A
count-2-revN/A
lower-+.f642.6
Applied rewrites2.6%
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-+.f64N/A
count-2-revN/A
sqr-sin-a-revN/A
lift-sin.f64N/A
lift-sin.f64N/A
pow2N/A
pow-to-expN/A
lower-exp.f64N/A
lower-*.f64N/A
lower-log.f641.5
Applied rewrites1.5%
Taylor expanded in ky around 0
lift-sin.f6429.8
Applied rewrites29.8%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))))
(t_2 (cos (+ kx kx)))
(t_3 (cos (+ ky ky))))
(if (<= t_1 -0.99)
(* (/ (sin ky) (sqrt (fma kx kx (- 0.5 (* 0.5 t_3))))) (sin th))
(if (<= t_1 -0.4)
(* (* th (sin ky)) (/ 1.0 (sqrt (- 1.0 (* 0.5 (+ t_3 t_2))))))
(if (<= t_1 0.7)
(* (/ (sin ky) (sqrt (- 0.5 (* 0.5 t_2)))) (sin th))
(if (<= t_1 2.0) (sin th) (* (/ (sin ky) (sin kx)) (sin th))))))))
double code(double kx, double ky, double th) {
double t_1 = sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)));
double t_2 = cos((kx + kx));
double t_3 = cos((ky + ky));
double tmp;
if (t_1 <= -0.99) {
tmp = (sin(ky) / sqrt(fma(kx, kx, (0.5 - (0.5 * t_3))))) * sin(th);
} else if (t_1 <= -0.4) {
tmp = (th * sin(ky)) * (1.0 / sqrt((1.0 - (0.5 * (t_3 + t_2)))));
} else if (t_1 <= 0.7) {
tmp = (sin(ky) / sqrt((0.5 - (0.5 * t_2)))) * sin(th);
} else if (t_1 <= 2.0) {
tmp = sin(th);
} else {
tmp = (sin(ky) / sin(kx)) * sin(th);
}
return tmp;
}
function code(kx, ky, th) t_1 = Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) t_2 = cos(Float64(kx + kx)) t_3 = cos(Float64(ky + ky)) tmp = 0.0 if (t_1 <= -0.99) tmp = Float64(Float64(sin(ky) / sqrt(fma(kx, kx, Float64(0.5 - Float64(0.5 * t_3))))) * sin(th)); elseif (t_1 <= -0.4) tmp = Float64(Float64(th * sin(ky)) * Float64(1.0 / sqrt(Float64(1.0 - Float64(0.5 * Float64(t_3 + t_2)))))); elseif (t_1 <= 0.7) tmp = Float64(Float64(sin(ky) / sqrt(Float64(0.5 - Float64(0.5 * t_2)))) * sin(th)); elseif (t_1 <= 2.0) tmp = sin(th); else tmp = Float64(Float64(sin(ky) / sin(kx)) * sin(th)); end return tmp end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Cos[N[(ky + ky), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$1, -0.99], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(kx * kx + N[(0.5 - N[(0.5 * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -0.4], N[(N[(th * N[Sin[ky], $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[Sqrt[N[(1.0 - N[(0.5 * N[(t$95$3 + t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.7], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(0.5 - N[(0.5 * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2.0], N[Sin[th], $MachinePrecision], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\
t_2 := \cos \left(kx + kx\right)\\
t_3 := \cos \left(ky + ky\right)\\
\mathbf{if}\;t\_1 \leq -0.99:\\
\;\;\;\;\frac{\sin ky}{\sqrt{\mathsf{fma}\left(kx, kx, 0.5 - 0.5 \cdot t\_3\right)}} \cdot \sin th\\
\mathbf{elif}\;t\_1 \leq -0.4:\\
\;\;\;\;\left(th \cdot \sin ky\right) \cdot \frac{1}{\sqrt{1 - 0.5 \cdot \left(t\_3 + t\_2\right)}}\\
\mathbf{elif}\;t\_1 \leq 0.7:\\
\;\;\;\;\frac{\sin ky}{\sqrt{0.5 - 0.5 \cdot t\_2}} \cdot \sin th\\
\mathbf{elif}\;t\_1 \leq 2:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\sin kx} \cdot \sin th\\
\end{array}
\end{array}
if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.98999999999999999Initial program 86.2%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6486.2
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6465.3
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6464.9
Applied rewrites64.9%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
sqr-sin-a-revN/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-fma.f6486.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6486.0
lift-*.f64N/A
count-2-revN/A
lower-+.f6486.0
Applied rewrites86.0%
Taylor expanded in kx around 0
unpow2N/A
pow2N/A
sqr-sin-a-revN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f6462.7
lift-*.f64N/A
count-2-revN/A
lift-+.f6462.7
Applied rewrites62.7%
if -0.98999999999999999 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.40000000000000002Initial program 99.3%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.3
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.3
Applied rewrites99.3%
lift-hypot.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-a-revN/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-a-revN/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift--.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+l-N/A
Applied rewrites98.9%
Taylor expanded in th around 0
lower-*.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower--.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
Applied rewrites50.9%
if -0.40000000000000002 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.69999999999999996Initial program 99.2%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.2
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6499.0
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6478.4
Applied rewrites78.4%
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lower--.f6478.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6478.4
lift-*.f64N/A
count-2-revN/A
lower-+.f6478.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6478.4
lift-*.f64N/A
count-2-revN/A
lower-+.f6478.4
Applied rewrites78.4%
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-+.f64N/A
count-2-revN/A
sqr-sin-a-revN/A
lift-sin.f64N/A
lift-sin.f64N/A
pow2N/A
pow-to-expN/A
lower-exp.f64N/A
lower-*.f64N/A
lower-log.f6439.5
Applied rewrites39.5%
Taylor expanded in ky around 0
pow2N/A
sqr-sin-a-revN/A
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f6463.8
lift-*.f64N/A
count-2-revN/A
lift-+.f6463.8
Applied rewrites63.8%
if 0.69999999999999996 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 2Initial program 99.6%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.6
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6480.0
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6479.5
Applied rewrites79.5%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
sqr-sin-a-revN/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-fma.f6499.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.2
lift-*.f64N/A
count-2-revN/A
lower-+.f6499.2
Applied rewrites99.2%
Taylor expanded in kx around 0
lift-sin.f6478.7
Applied rewrites78.7%
if 2 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 2.6%
lift-+.f64N/A
+-commutativeN/A
lower-+.f642.6
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f642.6
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f642.6
Applied rewrites2.6%
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lower--.f642.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f642.6
lift-*.f64N/A
count-2-revN/A
lower-+.f642.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f642.6
lift-*.f64N/A
count-2-revN/A
lower-+.f642.6
Applied rewrites2.6%
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-+.f64N/A
count-2-revN/A
sqr-sin-a-revN/A
lift-sin.f64N/A
lift-sin.f64N/A
pow2N/A
pow-to-expN/A
lower-exp.f64N/A
lower-*.f64N/A
lower-log.f641.5
Applied rewrites1.5%
Taylor expanded in ky around 0
lift-sin.f6429.8
Applied rewrites29.8%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))))))
(if (<= t_1 -0.99)
(*
(/ (sin ky) (sqrt (fma kx kx (- 0.5 (* 0.5 (cos (+ ky ky)))))))
(sin th))
(if (<= t_1 -0.4)
(* (* th (sin ky)) (/ 1.0 (hypot (sin kx) (sin ky))))
(if (<= t_1 0.7)
(* (/ (sin ky) (sqrt (- 0.5 (* 0.5 (cos (+ kx kx)))))) (sin th))
(if (<= t_1 2.0) (sin th) (* (/ (sin ky) (sin kx)) (sin th))))))))
double code(double kx, double ky, double th) {
double t_1 = sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)));
double tmp;
if (t_1 <= -0.99) {
tmp = (sin(ky) / sqrt(fma(kx, kx, (0.5 - (0.5 * cos((ky + ky))))))) * sin(th);
} else if (t_1 <= -0.4) {
tmp = (th * sin(ky)) * (1.0 / hypot(sin(kx), sin(ky)));
} else if (t_1 <= 0.7) {
tmp = (sin(ky) / sqrt((0.5 - (0.5 * cos((kx + kx)))))) * sin(th);
} else if (t_1 <= 2.0) {
tmp = sin(th);
} else {
tmp = (sin(ky) / sin(kx)) * sin(th);
}
return tmp;
}
function code(kx, ky, th) t_1 = Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) tmp = 0.0 if (t_1 <= -0.99) tmp = Float64(Float64(sin(ky) / sqrt(fma(kx, kx, Float64(0.5 - Float64(0.5 * cos(Float64(ky + ky))))))) * sin(th)); elseif (t_1 <= -0.4) tmp = Float64(Float64(th * sin(ky)) * Float64(1.0 / hypot(sin(kx), sin(ky)))); elseif (t_1 <= 0.7) tmp = Float64(Float64(sin(ky) / sqrt(Float64(0.5 - Float64(0.5 * cos(Float64(kx + kx)))))) * sin(th)); elseif (t_1 <= 2.0) tmp = sin(th); else tmp = Float64(Float64(sin(ky) / sin(kx)) * sin(th)); end return tmp end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -0.99], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(kx * kx + N[(0.5 - N[(0.5 * N[Cos[N[(ky + ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -0.4], N[(N[(th * N[Sin[ky], $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.7], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(0.5 - N[(0.5 * N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2.0], N[Sin[th], $MachinePrecision], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\
\mathbf{if}\;t\_1 \leq -0.99:\\
\;\;\;\;\frac{\sin ky}{\sqrt{\mathsf{fma}\left(kx, kx, 0.5 - 0.5 \cdot \cos \left(ky + ky\right)\right)}} \cdot \sin th\\
\mathbf{elif}\;t\_1 \leq -0.4:\\
\;\;\;\;\left(th \cdot \sin ky\right) \cdot \frac{1}{\mathsf{hypot}\left(\sin kx, \sin ky\right)}\\
\mathbf{elif}\;t\_1 \leq 0.7:\\
\;\;\;\;\frac{\sin ky}{\sqrt{0.5 - 0.5 \cdot \cos \left(kx + kx\right)}} \cdot \sin th\\
\mathbf{elif}\;t\_1 \leq 2:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\sin kx} \cdot \sin th\\
\end{array}
\end{array}
if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.98999999999999999Initial program 86.2%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6486.2
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6465.3
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6464.9
Applied rewrites64.9%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
sqr-sin-a-revN/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-fma.f6486.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6486.0
lift-*.f64N/A
count-2-revN/A
lower-+.f6486.0
Applied rewrites86.0%
Taylor expanded in kx around 0
unpow2N/A
pow2N/A
sqr-sin-a-revN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f6462.7
lift-*.f64N/A
count-2-revN/A
lift-+.f6462.7
Applied rewrites62.7%
if -0.98999999999999999 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.40000000000000002Initial program 99.3%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.3
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6499.0
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6499.0
Applied rewrites99.0%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
sqr-sin-a-revN/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-fma.f6499.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.1
lift-*.f64N/A
count-2-revN/A
lower-+.f6499.1
Applied rewrites99.1%
Taylor expanded in th around 0
lower-*.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
sqrt-divN/A
metadata-evalN/A
pow1/2N/A
pow2N/A
sqr-sin-a-revN/A
+-commutativeN/A
associate-+r-N/A
metadata-evalN/A
Applied rewrites51.1%
if -0.40000000000000002 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.69999999999999996Initial program 99.2%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.2
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6499.0
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6478.4
Applied rewrites78.4%
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lower--.f6478.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6478.4
lift-*.f64N/A
count-2-revN/A
lower-+.f6478.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6478.4
lift-*.f64N/A
count-2-revN/A
lower-+.f6478.4
Applied rewrites78.4%
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-+.f64N/A
count-2-revN/A
sqr-sin-a-revN/A
lift-sin.f64N/A
lift-sin.f64N/A
pow2N/A
pow-to-expN/A
lower-exp.f64N/A
lower-*.f64N/A
lower-log.f6439.5
Applied rewrites39.5%
Taylor expanded in ky around 0
pow2N/A
sqr-sin-a-revN/A
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f6463.8
lift-*.f64N/A
count-2-revN/A
lift-+.f6463.8
Applied rewrites63.8%
if 0.69999999999999996 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 2Initial program 99.6%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.6
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6480.0
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6479.5
Applied rewrites79.5%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
sqr-sin-a-revN/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-fma.f6499.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.2
lift-*.f64N/A
count-2-revN/A
lower-+.f6499.2
Applied rewrites99.2%
Taylor expanded in kx around 0
lift-sin.f6478.7
Applied rewrites78.7%
if 2 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 2.6%
lift-+.f64N/A
+-commutativeN/A
lower-+.f642.6
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f642.6
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f642.6
Applied rewrites2.6%
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lower--.f642.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f642.6
lift-*.f64N/A
count-2-revN/A
lower-+.f642.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f642.6
lift-*.f64N/A
count-2-revN/A
lower-+.f642.6
Applied rewrites2.6%
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-+.f64N/A
count-2-revN/A
sqr-sin-a-revN/A
lift-sin.f64N/A
lift-sin.f64N/A
pow2N/A
pow-to-expN/A
lower-exp.f64N/A
lower-*.f64N/A
lower-log.f641.5
Applied rewrites1.5%
Taylor expanded in ky around 0
lift-sin.f6429.8
Applied rewrites29.8%
(FPCore (kx ky th) :precision binary64 (if (<= kx 0.0115) (* (/ (sin ky) (sqrt (fma (sin ky) (sin ky) (* kx kx)))) (sin th)) (/ (* (sin th) (sin ky)) (sqrt (- 0.5 (* 0.5 (cos (+ kx kx))))))))
double code(double kx, double ky, double th) {
double tmp;
if (kx <= 0.0115) {
tmp = (sin(ky) / sqrt(fma(sin(ky), sin(ky), (kx * kx)))) * sin(th);
} else {
tmp = (sin(th) * sin(ky)) / sqrt((0.5 - (0.5 * cos((kx + kx)))));
}
return tmp;
}
function code(kx, ky, th) tmp = 0.0 if (kx <= 0.0115) tmp = Float64(Float64(sin(ky) / sqrt(fma(sin(ky), sin(ky), Float64(kx * kx)))) * sin(th)); else tmp = Float64(Float64(sin(th) * sin(ky)) / sqrt(Float64(0.5 - Float64(0.5 * cos(Float64(kx + kx)))))); end return tmp end
code[kx_, ky_, th_] := If[LessEqual[kx, 0.0115], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Sin[ky], $MachinePrecision] * N[Sin[ky], $MachinePrecision] + N[(kx * kx), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[th], $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(0.5 - N[(0.5 * N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;kx \leq 0.0115:\\
\;\;\;\;\frac{\sin ky}{\sqrt{\mathsf{fma}\left(\sin ky, \sin ky, kx \cdot kx\right)}} \cdot \sin th\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin th \cdot \sin ky}{\sqrt{0.5 - 0.5 \cdot \cos \left(kx + kx\right)}}\\
\end{array}
\end{array}
if kx < 0.0115Initial program 92.3%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6492.3
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6479.8
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6467.7
Applied rewrites67.7%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
sqr-sin-a-revN/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-fma.f6480.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6480.3
lift-*.f64N/A
count-2-revN/A
lower-+.f6480.3
Applied rewrites80.3%
Taylor expanded in kx around 0
unpow2N/A
lower-*.f6465.4
Applied rewrites65.4%
if 0.0115 < kx Initial program 99.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.4
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.5
Applied rewrites99.5%
lift-hypot.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-a-revN/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-a-revN/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift--.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+l-N/A
Applied rewrites99.1%
Taylor expanded in ky around 0
lower-*.f64N/A
lift-cos.f64N/A
count-2-revN/A
lift-+.f6460.0
Applied rewrites60.0%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))))))
(if (<= t_1 -0.7)
(* (/ (sin ky) (sqrt (- 0.5 (* 0.5 (cos (+ ky ky)))))) (sin th))
(if (<= t_1 0.7)
(* (/ (sin ky) (sqrt (- 0.5 (* 0.5 (cos (+ kx kx)))))) (sin th))
(if (<= t_1 2.0) (sin th) (* (/ (sin ky) (sin kx)) (sin th)))))))
double code(double kx, double ky, double th) {
double t_1 = sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)));
double tmp;
if (t_1 <= -0.7) {
tmp = (sin(ky) / sqrt((0.5 - (0.5 * cos((ky + ky)))))) * sin(th);
} else if (t_1 <= 0.7) {
tmp = (sin(ky) / sqrt((0.5 - (0.5 * cos((kx + kx)))))) * sin(th);
} else if (t_1 <= 2.0) {
tmp = sin(th);
} else {
tmp = (sin(ky) / sin(kx)) * sin(th);
}
return tmp;
}
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(kx, ky, th)
use fmin_fmax_functions
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: t_1
real(8) :: tmp
t_1 = sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))
if (t_1 <= (-0.7d0)) then
tmp = (sin(ky) / sqrt((0.5d0 - (0.5d0 * cos((ky + ky)))))) * sin(th)
else if (t_1 <= 0.7d0) then
tmp = (sin(ky) / sqrt((0.5d0 - (0.5d0 * cos((kx + kx)))))) * sin(th)
else if (t_1 <= 2.0d0) then
tmp = sin(th)
else
tmp = (sin(ky) / sin(kx)) * sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double t_1 = Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)));
double tmp;
if (t_1 <= -0.7) {
tmp = (Math.sin(ky) / Math.sqrt((0.5 - (0.5 * Math.cos((ky + ky)))))) * Math.sin(th);
} else if (t_1 <= 0.7) {
tmp = (Math.sin(ky) / Math.sqrt((0.5 - (0.5 * Math.cos((kx + kx)))))) * Math.sin(th);
} else if (t_1 <= 2.0) {
tmp = Math.sin(th);
} else {
tmp = (Math.sin(ky) / Math.sin(kx)) * Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): t_1 = math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0))) tmp = 0 if t_1 <= -0.7: tmp = (math.sin(ky) / math.sqrt((0.5 - (0.5 * math.cos((ky + ky)))))) * math.sin(th) elif t_1 <= 0.7: tmp = (math.sin(ky) / math.sqrt((0.5 - (0.5 * math.cos((kx + kx)))))) * math.sin(th) elif t_1 <= 2.0: tmp = math.sin(th) else: tmp = (math.sin(ky) / math.sin(kx)) * math.sin(th) return tmp
function code(kx, ky, th) t_1 = Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) tmp = 0.0 if (t_1 <= -0.7) tmp = Float64(Float64(sin(ky) / sqrt(Float64(0.5 - Float64(0.5 * cos(Float64(ky + ky)))))) * sin(th)); elseif (t_1 <= 0.7) tmp = Float64(Float64(sin(ky) / sqrt(Float64(0.5 - Float64(0.5 * cos(Float64(kx + kx)))))) * sin(th)); elseif (t_1 <= 2.0) tmp = sin(th); else tmp = Float64(Float64(sin(ky) / sin(kx)) * sin(th)); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))); tmp = 0.0; if (t_1 <= -0.7) tmp = (sin(ky) / sqrt((0.5 - (0.5 * cos((ky + ky)))))) * sin(th); elseif (t_1 <= 0.7) tmp = (sin(ky) / sqrt((0.5 - (0.5 * cos((kx + kx)))))) * sin(th); elseif (t_1 <= 2.0) tmp = sin(th); else tmp = (sin(ky) / sin(kx)) * sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -0.7], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(0.5 - N[(0.5 * N[Cos[N[(ky + ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.7], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(0.5 - N[(0.5 * N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2.0], N[Sin[th], $MachinePrecision], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\
\mathbf{if}\;t\_1 \leq -0.7:\\
\;\;\;\;\frac{\sin ky}{\sqrt{0.5 - 0.5 \cdot \cos \left(ky + ky\right)}} \cdot \sin th\\
\mathbf{elif}\;t\_1 \leq 0.7:\\
\;\;\;\;\frac{\sin ky}{\sqrt{0.5 - 0.5 \cdot \cos \left(kx + kx\right)}} \cdot \sin th\\
\mathbf{elif}\;t\_1 \leq 2:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\sin kx} \cdot \sin th\\
\end{array}
\end{array}
if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.69999999999999996Initial program 89.3%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6489.3
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6473.2
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6472.9
Applied rewrites72.9%
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lower--.f6472.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6472.9
lift-*.f64N/A
count-2-revN/A
lower-+.f6472.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6472.9
lift-*.f64N/A
count-2-revN/A
lower-+.f6472.9
Applied rewrites72.9%
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-+.f64N/A
count-2-revN/A
sqr-sin-a-revN/A
lift-sin.f64N/A
lift-sin.f64N/A
pow2N/A
pow-to-expN/A
lower-exp.f64N/A
lower-*.f64N/A
lower-log.f6436.0
Applied rewrites36.0%
Taylor expanded in kx around 0
lower-*.f64N/A
lift-cos.f64N/A
count-2-revN/A
lift-+.f6453.2
Applied rewrites53.2%
if -0.69999999999999996 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.69999999999999996Initial program 99.2%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.2
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6499.0
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6480.0
Applied rewrites80.0%
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lower--.f6480.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6480.0
lift-*.f64N/A
count-2-revN/A
lower-+.f6480.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6480.0
lift-*.f64N/A
count-2-revN/A
lower-+.f6480.0
Applied rewrites80.0%
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-+.f64N/A
count-2-revN/A
sqr-sin-a-revN/A
lift-sin.f64N/A
lift-sin.f64N/A
pow2N/A
pow-to-expN/A
lower-exp.f64N/A
lower-*.f64N/A
lower-log.f6440.5
Applied rewrites40.5%
Taylor expanded in ky around 0
pow2N/A
sqr-sin-a-revN/A
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f6460.4
lift-*.f64N/A
count-2-revN/A
lift-+.f6460.4
Applied rewrites60.4%
if 0.69999999999999996 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 2Initial program 99.6%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.6
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6480.0
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6479.5
Applied rewrites79.5%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
sqr-sin-a-revN/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-fma.f6499.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.2
lift-*.f64N/A
count-2-revN/A
lower-+.f6499.2
Applied rewrites99.2%
Taylor expanded in kx around 0
lift-sin.f6478.7
Applied rewrites78.7%
if 2 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 2.6%
lift-+.f64N/A
+-commutativeN/A
lower-+.f642.6
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f642.6
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f642.6
Applied rewrites2.6%
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lower--.f642.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f642.6
lift-*.f64N/A
count-2-revN/A
lower-+.f642.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f642.6
lift-*.f64N/A
count-2-revN/A
lower-+.f642.6
Applied rewrites2.6%
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-+.f64N/A
count-2-revN/A
sqr-sin-a-revN/A
lift-sin.f64N/A
lift-sin.f64N/A
pow2N/A
pow-to-expN/A
lower-exp.f64N/A
lower-*.f64N/A
lower-log.f641.5
Applied rewrites1.5%
Taylor expanded in ky around 0
lift-sin.f6429.8
Applied rewrites29.8%
(FPCore (kx ky th)
:precision binary64
(if (<= ky 1.05e-169)
(* (/ ky (sin kx)) (sin th))
(if (<= ky 0.009)
(*
(/ (sin ky) (sqrt (fma ky ky (- 0.5 (* 0.5 (cos (+ kx kx)))))))
(sin th))
(* (/ (sin ky) (sqrt (- 0.5 (* 0.5 (cos (+ ky ky)))))) (sin th)))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 1.05e-169) {
tmp = (ky / sin(kx)) * sin(th);
} else if (ky <= 0.009) {
tmp = (sin(ky) / sqrt(fma(ky, ky, (0.5 - (0.5 * cos((kx + kx))))))) * sin(th);
} else {
tmp = (sin(ky) / sqrt((0.5 - (0.5 * cos((ky + ky)))))) * sin(th);
}
return tmp;
}
function code(kx, ky, th) tmp = 0.0 if (ky <= 1.05e-169) tmp = Float64(Float64(ky / sin(kx)) * sin(th)); elseif (ky <= 0.009) tmp = Float64(Float64(sin(ky) / sqrt(fma(ky, ky, Float64(0.5 - Float64(0.5 * cos(Float64(kx + kx))))))) * sin(th)); else tmp = Float64(Float64(sin(ky) / sqrt(Float64(0.5 - Float64(0.5 * cos(Float64(ky + ky)))))) * sin(th)); end return tmp end
code[kx_, ky_, th_] := If[LessEqual[ky, 1.05e-169], N[(N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[ky, 0.009], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(ky * ky + N[(0.5 - N[(0.5 * N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(0.5 - N[(0.5 * N[Cos[N[(ky + ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 1.05 \cdot 10^{-169}:\\
\;\;\;\;\frac{ky}{\sin kx} \cdot \sin th\\
\mathbf{elif}\;ky \leq 0.009:\\
\;\;\;\;\frac{\sin ky}{\sqrt{\mathsf{fma}\left(ky, ky, 0.5 - 0.5 \cdot \cos \left(kx + kx\right)\right)}} \cdot \sin th\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\sqrt{0.5 - 0.5 \cdot \cos \left(ky + ky\right)}} \cdot \sin th\\
\end{array}
\end{array}
if ky < 1.05e-169Initial program 90.7%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6490.7
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6483.3
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6471.2
Applied rewrites71.2%
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lower--.f6471.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6471.2
lift-*.f64N/A
count-2-revN/A
lower-+.f6471.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6471.2
lift-*.f64N/A
count-2-revN/A
lower-+.f6471.2
Applied rewrites71.2%
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-+.f64N/A
count-2-revN/A
sqr-sin-a-revN/A
lift-sin.f64N/A
lift-sin.f64N/A
pow2N/A
pow-to-expN/A
lower-exp.f64N/A
lower-*.f64N/A
lower-log.f6434.8
Applied rewrites34.8%
Taylor expanded in ky around 0
lower-/.f64N/A
lift-sin.f6431.0
Applied rewrites31.0%
if 1.05e-169 < ky < 0.00899999999999999932Initial program 98.6%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6498.6
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6466.3
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6453.4
Applied rewrites53.4%
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lower--.f6453.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6453.4
lift-*.f64N/A
count-2-revN/A
lower-+.f6453.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6453.4
lift-*.f64N/A
count-2-revN/A
lower-+.f6453.4
Applied rewrites53.4%
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-+.f64N/A
count-2-revN/A
sqr-sin-a-revN/A
lift-sin.f64N/A
lift-sin.f64N/A
pow2N/A
pow-to-expN/A
lower-exp.f64N/A
lower-*.f64N/A
lower-log.f6429.7
Applied rewrites29.7%
Taylor expanded in ky around 0
unpow2N/A
pow2N/A
sqr-sin-a-revN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f6485.5
lift-*.f64N/A
count-2-revN/A
lift-+.f6485.5
Applied rewrites85.5%
if 0.00899999999999999932 < ky Initial program 99.6%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.6
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6499.0
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6498.9
Applied rewrites98.9%
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lower--.f6498.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6498.9
lift-*.f64N/A
count-2-revN/A
lower-+.f6498.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6498.9
lift-*.f64N/A
count-2-revN/A
lower-+.f6498.9
Applied rewrites98.9%
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-+.f64N/A
count-2-revN/A
sqr-sin-a-revN/A
lift-sin.f64N/A
lift-sin.f64N/A
pow2N/A
pow-to-expN/A
lower-exp.f64N/A
lower-*.f64N/A
lower-log.f6448.1
Applied rewrites48.1%
Taylor expanded in kx around 0
lower-*.f64N/A
lift-cos.f64N/A
count-2-revN/A
lift-+.f6459.5
Applied rewrites59.5%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))))))
(if (<= t_1 0.7)
(* (/ (sin ky) (sqrt (- 0.5 (* 0.5 (cos (+ kx kx)))))) (sin th))
(if (<= t_1 2.0) (sin th) (* (/ (sin ky) (sin kx)) (sin th))))))
double code(double kx, double ky, double th) {
double t_1 = sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)));
double tmp;
if (t_1 <= 0.7) {
tmp = (sin(ky) / sqrt((0.5 - (0.5 * cos((kx + kx)))))) * sin(th);
} else if (t_1 <= 2.0) {
tmp = sin(th);
} else {
tmp = (sin(ky) / sin(kx)) * sin(th);
}
return tmp;
}
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(kx, ky, th)
use fmin_fmax_functions
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: t_1
real(8) :: tmp
t_1 = sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))
if (t_1 <= 0.7d0) then
tmp = (sin(ky) / sqrt((0.5d0 - (0.5d0 * cos((kx + kx)))))) * sin(th)
else if (t_1 <= 2.0d0) then
tmp = sin(th)
else
tmp = (sin(ky) / sin(kx)) * sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double t_1 = Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)));
double tmp;
if (t_1 <= 0.7) {
tmp = (Math.sin(ky) / Math.sqrt((0.5 - (0.5 * Math.cos((kx + kx)))))) * Math.sin(th);
} else if (t_1 <= 2.0) {
tmp = Math.sin(th);
} else {
tmp = (Math.sin(ky) / Math.sin(kx)) * Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): t_1 = math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0))) tmp = 0 if t_1 <= 0.7: tmp = (math.sin(ky) / math.sqrt((0.5 - (0.5 * math.cos((kx + kx)))))) * math.sin(th) elif t_1 <= 2.0: tmp = math.sin(th) else: tmp = (math.sin(ky) / math.sin(kx)) * math.sin(th) return tmp
function code(kx, ky, th) t_1 = Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) tmp = 0.0 if (t_1 <= 0.7) tmp = Float64(Float64(sin(ky) / sqrt(Float64(0.5 - Float64(0.5 * cos(Float64(kx + kx)))))) * sin(th)); elseif (t_1 <= 2.0) tmp = sin(th); else tmp = Float64(Float64(sin(ky) / sin(kx)) * sin(th)); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))); tmp = 0.0; if (t_1 <= 0.7) tmp = (sin(ky) / sqrt((0.5 - (0.5 * cos((kx + kx)))))) * sin(th); elseif (t_1 <= 2.0) tmp = sin(th); else tmp = (sin(ky) / sin(kx)) * sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 0.7], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(0.5 - N[(0.5 * N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2.0], N[Sin[th], $MachinePrecision], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\
\mathbf{if}\;t\_1 \leq 0.7:\\
\;\;\;\;\frac{\sin ky}{\sqrt{0.5 - 0.5 \cdot \cos \left(kx + kx\right)}} \cdot \sin th\\
\mathbf{elif}\;t\_1 \leq 2:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\sin kx} \cdot \sin th\\
\end{array}
\end{array}
if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.69999999999999996Initial program 95.5%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6495.5
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6489.4
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6477.4
Applied rewrites77.4%
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lower--.f6477.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6477.4
lift-*.f64N/A
count-2-revN/A
lower-+.f6477.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6477.4
lift-*.f64N/A
count-2-revN/A
lower-+.f6477.4
Applied rewrites77.4%
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-+.f64N/A
count-2-revN/A
sqr-sin-a-revN/A
lift-sin.f64N/A
lift-sin.f64N/A
pow2N/A
pow-to-expN/A
lower-exp.f64N/A
lower-*.f64N/A
lower-log.f6438.8
Applied rewrites38.8%
Taylor expanded in ky around 0
pow2N/A
sqr-sin-a-revN/A
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f6440.6
lift-*.f64N/A
count-2-revN/A
lift-+.f6440.6
Applied rewrites40.6%
if 0.69999999999999996 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 2Initial program 99.6%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.6
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6480.0
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6479.5
Applied rewrites79.5%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
sqr-sin-a-revN/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-fma.f6499.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.2
lift-*.f64N/A
count-2-revN/A
lower-+.f6499.2
Applied rewrites99.2%
Taylor expanded in kx around 0
lift-sin.f6478.7
Applied rewrites78.7%
if 2 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 2.6%
lift-+.f64N/A
+-commutativeN/A
lower-+.f642.6
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f642.6
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f642.6
Applied rewrites2.6%
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lower--.f642.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f642.6
lift-*.f64N/A
count-2-revN/A
lower-+.f642.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f642.6
lift-*.f64N/A
count-2-revN/A
lower-+.f642.6
Applied rewrites2.6%
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-+.f64N/A
count-2-revN/A
sqr-sin-a-revN/A
lift-sin.f64N/A
lift-sin.f64N/A
pow2N/A
pow-to-expN/A
lower-exp.f64N/A
lower-*.f64N/A
lower-log.f641.5
Applied rewrites1.5%
Taylor expanded in ky around 0
lift-sin.f6429.8
Applied rewrites29.8%
(FPCore (kx ky th) :precision binary64 (if (<= (sin kx) -0.135) (* (* ky (/ 1.0 (sqrt (- 0.5 (* 0.5 (cos (+ kx kx))))))) (sin th)) (if (<= (sin kx) 5e-27) (sin th) (* (/ (sin ky) (sin kx)) (sin th)))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(kx) <= -0.135) {
tmp = (ky * (1.0 / sqrt((0.5 - (0.5 * cos((kx + kx))))))) * sin(th);
} else if (sin(kx) <= 5e-27) {
tmp = sin(th);
} else {
tmp = (sin(ky) / sin(kx)) * sin(th);
}
return tmp;
}
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(kx, ky, th)
use fmin_fmax_functions
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(kx) <= (-0.135d0)) then
tmp = (ky * (1.0d0 / sqrt((0.5d0 - (0.5d0 * cos((kx + kx))))))) * sin(th)
else if (sin(kx) <= 5d-27) then
tmp = sin(th)
else
tmp = (sin(ky) / sin(kx)) * sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(kx) <= -0.135) {
tmp = (ky * (1.0 / Math.sqrt((0.5 - (0.5 * Math.cos((kx + kx))))))) * Math.sin(th);
} else if (Math.sin(kx) <= 5e-27) {
tmp = Math.sin(th);
} else {
tmp = (Math.sin(ky) / Math.sin(kx)) * Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(kx) <= -0.135: tmp = (ky * (1.0 / math.sqrt((0.5 - (0.5 * math.cos((kx + kx))))))) * math.sin(th) elif math.sin(kx) <= 5e-27: tmp = math.sin(th) else: tmp = (math.sin(ky) / math.sin(kx)) * math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(kx) <= -0.135) tmp = Float64(Float64(ky * Float64(1.0 / sqrt(Float64(0.5 - Float64(0.5 * cos(Float64(kx + kx))))))) * sin(th)); elseif (sin(kx) <= 5e-27) tmp = sin(th); else tmp = Float64(Float64(sin(ky) / sin(kx)) * sin(th)); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(kx) <= -0.135) tmp = (ky * (1.0 / sqrt((0.5 - (0.5 * cos((kx + kx))))))) * sin(th); elseif (sin(kx) <= 5e-27) tmp = sin(th); else tmp = (sin(ky) / sin(kx)) * sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[kx], $MachinePrecision], -0.135], N[(N[(ky * N[(1.0 / N[Sqrt[N[(0.5 - N[(0.5 * N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 5e-27], N[Sin[th], $MachinePrecision], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin kx \leq -0.135:\\
\;\;\;\;\left(ky \cdot \frac{1}{\sqrt{0.5 - 0.5 \cdot \cos \left(kx + kx\right)}}\right) \cdot \sin th\\
\mathbf{elif}\;\sin kx \leq 5 \cdot 10^{-27}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\sin kx} \cdot \sin th\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.13500000000000001Initial program 99.4%
lift-sqrt.f64N/A
pow1/2N/A
sqr-powN/A
lower-*.f64N/A
Applied rewrites99.1%
Taylor expanded in ky around 0
lower-*.f64N/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f6450.0
lift-*.f64N/A
count-2-revN/A
lift-+.f6450.0
Applied rewrites50.0%
if -0.13500000000000001 < (sin.f64 kx) < 5.0000000000000002e-27Initial program 88.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6488.9
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6470.7
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6454.4
Applied rewrites54.4%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
sqr-sin-a-revN/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-fma.f6472.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6472.9
lift-*.f64N/A
count-2-revN/A
lower-+.f6472.9
Applied rewrites72.9%
Taylor expanded in kx around 0
lift-sin.f6438.8
Applied rewrites38.8%
if 5.0000000000000002e-27 < (sin.f64 kx) Initial program 99.4%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.4
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6499.2
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6496.1
Applied rewrites96.1%
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lower--.f6496.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6496.1
lift-*.f64N/A
count-2-revN/A
lower-+.f6496.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6496.1
lift-*.f64N/A
count-2-revN/A
lower-+.f6496.1
Applied rewrites96.1%
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-+.f64N/A
count-2-revN/A
sqr-sin-a-revN/A
lift-sin.f64N/A
lift-sin.f64N/A
pow2N/A
pow-to-expN/A
lower-exp.f64N/A
lower-*.f64N/A
lower-log.f6496.1
Applied rewrites96.1%
Taylor expanded in ky around 0
lift-sin.f6460.3
Applied rewrites60.3%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))))))
(if (<= t_1 5e-5)
(* (* ky (/ 1.0 (sqrt (- 0.5 (* 0.5 (cos (+ kx kx))))))) (sin th))
(if (<= t_1 2.0) (sin th) (* (/ ky (sin kx)) (sin th))))))
double code(double kx, double ky, double th) {
double t_1 = sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)));
double tmp;
if (t_1 <= 5e-5) {
tmp = (ky * (1.0 / sqrt((0.5 - (0.5 * cos((kx + kx))))))) * sin(th);
} else if (t_1 <= 2.0) {
tmp = sin(th);
} else {
tmp = (ky / sin(kx)) * sin(th);
}
return tmp;
}
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(kx, ky, th)
use fmin_fmax_functions
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: t_1
real(8) :: tmp
t_1 = sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))
if (t_1 <= 5d-5) then
tmp = (ky * (1.0d0 / sqrt((0.5d0 - (0.5d0 * cos((kx + kx))))))) * sin(th)
else if (t_1 <= 2.0d0) then
tmp = sin(th)
else
tmp = (ky / sin(kx)) * sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double t_1 = Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)));
double tmp;
if (t_1 <= 5e-5) {
tmp = (ky * (1.0 / Math.sqrt((0.5 - (0.5 * Math.cos((kx + kx))))))) * Math.sin(th);
} else if (t_1 <= 2.0) {
tmp = Math.sin(th);
} else {
tmp = (ky / Math.sin(kx)) * Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): t_1 = math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0))) tmp = 0 if t_1 <= 5e-5: tmp = (ky * (1.0 / math.sqrt((0.5 - (0.5 * math.cos((kx + kx))))))) * math.sin(th) elif t_1 <= 2.0: tmp = math.sin(th) else: tmp = (ky / math.sin(kx)) * math.sin(th) return tmp
function code(kx, ky, th) t_1 = Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) tmp = 0.0 if (t_1 <= 5e-5) tmp = Float64(Float64(ky * Float64(1.0 / sqrt(Float64(0.5 - Float64(0.5 * cos(Float64(kx + kx))))))) * sin(th)); elseif (t_1 <= 2.0) tmp = sin(th); else tmp = Float64(Float64(ky / sin(kx)) * sin(th)); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))); tmp = 0.0; if (t_1 <= 5e-5) tmp = (ky * (1.0 / sqrt((0.5 - (0.5 * cos((kx + kx))))))) * sin(th); elseif (t_1 <= 2.0) tmp = sin(th); else tmp = (ky / sin(kx)) * sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 5e-5], N[(N[(ky * N[(1.0 / N[Sqrt[N[(0.5 - N[(0.5 * N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2.0], N[Sin[th], $MachinePrecision], N[(N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\
\mathbf{if}\;t\_1 \leq 5 \cdot 10^{-5}:\\
\;\;\;\;\left(ky \cdot \frac{1}{\sqrt{0.5 - 0.5 \cdot \cos \left(kx + kx\right)}}\right) \cdot \sin th\\
\mathbf{elif}\;t\_1 \leq 2:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\frac{ky}{\sin kx} \cdot \sin th\\
\end{array}
\end{array}
if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 5.00000000000000024e-5Initial program 95.2%
lift-sqrt.f64N/A
pow1/2N/A
sqr-powN/A
lower-*.f64N/A
Applied rewrites75.3%
Taylor expanded in ky around 0
lower-*.f64N/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f6438.4
lift-*.f64N/A
count-2-revN/A
lift-+.f6438.4
Applied rewrites38.4%
if 5.00000000000000024e-5 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 2Initial program 99.5%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.5
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6483.7
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6483.3
Applied rewrites83.3%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
sqr-sin-a-revN/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-fma.f6499.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.1
lift-*.f64N/A
count-2-revN/A
lower-+.f6499.1
Applied rewrites99.1%
Taylor expanded in kx around 0
lift-sin.f6466.6
Applied rewrites66.6%
if 2 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 2.6%
lift-+.f64N/A
+-commutativeN/A
lower-+.f642.6
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f642.6
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f642.6
Applied rewrites2.6%
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lower--.f642.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f642.6
lift-*.f64N/A
count-2-revN/A
lower-+.f642.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f642.6
lift-*.f64N/A
count-2-revN/A
lower-+.f642.6
Applied rewrites2.6%
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-+.f64N/A
count-2-revN/A
sqr-sin-a-revN/A
lift-sin.f64N/A
lift-sin.f64N/A
pow2N/A
pow-to-expN/A
lower-exp.f64N/A
lower-*.f64N/A
lower-log.f641.5
Applied rewrites1.5%
Taylor expanded in ky around 0
lower-/.f64N/A
lift-sin.f6429.8
Applied rewrites29.8%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))))))
(if (<= t_1 5e-5)
(* (* ky (sin th)) (/ 1.0 (sqrt (- 0.5 (* 0.5 (cos (+ kx kx)))))))
(if (<= t_1 2.0) (sin th) (* (/ ky (sin kx)) (sin th))))))
double code(double kx, double ky, double th) {
double t_1 = sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)));
double tmp;
if (t_1 <= 5e-5) {
tmp = (ky * sin(th)) * (1.0 / sqrt((0.5 - (0.5 * cos((kx + kx))))));
} else if (t_1 <= 2.0) {
tmp = sin(th);
} else {
tmp = (ky / sin(kx)) * sin(th);
}
return tmp;
}
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(kx, ky, th)
use fmin_fmax_functions
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: t_1
real(8) :: tmp
t_1 = sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))
if (t_1 <= 5d-5) then
tmp = (ky * sin(th)) * (1.0d0 / sqrt((0.5d0 - (0.5d0 * cos((kx + kx))))))
else if (t_1 <= 2.0d0) then
tmp = sin(th)
else
tmp = (ky / sin(kx)) * sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double t_1 = Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)));
double tmp;
if (t_1 <= 5e-5) {
tmp = (ky * Math.sin(th)) * (1.0 / Math.sqrt((0.5 - (0.5 * Math.cos((kx + kx))))));
} else if (t_1 <= 2.0) {
tmp = Math.sin(th);
} else {
tmp = (ky / Math.sin(kx)) * Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): t_1 = math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0))) tmp = 0 if t_1 <= 5e-5: tmp = (ky * math.sin(th)) * (1.0 / math.sqrt((0.5 - (0.5 * math.cos((kx + kx)))))) elif t_1 <= 2.0: tmp = math.sin(th) else: tmp = (ky / math.sin(kx)) * math.sin(th) return tmp
function code(kx, ky, th) t_1 = Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) tmp = 0.0 if (t_1 <= 5e-5) tmp = Float64(Float64(ky * sin(th)) * Float64(1.0 / sqrt(Float64(0.5 - Float64(0.5 * cos(Float64(kx + kx))))))); elseif (t_1 <= 2.0) tmp = sin(th); else tmp = Float64(Float64(ky / sin(kx)) * sin(th)); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))); tmp = 0.0; if (t_1 <= 5e-5) tmp = (ky * sin(th)) * (1.0 / sqrt((0.5 - (0.5 * cos((kx + kx)))))); elseif (t_1 <= 2.0) tmp = sin(th); else tmp = (ky / sin(kx)) * sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 5e-5], N[(N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[Sqrt[N[(0.5 - N[(0.5 * N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2.0], N[Sin[th], $MachinePrecision], N[(N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\
\mathbf{if}\;t\_1 \leq 5 \cdot 10^{-5}:\\
\;\;\;\;\left(ky \cdot \sin th\right) \cdot \frac{1}{\sqrt{0.5 - 0.5 \cdot \cos \left(kx + kx\right)}}\\
\mathbf{elif}\;t\_1 \leq 2:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\frac{ky}{\sin kx} \cdot \sin th\\
\end{array}
\end{array}
if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 5.00000000000000024e-5Initial program 95.2%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.2
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6496.3
Applied rewrites96.3%
lift-hypot.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-a-revN/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-a-revN/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift--.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+l-N/A
Applied rewrites75.4%
Taylor expanded in ky around 0
lower-*.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f6438.3
lift-*.f64N/A
count-2-revN/A
lift-+.f6438.3
Applied rewrites38.3%
if 5.00000000000000024e-5 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 2Initial program 99.5%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.5
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6483.7
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6483.3
Applied rewrites83.3%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
sqr-sin-a-revN/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-fma.f6499.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.1
lift-*.f64N/A
count-2-revN/A
lower-+.f6499.1
Applied rewrites99.1%
Taylor expanded in kx around 0
lift-sin.f6466.6
Applied rewrites66.6%
if 2 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 2.6%
lift-+.f64N/A
+-commutativeN/A
lower-+.f642.6
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f642.6
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f642.6
Applied rewrites2.6%
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lower--.f642.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f642.6
lift-*.f64N/A
count-2-revN/A
lower-+.f642.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f642.6
lift-*.f64N/A
count-2-revN/A
lower-+.f642.6
Applied rewrites2.6%
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-+.f64N/A
count-2-revN/A
sqr-sin-a-revN/A
lift-sin.f64N/A
lift-sin.f64N/A
pow2N/A
pow-to-expN/A
lower-exp.f64N/A
lower-*.f64N/A
lower-log.f641.5
Applied rewrites1.5%
Taylor expanded in ky around 0
lower-/.f64N/A
lift-sin.f6429.8
Applied rewrites29.8%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (* (/ ky (sin kx)) (sin th)))
(t_2 (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))))))
(if (<= t_2 0.04) t_1 (if (<= t_2 2.0) (sin th) t_1))))
double code(double kx, double ky, double th) {
double t_1 = (ky / sin(kx)) * sin(th);
double t_2 = sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)));
double tmp;
if (t_2 <= 0.04) {
tmp = t_1;
} else if (t_2 <= 2.0) {
tmp = sin(th);
} else {
tmp = t_1;
}
return tmp;
}
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(kx, ky, th)
use fmin_fmax_functions
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = (ky / sin(kx)) * sin(th)
t_2 = sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))
if (t_2 <= 0.04d0) then
tmp = t_1
else if (t_2 <= 2.0d0) then
tmp = sin(th)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double t_1 = (ky / Math.sin(kx)) * Math.sin(th);
double t_2 = Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)));
double tmp;
if (t_2 <= 0.04) {
tmp = t_1;
} else if (t_2 <= 2.0) {
tmp = Math.sin(th);
} else {
tmp = t_1;
}
return tmp;
}
def code(kx, ky, th): t_1 = (ky / math.sin(kx)) * math.sin(th) t_2 = math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0))) tmp = 0 if t_2 <= 0.04: tmp = t_1 elif t_2 <= 2.0: tmp = math.sin(th) else: tmp = t_1 return tmp
function code(kx, ky, th) t_1 = Float64(Float64(ky / sin(kx)) * sin(th)) t_2 = Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) tmp = 0.0 if (t_2 <= 0.04) tmp = t_1; elseif (t_2 <= 2.0) tmp = sin(th); else tmp = t_1; end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = (ky / sin(kx)) * sin(th); t_2 = sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))); tmp = 0.0; if (t_2 <= 0.04) tmp = t_1; elseif (t_2 <= 2.0) tmp = sin(th); else tmp = t_1; end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, 0.04], t$95$1, If[LessEqual[t$95$2, 2.0], N[Sin[th], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{ky}{\sin kx} \cdot \sin th\\
t_2 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\
\mathbf{if}\;t\_2 \leq 0.04:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 2:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.0400000000000000008 or 2 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 91.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6491.9
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6485.5
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6472.9
Applied rewrites72.9%
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lower--.f6472.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6472.9
lift-*.f64N/A
count-2-revN/A
lower-+.f6472.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6472.9
lift-*.f64N/A
count-2-revN/A
lower-+.f6472.9
Applied rewrites72.9%
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-+.f64N/A
count-2-revN/A
sqr-sin-a-revN/A
lift-sin.f64N/A
lift-sin.f64N/A
pow2N/A
pow-to-expN/A
lower-exp.f64N/A
lower-*.f64N/A
lower-log.f6436.7
Applied rewrites36.7%
Taylor expanded in ky around 0
lower-/.f64N/A
lift-sin.f6434.1
Applied rewrites34.1%
if 0.0400000000000000008 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 2Initial program 99.5%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.5
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6483.7
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6483.3
Applied rewrites83.3%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
sqr-sin-a-revN/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-fma.f6499.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.2
lift-*.f64N/A
count-2-revN/A
lower-+.f6499.2
Applied rewrites99.2%
Taylor expanded in kx around 0
lift-sin.f6467.1
Applied rewrites67.1%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (/ (* ky (sin th)) (sin kx)))
(t_2 (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))))))
(if (<= t_2 0.04) t_1 (if (<= t_2 2.0) (sin th) t_1))))
double code(double kx, double ky, double th) {
double t_1 = (ky * sin(th)) / sin(kx);
double t_2 = sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)));
double tmp;
if (t_2 <= 0.04) {
tmp = t_1;
} else if (t_2 <= 2.0) {
tmp = sin(th);
} else {
tmp = t_1;
}
return tmp;
}
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(kx, ky, th)
use fmin_fmax_functions
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = (ky * sin(th)) / sin(kx)
t_2 = sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))
if (t_2 <= 0.04d0) then
tmp = t_1
else if (t_2 <= 2.0d0) then
tmp = sin(th)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double t_1 = (ky * Math.sin(th)) / Math.sin(kx);
double t_2 = Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)));
double tmp;
if (t_2 <= 0.04) {
tmp = t_1;
} else if (t_2 <= 2.0) {
tmp = Math.sin(th);
} else {
tmp = t_1;
}
return tmp;
}
def code(kx, ky, th): t_1 = (ky * math.sin(th)) / math.sin(kx) t_2 = math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0))) tmp = 0 if t_2 <= 0.04: tmp = t_1 elif t_2 <= 2.0: tmp = math.sin(th) else: tmp = t_1 return tmp
function code(kx, ky, th) t_1 = Float64(Float64(ky * sin(th)) / sin(kx)) t_2 = Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) tmp = 0.0 if (t_2 <= 0.04) tmp = t_1; elseif (t_2 <= 2.0) tmp = sin(th); else tmp = t_1; end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = (ky * sin(th)) / sin(kx); t_2 = sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))); tmp = 0.0; if (t_2 <= 0.04) tmp = t_1; elseif (t_2 <= 2.0) tmp = sin(th); else tmp = t_1; end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, 0.04], t$95$1, If[LessEqual[t$95$2, 2.0], N[Sin[th], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{ky \cdot \sin th}{\sin kx}\\
t_2 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\
\mathbf{if}\;t\_2 \leq 0.04:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 2:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.0400000000000000008 or 2 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 91.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6491.9
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6485.5
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6472.9
Applied rewrites72.9%
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lower--.f6472.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6472.9
lift-*.f64N/A
count-2-revN/A
lower-+.f6472.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6472.9
lift-*.f64N/A
count-2-revN/A
lower-+.f6472.9
Applied rewrites72.9%
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-+.f64N/A
count-2-revN/A
sqr-sin-a-revN/A
lift-sin.f64N/A
lift-sin.f64N/A
pow2N/A
pow-to-expN/A
lower-exp.f64N/A
lower-*.f64N/A
lower-log.f6436.7
Applied rewrites36.7%
Taylor expanded in ky around 0
lower-/.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6433.1
Applied rewrites33.1%
if 0.0400000000000000008 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 2Initial program 99.5%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.5
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6483.7
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6483.3
Applied rewrites83.3%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
sqr-sin-a-revN/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-fma.f6499.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.2
lift-*.f64N/A
count-2-revN/A
lower-+.f6499.2
Applied rewrites99.2%
Taylor expanded in kx around 0
lift-sin.f6467.1
Applied rewrites67.1%
(FPCore (kx ky th) :precision binary64 (sin th))
double code(double kx, double ky, double th) {
return sin(th);
}
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(kx, ky, th)
use fmin_fmax_functions
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = sin(th)
end function
public static double code(double kx, double ky, double th) {
return Math.sin(th);
}
def code(kx, ky, th): return math.sin(th)
function code(kx, ky, th) return sin(th) end
function tmp = code(kx, ky, th) tmp = sin(th); end
code[kx_, ky_, th_] := N[Sin[th], $MachinePrecision]
\begin{array}{l}
\\
\sin th
\end{array}
Initial program 94.1%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6494.1
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6485.0
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6476.0
Applied rewrites76.0%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
sqr-sin-a-revN/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-fma.f6485.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6485.3
lift-*.f64N/A
count-2-revN/A
lower-+.f6485.3
Applied rewrites85.3%
Taylor expanded in kx around 0
lift-sin.f6423.7
Applied rewrites23.7%
herbie shell --seed 2025112
(FPCore (kx ky th)
:name "Toniolo and Linder, Equation (3b), real"
:precision binary64
(* (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) (sin th)))