
(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);
}
real(8) function code(kx, ky, th)
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}
Sampling outcomes in binary64 precision:
Herbie found 18 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);
}
real(8) function code(kx, ky, th)
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 95.1%
remove-double-neg95.1%
sin-neg95.1%
neg-mul-195.1%
*-commutative95.1%
associate-*l*95.1%
associate-*l/93.7%
associate-/r/93.7%
associate-*l/95.1%
associate-/r/95.0%
sin-neg95.0%
neg-mul-195.0%
associate-/r*95.0%
associate-/r/95.1%
Simplified99.7%
Final simplification99.7%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.005) (* (sin th) (/ (sin ky) (log (+ ky 1.0)))) (if (<= (sin ky) 1e-7) (* (sin th) (fabs (/ (sin ky) (sin kx)))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.005) {
tmp = sin(th) * (sin(ky) / log((ky + 1.0)));
} else if (sin(ky) <= 1e-7) {
tmp = sin(th) * fabs((sin(ky) / sin(kx)));
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(ky) <= (-0.005d0)) then
tmp = sin(th) * (sin(ky) / log((ky + 1.0d0)))
else if (sin(ky) <= 1d-7) then
tmp = sin(th) * abs((sin(ky) / sin(kx)))
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -0.005) {
tmp = Math.sin(th) * (Math.sin(ky) / Math.log((ky + 1.0)));
} else if (Math.sin(ky) <= 1e-7) {
tmp = Math.sin(th) * Math.abs((Math.sin(ky) / Math.sin(kx)));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.005: tmp = math.sin(th) * (math.sin(ky) / math.log((ky + 1.0))) elif math.sin(ky) <= 1e-7: tmp = math.sin(th) * math.fabs((math.sin(ky) / math.sin(kx))) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.005) tmp = Float64(sin(th) * Float64(sin(ky) / log(Float64(ky + 1.0)))); elseif (sin(ky) <= 1e-7) tmp = Float64(sin(th) * abs(Float64(sin(ky) / sin(kx)))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.005) tmp = sin(th) * (sin(ky) / log((ky + 1.0))); elseif (sin(ky) <= 1e-7) tmp = sin(th) * abs((sin(ky) / sin(kx))); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.005], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Log[N[(ky + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-7], N[(N[Sin[th], $MachinePrecision] * N[Abs[N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.005:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\log \left(ky + 1\right)}\\
\mathbf{elif}\;\sin ky \leq 10^{-7}:\\
\;\;\;\;\sin th \cdot \left|\frac{\sin ky}{\sin kx}\right|\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.0050000000000000001Initial program 99.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-udef99.7%
add-log-exp99.0%
hypot-udef99.0%
unpow299.0%
unpow299.0%
+-commutative99.0%
unpow299.0%
unpow299.0%
hypot-def99.0%
Applied egg-rr99.0%
Taylor expanded in kx around 0 2.8%
Taylor expanded in ky around 0 6.2%
+-commutative6.2%
Simplified6.2%
if -0.0050000000000000001 < (sin.f64 ky) < 9.9999999999999995e-8Initial program 90.4%
Taylor expanded in ky around 0 51.4%
add-sqr-sqrt19.0%
sqrt-unprod40.7%
pow240.7%
Applied egg-rr40.7%
unpow240.7%
rem-sqrt-square46.4%
Simplified46.4%
if 9.9999999999999995e-8 < (sin.f64 ky) Initial program 99.8%
Taylor expanded in kx around 0 65.5%
Final simplification41.0%
(FPCore (kx ky th) :precision binary64 (if (<= (sin kx) -0.07) (* (sin th) (fabs (/ ky (sin kx)))) (if (<= (sin kx) 5e-68) (sin th) (* (sin ky) (/ (sin th) (sin kx))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(kx) <= -0.07) {
tmp = sin(th) * fabs((ky / sin(kx)));
} else if (sin(kx) <= 5e-68) {
tmp = sin(th);
} else {
tmp = sin(ky) * (sin(th) / sin(kx));
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(kx) <= (-0.07d0)) then
tmp = sin(th) * abs((ky / sin(kx)))
else if (sin(kx) <= 5d-68) then
tmp = sin(th)
else
tmp = sin(ky) * (sin(th) / sin(kx))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(kx) <= -0.07) {
tmp = Math.sin(th) * Math.abs((ky / Math.sin(kx)));
} else if (Math.sin(kx) <= 5e-68) {
tmp = Math.sin(th);
} else {
tmp = Math.sin(ky) * (Math.sin(th) / Math.sin(kx));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(kx) <= -0.07: tmp = math.sin(th) * math.fabs((ky / math.sin(kx))) elif math.sin(kx) <= 5e-68: tmp = math.sin(th) else: tmp = math.sin(ky) * (math.sin(th) / math.sin(kx)) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(kx) <= -0.07) tmp = Float64(sin(th) * abs(Float64(ky / sin(kx)))); elseif (sin(kx) <= 5e-68) tmp = sin(th); else tmp = Float64(sin(ky) * Float64(sin(th) / sin(kx))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(kx) <= -0.07) tmp = sin(th) * abs((ky / sin(kx))); elseif (sin(kx) <= 5e-68) tmp = sin(th); else tmp = sin(ky) * (sin(th) / sin(kx)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[kx], $MachinePrecision], -0.07], N[(N[Sin[th], $MachinePrecision] * N[Abs[N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 5e-68], N[Sin[th], $MachinePrecision], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin kx \leq -0.07:\\
\;\;\;\;\sin th \cdot \left|\frac{ky}{\sin kx}\right|\\
\mathbf{elif}\;\sin kx \leq 5 \cdot 10^{-68}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\sin kx}\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.070000000000000007Initial program 99.4%
Taylor expanded in ky around 0 15.5%
associate-/l*15.5%
associate-/r/15.5%
Simplified15.5%
add-sqr-sqrt8.0%
sqrt-unprod28.6%
pow228.6%
Applied egg-rr28.6%
unpow228.6%
rem-sqrt-square34.4%
Simplified34.4%
if -0.070000000000000007 < (sin.f64 kx) < 4.99999999999999971e-68Initial program 89.9%
Taylor expanded in kx around 0 41.7%
if 4.99999999999999971e-68 < (sin.f64 kx) Initial program 99.6%
expm1-log1p-u99.5%
expm1-udef46.3%
Applied egg-rr46.3%
expm1-def99.5%
expm1-log1p99.6%
*-commutative99.6%
associate-*r/99.1%
associate-*l/99.6%
*-commutative99.6%
hypot-def99.6%
unpow299.6%
unpow299.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.6%
Simplified99.6%
Taylor expanded in ky around 0 62.6%
Final simplification46.0%
(FPCore (kx ky th) :precision binary64 (if (<= (sin kx) -0.07) (* (sin th) (fabs (/ ky (sin kx)))) (if (<= (sin kx) 5e-68) (sin th) (/ (sin ky) (/ (sin kx) (sin th))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(kx) <= -0.07) {
tmp = sin(th) * fabs((ky / sin(kx)));
} else if (sin(kx) <= 5e-68) {
tmp = sin(th);
} else {
tmp = sin(ky) / (sin(kx) / sin(th));
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(kx) <= (-0.07d0)) then
tmp = sin(th) * abs((ky / sin(kx)))
else if (sin(kx) <= 5d-68) 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.07) {
tmp = Math.sin(th) * Math.abs((ky / Math.sin(kx)));
} else if (Math.sin(kx) <= 5e-68) {
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.07: tmp = math.sin(th) * math.fabs((ky / math.sin(kx))) elif math.sin(kx) <= 5e-68: 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.07) tmp = Float64(sin(th) * abs(Float64(ky / sin(kx)))); elseif (sin(kx) <= 5e-68) tmp = sin(th); else tmp = Float64(sin(ky) / Float64(sin(kx) / sin(th))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(kx) <= -0.07) tmp = sin(th) * abs((ky / sin(kx))); elseif (sin(kx) <= 5e-68) 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.07], N[(N[Sin[th], $MachinePrecision] * N[Abs[N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 5e-68], N[Sin[th], $MachinePrecision], N[(N[Sin[ky], $MachinePrecision] / N[(N[Sin[kx], $MachinePrecision] / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin kx \leq -0.07:\\
\;\;\;\;\sin th \cdot \left|\frac{ky}{\sin kx}\right|\\
\mathbf{elif}\;\sin kx \leq 5 \cdot 10^{-68}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\frac{\sin kx}{\sin th}}\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.070000000000000007Initial program 99.4%
Taylor expanded in ky around 0 15.5%
associate-/l*15.5%
associate-/r/15.5%
Simplified15.5%
add-sqr-sqrt8.0%
sqrt-unprod28.6%
pow228.6%
Applied egg-rr28.6%
unpow228.6%
rem-sqrt-square34.4%
Simplified34.4%
if -0.070000000000000007 < (sin.f64 kx) < 4.99999999999999971e-68Initial program 89.9%
Taylor expanded in kx around 0 41.7%
if 4.99999999999999971e-68 < (sin.f64 kx) Initial program 99.6%
Taylor expanded in ky around 0 62.5%
associate-*l/62.0%
associate-/l*62.5%
Applied egg-rr62.5%
Final simplification46.0%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.005) (/ (* (sin ky) th) (fabs (sin kx))) (if (<= (sin ky) 1e-7) (* (sin th) (fabs (/ ky (sin kx)))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.005) {
tmp = (sin(ky) * th) / fabs(sin(kx));
} else if (sin(ky) <= 1e-7) {
tmp = sin(th) * fabs((ky / sin(kx)));
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(ky) <= (-0.005d0)) then
tmp = (sin(ky) * th) / abs(sin(kx))
else if (sin(ky) <= 1d-7) then
tmp = sin(th) * abs((ky / sin(kx)))
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -0.005) {
tmp = (Math.sin(ky) * th) / Math.abs(Math.sin(kx));
} else if (Math.sin(ky) <= 1e-7) {
tmp = Math.sin(th) * Math.abs((ky / Math.sin(kx)));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.005: tmp = (math.sin(ky) * th) / math.fabs(math.sin(kx)) elif math.sin(ky) <= 1e-7: tmp = math.sin(th) * math.fabs((ky / math.sin(kx))) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.005) tmp = Float64(Float64(sin(ky) * th) / abs(sin(kx))); elseif (sin(ky) <= 1e-7) tmp = Float64(sin(th) * abs(Float64(ky / sin(kx)))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.005) tmp = (sin(ky) * th) / abs(sin(kx)); elseif (sin(ky) <= 1e-7) tmp = sin(th) * abs((ky / sin(kx))); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.005], N[(N[(N[Sin[ky], $MachinePrecision] * th), $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-7], N[(N[Sin[th], $MachinePrecision] * N[Abs[N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.005:\\
\;\;\;\;\frac{\sin ky \cdot th}{\left|\sin kx\right|}\\
\mathbf{elif}\;\sin ky \leq 10^{-7}:\\
\;\;\;\;\sin th \cdot \left|\frac{ky}{\sin kx}\right|\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.0050000000000000001Initial program 99.7%
Taylor expanded in ky around 0 8.2%
add-sqr-sqrt1.0%
sqrt-unprod1.9%
pow21.9%
Applied egg-rr1.9%
unpow21.9%
rem-sqrt-square2.1%
Simplified2.1%
Taylor expanded in th around 0 2.9%
fabs-div2.9%
rem-square-sqrt0.0%
fabs-sqr0.0%
rem-square-sqrt8.4%
associate-*r/8.4%
Simplified8.4%
if -0.0050000000000000001 < (sin.f64 ky) < 9.9999999999999995e-8Initial program 90.4%
Taylor expanded in ky around 0 49.1%
associate-/l*51.4%
associate-/r/51.4%
Simplified51.4%
add-sqr-sqrt19.0%
sqrt-unprod40.7%
pow240.7%
Applied egg-rr40.7%
unpow240.7%
rem-sqrt-square46.4%
Simplified46.4%
if 9.9999999999999995e-8 < (sin.f64 ky) Initial program 99.8%
Taylor expanded in kx around 0 65.5%
Final simplification41.6%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.005) (* (sin th) (/ (sin ky) (log (+ ky 1.0)))) (if (<= (sin ky) 1e-7) (* (sin th) (fabs (/ ky (sin kx)))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.005) {
tmp = sin(th) * (sin(ky) / log((ky + 1.0)));
} else if (sin(ky) <= 1e-7) {
tmp = sin(th) * fabs((ky / sin(kx)));
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(ky) <= (-0.005d0)) then
tmp = sin(th) * (sin(ky) / log((ky + 1.0d0)))
else if (sin(ky) <= 1d-7) then
tmp = sin(th) * abs((ky / sin(kx)))
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -0.005) {
tmp = Math.sin(th) * (Math.sin(ky) / Math.log((ky + 1.0)));
} else if (Math.sin(ky) <= 1e-7) {
tmp = Math.sin(th) * Math.abs((ky / Math.sin(kx)));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.005: tmp = math.sin(th) * (math.sin(ky) / math.log((ky + 1.0))) elif math.sin(ky) <= 1e-7: tmp = math.sin(th) * math.fabs((ky / math.sin(kx))) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.005) tmp = Float64(sin(th) * Float64(sin(ky) / log(Float64(ky + 1.0)))); elseif (sin(ky) <= 1e-7) tmp = Float64(sin(th) * abs(Float64(ky / sin(kx)))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.005) tmp = sin(th) * (sin(ky) / log((ky + 1.0))); elseif (sin(ky) <= 1e-7) tmp = sin(th) * abs((ky / sin(kx))); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.005], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Log[N[(ky + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-7], N[(N[Sin[th], $MachinePrecision] * N[Abs[N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.005:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\log \left(ky + 1\right)}\\
\mathbf{elif}\;\sin ky \leq 10^{-7}:\\
\;\;\;\;\sin th \cdot \left|\frac{ky}{\sin kx}\right|\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.0050000000000000001Initial program 99.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-udef99.7%
add-log-exp99.0%
hypot-udef99.0%
unpow299.0%
unpow299.0%
+-commutative99.0%
unpow299.0%
unpow299.0%
hypot-def99.0%
Applied egg-rr99.0%
Taylor expanded in kx around 0 2.8%
Taylor expanded in ky around 0 6.2%
+-commutative6.2%
Simplified6.2%
if -0.0050000000000000001 < (sin.f64 ky) < 9.9999999999999995e-8Initial program 90.4%
Taylor expanded in ky around 0 49.1%
associate-/l*51.4%
associate-/r/51.4%
Simplified51.4%
add-sqr-sqrt19.0%
sqrt-unprod40.7%
pow240.7%
Applied egg-rr40.7%
unpow240.7%
rem-sqrt-square46.4%
Simplified46.4%
if 9.9999999999999995e-8 < (sin.f64 ky) Initial program 99.8%
Taylor expanded in kx around 0 65.5%
Final simplification41.0%
(FPCore (kx ky th) :precision binary64 (* (sin ky) (/ (sin th) (hypot (sin ky) (sin kx)))))
double code(double kx, double ky, double th) {
return sin(ky) * (sin(th) / hypot(sin(ky), sin(kx)));
}
public static double code(double kx, double ky, double th) {
return Math.sin(ky) * (Math.sin(th) / Math.hypot(Math.sin(ky), Math.sin(kx)));
}
def code(kx, ky, th): return math.sin(ky) * (math.sin(th) / math.hypot(math.sin(ky), math.sin(kx)))
function code(kx, ky, th) return Float64(sin(ky) * Float64(sin(th) / hypot(sin(ky), sin(kx)))) end
function tmp = code(kx, ky, th) tmp = sin(ky) * (sin(th) / hypot(sin(ky), sin(kx))); end
code[kx_, ky_, th_] := N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}
\end{array}
Initial program 95.1%
expm1-log1p-u95.0%
expm1-udef41.3%
Applied egg-rr43.0%
expm1-def99.6%
expm1-log1p99.7%
*-commutative99.7%
associate-*r/96.5%
associate-*l/99.6%
*-commutative99.6%
hypot-def95.0%
unpow295.0%
unpow295.0%
+-commutative95.0%
unpow295.0%
unpow295.0%
hypot-def99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (hypot (sin kx) (sin ky))))
(if (<= th 1250.0)
(/ (sin ky) (* t_1 (+ (/ 1.0 th) (* th 0.16666666666666666))))
(if (<= th 2.65e+199)
(/ (* ky (sin th)) t_1)
(* (sin th) (/ (sin ky) (fabs (sin ky))))))))
double code(double kx, double ky, double th) {
double t_1 = hypot(sin(kx), sin(ky));
double tmp;
if (th <= 1250.0) {
tmp = sin(ky) / (t_1 * ((1.0 / th) + (th * 0.16666666666666666)));
} else if (th <= 2.65e+199) {
tmp = (ky * sin(th)) / t_1;
} else {
tmp = sin(th) * (sin(ky) / fabs(sin(ky)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = Math.hypot(Math.sin(kx), Math.sin(ky));
double tmp;
if (th <= 1250.0) {
tmp = Math.sin(ky) / (t_1 * ((1.0 / th) + (th * 0.16666666666666666)));
} else if (th <= 2.65e+199) {
tmp = (ky * Math.sin(th)) / t_1;
} else {
tmp = Math.sin(th) * (Math.sin(ky) / Math.abs(Math.sin(ky)));
}
return tmp;
}
def code(kx, ky, th): t_1 = math.hypot(math.sin(kx), math.sin(ky)) tmp = 0 if th <= 1250.0: tmp = math.sin(ky) / (t_1 * ((1.0 / th) + (th * 0.16666666666666666))) elif th <= 2.65e+199: tmp = (ky * math.sin(th)) / t_1 else: tmp = math.sin(th) * (math.sin(ky) / math.fabs(math.sin(ky))) return tmp
function code(kx, ky, th) t_1 = hypot(sin(kx), sin(ky)) tmp = 0.0 if (th <= 1250.0) tmp = Float64(sin(ky) / Float64(t_1 * Float64(Float64(1.0 / th) + Float64(th * 0.16666666666666666)))); elseif (th <= 2.65e+199) tmp = Float64(Float64(ky * sin(th)) / t_1); else tmp = Float64(sin(th) * Float64(sin(ky) / abs(sin(ky)))); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = hypot(sin(kx), sin(ky)); tmp = 0.0; if (th <= 1250.0) tmp = sin(ky) / (t_1 * ((1.0 / th) + (th * 0.16666666666666666))); elseif (th <= 2.65e+199) tmp = (ky * sin(th)) / t_1; else tmp = sin(th) * (sin(ky) / abs(sin(ky))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]}, If[LessEqual[th, 1250.0], N[(N[Sin[ky], $MachinePrecision] / N[(t$95$1 * N[(N[(1.0 / th), $MachinePrecision] + N[(th * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[th, 2.65e+199], N[(N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Abs[N[Sin[ky], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{hypot}\left(\sin kx, \sin ky\right)\\
\mathbf{if}\;th \leq 1250:\\
\;\;\;\;\frac{\sin ky}{t_1 \cdot \left(\frac{1}{th} + th \cdot 0.16666666666666666\right)}\\
\mathbf{elif}\;th \leq 2.65 \cdot 10^{+199}:\\
\;\;\;\;\frac{ky \cdot \sin th}{t_1}\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\left|\sin ky\right|}\\
\end{array}
\end{array}
if th < 1250Initial program 96.4%
expm1-log1p-u96.3%
expm1-udef39.2%
Applied egg-rr39.3%
expm1-def99.6%
expm1-log1p99.7%
*-commutative99.7%
associate-*r/95.8%
associate-*l/99.6%
*-commutative99.6%
hypot-def96.3%
unpow296.3%
unpow296.3%
+-commutative96.3%
unpow296.3%
unpow296.3%
hypot-def99.6%
Simplified99.6%
clear-num99.4%
un-div-inv99.5%
Applied egg-rr99.5%
Taylor expanded in th around 0 66.3%
+-commutative66.3%
+-commutative66.3%
unpow266.3%
unpow266.3%
hypot-def69.1%
associate-*r*69.1%
+-commutative69.1%
unpow269.1%
unpow269.1%
hypot-def69.1%
distribute-rgt-out69.1%
Simplified69.1%
if 1250 < th < 2.6499999999999998e199Initial program 92.4%
expm1-log1p-u92.0%
expm1-udef41.6%
Applied egg-rr49.0%
expm1-def99.4%
expm1-log1p99.6%
associate-*l/99.7%
Simplified99.7%
Taylor expanded in ky around 0 67.8%
if 2.6499999999999998e199 < th Initial program 86.4%
+-commutative86.4%
unpow286.4%
unpow286.4%
hypot-udef99.7%
add-log-exp77.0%
hypot-udef77.0%
unpow277.0%
unpow277.0%
+-commutative77.0%
unpow277.0%
unpow277.0%
hypot-def77.0%
Applied egg-rr77.0%
Taylor expanded in kx around 0 18.1%
add-sqr-sqrt17.5%
fabs-sqr17.5%
add-sqr-sqrt38.2%
rem-log-exp52.5%
Applied egg-rr52.5%
Final simplification67.5%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (hypot (sin kx) (sin ky))))
(if (<= th 1250.0)
(/ (sin ky) (/ t_1 th))
(if (<= th 1.06e+200)
(/ (* ky (sin th)) t_1)
(* (sin th) (/ (sin ky) (fabs (sin ky))))))))
double code(double kx, double ky, double th) {
double t_1 = hypot(sin(kx), sin(ky));
double tmp;
if (th <= 1250.0) {
tmp = sin(ky) / (t_1 / th);
} else if (th <= 1.06e+200) {
tmp = (ky * sin(th)) / t_1;
} else {
tmp = sin(th) * (sin(ky) / fabs(sin(ky)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = Math.hypot(Math.sin(kx), Math.sin(ky));
double tmp;
if (th <= 1250.0) {
tmp = Math.sin(ky) / (t_1 / th);
} else if (th <= 1.06e+200) {
tmp = (ky * Math.sin(th)) / t_1;
} else {
tmp = Math.sin(th) * (Math.sin(ky) / Math.abs(Math.sin(ky)));
}
return tmp;
}
def code(kx, ky, th): t_1 = math.hypot(math.sin(kx), math.sin(ky)) tmp = 0 if th <= 1250.0: tmp = math.sin(ky) / (t_1 / th) elif th <= 1.06e+200: tmp = (ky * math.sin(th)) / t_1 else: tmp = math.sin(th) * (math.sin(ky) / math.fabs(math.sin(ky))) return tmp
function code(kx, ky, th) t_1 = hypot(sin(kx), sin(ky)) tmp = 0.0 if (th <= 1250.0) tmp = Float64(sin(ky) / Float64(t_1 / th)); elseif (th <= 1.06e+200) tmp = Float64(Float64(ky * sin(th)) / t_1); else tmp = Float64(sin(th) * Float64(sin(ky) / abs(sin(ky)))); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = hypot(sin(kx), sin(ky)); tmp = 0.0; if (th <= 1250.0) tmp = sin(ky) / (t_1 / th); elseif (th <= 1.06e+200) tmp = (ky * sin(th)) / t_1; else tmp = sin(th) * (sin(ky) / abs(sin(ky))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]}, If[LessEqual[th, 1250.0], N[(N[Sin[ky], $MachinePrecision] / N[(t$95$1 / th), $MachinePrecision]), $MachinePrecision], If[LessEqual[th, 1.06e+200], N[(N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Abs[N[Sin[ky], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{hypot}\left(\sin kx, \sin ky\right)\\
\mathbf{if}\;th \leq 1250:\\
\;\;\;\;\frac{\sin ky}{\frac{t_1}{th}}\\
\mathbf{elif}\;th \leq 1.06 \cdot 10^{+200}:\\
\;\;\;\;\frac{ky \cdot \sin th}{t_1}\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\left|\sin ky\right|}\\
\end{array}
\end{array}
if th < 1250Initial program 96.4%
expm1-log1p-u96.3%
expm1-udef39.2%
Applied egg-rr39.3%
expm1-def99.6%
expm1-log1p99.7%
*-commutative99.7%
associate-*r/95.8%
associate-*l/99.6%
*-commutative99.6%
hypot-def96.3%
unpow296.3%
unpow296.3%
+-commutative96.3%
unpow296.3%
unpow296.3%
hypot-def99.6%
Simplified99.6%
clear-num99.4%
un-div-inv99.5%
Applied egg-rr99.5%
Taylor expanded in th around 0 65.8%
associate-*l/65.9%
+-commutative65.9%
unpow265.9%
unpow265.9%
hypot-def68.7%
*-lft-identity68.7%
hypot-def65.9%
unpow265.9%
unpow265.9%
+-commutative65.9%
unpow265.9%
unpow265.9%
hypot-def68.7%
Simplified68.7%
if 1250 < th < 1.0599999999999999e200Initial program 92.4%
expm1-log1p-u92.0%
expm1-udef41.6%
Applied egg-rr49.0%
expm1-def99.4%
expm1-log1p99.6%
associate-*l/99.7%
Simplified99.7%
Taylor expanded in ky around 0 67.8%
if 1.0599999999999999e200 < th Initial program 86.4%
+-commutative86.4%
unpow286.4%
unpow286.4%
hypot-udef99.7%
add-log-exp77.0%
hypot-udef77.0%
unpow277.0%
unpow277.0%
+-commutative77.0%
unpow277.0%
unpow277.0%
hypot-def77.0%
Applied egg-rr77.0%
Taylor expanded in kx around 0 18.1%
add-sqr-sqrt17.5%
fabs-sqr17.5%
add-sqr-sqrt38.2%
rem-log-exp52.5%
Applied egg-rr52.5%
Final simplification67.2%
(FPCore (kx ky th) :precision binary64 (if (<= th 2.9e-6) (/ (sin ky) (/ (hypot (sin kx) (sin ky)) th)) (* (sin th) (/ (sin ky) (fabs (sin ky))))))
double code(double kx, double ky, double th) {
double tmp;
if (th <= 2.9e-6) {
tmp = sin(ky) / (hypot(sin(kx), sin(ky)) / th);
} else {
tmp = sin(th) * (sin(ky) / fabs(sin(ky)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (th <= 2.9e-6) {
tmp = Math.sin(ky) / (Math.hypot(Math.sin(kx), Math.sin(ky)) / th);
} else {
tmp = Math.sin(th) * (Math.sin(ky) / Math.abs(Math.sin(ky)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if th <= 2.9e-6: tmp = math.sin(ky) / (math.hypot(math.sin(kx), math.sin(ky)) / th) else: tmp = math.sin(th) * (math.sin(ky) / math.fabs(math.sin(ky))) return tmp
function code(kx, ky, th) tmp = 0.0 if (th <= 2.9e-6) tmp = Float64(sin(ky) / Float64(hypot(sin(kx), sin(ky)) / th)); else tmp = Float64(sin(th) * Float64(sin(ky) / abs(sin(ky)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (th <= 2.9e-6) tmp = sin(ky) / (hypot(sin(kx), sin(ky)) / th); else tmp = sin(th) * (sin(ky) / abs(sin(ky))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[th, 2.9e-6], N[(N[Sin[ky], $MachinePrecision] / N[(N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision] / th), $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Abs[N[Sin[ky], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;th \leq 2.9 \cdot 10^{-6}:\\
\;\;\;\;\frac{\sin ky}{\frac{\mathsf{hypot}\left(\sin kx, \sin ky\right)}{th}}\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\left|\sin ky\right|}\\
\end{array}
\end{array}
if th < 2.9000000000000002e-6Initial program 96.4%
expm1-log1p-u96.3%
expm1-udef38.7%
Applied egg-rr38.9%
expm1-def99.6%
expm1-log1p99.7%
*-commutative99.7%
associate-*r/95.7%
associate-*l/99.6%
*-commutative99.6%
hypot-def96.3%
unpow296.3%
unpow296.3%
+-commutative96.3%
unpow296.3%
unpow296.3%
hypot-def99.6%
Simplified99.6%
clear-num99.4%
un-div-inv99.5%
Applied egg-rr99.5%
Taylor expanded in th around 0 66.0%
associate-*l/66.0%
+-commutative66.0%
unpow266.0%
unpow266.0%
hypot-def68.9%
*-lft-identity68.9%
hypot-def66.0%
unpow266.0%
unpow266.0%
+-commutative66.0%
unpow266.0%
unpow266.0%
hypot-def68.9%
Simplified68.9%
if 2.9000000000000002e-6 < th Initial program 90.1%
+-commutative90.1%
unpow290.1%
unpow290.1%
hypot-udef99.6%
add-log-exp74.3%
hypot-udef74.3%
unpow274.3%
unpow274.3%
+-commutative74.3%
unpow274.3%
unpow274.3%
hypot-def74.3%
Applied egg-rr74.3%
Taylor expanded in kx around 0 13.7%
add-sqr-sqrt13.2%
fabs-sqr13.2%
add-sqr-sqrt31.4%
rem-log-exp42.5%
Applied egg-rr42.5%
Final simplification63.6%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) 1e-53) (* (sin th) (expm1 (/ ky (sin kx)))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= 1e-53) {
tmp = sin(th) * expm1((ky / sin(kx)));
} else {
tmp = sin(th);
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= 1e-53) {
tmp = Math.sin(th) * Math.expm1((ky / Math.sin(kx)));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= 1e-53: tmp = math.sin(th) * math.expm1((ky / math.sin(kx))) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= 1e-53) tmp = Float64(sin(th) * expm1(Float64(ky / sin(kx)))); else tmp = sin(th); end return tmp end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-53], N[(N[Sin[th], $MachinePrecision] * N[(Exp[N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq 10^{-53}:\\
\;\;\;\;\sin th \cdot \mathsf{expm1}\left(\frac{ky}{\sin kx}\right)\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < 1.00000000000000003e-53Initial program 93.3%
remove-double-neg93.3%
sin-neg93.3%
neg-mul-193.3%
*-commutative93.3%
associate-*l*93.3%
associate-*l/91.7%
associate-/r/91.7%
associate-*l/93.3%
associate-/r/93.2%
sin-neg93.2%
neg-mul-193.2%
associate-/r*93.2%
associate-/r/93.3%
Simplified99.7%
expm1-log1p-u99.7%
hypot-udef93.2%
unpow293.2%
unpow293.2%
+-commutative93.2%
unpow293.2%
unpow293.2%
hypot-def99.7%
Applied egg-rr99.7%
Taylor expanded in ky around 0 48.5%
if 1.00000000000000003e-53 < (sin.f64 ky) Initial program 99.7%
Taylor expanded in kx around 0 60.6%
Final simplification52.0%
(FPCore (kx ky th) :precision binary64 (if (<= ky 9e-8) (* (sin th) (fabs (/ (sin ky) (sin kx)))) (* (sin th) (/ (sin ky) (fabs (sin ky))))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 9e-8) {
tmp = sin(th) * fabs((sin(ky) / sin(kx)));
} else {
tmp = sin(th) * (sin(ky) / fabs(sin(ky)));
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (ky <= 9d-8) then
tmp = sin(th) * abs((sin(ky) / sin(kx)))
else
tmp = sin(th) * (sin(ky) / abs(sin(ky)))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= 9e-8) {
tmp = Math.sin(th) * Math.abs((Math.sin(ky) / Math.sin(kx)));
} else {
tmp = Math.sin(th) * (Math.sin(ky) / Math.abs(Math.sin(ky)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 9e-8: tmp = math.sin(th) * math.fabs((math.sin(ky) / math.sin(kx))) 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 <= 9e-8) tmp = Float64(sin(th) * abs(Float64(sin(ky) / sin(kx)))); else tmp = Float64(sin(th) * Float64(sin(ky) / abs(sin(ky)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 9e-8) tmp = sin(th) * abs((sin(ky) / sin(kx))); else tmp = sin(th) * (sin(ky) / abs(sin(ky))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 9e-8], N[(N[Sin[th], $MachinePrecision] * N[Abs[N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Abs[N[Sin[ky], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 9 \cdot 10^{-8}:\\
\;\;\;\;\sin th \cdot \left|\frac{\sin ky}{\sin kx}\right|\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\left|\sin ky\right|}\\
\end{array}
\end{array}
if ky < 8.99999999999999986e-8Initial program 93.5%
Taylor expanded in ky around 0 36.3%
add-sqr-sqrt13.5%
sqrt-unprod29.4%
pow229.4%
Applied egg-rr29.4%
unpow229.4%
rem-sqrt-square33.3%
Simplified33.3%
if 8.99999999999999986e-8 < ky Initial program 99.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-udef99.7%
add-log-exp98.6%
hypot-udef98.6%
unpow298.6%
unpow298.6%
+-commutative98.6%
unpow298.6%
unpow298.6%
hypot-def98.6%
Applied egg-rr98.6%
Taylor expanded in kx around 0 40.4%
add-sqr-sqrt39.2%
fabs-sqr39.2%
add-sqr-sqrt64.3%
rem-log-exp65.3%
Applied egg-rr65.3%
Final simplification41.7%
(FPCore (kx ky th) :precision binary64 (if (<= ky 8.4e-7) (* (sin th) (fabs (/ ky (sin kx)))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 8.4e-7) {
tmp = sin(th) * fabs((ky / sin(kx)));
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (ky <= 8.4d-7) then
tmp = sin(th) * abs((ky / sin(kx)))
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= 8.4e-7) {
tmp = Math.sin(th) * Math.abs((ky / Math.sin(kx)));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 8.4e-7: tmp = math.sin(th) * math.fabs((ky / math.sin(kx))) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 8.4e-7) tmp = Float64(sin(th) * abs(Float64(ky / sin(kx)))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 8.4e-7) tmp = sin(th) * abs((ky / sin(kx))); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 8.4e-7], N[(N[Sin[th], $MachinePrecision] * N[Abs[N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 8.4 \cdot 10^{-7}:\\
\;\;\;\;\sin th \cdot \left|\frac{ky}{\sin kx}\right|\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 8.4e-7Initial program 93.5%
Taylor expanded in ky around 0 33.8%
associate-/l*35.3%
associate-/r/35.2%
Simplified35.2%
add-sqr-sqrt13.2%
sqrt-unprod27.8%
pow227.8%
Applied egg-rr27.8%
unpow227.8%
rem-sqrt-square31.8%
Simplified31.8%
if 8.4e-7 < ky Initial program 99.7%
Taylor expanded in kx around 0 41.2%
Final simplification34.2%
(FPCore (kx ky th) :precision binary64 (if (<= ky 3e-51) (* (sin th) (/ ky (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 3e-51) {
tmp = sin(th) * (ky / sin(kx));
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (ky <= 3d-51) then
tmp = sin(th) * (ky / sin(kx))
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= 3e-51) {
tmp = Math.sin(th) * (ky / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 3e-51: tmp = math.sin(th) * (ky / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 3e-51) tmp = Float64(sin(th) * Float64(ky / sin(kx))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 3e-51) tmp = sin(th) * (ky / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 3e-51], N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 3 \cdot 10^{-51}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 3.00000000000000002e-51Initial program 93.3%
Taylor expanded in ky around 0 33.0%
associate-/l*34.6%
associate-/r/34.6%
Simplified34.6%
if 3.00000000000000002e-51 < ky Initial program 99.7%
Taylor expanded in kx around 0 39.1%
Final simplification35.9%
(FPCore (kx ky th) :precision binary64 (if (<= ky 1.25e-149) (* (sin th) (/ ky kx)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 1.25e-149) {
tmp = sin(th) * (ky / kx);
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (ky <= 1.25d-149) then
tmp = sin(th) * (ky / kx)
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= 1.25e-149) {
tmp = Math.sin(th) * (ky / kx);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 1.25e-149: tmp = math.sin(th) * (ky / kx) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 1.25e-149) tmp = Float64(sin(th) * Float64(ky / kx)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 1.25e-149) tmp = sin(th) * (ky / kx); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 1.25e-149], N[(N[Sin[th], $MachinePrecision] * N[(ky / kx), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 1.25 \cdot 10^{-149}:\\
\;\;\;\;\sin th \cdot \frac{ky}{kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 1.24999999999999992e-149Initial program 92.6%
Taylor expanded in ky around 0 32.7%
associate-/l*34.5%
associate-/r/34.5%
Simplified34.5%
Taylor expanded in kx around 0 25.1%
if 1.24999999999999992e-149 < ky Initial program 99.7%
Taylor expanded in kx around 0 40.8%
Final simplification30.8%
(FPCore (kx ky th) :precision binary64 (if (<= ky 2.6e-150) (/ (sin th) (/ kx ky)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 2.6e-150) {
tmp = sin(th) / (kx / ky);
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (ky <= 2.6d-150) then
tmp = sin(th) / (kx / ky)
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= 2.6e-150) {
tmp = Math.sin(th) / (kx / ky);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 2.6e-150: tmp = math.sin(th) / (kx / ky) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 2.6e-150) tmp = Float64(sin(th) / Float64(kx / ky)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 2.6e-150) tmp = sin(th) / (kx / ky); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 2.6e-150], N[(N[Sin[th], $MachinePrecision] / N[(kx / ky), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 2.6 \cdot 10^{-150}:\\
\;\;\;\;\frac{\sin th}{\frac{kx}{ky}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 2.5999999999999998e-150Initial program 92.6%
Taylor expanded in ky around 0 32.7%
associate-/l*34.5%
associate-/r/34.5%
Simplified34.5%
Taylor expanded in kx around 0 25.1%
*-commutative25.1%
clear-num25.1%
un-div-inv25.1%
Applied egg-rr25.1%
if 2.5999999999999998e-150 < ky Initial program 99.7%
Taylor expanded in kx around 0 40.8%
Final simplification30.8%
(FPCore (kx ky th) :precision binary64 (if (<= ky 4.2e-160) (/ ky (/ kx th)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 4.2e-160) {
tmp = ky / (kx / th);
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (ky <= 4.2d-160) then
tmp = ky / (kx / th)
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= 4.2e-160) {
tmp = ky / (kx / th);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 4.2e-160: tmp = ky / (kx / th) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 4.2e-160) tmp = Float64(ky / Float64(kx / th)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 4.2e-160) tmp = ky / (kx / th); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 4.2e-160], N[(ky / N[(kx / th), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 4.2 \cdot 10^{-160}:\\
\;\;\;\;\frac{ky}{\frac{kx}{th}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 4.2000000000000001e-160Initial program 92.5%
Taylor expanded in ky around 0 33.1%
associate-/l*34.9%
associate-/r/34.8%
Simplified34.8%
Taylor expanded in kx around 0 25.4%
Taylor expanded in th around 0 19.7%
associate-/l*21.5%
Simplified21.5%
if 4.2000000000000001e-160 < ky Initial program 99.7%
Taylor expanded in kx around 0 40.1%
Final simplification28.4%
(FPCore (kx ky th) :precision binary64 (/ ky (/ kx th)))
double code(double kx, double ky, double th) {
return ky / (kx / th);
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = ky / (kx / th)
end function
public static double code(double kx, double ky, double th) {
return ky / (kx / th);
}
def code(kx, ky, th): return ky / (kx / th)
function code(kx, ky, th) return Float64(ky / Float64(kx / th)) end
function tmp = code(kx, ky, th) tmp = ky / (kx / th); end
code[kx_, ky_, th_] := N[(ky / N[(kx / th), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{ky}{\frac{kx}{th}}
\end{array}
Initial program 95.1%
Taylor expanded in ky around 0 25.7%
associate-/l*26.9%
associate-/r/26.8%
Simplified26.8%
Taylor expanded in kx around 0 18.9%
Taylor expanded in th around 0 15.3%
associate-/l*16.5%
Simplified16.5%
Final simplification16.5%
herbie shell --seed 2024010
(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)))