
(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 16 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (kx ky th) :precision binary64 (* (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) (sin th)))
double code(double kx, double ky, double th) {
return (sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) * sin(th);
}
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 97.0%
+-commutative97.0%
unpow297.0%
unpow297.0%
hypot-def99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (/ ky (sin kx))))
(if (<= (sin ky) -4e-28)
(/ 1.0 (fabs (fma th 0.16666666666666666 (/ 1.0 th))))
(if (<= (sin ky) -2e-301)
(* t_1 (/ -1.0 (/ -1.0 (sin th))))
(if (<= (sin ky) 5e-26) (* (sin th) (fabs t_1)) (sin th))))))
double code(double kx, double ky, double th) {
double t_1 = ky / sin(kx);
double tmp;
if (sin(ky) <= -4e-28) {
tmp = 1.0 / fabs(fma(th, 0.16666666666666666, (1.0 / th)));
} else if (sin(ky) <= -2e-301) {
tmp = t_1 * (-1.0 / (-1.0 / sin(th)));
} else if (sin(ky) <= 5e-26) {
tmp = sin(th) * fabs(t_1);
} else {
tmp = sin(th);
}
return tmp;
}
function code(kx, ky, th) t_1 = Float64(ky / sin(kx)) tmp = 0.0 if (sin(ky) <= -4e-28) tmp = Float64(1.0 / abs(fma(th, 0.16666666666666666, Float64(1.0 / th)))); elseif (sin(ky) <= -2e-301) tmp = Float64(t_1 * Float64(-1.0 / Float64(-1.0 / sin(th)))); elseif (sin(ky) <= 5e-26) tmp = Float64(sin(th) * abs(t_1)); else tmp = sin(th); end return tmp end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Sin[ky], $MachinePrecision], -4e-28], N[(1.0 / N[Abs[N[(th * 0.16666666666666666 + N[(1.0 / th), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], -2e-301], N[(t$95$1 * N[(-1.0 / N[(-1.0 / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 5e-26], N[(N[Sin[th], $MachinePrecision] * N[Abs[t$95$1], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{ky}{\sin kx}\\
\mathbf{if}\;\sin ky \leq -4 \cdot 10^{-28}:\\
\;\;\;\;\frac{1}{\left|\mathsf{fma}\left(th, 0.16666666666666666, \frac{1}{th}\right)\right|}\\
\mathbf{elif}\;\sin ky \leq -2 \cdot 10^{-301}:\\
\;\;\;\;t_1 \cdot \frac{-1}{\frac{-1}{\sin th}}\\
\mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-26}:\\
\;\;\;\;\sin th \cdot \left|t_1\right|\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -3.99999999999999988e-28Initial program 99.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.6%
Simplified99.6%
associate-/r/99.6%
div-inv99.6%
associate-/r*99.4%
hypot-udef99.4%
unpow299.4%
unpow299.4%
+-commutative99.4%
unpow299.4%
unpow299.4%
hypot-def99.4%
Applied egg-rr99.4%
Taylor expanded in th around 0 51.2%
*-commutative51.2%
Simplified51.2%
Taylor expanded in kx around 0 4.1%
add-sqr-sqrt1.8%
sqrt-unprod10.0%
pow210.0%
+-commutative10.0%
*-commutative10.0%
fma-def10.0%
Applied egg-rr10.0%
unpow210.0%
rem-sqrt-square20.6%
Simplified20.6%
if -3.99999999999999988e-28 < (sin.f64 ky) < -2.00000000000000013e-301Initial program 90.4%
+-commutative90.4%
unpow290.4%
unpow290.4%
hypot-def99.7%
Simplified99.7%
associate-/r/99.5%
div-inv99.3%
associate-/r*99.5%
hypot-udef90.2%
unpow290.2%
unpow290.2%
+-commutative90.2%
unpow290.2%
unpow290.2%
hypot-def99.5%
Applied egg-rr99.5%
Taylor expanded in ky around 0 40.9%
add-sqr-sqrt9.5%
sqrt-unprod19.4%
pow219.4%
Applied egg-rr19.4%
unpow219.4%
rem-sqrt-square19.2%
Simplified19.2%
frac-2neg19.2%
div-inv19.2%
add-sqr-sqrt9.5%
fabs-sqr9.5%
add-sqr-sqrt40.9%
distribute-neg-frac40.9%
distribute-neg-frac40.9%
metadata-eval40.9%
Applied egg-rr40.9%
if -2.00000000000000013e-301 < (sin.f64 ky) < 5.00000000000000019e-26Initial program 98.0%
+-commutative98.0%
unpow298.0%
unpow298.0%
hypot-def99.7%
Simplified99.7%
associate-/r/99.6%
div-inv99.5%
associate-/r*99.5%
hypot-udef97.8%
unpow297.8%
unpow297.8%
+-commutative97.8%
unpow297.8%
unpow297.8%
hypot-def99.5%
Applied egg-rr99.5%
Taylor expanded in ky around 0 50.2%
add-sqr-sqrt43.3%
sqrt-unprod60.3%
pow260.3%
Applied egg-rr60.3%
unpow260.3%
rem-sqrt-square80.0%
Simplified80.0%
Taylor expanded in ky around 0 80.1%
*-commutative80.1%
Simplified80.1%
if 5.00000000000000019e-26 < (sin.f64 ky) Initial program 99.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.6%
Simplified99.6%
Taylor expanded in kx around 0 59.8%
Final simplification50.4%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -0.03)
(/ 1.0 (fabs (fma th 0.16666666666666666 (/ 1.0 th))))
(if (<= (sin ky) 1e-12)
(* ky (/ (sin th) (hypot (sin ky) (sin kx))))
(sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.03) {
tmp = 1.0 / fabs(fma(th, 0.16666666666666666, (1.0 / th)));
} else if (sin(ky) <= 1e-12) {
tmp = ky * (sin(th) / hypot(sin(ky), sin(kx)));
} else {
tmp = sin(th);
}
return tmp;
}
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.03) tmp = Float64(1.0 / abs(fma(th, 0.16666666666666666, Float64(1.0 / th)))); elseif (sin(ky) <= 1e-12) tmp = Float64(ky * Float64(sin(th) / hypot(sin(ky), sin(kx)))); else tmp = sin(th); end return tmp end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.03], N[(1.0 / N[Abs[N[(th * 0.16666666666666666 + N[(1.0 / th), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-12], N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.03:\\
\;\;\;\;\frac{1}{\left|\mathsf{fma}\left(th, 0.16666666666666666, \frac{1}{th}\right)\right|}\\
\mathbf{elif}\;\sin ky \leq 10^{-12}:\\
\;\;\;\;ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.029999999999999999Initial program 99.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.6%
Simplified99.6%
associate-/r/99.6%
div-inv99.6%
associate-/r*99.3%
hypot-udef99.3%
unpow299.3%
unpow299.3%
+-commutative99.3%
unpow299.3%
unpow299.3%
hypot-def99.3%
Applied egg-rr99.3%
Taylor expanded in th around 0 51.2%
*-commutative51.2%
Simplified51.2%
Taylor expanded in kx around 0 4.1%
add-sqr-sqrt1.8%
sqrt-unprod10.4%
pow210.4%
+-commutative10.4%
*-commutative10.4%
fma-def10.4%
Applied egg-rr10.4%
unpow210.4%
rem-sqrt-square20.2%
Simplified20.2%
if -0.029999999999999999 < (sin.f64 ky) < 9.9999999999999998e-13Initial program 94.3%
associate-*l/89.7%
+-commutative89.7%
unpow289.7%
unpow289.7%
hypot-def93.7%
Simplified93.7%
Taylor expanded in ky around 0 93.2%
expm1-log1p-u93.2%
expm1-udef31.8%
associate-/l*31.8%
Applied egg-rr31.8%
expm1-def99.0%
expm1-log1p99.0%
associate-/r/99.2%
*-commutative99.2%
Simplified99.2%
if 9.9999999999999998e-13 < (sin.f64 ky) Initial program 99.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.6%
Simplified99.6%
Taylor expanded in kx around 0 60.1%
Final simplification70.7%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -0.03)
(/ 1.0 (fabs (fma th 0.16666666666666666 (/ 1.0 th))))
(if (<= (sin ky) 1e-12)
(* (sin th) (/ ky (hypot (sin ky) (sin kx))))
(sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.03) {
tmp = 1.0 / fabs(fma(th, 0.16666666666666666, (1.0 / th)));
} else if (sin(ky) <= 1e-12) {
tmp = sin(th) * (ky / hypot(sin(ky), sin(kx)));
} else {
tmp = sin(th);
}
return tmp;
}
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.03) tmp = Float64(1.0 / abs(fma(th, 0.16666666666666666, Float64(1.0 / th)))); elseif (sin(ky) <= 1e-12) tmp = Float64(sin(th) * Float64(ky / hypot(sin(ky), sin(kx)))); else tmp = sin(th); end return tmp end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.03], N[(1.0 / N[Abs[N[(th * 0.16666666666666666 + N[(1.0 / th), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-12], N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.03:\\
\;\;\;\;\frac{1}{\left|\mathsf{fma}\left(th, 0.16666666666666666, \frac{1}{th}\right)\right|}\\
\mathbf{elif}\;\sin ky \leq 10^{-12}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.029999999999999999Initial program 99.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.6%
Simplified99.6%
associate-/r/99.6%
div-inv99.6%
associate-/r*99.3%
hypot-udef99.3%
unpow299.3%
unpow299.3%
+-commutative99.3%
unpow299.3%
unpow299.3%
hypot-def99.3%
Applied egg-rr99.3%
Taylor expanded in th around 0 51.2%
*-commutative51.2%
Simplified51.2%
Taylor expanded in kx around 0 4.1%
add-sqr-sqrt1.8%
sqrt-unprod10.4%
pow210.4%
+-commutative10.4%
*-commutative10.4%
fma-def10.4%
Applied egg-rr10.4%
unpow210.4%
rem-sqrt-square20.2%
Simplified20.2%
if -0.029999999999999999 < (sin.f64 ky) < 9.9999999999999998e-13Initial program 94.3%
associate-*l/89.7%
+-commutative89.7%
unpow289.7%
unpow289.7%
hypot-def93.7%
Simplified93.7%
Taylor expanded in ky around 0 93.2%
*-un-lft-identity93.2%
times-frac99.2%
/-rgt-identity99.2%
Applied egg-rr99.2%
if 9.9999999999999998e-13 < (sin.f64 ky) Initial program 99.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.6%
Simplified99.6%
Taylor expanded in kx around 0 60.1%
Final simplification70.8%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (hypot (sin ky) (sin kx))))
(if (<= (sin ky) -0.03)
(/ (sin ky) (/ t_1 th))
(if (<= (sin ky) 1e-12) (* (sin th) (/ ky t_1)) (sin th)))))
double code(double kx, double ky, double th) {
double t_1 = hypot(sin(ky), sin(kx));
double tmp;
if (sin(ky) <= -0.03) {
tmp = sin(ky) / (t_1 / th);
} else if (sin(ky) <= 1e-12) {
tmp = sin(th) * (ky / t_1);
} else {
tmp = sin(th);
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = Math.hypot(Math.sin(ky), Math.sin(kx));
double tmp;
if (Math.sin(ky) <= -0.03) {
tmp = Math.sin(ky) / (t_1 / th);
} else if (Math.sin(ky) <= 1e-12) {
tmp = Math.sin(th) * (ky / t_1);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): t_1 = math.hypot(math.sin(ky), math.sin(kx)) tmp = 0 if math.sin(ky) <= -0.03: tmp = math.sin(ky) / (t_1 / th) elif math.sin(ky) <= 1e-12: tmp = math.sin(th) * (ky / t_1) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) t_1 = hypot(sin(ky), sin(kx)) tmp = 0.0 if (sin(ky) <= -0.03) tmp = Float64(sin(ky) / Float64(t_1 / th)); elseif (sin(ky) <= 1e-12) tmp = Float64(sin(th) * Float64(ky / t_1)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = hypot(sin(ky), sin(kx)); tmp = 0.0; if (sin(ky) <= -0.03) tmp = sin(ky) / (t_1 / th); elseif (sin(ky) <= 1e-12) tmp = sin(th) * (ky / t_1); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]}, If[LessEqual[N[Sin[ky], $MachinePrecision], -0.03], N[(N[Sin[ky], $MachinePrecision] / N[(t$95$1 / th), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-12], N[(N[Sin[th], $MachinePrecision] * N[(ky / t$95$1), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{hypot}\left(\sin ky, \sin kx\right)\\
\mathbf{if}\;\sin ky \leq -0.03:\\
\;\;\;\;\frac{\sin ky}{\frac{t_1}{th}}\\
\mathbf{elif}\;\sin ky \leq 10^{-12}:\\
\;\;\;\;\sin th \cdot \frac{ky}{t_1}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.029999999999999999Initial program 99.6%
associate-/r/99.6%
+-commutative99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
+-commutative99.6%
Simplified99.6%
Taylor expanded in th around 0 50.4%
associate-*r/50.5%
+-commutative50.5%
unpow250.5%
unpow250.5%
hypot-def50.5%
*-rgt-identity50.5%
hypot-def50.5%
unpow250.5%
unpow250.5%
+-commutative50.5%
unpow250.5%
unpow250.5%
hypot-def50.5%
Simplified50.5%
if -0.029999999999999999 < (sin.f64 ky) < 9.9999999999999998e-13Initial program 94.3%
associate-*l/89.7%
+-commutative89.7%
unpow289.7%
unpow289.7%
hypot-def93.7%
Simplified93.7%
Taylor expanded in ky around 0 93.2%
*-un-lft-identity93.2%
times-frac99.2%
/-rgt-identity99.2%
Applied egg-rr99.2%
if 9.9999999999999998e-13 < (sin.f64 ky) Initial program 99.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.6%
Simplified99.6%
Taylor expanded in kx around 0 60.1%
Final simplification77.4%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -0.03)
(/
(/ (sin ky) (hypot (sin kx) (sin ky)))
(+ (/ 1.0 th) (* th 0.16666666666666666)))
(if (<= (sin ky) 1e-12)
(* (sin th) (/ ky (hypot (sin ky) (sin kx))))
(sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.03) {
tmp = (sin(ky) / hypot(sin(kx), sin(ky))) / ((1.0 / th) + (th * 0.16666666666666666));
} else if (sin(ky) <= 1e-12) {
tmp = sin(th) * (ky / hypot(sin(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) <= -0.03) {
tmp = (Math.sin(ky) / Math.hypot(Math.sin(kx), Math.sin(ky))) / ((1.0 / th) + (th * 0.16666666666666666));
} else if (Math.sin(ky) <= 1e-12) {
tmp = Math.sin(th) * (ky / Math.hypot(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.03: tmp = (math.sin(ky) / math.hypot(math.sin(kx), math.sin(ky))) / ((1.0 / th) + (th * 0.16666666666666666)) elif math.sin(ky) <= 1e-12: tmp = math.sin(th) * (ky / math.hypot(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.03) tmp = Float64(Float64(sin(ky) / hypot(sin(kx), sin(ky))) / Float64(Float64(1.0 / th) + Float64(th * 0.16666666666666666))); elseif (sin(ky) <= 1e-12) tmp = Float64(sin(th) * Float64(ky / hypot(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.03) tmp = (sin(ky) / hypot(sin(kx), sin(ky))) / ((1.0 / th) + (th * 0.16666666666666666)); elseif (sin(ky) <= 1e-12) tmp = sin(th) * (ky / hypot(sin(ky), sin(kx))); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.03], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 / th), $MachinePrecision] + N[(th * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-12], N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.03:\\
\;\;\;\;\frac{\frac{\sin ky}{\mathsf{hypot}\left(\sin kx, \sin ky\right)}}{\frac{1}{th} + th \cdot 0.16666666666666666}\\
\mathbf{elif}\;\sin ky \leq 10^{-12}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.029999999999999999Initial program 99.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.6%
Simplified99.6%
associate-/r/99.6%
div-inv99.6%
associate-/r*99.3%
hypot-udef99.3%
unpow299.3%
unpow299.3%
+-commutative99.3%
unpow299.3%
unpow299.3%
hypot-def99.3%
Applied egg-rr99.3%
Taylor expanded in th around 0 51.2%
*-commutative51.2%
Simplified51.2%
if -0.029999999999999999 < (sin.f64 ky) < 9.9999999999999998e-13Initial program 94.3%
associate-*l/89.7%
+-commutative89.7%
unpow289.7%
unpow289.7%
hypot-def93.7%
Simplified93.7%
Taylor expanded in ky around 0 93.2%
*-un-lft-identity93.2%
times-frac99.2%
/-rgt-identity99.2%
Applied egg-rr99.2%
if 9.9999999999999998e-13 < (sin.f64 ky) Initial program 99.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.6%
Simplified99.6%
Taylor expanded in kx around 0 60.1%
Final simplification77.6%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -4e-28) (/ 1.0 (fabs (fma th 0.16666666666666666 (/ 1.0 th)))) (if (<= (sin ky) 5e-26) (* (sin th) (/ ky (sin kx))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -4e-28) {
tmp = 1.0 / fabs(fma(th, 0.16666666666666666, (1.0 / th)));
} else if (sin(ky) <= 5e-26) {
tmp = sin(th) * (ky / sin(kx));
} else {
tmp = sin(th);
}
return tmp;
}
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -4e-28) tmp = Float64(1.0 / abs(fma(th, 0.16666666666666666, Float64(1.0 / th)))); elseif (sin(ky) <= 5e-26) tmp = Float64(sin(th) * Float64(ky / sin(kx))); else tmp = sin(th); end return tmp end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -4e-28], N[(1.0 / N[Abs[N[(th * 0.16666666666666666 + N[(1.0 / th), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 5e-26], 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 -4 \cdot 10^{-28}:\\
\;\;\;\;\frac{1}{\left|\mathsf{fma}\left(th, 0.16666666666666666, \frac{1}{th}\right)\right|}\\
\mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-26}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -3.99999999999999988e-28Initial program 99.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.6%
Simplified99.6%
associate-/r/99.6%
div-inv99.6%
associate-/r*99.4%
hypot-udef99.4%
unpow299.4%
unpow299.4%
+-commutative99.4%
unpow299.4%
unpow299.4%
hypot-def99.4%
Applied egg-rr99.4%
Taylor expanded in th around 0 51.2%
*-commutative51.2%
Simplified51.2%
Taylor expanded in kx around 0 4.1%
add-sqr-sqrt1.8%
sqrt-unprod10.0%
pow210.0%
+-commutative10.0%
*-commutative10.0%
fma-def10.0%
Applied egg-rr10.0%
unpow210.0%
rem-sqrt-square20.6%
Simplified20.6%
if -3.99999999999999988e-28 < (sin.f64 ky) < 5.00000000000000019e-26Initial program 94.0%
Taylor expanded in ky around 0 45.4%
if 5.00000000000000019e-26 < (sin.f64 ky) Initial program 99.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.6%
Simplified99.6%
Taylor expanded in kx around 0 59.8%
Final simplification43.9%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -2e-52) (* (sin ky) (/ th (sin kx))) (if (<= (sin ky) 1e-143) (/ (/ ky kx) (/ 1.0 (sin th))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -2e-52) {
tmp = sin(ky) * (th / sin(kx));
} else if (sin(ky) <= 1e-143) {
tmp = (ky / kx) / (1.0 / 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-52)) then
tmp = sin(ky) * (th / sin(kx))
else if (sin(ky) <= 1d-143) then
tmp = (ky / kx) / (1.0d0 / 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-52) {
tmp = Math.sin(ky) * (th / Math.sin(kx));
} else if (Math.sin(ky) <= 1e-143) {
tmp = (ky / kx) / (1.0 / Math.sin(th));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -2e-52: tmp = math.sin(ky) * (th / math.sin(kx)) elif math.sin(ky) <= 1e-143: tmp = (ky / kx) / (1.0 / math.sin(th)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -2e-52) tmp = Float64(sin(ky) * Float64(th / sin(kx))); elseif (sin(ky) <= 1e-143) tmp = Float64(Float64(ky / kx) / Float64(1.0 / sin(th))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -2e-52) tmp = sin(ky) * (th / sin(kx)); elseif (sin(ky) <= 1e-143) tmp = (ky / kx) / (1.0 / sin(th)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -2e-52], N[(N[Sin[ky], $MachinePrecision] * N[(th / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-143], N[(N[(ky / kx), $MachinePrecision] / N[(1.0 / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -2 \cdot 10^{-52}:\\
\;\;\;\;\sin ky \cdot \frac{th}{\sin kx}\\
\mathbf{elif}\;\sin ky \leq 10^{-143}:\\
\;\;\;\;\frac{\frac{ky}{kx}}{\frac{1}{\sin th}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -2e-52Initial program 99.6%
associate-/r/99.6%
+-commutative99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
+-commutative99.6%
Simplified99.6%
Taylor expanded in ky around 0 10.2%
Taylor expanded in th around 0 9.6%
associate-/l*9.7%
Simplified9.7%
Taylor expanded in ky around inf 9.6%
associate-*r/9.7%
Simplified9.7%
if -2e-52 < (sin.f64 ky) < 9.9999999999999995e-144Initial program 91.5%
+-commutative91.5%
unpow291.5%
unpow291.5%
hypot-def99.7%
Simplified99.7%
associate-/r/99.6%
div-inv99.4%
associate-/r*99.5%
hypot-udef91.3%
unpow291.3%
unpow291.3%
+-commutative91.3%
unpow291.3%
unpow291.3%
hypot-def99.5%
Applied egg-rr99.5%
Taylor expanded in ky around 0 50.5%
Taylor expanded in kx around 0 35.6%
if 9.9999999999999995e-144 < (sin.f64 ky) Initial program 99.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 54.3%
Final simplification36.6%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) 1e-143) (* (sin ky) (/ (sin th) kx)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= 1e-143) {
tmp = sin(ky) * (sin(th) / 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) <= 1d-143) then
tmp = sin(ky) * (sin(th) / 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) <= 1e-143) {
tmp = Math.sin(ky) * (Math.sin(th) / kx);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= 1e-143: tmp = math.sin(ky) * (math.sin(th) / kx) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= 1e-143) tmp = Float64(sin(ky) * Float64(sin(th) / kx)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= 1e-143) tmp = sin(ky) * (sin(th) / kx); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-143], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / kx), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq 10^{-143}:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < 9.9999999999999995e-144Initial program 95.1%
associate-/r/95.0%
+-commutative95.0%
unpow295.0%
sqr-neg95.0%
sin-neg95.0%
sin-neg95.0%
unpow295.0%
+-commutative95.0%
Simplified99.6%
Taylor expanded in ky around 0 32.5%
*-un-lft-identity32.5%
div-inv32.4%
times-frac31.6%
Applied egg-rr31.6%
Taylor expanded in kx around 0 21.0%
*-commutative21.0%
*-lft-identity21.0%
times-frac21.8%
/-rgt-identity21.8%
Simplified21.8%
if 9.9999999999999995e-144 < (sin.f64 ky) Initial program 99.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 54.3%
Final simplification35.3%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) 5e-26) (* (sin th) (/ ky (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= 5e-26) {
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) <= 5d-26) 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) <= 5e-26) {
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) <= 5e-26: 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) <= 5e-26) 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) <= 5e-26) 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], 5e-26], 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 5 \cdot 10^{-26}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < 5.00000000000000019e-26Initial program 95.9%
Taylor expanded in ky around 0 31.1%
if 5.00000000000000019e-26 < (sin.f64 ky) Initial program 99.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.6%
Simplified99.6%
Taylor expanded in kx around 0 59.8%
Final simplification39.8%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) 1e-143) (/ (/ ky kx) (/ 1.0 (sin th))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= 1e-143) {
tmp = (ky / kx) / (1.0 / 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) <= 1d-143) then
tmp = (ky / kx) / (1.0d0 / 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) <= 1e-143) {
tmp = (ky / kx) / (1.0 / Math.sin(th));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= 1e-143: tmp = (ky / kx) / (1.0 / math.sin(th)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= 1e-143) tmp = Float64(Float64(ky / kx) / Float64(1.0 / sin(th))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= 1e-143) tmp = (ky / kx) / (1.0 / sin(th)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-143], N[(N[(ky / kx), $MachinePrecision] / N[(1.0 / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq 10^{-143}:\\
\;\;\;\;\frac{\frac{ky}{kx}}{\frac{1}{\sin th}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < 9.9999999999999995e-144Initial program 95.1%
+-commutative95.1%
unpow295.1%
unpow295.1%
hypot-def99.7%
Simplified99.7%
associate-/r/99.6%
div-inv99.5%
associate-/r*99.5%
hypot-udef94.9%
unpow294.9%
unpow294.9%
+-commutative94.9%
unpow294.9%
unpow294.9%
hypot-def99.5%
Applied egg-rr99.5%
Taylor expanded in ky around 0 30.5%
Taylor expanded in kx around 0 21.3%
if 9.9999999999999995e-144 < (sin.f64 ky) Initial program 99.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 54.3%
Final simplification35.0%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) 1e-143) (/ ky (/ (sin kx) th)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= 1e-143) {
tmp = ky / (sin(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 (sin(ky) <= 1d-143) then
tmp = ky / (sin(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 (Math.sin(ky) <= 1e-143) {
tmp = ky / (Math.sin(kx) / th);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= 1e-143: tmp = ky / (math.sin(kx) / th) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= 1e-143) tmp = Float64(ky / Float64(sin(kx) / th)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= 1e-143) tmp = ky / (sin(kx) / th); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-143], N[(ky / N[(N[Sin[kx], $MachinePrecision] / th), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq 10^{-143}:\\
\;\;\;\;\frac{ky}{\frac{\sin kx}{th}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < 9.9999999999999995e-144Initial program 95.1%
+-commutative95.1%
unpow295.1%
unpow295.1%
hypot-def99.7%
Simplified99.7%
associate-/r/99.6%
div-inv99.5%
associate-/r*99.5%
hypot-udef94.9%
unpow294.9%
unpow294.9%
+-commutative94.9%
unpow294.9%
unpow294.9%
hypot-def99.5%
Applied egg-rr99.5%
Taylor expanded in ky around 0 30.5%
Taylor expanded in th around 0 19.5%
*-commutative19.5%
associate-/l*20.2%
Simplified20.2%
if 9.9999999999999995e-144 < (sin.f64 ky) Initial program 99.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 54.3%
Final simplification34.3%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) 1e-143) (/ (sin th) (/ kx ky)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= 1e-143) {
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 (sin(ky) <= 1d-143) 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 (Math.sin(ky) <= 1e-143) {
tmp = Math.sin(th) / (kx / ky);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= 1e-143: tmp = math.sin(th) / (kx / ky) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= 1e-143) 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 (sin(ky) <= 1e-143) tmp = sin(th) / (kx / ky); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-143], N[(N[Sin[th], $MachinePrecision] / N[(kx / ky), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq 10^{-143}:\\
\;\;\;\;\frac{\sin th}{\frac{kx}{ky}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < 9.9999999999999995e-144Initial program 95.1%
+-commutative95.1%
unpow295.1%
unpow295.1%
hypot-def99.7%
Simplified99.7%
associate-/r/99.6%
div-inv99.5%
associate-/r*99.5%
hypot-udef94.9%
unpow294.9%
unpow294.9%
+-commutative94.9%
unpow294.9%
unpow294.9%
hypot-def99.5%
Applied egg-rr99.5%
Taylor expanded in ky around 0 30.5%
Taylor expanded in kx around 0 20.6%
associate-/l*21.3%
Simplified21.3%
if 9.9999999999999995e-144 < (sin.f64 ky) Initial program 99.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 54.3%
Final simplification35.0%
(FPCore (kx ky th) :precision binary64 (sin th))
double code(double kx, double ky, double th) {
return 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(th)
end function
public static double code(double kx, double ky, double th) {
return Math.sin(th);
}
def code(kx, ky, th): return math.sin(th)
function code(kx, ky, th) return sin(th) end
function tmp = code(kx, ky, th) tmp = sin(th); end
code[kx_, ky_, th_] := N[Sin[th], $MachinePrecision]
\begin{array}{l}
\\
\sin th
\end{array}
Initial program 97.0%
+-commutative97.0%
unpow297.0%
unpow297.0%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 24.5%
Final simplification24.5%
(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 97.0%
+-commutative97.0%
unpow297.0%
unpow297.0%
hypot-def99.7%
Simplified99.7%
associate-/r/99.6%
div-inv99.4%
associate-/r*99.5%
hypot-udef96.8%
unpow296.8%
unpow296.8%
+-commutative96.8%
unpow296.8%
unpow296.8%
hypot-def99.5%
Applied egg-rr99.5%
Taylor expanded in th around 0 49.3%
*-commutative49.3%
Simplified49.3%
Taylor expanded in kx around 0 14.2%
Final simplification14.2%
(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 97.0%
+-commutative97.0%
unpow297.0%
unpow297.0%
hypot-def99.7%
Simplified99.7%
associate-/r/99.6%
div-inv99.4%
associate-/r*99.5%
hypot-udef96.8%
unpow296.8%
unpow296.8%
+-commutative96.8%
unpow296.8%
unpow296.8%
hypot-def99.5%
Applied egg-rr99.5%
Taylor expanded in th around 0 49.3%
*-commutative49.3%
Simplified49.3%
Taylor expanded in kx around 0 14.2%
Taylor expanded in th around 0 13.6%
Final simplification13.6%
herbie shell --seed 2023274
(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)))