
(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 20 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) (/ (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 93.7%
lift-*.f64N/A
lift-/.f64N/A
lift-sin.f64N/A
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
lift-sin.f64N/A
lift-pow.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lift-sin.f64N/A
lower-/.f64N/A
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 (/ (* (sin ky) th) (hypot (sin kx) (sin ky)))))
(if (<= t_1 -0.99)
(* (/ (sin ky) (fabs (sin ky))) (sin th))
(if (<= t_1 -0.45)
t_2
(if (<= t_1 0.005)
(* (sin ky) (/ (sin th) (fabs (sin kx))))
(if (<= t_1 0.9995889899187828)
t_2
(if (<= t_1 2.0)
(* (/ ky (fabs ky)) (sin th))
(* ky (/ (sin th) (hypot (sin kx) ky))))))))))
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 = (sin(ky) * th) / hypot(sin(kx), sin(ky));
double tmp;
if (t_1 <= -0.99) {
tmp = (sin(ky) / fabs(sin(ky))) * sin(th);
} else if (t_1 <= -0.45) {
tmp = t_2;
} else if (t_1 <= 0.005) {
tmp = sin(ky) * (sin(th) / fabs(sin(kx)));
} else if (t_1 <= 0.9995889899187828) {
tmp = t_2;
} else if (t_1 <= 2.0) {
tmp = (ky / fabs(ky)) * sin(th);
} else {
tmp = ky * (sin(th) / hypot(sin(kx), ky));
}
return tmp;
}
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 t_2 = (Math.sin(ky) * th) / Math.hypot(Math.sin(kx), Math.sin(ky));
double tmp;
if (t_1 <= -0.99) {
tmp = (Math.sin(ky) / Math.abs(Math.sin(ky))) * Math.sin(th);
} else if (t_1 <= -0.45) {
tmp = t_2;
} else if (t_1 <= 0.005) {
tmp = Math.sin(ky) * (Math.sin(th) / Math.abs(Math.sin(kx)));
} else if (t_1 <= 0.9995889899187828) {
tmp = t_2;
} else if (t_1 <= 2.0) {
tmp = (ky / Math.abs(ky)) * Math.sin(th);
} else {
tmp = ky * (Math.sin(th) / Math.hypot(Math.sin(kx), ky));
}
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))) t_2 = (math.sin(ky) * th) / math.hypot(math.sin(kx), math.sin(ky)) tmp = 0 if t_1 <= -0.99: tmp = (math.sin(ky) / math.fabs(math.sin(ky))) * math.sin(th) elif t_1 <= -0.45: tmp = t_2 elif t_1 <= 0.005: tmp = math.sin(ky) * (math.sin(th) / math.fabs(math.sin(kx))) elif t_1 <= 0.9995889899187828: tmp = t_2 elif t_1 <= 2.0: tmp = (ky / math.fabs(ky)) * math.sin(th) else: tmp = ky * (math.sin(th) / math.hypot(math.sin(kx), ky)) return tmp
function code(kx, ky, th) t_1 = Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) t_2 = Float64(Float64(sin(ky) * th) / hypot(sin(kx), sin(ky))) tmp = 0.0 if (t_1 <= -0.99) tmp = Float64(Float64(sin(ky) / abs(sin(ky))) * sin(th)); elseif (t_1 <= -0.45) tmp = t_2; elseif (t_1 <= 0.005) tmp = Float64(sin(ky) * Float64(sin(th) / abs(sin(kx)))); elseif (t_1 <= 0.9995889899187828) tmp = t_2; elseif (t_1 <= 2.0) tmp = Float64(Float64(ky / abs(ky)) * sin(th)); else tmp = Float64(ky * Float64(sin(th) / hypot(sin(kx), ky))); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))); t_2 = (sin(ky) * th) / hypot(sin(kx), sin(ky)); tmp = 0.0; if (t_1 <= -0.99) tmp = (sin(ky) / abs(sin(ky))) * sin(th); elseif (t_1 <= -0.45) tmp = t_2; elseif (t_1 <= 0.005) tmp = sin(ky) * (sin(th) / abs(sin(kx))); elseif (t_1 <= 0.9995889899187828) tmp = t_2; elseif (t_1 <= 2.0) tmp = (ky / abs(ky)) * sin(th); else tmp = ky * (sin(th) / hypot(sin(kx), ky)); 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]}, Block[{t$95$2 = N[(N[(N[Sin[ky], $MachinePrecision] * th), $MachinePrecision] / N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -0.99], N[(N[(N[Sin[ky], $MachinePrecision] / N[Abs[N[Sin[ky], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -0.45], t$95$2, If[LessEqual[t$95$1, 0.005], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.9995889899187828], t$95$2, If[LessEqual[t$95$1, 2.0], N[(N[(ky / N[Abs[ky], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + ky ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\
t_2 := \frac{\sin ky \cdot th}{\mathsf{hypot}\left(\sin kx, \sin ky\right)}\\
\mathbf{if}\;t\_1 \leq -0.99:\\
\;\;\;\;\frac{\sin ky}{\left|\sin ky\right|} \cdot \sin th\\
\mathbf{elif}\;t\_1 \leq -0.45:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 0.005:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\left|\sin kx\right|}\\
\mathbf{elif}\;t\_1 \leq 0.9995889899187828:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 2:\\
\;\;\;\;\frac{ky}{\left|ky\right|} \cdot \sin th\\
\mathbf{else}:\\
\;\;\;\;ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin kx, ky\right)}\\
\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 93.7%
Taylor expanded in kx around 0
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f64N/A
lift-sin.f6444.4
Applied rewrites44.4%
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.450000000000000011 or 0.0050000000000000001 < (/.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.999588989918782755Initial program 93.7%
Taylor expanded in th around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f64N/A
lift-sin.f64N/A
lift-sin.f6447.9
Applied rewrites47.9%
if -0.450000000000000011 < (/.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.0050000000000000001Initial program 93.7%
lift-*.f64N/A
lift-/.f64N/A
lift-sin.f64N/A
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
lift-sin.f64N/A
lift-pow.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lift-sin.f64N/A
lower-/.f64N/A
Applied rewrites99.6%
Taylor expanded in ky around 0
pow2N/A
rem-sqrt-square-revN/A
lower-fabs.f64N/A
lift-sin.f6444.2
Applied rewrites44.2%
if 0.999588989918782755 < (/.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 93.7%
Taylor expanded in kx around 0
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f64N/A
lift-sin.f6444.4
Applied rewrites44.4%
Taylor expanded in ky around 0
Applied rewrites16.0%
Taylor expanded in ky around 0
Applied rewrites30.3%
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 93.7%
lift-*.f64N/A
lift-/.f64N/A
lift-sin.f64N/A
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
lift-sin.f64N/A
lift-pow.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lift-sin.f64N/A
lower-/.f64N/A
Applied rewrites99.6%
Taylor expanded in ky around 0
Applied rewrites50.8%
Taylor expanded in ky around 0
Applied rewrites61.9%
(FPCore (kx ky th) :precision binary64 (if (<= th 0.102) (* (sin ky) (/ th (hypot (sin kx) (sin ky)))) (* ky (/ (sin th) (hypot (sin kx) ky)))))
double code(double kx, double ky, double th) {
double tmp;
if (th <= 0.102) {
tmp = sin(ky) * (th / hypot(sin(kx), sin(ky)));
} else {
tmp = ky * (sin(th) / hypot(sin(kx), ky));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (th <= 0.102) {
tmp = Math.sin(ky) * (th / Math.hypot(Math.sin(kx), Math.sin(ky)));
} else {
tmp = ky * (Math.sin(th) / Math.hypot(Math.sin(kx), ky));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if th <= 0.102: tmp = math.sin(ky) * (th / math.hypot(math.sin(kx), math.sin(ky))) else: tmp = ky * (math.sin(th) / math.hypot(math.sin(kx), ky)) return tmp
function code(kx, ky, th) tmp = 0.0 if (th <= 0.102) tmp = Float64(sin(ky) * Float64(th / hypot(sin(kx), sin(ky)))); else tmp = Float64(ky * Float64(sin(th) / hypot(sin(kx), ky))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (th <= 0.102) tmp = sin(ky) * (th / hypot(sin(kx), sin(ky))); else tmp = ky * (sin(th) / hypot(sin(kx), ky)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[th, 0.102], N[(N[Sin[ky], $MachinePrecision] * N[(th / N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + ky ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;th \leq 0.102:\\
\;\;\;\;\sin ky \cdot \frac{th}{\mathsf{hypot}\left(\sin kx, \sin ky\right)}\\
\mathbf{else}:\\
\;\;\;\;ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin kx, ky\right)}\\
\end{array}
\end{array}
if th < 0.101999999999999993Initial program 93.7%
lift-*.f64N/A
lift-/.f64N/A
lift-sin.f64N/A
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
lift-sin.f64N/A
lift-pow.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lift-sin.f64N/A
lower-/.f64N/A
Applied rewrites99.6%
Taylor expanded in th around 0
Applied rewrites51.5%
if 0.101999999999999993 < th Initial program 93.7%
lift-*.f64N/A
lift-/.f64N/A
lift-sin.f64N/A
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
lift-sin.f64N/A
lift-pow.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lift-sin.f64N/A
lower-/.f64N/A
Applied rewrites99.6%
Taylor expanded in ky around 0
Applied rewrites50.8%
Taylor expanded in ky around 0
Applied rewrites61.9%
(FPCore (kx ky th) :precision binary64 (if (<= ky 35.0) (* ky (/ (sin th) (hypot (sin kx) ky))) (* (/ (sin ky) (fabs (sin ky))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 35.0) {
tmp = ky * (sin(th) / hypot(sin(kx), ky));
} else {
tmp = (sin(ky) / fabs(sin(ky))) * sin(th);
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= 35.0) {
tmp = ky * (Math.sin(th) / Math.hypot(Math.sin(kx), ky));
} else {
tmp = (Math.sin(ky) / Math.abs(Math.sin(ky))) * Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 35.0: tmp = ky * (math.sin(th) / math.hypot(math.sin(kx), ky)) else: tmp = (math.sin(ky) / math.fabs(math.sin(ky))) * math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 35.0) tmp = Float64(ky * Float64(sin(th) / hypot(sin(kx), ky))); else tmp = Float64(Float64(sin(ky) / abs(sin(ky))) * sin(th)); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 35.0) tmp = ky * (sin(th) / hypot(sin(kx), ky)); else tmp = (sin(ky) / abs(sin(ky))) * sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 35.0], N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + ky ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[ky], $MachinePrecision] / N[Abs[N[Sin[ky], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 35:\\
\;\;\;\;ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin kx, ky\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\left|\sin ky\right|} \cdot \sin th\\
\end{array}
\end{array}
if ky < 35Initial program 93.7%
lift-*.f64N/A
lift-/.f64N/A
lift-sin.f64N/A
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
lift-sin.f64N/A
lift-pow.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lift-sin.f64N/A
lower-/.f64N/A
Applied rewrites99.6%
Taylor expanded in ky around 0
Applied rewrites50.8%
Taylor expanded in ky around 0
Applied rewrites61.9%
if 35 < ky Initial program 93.7%
Taylor expanded in kx around 0
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f64N/A
lift-sin.f6444.4
Applied rewrites44.4%
(FPCore (kx ky th) :precision binary64 (if (<= ky 60.0) (* ky (/ (sin th) (hypot (sin kx) ky))) (* (sin ky) (/ (sin th) (fabs (sin ky))))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 60.0) {
tmp = ky * (sin(th) / hypot(sin(kx), ky));
} else {
tmp = sin(ky) * (sin(th) / fabs(sin(ky)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= 60.0) {
tmp = ky * (Math.sin(th) / Math.hypot(Math.sin(kx), ky));
} else {
tmp = Math.sin(ky) * (Math.sin(th) / Math.abs(Math.sin(ky)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 60.0: tmp = ky * (math.sin(th) / math.hypot(math.sin(kx), ky)) else: tmp = math.sin(ky) * (math.sin(th) / math.fabs(math.sin(ky))) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 60.0) tmp = Float64(ky * Float64(sin(th) / hypot(sin(kx), ky))); else tmp = Float64(sin(ky) * Float64(sin(th) / abs(sin(ky)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 60.0) tmp = ky * (sin(th) / hypot(sin(kx), ky)); else tmp = sin(ky) * (sin(th) / abs(sin(ky))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 60.0], N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + ky ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Abs[N[Sin[ky], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 60:\\
\;\;\;\;ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin kx, ky\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\left|\sin ky\right|}\\
\end{array}
\end{array}
if ky < 60Initial program 93.7%
lift-*.f64N/A
lift-/.f64N/A
lift-sin.f64N/A
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
lift-sin.f64N/A
lift-pow.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lift-sin.f64N/A
lower-/.f64N/A
Applied rewrites99.6%
Taylor expanded in ky around 0
Applied rewrites50.8%
Taylor expanded in ky around 0
Applied rewrites61.9%
if 60 < ky Initial program 93.7%
lift-*.f64N/A
lift-/.f64N/A
lift-sin.f64N/A
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
lift-sin.f64N/A
lift-pow.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lift-sin.f64N/A
lower-/.f64N/A
Applied rewrites99.6%
Taylor expanded in kx around 0
lower-/.f64N/A
lift-sin.f64N/A
pow2N/A
rem-sqrt-square-revN/A
lift-sin.f64N/A
lift-fabs.f6444.4
Applied rewrites44.4%
(FPCore (kx ky th) :precision binary64 (if (<= ky 41.0) (* ky (/ (sin th) (hypot (sin kx) ky))) (/ (* (sin th) (sin ky)) (fabs (sin ky)))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 41.0) {
tmp = ky * (sin(th) / hypot(sin(kx), ky));
} else {
tmp = (sin(th) * sin(ky)) / fabs(sin(ky));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= 41.0) {
tmp = ky * (Math.sin(th) / Math.hypot(Math.sin(kx), ky));
} else {
tmp = (Math.sin(th) * Math.sin(ky)) / Math.abs(Math.sin(ky));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 41.0: tmp = ky * (math.sin(th) / math.hypot(math.sin(kx), ky)) else: tmp = (math.sin(th) * math.sin(ky)) / math.fabs(math.sin(ky)) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 41.0) tmp = Float64(ky * Float64(sin(th) / hypot(sin(kx), ky))); else tmp = Float64(Float64(sin(th) * sin(ky)) / abs(sin(ky))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 41.0) tmp = ky * (sin(th) / hypot(sin(kx), ky)); else tmp = (sin(th) * sin(ky)) / abs(sin(ky)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 41.0], N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + ky ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[th], $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision] / N[Abs[N[Sin[ky], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 41:\\
\;\;\;\;ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin kx, ky\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin th \cdot \sin ky}{\left|\sin ky\right|}\\
\end{array}
\end{array}
if ky < 41Initial program 93.7%
lift-*.f64N/A
lift-/.f64N/A
lift-sin.f64N/A
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
lift-sin.f64N/A
lift-pow.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lift-sin.f64N/A
lower-/.f64N/A
Applied rewrites99.6%
Taylor expanded in ky around 0
Applied rewrites50.8%
Taylor expanded in ky around 0
Applied rewrites61.9%
if 41 < ky Initial program 93.7%
Taylor expanded in kx around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f64N/A
lift-sin.f6449.5
Applied rewrites49.5%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -0.05)
(*
(/ (sin ky) (fabs (sin ky)))
(*
(fma
(-
(*
(fma (* th th) -0.0001984126984126984 0.008333333333333333)
(* th th))
0.16666666666666666)
(* th th)
1.0)
th))
(if (<= (sin ky) 1e-6)
(* ky (/ (sin th) (hypot (sin kx) ky)))
(* (/ ky (fabs ky)) (sin th)))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.05) {
tmp = (sin(ky) / fabs(sin(ky))) * (fma(((fma((th * th), -0.0001984126984126984, 0.008333333333333333) * (th * th)) - 0.16666666666666666), (th * th), 1.0) * th);
} else if (sin(ky) <= 1e-6) {
tmp = ky * (sin(th) / hypot(sin(kx), ky));
} else {
tmp = (ky / fabs(ky)) * sin(th);
}
return tmp;
}
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.05) tmp = Float64(Float64(sin(ky) / abs(sin(ky))) * Float64(fma(Float64(Float64(fma(Float64(th * th), -0.0001984126984126984, 0.008333333333333333) * Float64(th * th)) - 0.16666666666666666), Float64(th * th), 1.0) * th)); elseif (sin(ky) <= 1e-6) tmp = Float64(ky * Float64(sin(th) / hypot(sin(kx), ky))); else tmp = Float64(Float64(ky / abs(ky)) * sin(th)); end return tmp end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.05], N[(N[(N[Sin[ky], $MachinePrecision] / N[Abs[N[Sin[ky], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(N[(N[(th * th), $MachinePrecision] * -0.0001984126984126984 + 0.008333333333333333), $MachinePrecision] * N[(th * th), $MachinePrecision]), $MachinePrecision] - 0.16666666666666666), $MachinePrecision] * N[(th * th), $MachinePrecision] + 1.0), $MachinePrecision] * th), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-6], N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + ky ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(ky / N[Abs[ky], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.05:\\
\;\;\;\;\frac{\sin ky}{\left|\sin ky\right|} \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(th \cdot th, -0.0001984126984126984, 0.008333333333333333\right) \cdot \left(th \cdot th\right) - 0.16666666666666666, th \cdot th, 1\right) \cdot th\right)\\
\mathbf{elif}\;\sin ky \leq 10^{-6}:\\
\;\;\;\;ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin kx, ky\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{ky}{\left|ky\right|} \cdot \sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.050000000000000003Initial program 93.7%
Taylor expanded in kx around 0
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f64N/A
lift-sin.f6444.4
Applied rewrites44.4%
Taylor expanded in th around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites23.7%
if -0.050000000000000003 < (sin.f64 ky) < 9.99999999999999955e-7Initial program 93.7%
lift-*.f64N/A
lift-/.f64N/A
lift-sin.f64N/A
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
lift-sin.f64N/A
lift-pow.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lift-sin.f64N/A
lower-/.f64N/A
Applied rewrites99.6%
Taylor expanded in ky around 0
Applied rewrites50.8%
Taylor expanded in ky around 0
Applied rewrites61.9%
if 9.99999999999999955e-7 < (sin.f64 ky) Initial program 93.7%
Taylor expanded in kx around 0
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f64N/A
lift-sin.f6444.4
Applied rewrites44.4%
Taylor expanded in ky around 0
Applied rewrites16.0%
Taylor expanded in ky around 0
Applied rewrites30.3%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -0.005)
(*
(/ (sin ky) (fabs (sin ky)))
(*
(fma
(- (* (* th th) 0.008333333333333333) 0.16666666666666666)
(* th th)
1.0)
th))
(if (<= (sin ky) 1e-6)
(* ky (/ (sin th) (hypot (sin kx) ky)))
(* (/ ky (fabs ky)) (sin th)))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.005) {
tmp = (sin(ky) / fabs(sin(ky))) * (fma((((th * th) * 0.008333333333333333) - 0.16666666666666666), (th * th), 1.0) * th);
} else if (sin(ky) <= 1e-6) {
tmp = ky * (sin(th) / hypot(sin(kx), ky));
} else {
tmp = (ky / fabs(ky)) * sin(th);
}
return tmp;
}
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.005) tmp = Float64(Float64(sin(ky) / abs(sin(ky))) * Float64(fma(Float64(Float64(Float64(th * th) * 0.008333333333333333) - 0.16666666666666666), Float64(th * th), 1.0) * th)); elseif (sin(ky) <= 1e-6) tmp = Float64(ky * Float64(sin(th) / hypot(sin(kx), ky))); else tmp = Float64(Float64(ky / abs(ky)) * sin(th)); end return tmp end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.005], N[(N[(N[Sin[ky], $MachinePrecision] / N[Abs[N[Sin[ky], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(N[(th * th), $MachinePrecision] * 0.008333333333333333), $MachinePrecision] - 0.16666666666666666), $MachinePrecision] * N[(th * th), $MachinePrecision] + 1.0), $MachinePrecision] * th), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-6], N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + ky ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(ky / N[Abs[ky], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.005:\\
\;\;\;\;\frac{\sin ky}{\left|\sin ky\right|} \cdot \left(\mathsf{fma}\left(\left(th \cdot th\right) \cdot 0.008333333333333333 - 0.16666666666666666, th \cdot th, 1\right) \cdot th\right)\\
\mathbf{elif}\;\sin ky \leq 10^{-6}:\\
\;\;\;\;ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin kx, ky\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{ky}{\left|ky\right|} \cdot \sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.0050000000000000001Initial program 93.7%
Taylor expanded in kx around 0
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f64N/A
lift-sin.f6444.4
Applied rewrites44.4%
Taylor expanded in th around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6423.7
Applied rewrites23.7%
if -0.0050000000000000001 < (sin.f64 ky) < 9.99999999999999955e-7Initial program 93.7%
lift-*.f64N/A
lift-/.f64N/A
lift-sin.f64N/A
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
lift-sin.f64N/A
lift-pow.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lift-sin.f64N/A
lower-/.f64N/A
Applied rewrites99.6%
Taylor expanded in ky around 0
Applied rewrites50.8%
Taylor expanded in ky around 0
Applied rewrites61.9%
if 9.99999999999999955e-7 < (sin.f64 ky) Initial program 93.7%
Taylor expanded in kx around 0
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f64N/A
lift-sin.f6444.4
Applied rewrites44.4%
Taylor expanded in ky around 0
Applied rewrites16.0%
Taylor expanded in ky around 0
Applied rewrites30.3%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -0.05)
(*
(/ (sin ky) (fabs (sin ky)))
(* (fma (* th th) -0.16666666666666666 1.0) th))
(if (<= (sin ky) 1e-6)
(* ky (/ (sin th) (hypot (sin kx) ky)))
(* (/ ky (fabs ky)) (sin th)))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.05) {
tmp = (sin(ky) / fabs(sin(ky))) * (fma((th * th), -0.16666666666666666, 1.0) * th);
} else if (sin(ky) <= 1e-6) {
tmp = ky * (sin(th) / hypot(sin(kx), ky));
} else {
tmp = (ky / fabs(ky)) * sin(th);
}
return tmp;
}
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.05) tmp = Float64(Float64(sin(ky) / abs(sin(ky))) * Float64(fma(Float64(th * th), -0.16666666666666666, 1.0) * th)); elseif (sin(ky) <= 1e-6) tmp = Float64(ky * Float64(sin(th) / hypot(sin(kx), ky))); else tmp = Float64(Float64(ky / abs(ky)) * sin(th)); end return tmp end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.05], N[(N[(N[Sin[ky], $MachinePrecision] / N[Abs[N[Sin[ky], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(th * th), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * th), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-6], N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + ky ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(ky / N[Abs[ky], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.05:\\
\;\;\;\;\frac{\sin ky}{\left|\sin ky\right|} \cdot \left(\mathsf{fma}\left(th \cdot th, -0.16666666666666666, 1\right) \cdot th\right)\\
\mathbf{elif}\;\sin ky \leq 10^{-6}:\\
\;\;\;\;ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin kx, ky\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{ky}{\left|ky\right|} \cdot \sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.050000000000000003Initial program 93.7%
Taylor expanded in kx around 0
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f64N/A
lift-sin.f6444.4
Applied rewrites44.4%
Taylor expanded in th around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6423.7
Applied rewrites23.7%
if -0.050000000000000003 < (sin.f64 ky) < 9.99999999999999955e-7Initial program 93.7%
lift-*.f64N/A
lift-/.f64N/A
lift-sin.f64N/A
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
lift-sin.f64N/A
lift-pow.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lift-sin.f64N/A
lower-/.f64N/A
Applied rewrites99.6%
Taylor expanded in ky around 0
Applied rewrites50.8%
Taylor expanded in ky around 0
Applied rewrites61.9%
if 9.99999999999999955e-7 < (sin.f64 ky) Initial program 93.7%
Taylor expanded in kx around 0
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f64N/A
lift-sin.f6444.4
Applied rewrites44.4%
Taylor expanded in ky around 0
Applied rewrites16.0%
Taylor expanded in ky around 0
Applied rewrites30.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 -0.41)
(*
(/ (sin ky) (fabs (sin ky)))
(* (fma (* th th) -0.16666666666666666 1.0) th))
(if (<= t_1 2e-6)
(* ky (/ (sin th) (fabs (sin kx))))
(* (/ ky (fabs ky)) (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.41) {
tmp = (sin(ky) / fabs(sin(ky))) * (fma((th * th), -0.16666666666666666, 1.0) * th);
} else if (t_1 <= 2e-6) {
tmp = ky * (sin(th) / fabs(sin(kx)));
} else {
tmp = (ky / fabs(ky)) * 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.41) tmp = Float64(Float64(sin(ky) / abs(sin(ky))) * Float64(fma(Float64(th * th), -0.16666666666666666, 1.0) * th)); elseif (t_1 <= 2e-6) tmp = Float64(ky * Float64(sin(th) / abs(sin(kx)))); else tmp = Float64(Float64(ky / abs(ky)) * 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.41], N[(N[(N[Sin[ky], $MachinePrecision] / N[Abs[N[Sin[ky], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(th * th), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * th), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e-6], N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(ky / N[Abs[ky], $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.41:\\
\;\;\;\;\frac{\sin ky}{\left|\sin ky\right|} \cdot \left(\mathsf{fma}\left(th \cdot th, -0.16666666666666666, 1\right) \cdot th\right)\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-6}:\\
\;\;\;\;ky \cdot \frac{\sin th}{\left|\sin kx\right|}\\
\mathbf{else}:\\
\;\;\;\;\frac{ky}{\left|ky\right|} \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.409999999999999976Initial program 93.7%
Taylor expanded in kx around 0
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f64N/A
lift-sin.f6444.4
Applied rewrites44.4%
Taylor expanded in th around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6423.7
Applied rewrites23.7%
if -0.409999999999999976 < (/.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))))) < 1.99999999999999991e-6Initial program 93.7%
Taylor expanded in ky around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f64N/A
lift-sin.f6437.1
Applied rewrites37.1%
lift-/.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lift-fabs.f64N/A
lift-sin.f64N/A
associate-/l*N/A
rem-sqrt-square-revN/A
pow2N/A
lower-*.f64N/A
lower-/.f64N/A
lift-sin.f64N/A
pow2N/A
rem-sqrt-square-revN/A
lower-fabs.f64N/A
lift-sin.f6438.9
Applied rewrites38.9%
if 1.99999999999999991e-6 < (/.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 93.7%
Taylor expanded in kx around 0
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f64N/A
lift-sin.f6444.4
Applied rewrites44.4%
Taylor expanded in ky around 0
Applied rewrites16.0%
Taylor expanded in ky around 0
Applied rewrites30.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 -0.02)
(* (/ (sin ky) (fabs (sin ky))) th)
(if (<= t_1 2e-6)
(* ky (/ (sin th) (fabs (sin kx))))
(* (/ ky (fabs ky)) (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.02) {
tmp = (sin(ky) / fabs(sin(ky))) * th;
} else if (t_1 <= 2e-6) {
tmp = ky * (sin(th) / fabs(sin(kx)));
} else {
tmp = (ky / fabs(ky)) * 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.02d0)) then
tmp = (sin(ky) / abs(sin(ky))) * th
else if (t_1 <= 2d-6) then
tmp = ky * (sin(th) / abs(sin(kx)))
else
tmp = (ky / abs(ky)) * 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.02) {
tmp = (Math.sin(ky) / Math.abs(Math.sin(ky))) * th;
} else if (t_1 <= 2e-6) {
tmp = ky * (Math.sin(th) / Math.abs(Math.sin(kx)));
} else {
tmp = (ky / Math.abs(ky)) * 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.02: tmp = (math.sin(ky) / math.fabs(math.sin(ky))) * th elif t_1 <= 2e-6: tmp = ky * (math.sin(th) / math.fabs(math.sin(kx))) else: tmp = (ky / math.fabs(ky)) * 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.02) tmp = Float64(Float64(sin(ky) / abs(sin(ky))) * th); elseif (t_1 <= 2e-6) tmp = Float64(ky * Float64(sin(th) / abs(sin(kx)))); else tmp = Float64(Float64(ky / abs(ky)) * 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.02) tmp = (sin(ky) / abs(sin(ky))) * th; elseif (t_1 <= 2e-6) tmp = ky * (sin(th) / abs(sin(kx))); else tmp = (ky / abs(ky)) * 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.02], N[(N[(N[Sin[ky], $MachinePrecision] / N[Abs[N[Sin[ky], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * th), $MachinePrecision], If[LessEqual[t$95$1, 2e-6], N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(ky / N[Abs[ky], $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.02:\\
\;\;\;\;\frac{\sin ky}{\left|\sin ky\right|} \cdot th\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-6}:\\
\;\;\;\;ky \cdot \frac{\sin th}{\left|\sin kx\right|}\\
\mathbf{else}:\\
\;\;\;\;\frac{ky}{\left|ky\right|} \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.0200000000000000004Initial program 93.7%
Taylor expanded in kx around 0
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f64N/A
lift-sin.f6444.4
Applied rewrites44.4%
Taylor expanded in th around 0
Applied rewrites23.9%
if -0.0200000000000000004 < (/.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))))) < 1.99999999999999991e-6Initial program 93.7%
Taylor expanded in ky around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f64N/A
lift-sin.f6437.1
Applied rewrites37.1%
lift-/.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lift-fabs.f64N/A
lift-sin.f64N/A
associate-/l*N/A
rem-sqrt-square-revN/A
pow2N/A
lower-*.f64N/A
lower-/.f64N/A
lift-sin.f64N/A
pow2N/A
rem-sqrt-square-revN/A
lower-fabs.f64N/A
lift-sin.f6438.9
Applied rewrites38.9%
if 1.99999999999999991e-6 < (/.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 93.7%
Taylor expanded in kx around 0
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f64N/A
lift-sin.f6444.4
Applied rewrites44.4%
Taylor expanded in ky around 0
Applied rewrites16.0%
Taylor expanded in ky around 0
Applied rewrites30.3%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (* (fma (* ky ky) -0.16666666666666666 1.0) ky))
(t_2 (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))))))
(if (<= t_2 -0.5)
(* (/ t_1 (fabs t_1)) (sin th))
(if (<= t_2 2e-6)
(* ky (/ (sin th) (fabs (sin kx))))
(* (/ ky (fabs ky)) (sin th))))))
double code(double kx, double ky, double th) {
double t_1 = fma((ky * ky), -0.16666666666666666, 1.0) * ky;
double t_2 = sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)));
double tmp;
if (t_2 <= -0.5) {
tmp = (t_1 / fabs(t_1)) * sin(th);
} else if (t_2 <= 2e-6) {
tmp = ky * (sin(th) / fabs(sin(kx)));
} else {
tmp = (ky / fabs(ky)) * sin(th);
}
return tmp;
}
function code(kx, ky, th) t_1 = Float64(fma(Float64(ky * ky), -0.16666666666666666, 1.0) * ky) t_2 = Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) tmp = 0.0 if (t_2 <= -0.5) tmp = Float64(Float64(t_1 / abs(t_1)) * sin(th)); elseif (t_2 <= 2e-6) tmp = Float64(ky * Float64(sin(th) / abs(sin(kx)))); else tmp = Float64(Float64(ky / abs(ky)) * sin(th)); end return tmp end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[(N[(ky * ky), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * ky), $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.5], N[(N[(t$95$1 / N[Abs[t$95$1], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2e-6], N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(ky / N[Abs[ky], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(ky \cdot ky, -0.16666666666666666, 1\right) \cdot ky\\
t_2 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\
\mathbf{if}\;t\_2 \leq -0.5:\\
\;\;\;\;\frac{t\_1}{\left|t\_1\right|} \cdot \sin th\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{-6}:\\
\;\;\;\;ky \cdot \frac{\sin th}{\left|\sin kx\right|}\\
\mathbf{else}:\\
\;\;\;\;\frac{ky}{\left|ky\right|} \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.5Initial program 93.7%
Taylor expanded in kx around 0
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f64N/A
lift-sin.f6444.4
Applied rewrites44.4%
Taylor expanded in ky around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
pow2N/A
lower-*.f6415.6
Applied rewrites15.6%
Taylor expanded in ky around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
pow2N/A
lower-*.f6419.9
Applied rewrites19.9%
if -0.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))))) < 1.99999999999999991e-6Initial program 93.7%
Taylor expanded in ky around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f64N/A
lift-sin.f6437.1
Applied rewrites37.1%
lift-/.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lift-fabs.f64N/A
lift-sin.f64N/A
associate-/l*N/A
rem-sqrt-square-revN/A
pow2N/A
lower-*.f64N/A
lower-/.f64N/A
lift-sin.f64N/A
pow2N/A
rem-sqrt-square-revN/A
lower-fabs.f64N/A
lift-sin.f6438.9
Applied rewrites38.9%
if 1.99999999999999991e-6 < (/.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 93.7%
Taylor expanded in kx around 0
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f64N/A
lift-sin.f6444.4
Applied rewrites44.4%
Taylor expanded in ky around 0
Applied rewrites16.0%
Taylor expanded in ky around 0
Applied rewrites30.3%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (* (fma (* ky ky) -0.16666666666666666 1.0) ky))
(t_2 (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))))))
(if (<= t_2 -0.5)
(* (/ t_1 (fabs t_1)) (sin th))
(if (<= t_2 2e-6)
(* (/ ky (fabs (sin kx))) (sin th))
(* (/ ky (fabs ky)) (sin th))))))
double code(double kx, double ky, double th) {
double t_1 = fma((ky * ky), -0.16666666666666666, 1.0) * ky;
double t_2 = sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)));
double tmp;
if (t_2 <= -0.5) {
tmp = (t_1 / fabs(t_1)) * sin(th);
} else if (t_2 <= 2e-6) {
tmp = (ky / fabs(sin(kx))) * sin(th);
} else {
tmp = (ky / fabs(ky)) * sin(th);
}
return tmp;
}
function code(kx, ky, th) t_1 = Float64(fma(Float64(ky * ky), -0.16666666666666666, 1.0) * ky) t_2 = Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) tmp = 0.0 if (t_2 <= -0.5) tmp = Float64(Float64(t_1 / abs(t_1)) * sin(th)); elseif (t_2 <= 2e-6) tmp = Float64(Float64(ky / abs(sin(kx))) * sin(th)); else tmp = Float64(Float64(ky / abs(ky)) * sin(th)); end return tmp end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[(N[(ky * ky), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * ky), $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.5], N[(N[(t$95$1 / N[Abs[t$95$1], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2e-6], N[(N[(ky / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], N[(N[(ky / N[Abs[ky], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(ky \cdot ky, -0.16666666666666666, 1\right) \cdot ky\\
t_2 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\
\mathbf{if}\;t\_2 \leq -0.5:\\
\;\;\;\;\frac{t\_1}{\left|t\_1\right|} \cdot \sin th\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{-6}:\\
\;\;\;\;\frac{ky}{\left|\sin kx\right|} \cdot \sin th\\
\mathbf{else}:\\
\;\;\;\;\frac{ky}{\left|ky\right|} \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.5Initial program 93.7%
Taylor expanded in kx around 0
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f64N/A
lift-sin.f6444.4
Applied rewrites44.4%
Taylor expanded in ky around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
pow2N/A
lower-*.f6415.6
Applied rewrites15.6%
Taylor expanded in ky around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
pow2N/A
lower-*.f6419.9
Applied rewrites19.9%
if -0.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))))) < 1.99999999999999991e-6Initial program 93.7%
Taylor expanded in ky around 0
lower-/.f64N/A
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f64N/A
lift-sin.f6438.9
Applied rewrites38.9%
if 1.99999999999999991e-6 < (/.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 93.7%
Taylor expanded in kx around 0
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f64N/A
lift-sin.f6444.4
Applied rewrites44.4%
Taylor expanded in ky around 0
Applied rewrites16.0%
Taylor expanded in ky around 0
Applied rewrites30.3%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (* (fma (* ky ky) -0.16666666666666666 1.0) ky))
(t_2 (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))))))
(if (<= t_2 -0.5)
(* (/ t_1 (fabs t_1)) (sin th))
(if (<= t_2 2e-6)
(/ (* (sin th) ky) (fabs (sin kx)))
(* (/ ky (fabs ky)) (sin th))))))
double code(double kx, double ky, double th) {
double t_1 = fma((ky * ky), -0.16666666666666666, 1.0) * ky;
double t_2 = sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)));
double tmp;
if (t_2 <= -0.5) {
tmp = (t_1 / fabs(t_1)) * sin(th);
} else if (t_2 <= 2e-6) {
tmp = (sin(th) * ky) / fabs(sin(kx));
} else {
tmp = (ky / fabs(ky)) * sin(th);
}
return tmp;
}
function code(kx, ky, th) t_1 = Float64(fma(Float64(ky * ky), -0.16666666666666666, 1.0) * ky) t_2 = Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) tmp = 0.0 if (t_2 <= -0.5) tmp = Float64(Float64(t_1 / abs(t_1)) * sin(th)); elseif (t_2 <= 2e-6) tmp = Float64(Float64(sin(th) * ky) / abs(sin(kx))); else tmp = Float64(Float64(ky / abs(ky)) * sin(th)); end return tmp end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[(N[(ky * ky), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * ky), $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.5], N[(N[(t$95$1 / N[Abs[t$95$1], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2e-6], N[(N[(N[Sin[th], $MachinePrecision] * ky), $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(ky / N[Abs[ky], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(ky \cdot ky, -0.16666666666666666, 1\right) \cdot ky\\
t_2 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\
\mathbf{if}\;t\_2 \leq -0.5:\\
\;\;\;\;\frac{t\_1}{\left|t\_1\right|} \cdot \sin th\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{-6}:\\
\;\;\;\;\frac{\sin th \cdot ky}{\left|\sin kx\right|}\\
\mathbf{else}:\\
\;\;\;\;\frac{ky}{\left|ky\right|} \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.5Initial program 93.7%
Taylor expanded in kx around 0
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f64N/A
lift-sin.f6444.4
Applied rewrites44.4%
Taylor expanded in ky around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
pow2N/A
lower-*.f6415.6
Applied rewrites15.6%
Taylor expanded in ky around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
pow2N/A
lower-*.f6419.9
Applied rewrites19.9%
if -0.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))))) < 1.99999999999999991e-6Initial program 93.7%
Taylor expanded in ky around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f64N/A
lift-sin.f6437.1
Applied rewrites37.1%
if 1.99999999999999991e-6 < (/.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 93.7%
Taylor expanded in kx around 0
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f64N/A
lift-sin.f6444.4
Applied rewrites44.4%
Taylor expanded in ky around 0
Applied rewrites16.0%
Taylor expanded in ky around 0
Applied rewrites30.3%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (* (fma (* ky ky) -0.16666666666666666 1.0) ky))
(t_2 (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))))))
(if (<= t_2 -0.5)
(* (/ t_1 (fabs t_1)) (sin th))
(if (<= t_2 2e-6)
(* (/ ky (fabs (sin kx))) th)
(* (/ ky (fabs ky)) (sin th))))))
double code(double kx, double ky, double th) {
double t_1 = fma((ky * ky), -0.16666666666666666, 1.0) * ky;
double t_2 = sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)));
double tmp;
if (t_2 <= -0.5) {
tmp = (t_1 / fabs(t_1)) * sin(th);
} else if (t_2 <= 2e-6) {
tmp = (ky / fabs(sin(kx))) * th;
} else {
tmp = (ky / fabs(ky)) * sin(th);
}
return tmp;
}
function code(kx, ky, th) t_1 = Float64(fma(Float64(ky * ky), -0.16666666666666666, 1.0) * ky) t_2 = Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) tmp = 0.0 if (t_2 <= -0.5) tmp = Float64(Float64(t_1 / abs(t_1)) * sin(th)); elseif (t_2 <= 2e-6) tmp = Float64(Float64(ky / abs(sin(kx))) * th); else tmp = Float64(Float64(ky / abs(ky)) * sin(th)); end return tmp end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[(N[(ky * ky), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * ky), $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.5], N[(N[(t$95$1 / N[Abs[t$95$1], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2e-6], N[(N[(ky / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * th), $MachinePrecision], N[(N[(ky / N[Abs[ky], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(ky \cdot ky, -0.16666666666666666, 1\right) \cdot ky\\
t_2 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\
\mathbf{if}\;t\_2 \leq -0.5:\\
\;\;\;\;\frac{t\_1}{\left|t\_1\right|} \cdot \sin th\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{-6}:\\
\;\;\;\;\frac{ky}{\left|\sin kx\right|} \cdot th\\
\mathbf{else}:\\
\;\;\;\;\frac{ky}{\left|ky\right|} \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.5Initial program 93.7%
Taylor expanded in kx around 0
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f64N/A
lift-sin.f6444.4
Applied rewrites44.4%
Taylor expanded in ky around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
pow2N/A
lower-*.f6415.6
Applied rewrites15.6%
Taylor expanded in ky around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
pow2N/A
lower-*.f6419.9
Applied rewrites19.9%
if -0.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))))) < 1.99999999999999991e-6Initial program 93.7%
Taylor expanded in kx around 0
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f64N/A
lift-sin.f6444.4
Applied rewrites44.4%
Taylor expanded in th around 0
Applied rewrites23.9%
Taylor expanded in ky around 0
lower-/.f64N/A
pow2N/A
rem-sqrt-square-revN/A
lift-sin.f64N/A
lift-fabs.f6420.8
Applied rewrites20.8%
if 1.99999999999999991e-6 < (/.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 93.7%
Taylor expanded in kx around 0
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f64N/A
lift-sin.f6444.4
Applied rewrites44.4%
Taylor expanded in ky around 0
Applied rewrites16.0%
Taylor expanded in ky around 0
Applied rewrites30.3%
(FPCore (kx ky th) :precision binary64 (if (<= (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) 2e-6) (* (/ ky (fabs (sin kx))) th) (* (/ ky (fabs ky)) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if ((sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) <= 2e-6) {
tmp = (ky / fabs(sin(kx))) * th;
} else {
tmp = (ky / fabs(ky)) * 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(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))) <= 2d-6) then
tmp = (ky / abs(sin(kx))) * th
else
tmp = (ky / abs(ky)) * sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if ((Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))) <= 2e-6) {
tmp = (ky / Math.abs(Math.sin(kx))) * th;
} else {
tmp = (ky / Math.abs(ky)) * Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if (math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))) <= 2e-6: tmp = (ky / math.fabs(math.sin(kx))) * th else: tmp = (ky / math.fabs(ky)) * math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) <= 2e-6) tmp = Float64(Float64(ky / abs(sin(kx))) * th); else tmp = Float64(Float64(ky / abs(ky)) * sin(th)); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if ((sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) <= 2e-6) tmp = (ky / abs(sin(kx))) * th; else tmp = (ky / abs(ky)) * sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[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], 2e-6], N[(N[(ky / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * th), $MachinePrecision], N[(N[(ky / N[Abs[ky], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 2 \cdot 10^{-6}:\\
\;\;\;\;\frac{ky}{\left|\sin kx\right|} \cdot th\\
\mathbf{else}:\\
\;\;\;\;\frac{ky}{\left|ky\right|} \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))))) < 1.99999999999999991e-6Initial program 93.7%
Taylor expanded in kx around 0
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f64N/A
lift-sin.f6444.4
Applied rewrites44.4%
Taylor expanded in th around 0
Applied rewrites23.9%
Taylor expanded in ky around 0
lower-/.f64N/A
pow2N/A
rem-sqrt-square-revN/A
lift-sin.f64N/A
lift-fabs.f6420.8
Applied rewrites20.8%
if 1.99999999999999991e-6 < (/.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 93.7%
Taylor expanded in kx around 0
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f64N/A
lift-sin.f6444.4
Applied rewrites44.4%
Taylor expanded in ky around 0
Applied rewrites16.0%
Taylor expanded in ky around 0
Applied rewrites30.3%
(FPCore (kx ky th) :precision binary64 (if (<= (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) 2e-6) (* (/ ky (fabs (sin kx))) th) (* (/ ky ky) th)))
double code(double kx, double ky, double th) {
double tmp;
if ((sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) <= 2e-6) {
tmp = (ky / fabs(sin(kx))) * th;
} else {
tmp = (ky / ky) * 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(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))) <= 2d-6) then
tmp = (ky / abs(sin(kx))) * th
else
tmp = (ky / ky) * th
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if ((Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))) <= 2e-6) {
tmp = (ky / Math.abs(Math.sin(kx))) * th;
} else {
tmp = (ky / ky) * th;
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if (math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))) <= 2e-6: tmp = (ky / math.fabs(math.sin(kx))) * th else: tmp = (ky / ky) * th return tmp
function code(kx, ky, th) tmp = 0.0 if (Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) <= 2e-6) tmp = Float64(Float64(ky / abs(sin(kx))) * th); else tmp = Float64(Float64(ky / ky) * th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if ((sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) <= 2e-6) tmp = (ky / abs(sin(kx))) * th; else tmp = (ky / ky) * th; end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[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], 2e-6], N[(N[(ky / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * th), $MachinePrecision], N[(N[(ky / ky), $MachinePrecision] * th), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 2 \cdot 10^{-6}:\\
\;\;\;\;\frac{ky}{\left|\sin kx\right|} \cdot th\\
\mathbf{else}:\\
\;\;\;\;\frac{ky}{ky} \cdot 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))))) < 1.99999999999999991e-6Initial program 93.7%
Taylor expanded in kx around 0
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f64N/A
lift-sin.f6444.4
Applied rewrites44.4%
Taylor expanded in th around 0
Applied rewrites23.9%
Taylor expanded in ky around 0
lower-/.f64N/A
pow2N/A
rem-sqrt-square-revN/A
lift-sin.f64N/A
lift-fabs.f6420.8
Applied rewrites20.8%
if 1.99999999999999991e-6 < (/.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 93.7%
Taylor expanded in kx around 0
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f64N/A
lift-sin.f6444.4
Applied rewrites44.4%
Taylor expanded in th around 0
Applied rewrites23.9%
Taylor expanded in ky around 0
rem-sqrt-square-revN/A
sqr-sin-a-revN/A
pow1/2N/A
metadata-evalN/A
pow-negN/A
sqr-sin-a-revN/A
pow-prod-downN/A
pow-prod-upN/A
metadata-evalN/A
rem-sqrt-square-revN/A
sqr-sin-a-revN/A
pow1/2N/A
metadata-evalN/A
pow-negN/A
sqr-sin-a-revN/A
pow-prod-downN/A
pow-prod-upN/A
metadata-evalN/A
pow-flipN/A
metadata-evalN/A
unpow1N/A
lift-sin.f6413.8
Applied rewrites13.8%
Taylor expanded in ky around 0
Applied rewrites6.4%
Taylor expanded in ky around 0
Applied rewrites13.8%
(FPCore (kx ky th) :precision binary64 (if (<= (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) 2e-6) (/ (* th ky) (fabs (sin kx))) (* (/ ky ky) th)))
double code(double kx, double ky, double th) {
double tmp;
if ((sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) <= 2e-6) {
tmp = (th * ky) / fabs(sin(kx));
} else {
tmp = (ky / ky) * 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(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))) <= 2d-6) then
tmp = (th * ky) / abs(sin(kx))
else
tmp = (ky / ky) * th
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if ((Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))) <= 2e-6) {
tmp = (th * ky) / Math.abs(Math.sin(kx));
} else {
tmp = (ky / ky) * th;
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if (math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))) <= 2e-6: tmp = (th * ky) / math.fabs(math.sin(kx)) else: tmp = (ky / ky) * th return tmp
function code(kx, ky, th) tmp = 0.0 if (Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) <= 2e-6) tmp = Float64(Float64(th * ky) / abs(sin(kx))); else tmp = Float64(Float64(ky / ky) * th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if ((sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) <= 2e-6) tmp = (th * ky) / abs(sin(kx)); else tmp = (ky / ky) * th; end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[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], 2e-6], N[(N[(th * ky), $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(ky / ky), $MachinePrecision] * th), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 2 \cdot 10^{-6}:\\
\;\;\;\;\frac{th \cdot ky}{\left|\sin kx\right|}\\
\mathbf{else}:\\
\;\;\;\;\frac{ky}{ky} \cdot 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))))) < 1.99999999999999991e-6Initial program 93.7%
Taylor expanded in ky around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f64N/A
lift-sin.f6437.1
Applied rewrites37.1%
Taylor expanded in th around 0
Applied rewrites18.9%
if 1.99999999999999991e-6 < (/.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 93.7%
Taylor expanded in kx around 0
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f64N/A
lift-sin.f6444.4
Applied rewrites44.4%
Taylor expanded in th around 0
Applied rewrites23.9%
Taylor expanded in ky around 0
rem-sqrt-square-revN/A
sqr-sin-a-revN/A
pow1/2N/A
metadata-evalN/A
pow-negN/A
sqr-sin-a-revN/A
pow-prod-downN/A
pow-prod-upN/A
metadata-evalN/A
rem-sqrt-square-revN/A
sqr-sin-a-revN/A
pow1/2N/A
metadata-evalN/A
pow-negN/A
sqr-sin-a-revN/A
pow-prod-downN/A
pow-prod-upN/A
metadata-evalN/A
pow-flipN/A
metadata-evalN/A
unpow1N/A
lift-sin.f6413.8
Applied rewrites13.8%
Taylor expanded in ky around 0
Applied rewrites6.4%
Taylor expanded in ky around 0
Applied rewrites13.8%
(FPCore (kx ky th) :precision binary64 (if (<= (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) 2e-7) (* th (/ ky (fabs kx))) (* (/ ky ky) th)))
double code(double kx, double ky, double th) {
double tmp;
if ((sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) <= 2e-7) {
tmp = th * (ky / fabs(kx));
} else {
tmp = (ky / ky) * 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(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))) <= 2d-7) then
tmp = th * (ky / abs(kx))
else
tmp = (ky / ky) * th
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if ((Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))) <= 2e-7) {
tmp = th * (ky / Math.abs(kx));
} else {
tmp = (ky / ky) * th;
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if (math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))) <= 2e-7: tmp = th * (ky / math.fabs(kx)) else: tmp = (ky / ky) * th return tmp
function code(kx, ky, th) tmp = 0.0 if (Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) <= 2e-7) tmp = Float64(th * Float64(ky / abs(kx))); else tmp = Float64(Float64(ky / ky) * th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if ((sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) <= 2e-7) tmp = th * (ky / abs(kx)); else tmp = (ky / ky) * th; end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[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], 2e-7], N[(th * N[(ky / N[Abs[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(ky / ky), $MachinePrecision] * th), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 2 \cdot 10^{-7}:\\
\;\;\;\;th \cdot \frac{ky}{\left|kx\right|}\\
\mathbf{else}:\\
\;\;\;\;\frac{ky}{ky} \cdot 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))))) < 1.9999999999999999e-7Initial program 93.7%
Taylor expanded in ky around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f64N/A
lift-sin.f6437.1
Applied rewrites37.1%
Taylor expanded in th around 0
Applied rewrites18.9%
Taylor expanded in kx around 0
Applied rewrites13.4%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6415.3
Applied rewrites15.3%
if 1.9999999999999999e-7 < (/.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 93.7%
Taylor expanded in kx around 0
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f64N/A
lift-sin.f6444.4
Applied rewrites44.4%
Taylor expanded in th around 0
Applied rewrites23.9%
Taylor expanded in ky around 0
rem-sqrt-square-revN/A
sqr-sin-a-revN/A
pow1/2N/A
metadata-evalN/A
pow-negN/A
sqr-sin-a-revN/A
pow-prod-downN/A
pow-prod-upN/A
metadata-evalN/A
rem-sqrt-square-revN/A
sqr-sin-a-revN/A
pow1/2N/A
metadata-evalN/A
pow-negN/A
sqr-sin-a-revN/A
pow-prod-downN/A
pow-prod-upN/A
metadata-evalN/A
pow-flipN/A
metadata-evalN/A
unpow1N/A
lift-sin.f6413.8
Applied rewrites13.8%
Taylor expanded in ky around 0
Applied rewrites6.4%
Taylor expanded in ky around 0
Applied rewrites13.8%
(FPCore (kx ky th) :precision binary64 (* (/ ky ky) th))
double code(double kx, double ky, double th) {
return (ky / ky) * 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 = (ky / ky) * th
end function
public static double code(double kx, double ky, double th) {
return (ky / ky) * th;
}
def code(kx, ky, th): return (ky / ky) * th
function code(kx, ky, th) return Float64(Float64(ky / ky) * th) end
function tmp = code(kx, ky, th) tmp = (ky / ky) * th; end
code[kx_, ky_, th_] := N[(N[(ky / ky), $MachinePrecision] * th), $MachinePrecision]
\begin{array}{l}
\\
\frac{ky}{ky} \cdot th
\end{array}
Initial program 93.7%
Taylor expanded in kx around 0
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f64N/A
lift-sin.f6444.4
Applied rewrites44.4%
Taylor expanded in th around 0
Applied rewrites23.9%
Taylor expanded in ky around 0
rem-sqrt-square-revN/A
sqr-sin-a-revN/A
pow1/2N/A
metadata-evalN/A
pow-negN/A
sqr-sin-a-revN/A
pow-prod-downN/A
pow-prod-upN/A
metadata-evalN/A
rem-sqrt-square-revN/A
sqr-sin-a-revN/A
pow1/2N/A
metadata-evalN/A
pow-negN/A
sqr-sin-a-revN/A
pow-prod-downN/A
pow-prod-upN/A
metadata-evalN/A
pow-flipN/A
metadata-evalN/A
unpow1N/A
lift-sin.f6413.8
Applied rewrites13.8%
Taylor expanded in ky around 0
Applied rewrites6.4%
Taylor expanded in ky around 0
Applied rewrites13.8%
herbie shell --seed 2025137
(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)))