
(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 17 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 94.8%
+-commutative94.8%
unpow294.8%
unpow294.8%
hypot-def99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -0.0238)
(/ (sin ky) (/ (hypot (sin ky) (sin kx)) th))
(if (<= (sin ky) 0.0002)
(/ (sin th) (/ (hypot (sin kx) ky) (sin ky)))
(sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.0238) {
tmp = sin(ky) / (hypot(sin(ky), sin(kx)) / th);
} else if (sin(ky) <= 0.0002) {
tmp = sin(th) / (hypot(sin(kx), ky) / sin(ky));
} else {
tmp = sin(th);
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -0.0238) {
tmp = Math.sin(ky) / (Math.hypot(Math.sin(ky), Math.sin(kx)) / th);
} else if (Math.sin(ky) <= 0.0002) {
tmp = Math.sin(th) / (Math.hypot(Math.sin(kx), ky) / Math.sin(ky));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.0238: tmp = math.sin(ky) / (math.hypot(math.sin(ky), math.sin(kx)) / th) elif math.sin(ky) <= 0.0002: tmp = math.sin(th) / (math.hypot(math.sin(kx), ky) / math.sin(ky)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.0238) tmp = Float64(sin(ky) / Float64(hypot(sin(ky), sin(kx)) / th)); elseif (sin(ky) <= 0.0002) tmp = Float64(sin(th) / Float64(hypot(sin(kx), ky) / sin(ky))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.0238) tmp = sin(ky) / (hypot(sin(ky), sin(kx)) / th); elseif (sin(ky) <= 0.0002) tmp = sin(th) / (hypot(sin(kx), ky) / sin(ky)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.0238], N[(N[Sin[ky], $MachinePrecision] / N[(N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision] / th), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 0.0002], N[(N[Sin[th], $MachinePrecision] / N[(N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + ky ^ 2], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.0238:\\
\;\;\;\;\frac{\sin ky}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right)}{th}}\\
\mathbf{elif}\;\sin ky \leq 0.0002:\\
\;\;\;\;\frac{\sin th}{\frac{\mathsf{hypot}\left(\sin kx, ky\right)}{\sin ky}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.023800000000000002Initial program 99.5%
associate-/r/99.4%
+-commutative99.4%
unpow299.4%
sqr-neg99.4%
sin-neg99.4%
sin-neg99.4%
unpow299.4%
+-commutative99.4%
Simplified99.5%
Taylor expanded in th around 0 63.0%
unpow263.0%
unpow263.0%
hypot-def63.0%
associate-*l/63.1%
*-lft-identity63.1%
hypot-def63.0%
unpow263.0%
unpow263.0%
+-commutative63.0%
unpow263.0%
unpow263.0%
hypot-def63.1%
Simplified63.1%
if -0.023800000000000002 < (sin.f64 ky) < 2.0000000000000001e-4Initial program 89.6%
*-commutative89.6%
clear-num89.6%
+-commutative89.6%
unpow289.6%
unpow289.6%
hypot-udef99.6%
un-div-inv99.6%
Applied egg-rr99.6%
Taylor expanded in ky around 0 98.4%
if 2.0000000000000001e-4 < (sin.f64 ky) Initial program 99.7%
Taylor expanded in kx around 0 64.6%
Final simplification80.4%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -0.0238)
(/ (* (sin ky) th) (hypot (sin ky) (sin kx)))
(if (<= (sin ky) 0.0002)
(/ (sin th) (/ (hypot (sin kx) ky) (sin ky)))
(sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.0238) {
tmp = (sin(ky) * th) / hypot(sin(ky), sin(kx));
} else if (sin(ky) <= 0.0002) {
tmp = sin(th) / (hypot(sin(kx), ky) / sin(ky));
} else {
tmp = sin(th);
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -0.0238) {
tmp = (Math.sin(ky) * th) / Math.hypot(Math.sin(ky), Math.sin(kx));
} else if (Math.sin(ky) <= 0.0002) {
tmp = Math.sin(th) / (Math.hypot(Math.sin(kx), ky) / Math.sin(ky));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.0238: tmp = (math.sin(ky) * th) / math.hypot(math.sin(ky), math.sin(kx)) elif math.sin(ky) <= 0.0002: tmp = math.sin(th) / (math.hypot(math.sin(kx), ky) / math.sin(ky)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.0238) tmp = Float64(Float64(sin(ky) * th) / hypot(sin(ky), sin(kx))); elseif (sin(ky) <= 0.0002) tmp = Float64(sin(th) / Float64(hypot(sin(kx), ky) / sin(ky))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.0238) tmp = (sin(ky) * th) / hypot(sin(ky), sin(kx)); elseif (sin(ky) <= 0.0002) tmp = sin(th) / (hypot(sin(kx), ky) / sin(ky)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.0238], N[(N[(N[Sin[ky], $MachinePrecision] * th), $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 0.0002], N[(N[Sin[th], $MachinePrecision] / N[(N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + ky ^ 2], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.0238:\\
\;\;\;\;\frac{\sin ky \cdot th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\
\mathbf{elif}\;\sin ky \leq 0.0002:\\
\;\;\;\;\frac{\sin th}{\frac{\mathsf{hypot}\left(\sin kx, ky\right)}{\sin ky}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.023800000000000002Initial program 99.5%
associate-*l/99.5%
+-commutative99.5%
unpow299.5%
unpow299.5%
hypot-def99.5%
Simplified99.5%
Taylor expanded in th around 0 63.1%
*-commutative63.1%
Simplified63.1%
if -0.023800000000000002 < (sin.f64 ky) < 2.0000000000000001e-4Initial program 89.6%
*-commutative89.6%
clear-num89.6%
+-commutative89.6%
unpow289.6%
unpow289.6%
hypot-udef99.6%
un-div-inv99.6%
Applied egg-rr99.6%
Taylor expanded in ky around 0 98.4%
if 2.0000000000000001e-4 < (sin.f64 ky) Initial program 99.7%
Taylor expanded in kx around 0 64.6%
Final simplification80.4%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -0.0238)
(/
(sin ky)
(* (hypot (sin ky) (sin kx)) (+ (/ 1.0 th) (* th 0.16666666666666666))))
(if (<= (sin ky) 0.0002)
(/ (sin th) (/ (hypot (sin kx) ky) (sin ky)))
(sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.0238) {
tmp = sin(ky) / (hypot(sin(ky), sin(kx)) * ((1.0 / th) + (th * 0.16666666666666666)));
} else if (sin(ky) <= 0.0002) {
tmp = sin(th) / (hypot(sin(kx), ky) / sin(ky));
} else {
tmp = sin(th);
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -0.0238) {
tmp = Math.sin(ky) / (Math.hypot(Math.sin(ky), Math.sin(kx)) * ((1.0 / th) + (th * 0.16666666666666666)));
} else if (Math.sin(ky) <= 0.0002) {
tmp = Math.sin(th) / (Math.hypot(Math.sin(kx), ky) / Math.sin(ky));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.0238: tmp = math.sin(ky) / (math.hypot(math.sin(ky), math.sin(kx)) * ((1.0 / th) + (th * 0.16666666666666666))) elif math.sin(ky) <= 0.0002: tmp = math.sin(th) / (math.hypot(math.sin(kx), ky) / math.sin(ky)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.0238) tmp = Float64(sin(ky) / Float64(hypot(sin(ky), sin(kx)) * Float64(Float64(1.0 / th) + Float64(th * 0.16666666666666666)))); elseif (sin(ky) <= 0.0002) tmp = Float64(sin(th) / Float64(hypot(sin(kx), ky) / sin(ky))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.0238) tmp = sin(ky) / (hypot(sin(ky), sin(kx)) * ((1.0 / th) + (th * 0.16666666666666666))); elseif (sin(ky) <= 0.0002) tmp = sin(th) / (hypot(sin(kx), ky) / sin(ky)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.0238], N[(N[Sin[ky], $MachinePrecision] / N[(N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision] * N[(N[(1.0 / th), $MachinePrecision] + N[(th * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 0.0002], N[(N[Sin[th], $MachinePrecision] / N[(N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + ky ^ 2], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.0238:\\
\;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \left(\frac{1}{th} + th \cdot 0.16666666666666666\right)}\\
\mathbf{elif}\;\sin ky \leq 0.0002:\\
\;\;\;\;\frac{\sin th}{\frac{\mathsf{hypot}\left(\sin kx, ky\right)}{\sin ky}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.023800000000000002Initial program 99.5%
associate-/r/99.4%
+-commutative99.4%
unpow299.4%
sqr-neg99.4%
sin-neg99.4%
sin-neg99.4%
unpow299.4%
+-commutative99.4%
Simplified99.5%
Taylor expanded in th around 0 63.2%
+-commutative63.2%
*-commutative63.2%
unpow263.2%
unpow263.2%
hypot-def63.3%
associate-*r/63.3%
*-commutative63.3%
associate-*l/63.3%
associate-*r*63.3%
Simplified63.3%
if -0.023800000000000002 < (sin.f64 ky) < 2.0000000000000001e-4Initial program 89.6%
*-commutative89.6%
clear-num89.6%
+-commutative89.6%
unpow289.6%
unpow289.6%
hypot-udef99.6%
un-div-inv99.6%
Applied egg-rr99.6%
Taylor expanded in ky around 0 98.4%
if 2.0000000000000001e-4 < (sin.f64 ky) Initial program 99.7%
Taylor expanded in kx around 0 64.6%
Final simplification80.5%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.08) (/ 1.0 (fabs (fma 0.16666666666666666 th (/ 1.0 th)))) (if (<= (sin ky) 2e-38) (* (sin ky) (/ (sin th) (sin kx))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.08) {
tmp = 1.0 / fabs(fma(0.16666666666666666, th, (1.0 / th)));
} else if (sin(ky) <= 2e-38) {
tmp = sin(ky) * (sin(th) / sin(kx));
} else {
tmp = sin(th);
}
return tmp;
}
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.08) tmp = Float64(1.0 / abs(fma(0.16666666666666666, th, Float64(1.0 / th)))); elseif (sin(ky) <= 2e-38) tmp = Float64(sin(ky) * Float64(sin(th) / sin(kx))); else tmp = sin(th); end return tmp end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.08], N[(1.0 / N[Abs[N[(0.16666666666666666 * th + N[(1.0 / th), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-38], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.08:\\
\;\;\;\;\frac{1}{\left|\mathsf{fma}\left(0.16666666666666666, th, \frac{1}{th}\right)\right|}\\
\mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-38}:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.0800000000000000017Initial program 99.5%
associate-/r/99.4%
+-commutative99.4%
unpow299.4%
sqr-neg99.4%
sin-neg99.4%
sin-neg99.4%
unpow299.4%
+-commutative99.4%
Simplified99.5%
Taylor expanded in th around 0 61.6%
+-commutative61.6%
*-commutative61.6%
unpow261.6%
unpow261.6%
hypot-def61.6%
associate-*r/61.6%
*-commutative61.6%
associate-*l/61.6%
associate-*r*61.6%
Simplified61.6%
Taylor expanded in kx around 0 4.2%
add-sqr-sqrt2.4%
sqrt-unprod14.2%
pow214.2%
*-commutative14.2%
fma-def14.2%
Applied egg-rr14.2%
fma-udef14.2%
*-commutative14.2%
unpow214.2%
rem-sqrt-square21.5%
fma-def21.5%
Simplified21.5%
if -0.0800000000000000017 < (sin.f64 ky) < 1.9999999999999999e-38Initial program 89.2%
+-commutative89.2%
unpow289.2%
unpow289.2%
hypot-def99.6%
Simplified99.6%
clear-num99.6%
inv-pow99.6%
hypot-udef89.2%
unpow289.2%
unpow289.2%
+-commutative89.2%
unpow289.2%
unpow289.2%
hypot-def99.6%
Applied egg-rr99.6%
unpow-199.6%
hypot-def89.2%
unpow289.2%
unpow289.2%
+-commutative89.2%
unpow289.2%
unpow289.2%
hypot-def99.6%
Simplified99.6%
expm1-log1p-u99.5%
expm1-udef36.4%
associate-*l/36.4%
*-un-lft-identity36.4%
Applied egg-rr36.4%
expm1-def99.6%
expm1-log1p99.6%
associate-/r/99.6%
Simplified99.6%
Taylor expanded in ky around 0 45.6%
if 1.9999999999999999e-38 < (sin.f64 ky) Initial program 99.7%
Taylor expanded in kx around 0 64.4%
Final simplification44.6%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.08) (/ 1.0 (fabs (fma 0.16666666666666666 th (/ 1.0 th)))) (if (<= (sin ky) 2e-38) (/ (sin ky) (/ (sin kx) (sin th))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.08) {
tmp = 1.0 / fabs(fma(0.16666666666666666, th, (1.0 / th)));
} else if (sin(ky) <= 2e-38) {
tmp = sin(ky) / (sin(kx) / sin(th));
} else {
tmp = sin(th);
}
return tmp;
}
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.08) tmp = Float64(1.0 / abs(fma(0.16666666666666666, th, Float64(1.0 / th)))); elseif (sin(ky) <= 2e-38) tmp = Float64(sin(ky) / Float64(sin(kx) / sin(th))); else tmp = sin(th); end return tmp end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.08], N[(1.0 / N[Abs[N[(0.16666666666666666 * th + N[(1.0 / th), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-38], N[(N[Sin[ky], $MachinePrecision] / N[(N[Sin[kx], $MachinePrecision] / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.08:\\
\;\;\;\;\frac{1}{\left|\mathsf{fma}\left(0.16666666666666666, th, \frac{1}{th}\right)\right|}\\
\mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-38}:\\
\;\;\;\;\frac{\sin ky}{\frac{\sin kx}{\sin th}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.0800000000000000017Initial program 99.5%
associate-/r/99.4%
+-commutative99.4%
unpow299.4%
sqr-neg99.4%
sin-neg99.4%
sin-neg99.4%
unpow299.4%
+-commutative99.4%
Simplified99.5%
Taylor expanded in th around 0 61.6%
+-commutative61.6%
*-commutative61.6%
unpow261.6%
unpow261.6%
hypot-def61.6%
associate-*r/61.6%
*-commutative61.6%
associate-*l/61.6%
associate-*r*61.6%
Simplified61.6%
Taylor expanded in kx around 0 4.2%
add-sqr-sqrt2.4%
sqrt-unprod14.2%
pow214.2%
*-commutative14.2%
fma-def14.2%
Applied egg-rr14.2%
fma-udef14.2%
*-commutative14.2%
unpow214.2%
rem-sqrt-square21.5%
fma-def21.5%
Simplified21.5%
if -0.0800000000000000017 < (sin.f64 ky) < 1.9999999999999999e-38Initial program 89.2%
associate-/r/89.3%
+-commutative89.3%
unpow289.3%
sqr-neg89.3%
sin-neg89.3%
sin-neg89.3%
unpow289.3%
+-commutative89.3%
Simplified99.7%
Taylor expanded in ky around 0 45.6%
if 1.9999999999999999e-38 < (sin.f64 ky) Initial program 99.7%
Taylor expanded in kx around 0 64.4%
Final simplification44.6%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.02) (/ (sin ky) (/ (hypot kx (sin ky)) th)) (if (<= (sin ky) 2e-38) (/ (sin ky) (/ (sin kx) (sin th))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.02) {
tmp = sin(ky) / (hypot(kx, sin(ky)) / th);
} else if (sin(ky) <= 2e-38) {
tmp = sin(ky) / (sin(kx) / sin(th));
} else {
tmp = sin(th);
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -0.02) {
tmp = Math.sin(ky) / (Math.hypot(kx, Math.sin(ky)) / th);
} else if (Math.sin(ky) <= 2e-38) {
tmp = Math.sin(ky) / (Math.sin(kx) / Math.sin(th));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.02: tmp = math.sin(ky) / (math.hypot(kx, math.sin(ky)) / th) elif math.sin(ky) <= 2e-38: tmp = math.sin(ky) / (math.sin(kx) / math.sin(th)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.02) tmp = Float64(sin(ky) / Float64(hypot(kx, sin(ky)) / th)); elseif (sin(ky) <= 2e-38) tmp = Float64(sin(ky) / Float64(sin(kx) / sin(th))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.02) tmp = sin(ky) / (hypot(kx, sin(ky)) / th); elseif (sin(ky) <= 2e-38) tmp = sin(ky) / (sin(kx) / sin(th)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.02], N[(N[Sin[ky], $MachinePrecision] / N[(N[Sqrt[kx ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision] / th), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-38], N[(N[Sin[ky], $MachinePrecision] / N[(N[Sin[kx], $MachinePrecision] / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.02:\\
\;\;\;\;\frac{\sin ky}{\frac{\mathsf{hypot}\left(kx, \sin ky\right)}{th}}\\
\mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-38}:\\
\;\;\;\;\frac{\sin ky}{\frac{\sin kx}{\sin th}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.0200000000000000004Initial program 99.5%
associate-/r/99.4%
+-commutative99.4%
unpow299.4%
sqr-neg99.4%
sin-neg99.4%
sin-neg99.4%
unpow299.4%
+-commutative99.4%
Simplified99.5%
Taylor expanded in th around 0 62.3%
+-commutative62.3%
*-commutative62.3%
unpow262.3%
unpow262.3%
hypot-def62.4%
associate-*r/62.4%
*-commutative62.4%
associate-*l/62.4%
associate-*r*62.4%
Simplified62.4%
Taylor expanded in kx around 0 36.4%
Taylor expanded in th around 0 36.4%
associate-*l/36.5%
+-commutative36.5%
unpow236.5%
unpow236.5%
hypot-def36.4%
*-lft-identity36.4%
hypot-def36.5%
unpow236.5%
unpow236.5%
+-commutative36.5%
unpow236.5%
unpow236.5%
hypot-def36.4%
Simplified36.4%
if -0.0200000000000000004 < (sin.f64 ky) < 1.9999999999999999e-38Initial program 88.9%
associate-/r/89.0%
+-commutative89.0%
unpow289.0%
sqr-neg89.0%
sin-neg89.0%
sin-neg89.0%
unpow289.0%
+-commutative89.0%
Simplified99.7%
Taylor expanded in ky around 0 46.9%
if 1.9999999999999999e-38 < (sin.f64 ky) Initial program 99.7%
Taylor expanded in kx around 0 64.4%
Final simplification48.9%
(FPCore (kx ky th) :precision binary64 (if (<= (sin kx) 1e-22) (* (sin th) (/ (sin ky) (hypot (sin ky) kx))) (/ (sin ky) (/ (sin kx) (sin th)))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(kx) <= 1e-22) {
tmp = sin(th) * (sin(ky) / hypot(sin(ky), kx));
} else {
tmp = sin(ky) / (sin(kx) / sin(th));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(kx) <= 1e-22) {
tmp = Math.sin(th) * (Math.sin(ky) / Math.hypot(Math.sin(ky), kx));
} else {
tmp = Math.sin(ky) / (Math.sin(kx) / Math.sin(th));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(kx) <= 1e-22: tmp = math.sin(th) * (math.sin(ky) / math.hypot(math.sin(ky), kx)) else: tmp = math.sin(ky) / (math.sin(kx) / math.sin(th)) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(kx) <= 1e-22) tmp = Float64(sin(th) * Float64(sin(ky) / hypot(sin(ky), kx))); 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) <= 1e-22) tmp = sin(th) * (sin(ky) / hypot(sin(ky), kx)); else tmp = sin(ky) / (sin(kx) / sin(th)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[kx], $MachinePrecision], 1e-22], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + kx ^ 2], $MachinePrecision]), $MachinePrecision]), $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 10^{-22}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\frac{\sin kx}{\sin th}}\\
\end{array}
\end{array}
if (sin.f64 kx) < 1e-22Initial program 93.2%
+-commutative93.2%
unpow293.2%
unpow293.2%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 75.2%
if 1e-22 < (sin.f64 kx) Initial program 99.4%
associate-/r/99.4%
+-commutative99.4%
unpow299.4%
sqr-neg99.4%
sin-neg99.4%
sin-neg99.4%
unpow299.4%
+-commutative99.4%
Simplified99.5%
Taylor expanded in ky around 0 56.3%
Final simplification70.3%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.05) (/ 1.0 (fabs (fma 0.16666666666666666 th (/ 1.0 th)))) (if (<= (sin ky) 2e-38) (/ ky (/ (sin kx) (sin th))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.05) {
tmp = 1.0 / fabs(fma(0.16666666666666666, th, (1.0 / th)));
} else if (sin(ky) <= 2e-38) {
tmp = ky / (sin(kx) / sin(th));
} else {
tmp = sin(th);
}
return tmp;
}
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.05) tmp = Float64(1.0 / abs(fma(0.16666666666666666, th, Float64(1.0 / th)))); elseif (sin(ky) <= 2e-38) tmp = Float64(ky / Float64(sin(kx) / sin(th))); else tmp = sin(th); end return tmp end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.05], N[(1.0 / N[Abs[N[(0.16666666666666666 * th + N[(1.0 / th), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-38], N[(ky / N[(N[Sin[kx], $MachinePrecision] / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.05:\\
\;\;\;\;\frac{1}{\left|\mathsf{fma}\left(0.16666666666666666, th, \frac{1}{th}\right)\right|}\\
\mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-38}:\\
\;\;\;\;\frac{ky}{\frac{\sin kx}{\sin th}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.050000000000000003Initial program 99.6%
associate-/r/99.4%
+-commutative99.4%
unpow299.4%
sqr-neg99.4%
sin-neg99.4%
sin-neg99.4%
unpow299.4%
+-commutative99.4%
Simplified99.5%
Taylor expanded in th around 0 62.1%
+-commutative62.1%
*-commutative62.1%
unpow262.1%
unpow262.1%
hypot-def62.2%
associate-*r/62.2%
*-commutative62.2%
associate-*l/62.2%
associate-*r*62.2%
Simplified62.2%
Taylor expanded in kx around 0 4.2%
add-sqr-sqrt2.4%
sqrt-unprod14.1%
pow214.1%
*-commutative14.1%
fma-def14.1%
Applied egg-rr14.1%
fma-udef14.1%
*-commutative14.1%
unpow214.1%
rem-sqrt-square21.3%
fma-def21.3%
Simplified21.3%
if -0.050000000000000003 < (sin.f64 ky) < 1.9999999999999999e-38Initial program 89.1%
Taylor expanded in ky around 0 43.5%
associate-/l*45.9%
Simplified45.9%
if 1.9999999999999999e-38 < (sin.f64 ky) Initial program 99.7%
Taylor expanded in kx around 0 64.4%
Final simplification44.6%
(FPCore (kx ky th) :precision binary64 (if (<= kx 0.0136) (* (sin th) (/ (sin ky) (hypot (sin ky) kx))) (/ (sin ky) (/ (hypot (sin ky) (sin kx)) th))))
double code(double kx, double ky, double th) {
double tmp;
if (kx <= 0.0136) {
tmp = sin(th) * (sin(ky) / hypot(sin(ky), kx));
} else {
tmp = sin(ky) / (hypot(sin(ky), sin(kx)) / th);
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (kx <= 0.0136) {
tmp = Math.sin(th) * (Math.sin(ky) / Math.hypot(Math.sin(ky), kx));
} else {
tmp = Math.sin(ky) / (Math.hypot(Math.sin(ky), Math.sin(kx)) / th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if kx <= 0.0136: tmp = math.sin(th) * (math.sin(ky) / math.hypot(math.sin(ky), kx)) else: tmp = math.sin(ky) / (math.hypot(math.sin(ky), math.sin(kx)) / th) return tmp
function code(kx, ky, th) tmp = 0.0 if (kx <= 0.0136) tmp = Float64(sin(th) * Float64(sin(ky) / hypot(sin(ky), kx))); else tmp = Float64(sin(ky) / Float64(hypot(sin(ky), sin(kx)) / th)); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (kx <= 0.0136) tmp = sin(th) * (sin(ky) / hypot(sin(ky), kx)); else tmp = sin(ky) / (hypot(sin(ky), sin(kx)) / th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[kx, 0.0136], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + kx ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[ky], $MachinePrecision] / N[(N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision] / th), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;kx \leq 0.0136:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right)}{th}}\\
\end{array}
\end{array}
if kx < 0.0135999999999999992Initial program 93.2%
+-commutative93.2%
unpow293.2%
unpow293.2%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 73.1%
if 0.0135999999999999992 < kx Initial program 99.4%
associate-/r/99.5%
+-commutative99.5%
unpow299.5%
sqr-neg99.5%
sin-neg99.5%
sin-neg99.5%
unpow299.5%
+-commutative99.5%
Simplified99.6%
Taylor expanded in th around 0 49.6%
unpow249.6%
unpow249.6%
hypot-def49.7%
associate-*l/49.7%
*-lft-identity49.7%
hypot-def49.7%
unpow249.7%
unpow249.7%
+-commutative49.7%
unpow249.7%
unpow249.7%
hypot-def49.7%
Simplified49.7%
Final simplification67.2%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) 2e-38) (* (sin th) (/ ky (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= 2e-38) {
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 (sin(ky) <= 2d-38) 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 (Math.sin(ky) <= 2e-38) {
tmp = Math.sin(th) * (ky / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= 2e-38: tmp = math.sin(th) * (ky / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= 2e-38) 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 (sin(ky) <= 2e-38) tmp = sin(th) * (ky / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-38], 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}\;\sin ky \leq 2 \cdot 10^{-38}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < 1.9999999999999999e-38Initial program 92.9%
+-commutative92.9%
unpow292.9%
unpow292.9%
hypot-def99.6%
Simplified99.6%
Taylor expanded in ky around 0 30.4%
if 1.9999999999999999e-38 < (sin.f64 ky) Initial program 99.7%
Taylor expanded in kx around 0 64.4%
Final simplification39.8%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) 2e-38) (/ ky (/ (sin kx) (sin th))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= 2e-38) {
tmp = ky / (sin(kx) / sin(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 (sin(ky) <= 2d-38) then
tmp = ky / (sin(kx) / sin(th))
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) <= 2e-38) {
tmp = ky / (Math.sin(kx) / Math.sin(th));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= 2e-38: tmp = ky / (math.sin(kx) / math.sin(th)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= 2e-38) tmp = Float64(ky / Float64(sin(kx) / sin(th))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= 2e-38) tmp = ky / (sin(kx) / sin(th)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-38], N[(ky / N[(N[Sin[kx], $MachinePrecision] / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq 2 \cdot 10^{-38}:\\
\;\;\;\;\frac{ky}{\frac{\sin kx}{\sin th}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < 1.9999999999999999e-38Initial program 92.9%
Taylor expanded in ky around 0 28.9%
associate-/l*30.4%
Simplified30.4%
if 1.9999999999999999e-38 < (sin.f64 ky) Initial program 99.7%
Taylor expanded in kx around 0 64.4%
Final simplification39.8%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) 5e-173) (/ ky (* (sin kx) (+ (/ 1.0 th) (* th 0.16666666666666666)))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= 5e-173) {
tmp = ky / (sin(kx) * ((1.0 / th) + (th * 0.16666666666666666)));
} 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) <= 5d-173) then
tmp = ky / (sin(kx) * ((1.0d0 / th) + (th * 0.16666666666666666d0)))
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) <= 5e-173) {
tmp = ky / (Math.sin(kx) * ((1.0 / th) + (th * 0.16666666666666666)));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= 5e-173: tmp = ky / (math.sin(kx) * ((1.0 / th) + (th * 0.16666666666666666))) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= 5e-173) tmp = Float64(ky / Float64(sin(kx) * Float64(Float64(1.0 / th) + Float64(th * 0.16666666666666666)))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= 5e-173) tmp = ky / (sin(kx) * ((1.0 / th) + (th * 0.16666666666666666))); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], 5e-173], N[(ky / N[(N[Sin[kx], $MachinePrecision] * N[(N[(1.0 / th), $MachinePrecision] + N[(th * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq 5 \cdot 10^{-173}:\\
\;\;\;\;\frac{ky}{\sin kx \cdot \left(\frac{1}{th} + th \cdot 0.16666666666666666\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < 5.0000000000000002e-173Initial program 91.7%
associate-/r/91.7%
+-commutative91.7%
unpow291.7%
sqr-neg91.7%
sin-neg91.7%
sin-neg91.7%
unpow291.7%
+-commutative91.7%
Simplified99.6%
Taylor expanded in th around 0 48.8%
+-commutative48.8%
*-commutative48.8%
unpow248.8%
unpow248.8%
hypot-def52.6%
associate-*r/52.6%
*-commutative52.6%
associate-*l/52.6%
associate-*r*52.6%
Simplified52.6%
Taylor expanded in ky around 0 18.2%
if 5.0000000000000002e-173 < (sin.f64 ky) Initial program 99.7%
Taylor expanded in kx around 0 55.2%
Final simplification32.5%
(FPCore (kx ky th)
:precision binary64
(if (<= ky -8.5e+18)
(sin th)
(if (<= ky 1.9e-169)
(/ ky (* kx (+ (/ 1.0 th) (* th 0.16666666666666666))))
(sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= -8.5e+18) {
tmp = sin(th);
} else if (ky <= 1.9e-169) {
tmp = ky / (kx * ((1.0 / th) + (th * 0.16666666666666666)));
} 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.5d+18)) then
tmp = sin(th)
else if (ky <= 1.9d-169) then
tmp = ky / (kx * ((1.0d0 / th) + (th * 0.16666666666666666d0)))
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.5e+18) {
tmp = Math.sin(th);
} else if (ky <= 1.9e-169) {
tmp = ky / (kx * ((1.0 / th) + (th * 0.16666666666666666)));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= -8.5e+18: tmp = math.sin(th) elif ky <= 1.9e-169: tmp = ky / (kx * ((1.0 / th) + (th * 0.16666666666666666))) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= -8.5e+18) tmp = sin(th); elseif (ky <= 1.9e-169) tmp = Float64(ky / Float64(kx * Float64(Float64(1.0 / th) + Float64(th * 0.16666666666666666)))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= -8.5e+18) tmp = sin(th); elseif (ky <= 1.9e-169) tmp = ky / (kx * ((1.0 / th) + (th * 0.16666666666666666))); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, -8.5e+18], N[Sin[th], $MachinePrecision], If[LessEqual[ky, 1.9e-169], N[(ky / N[(kx * N[(N[(1.0 / th), $MachinePrecision] + N[(th * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq -8.5 \cdot 10^{+18}:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;ky \leq 1.9 \cdot 10^{-169}:\\
\;\;\;\;\frac{ky}{kx \cdot \left(\frac{1}{th} + th \cdot 0.16666666666666666\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < -8.5e18 or 1.9e-169 < ky Initial program 99.6%
Taylor expanded in kx around 0 34.6%
if -8.5e18 < ky < 1.9e-169Initial program 86.2%
associate-/r/86.3%
+-commutative86.3%
unpow286.3%
sqr-neg86.3%
sin-neg86.3%
sin-neg86.3%
unpow286.3%
+-commutative86.3%
Simplified99.7%
Taylor expanded in th around 0 39.1%
+-commutative39.1%
*-commutative39.1%
unpow239.1%
unpow239.1%
hypot-def45.6%
associate-*r/45.6%
*-commutative45.6%
associate-*l/45.6%
associate-*r*45.6%
Simplified45.6%
Taylor expanded in kx around 0 36.3%
Taylor expanded in ky around 0 25.6%
Final simplification31.4%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (+ (/ 1.0 th) (* th 0.16666666666666666))))
(if (or (<= ky -3.3e+21) (not (<= ky 3.8e-125)))
(/ 1.0 t_1)
(/ ky (* kx t_1)))))
double code(double kx, double ky, double th) {
double t_1 = (1.0 / th) + (th * 0.16666666666666666);
double tmp;
if ((ky <= -3.3e+21) || !(ky <= 3.8e-125)) {
tmp = 1.0 / t_1;
} else {
tmp = ky / (kx * t_1);
}
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) :: t_1
real(8) :: tmp
t_1 = (1.0d0 / th) + (th * 0.16666666666666666d0)
if ((ky <= (-3.3d+21)) .or. (.not. (ky <= 3.8d-125))) then
tmp = 1.0d0 / t_1
else
tmp = ky / (kx * t_1)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double t_1 = (1.0 / th) + (th * 0.16666666666666666);
double tmp;
if ((ky <= -3.3e+21) || !(ky <= 3.8e-125)) {
tmp = 1.0 / t_1;
} else {
tmp = ky / (kx * t_1);
}
return tmp;
}
def code(kx, ky, th): t_1 = (1.0 / th) + (th * 0.16666666666666666) tmp = 0 if (ky <= -3.3e+21) or not (ky <= 3.8e-125): tmp = 1.0 / t_1 else: tmp = ky / (kx * t_1) return tmp
function code(kx, ky, th) t_1 = Float64(Float64(1.0 / th) + Float64(th * 0.16666666666666666)) tmp = 0.0 if ((ky <= -3.3e+21) || !(ky <= 3.8e-125)) tmp = Float64(1.0 / t_1); else tmp = Float64(ky / Float64(kx * t_1)); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = (1.0 / th) + (th * 0.16666666666666666); tmp = 0.0; if ((ky <= -3.3e+21) || ~((ky <= 3.8e-125))) tmp = 1.0 / t_1; else tmp = ky / (kx * t_1); end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[(1.0 / th), $MachinePrecision] + N[(th * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[ky, -3.3e+21], N[Not[LessEqual[ky, 3.8e-125]], $MachinePrecision]], N[(1.0 / t$95$1), $MachinePrecision], N[(ky / N[(kx * t$95$1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{1}{th} + th \cdot 0.16666666666666666\\
\mathbf{if}\;ky \leq -3.3 \cdot 10^{+21} \lor \neg \left(ky \leq 3.8 \cdot 10^{-125}\right):\\
\;\;\;\;\frac{1}{t_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{ky}{kx \cdot t_1}\\
\end{array}
\end{array}
if ky < -3.3e21 or 3.8000000000000001e-125 < ky Initial program 99.6%
associate-/r/99.5%
+-commutative99.5%
unpow299.5%
sqr-neg99.5%
sin-neg99.5%
sin-neg99.5%
unpow299.5%
+-commutative99.5%
Simplified99.5%
Taylor expanded in th around 0 49.0%
+-commutative49.0%
*-commutative49.0%
unpow249.0%
unpow249.0%
hypot-def49.1%
associate-*r/49.1%
*-commutative49.1%
associate-*l/49.1%
associate-*r*49.1%
Simplified49.1%
Taylor expanded in kx around 0 15.2%
if -3.3e21 < ky < 3.8000000000000001e-125Initial program 87.1%
associate-/r/87.2%
+-commutative87.2%
unpow287.2%
sqr-neg87.2%
sin-neg87.2%
sin-neg87.2%
unpow287.2%
+-commutative87.2%
Simplified99.7%
Taylor expanded in th around 0 37.9%
+-commutative37.9%
*-commutative37.9%
unpow237.9%
unpow237.9%
hypot-def44.0%
associate-*r/44.0%
*-commutative44.0%
associate-*l/44.0%
associate-*r*44.0%
Simplified44.0%
Taylor expanded in kx around 0 35.0%
Taylor expanded in ky around 0 24.0%
Final simplification18.6%
(FPCore (kx ky th) :precision binary64 (/ 1.0 (+ (/ 1.0 th) (* th 0.16666666666666666))))
double code(double kx, double ky, double th) {
return 1.0 / ((1.0 / th) + (th * 0.16666666666666666));
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = 1.0d0 / ((1.0d0 / th) + (th * 0.16666666666666666d0))
end function
public static double code(double kx, double ky, double th) {
return 1.0 / ((1.0 / th) + (th * 0.16666666666666666));
}
def code(kx, ky, th): return 1.0 / ((1.0 / th) + (th * 0.16666666666666666))
function code(kx, ky, th) return Float64(1.0 / Float64(Float64(1.0 / th) + Float64(th * 0.16666666666666666))) end
function tmp = code(kx, ky, th) tmp = 1.0 / ((1.0 / th) + (th * 0.16666666666666666)); end
code[kx_, ky_, th_] := N[(1.0 / N[(N[(1.0 / th), $MachinePrecision] + N[(th * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\frac{1}{th} + th \cdot 0.16666666666666666}
\end{array}
Initial program 94.8%
associate-/r/94.8%
+-commutative94.8%
unpow294.8%
sqr-neg94.8%
sin-neg94.8%
sin-neg94.8%
unpow294.8%
+-commutative94.8%
Simplified99.6%
Taylor expanded in th around 0 44.7%
+-commutative44.7%
*-commutative44.7%
unpow244.7%
unpow244.7%
hypot-def47.1%
associate-*r/47.2%
*-commutative47.2%
associate-*l/47.1%
associate-*r*47.1%
Simplified47.1%
Taylor expanded in kx around 0 11.1%
Final simplification11.1%
(FPCore (kx ky th) :precision binary64 th)
double code(double kx, double ky, double th) {
return th;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = th
end function
public static double code(double kx, double ky, double th) {
return th;
}
def code(kx, ky, th): return th
function code(kx, ky, th) return th end
function tmp = code(kx, ky, th) tmp = th; end
code[kx_, ky_, th_] := th
\begin{array}{l}
\\
th
\end{array}
Initial program 94.8%
associate-/r/94.8%
+-commutative94.8%
unpow294.8%
sqr-neg94.8%
sin-neg94.8%
sin-neg94.8%
unpow294.8%
+-commutative94.8%
Simplified99.6%
Taylor expanded in th around 0 44.7%
+-commutative44.7%
*-commutative44.7%
unpow244.7%
unpow244.7%
hypot-def47.1%
associate-*r/47.2%
*-commutative47.2%
associate-*l/47.1%
associate-*r*47.1%
Simplified47.1%
Taylor expanded in kx around 0 11.1%
Taylor expanded in th around 0 10.5%
Final simplification10.5%
herbie shell --seed 2023264
(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)))