
(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) (/ (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 91.6%
associate-*l/89.9%
associate-*r/91.6%
+-commutative91.6%
unpow291.6%
unpow291.6%
hypot-def99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (/ (* (sin ky) (sin th)) (fabs (sin kx)))))
(if (<= (sin th) -0.8)
t_1
(if (<= (sin th) -0.65)
(fabs (sin th))
(if (<= (sin th) -0.01)
t_1
(if (<= (sin th) 1e-7)
(* (sin ky) (/ th (hypot (sin ky) (sin kx))))
(if (<= (sin th) 0.87)
(/ (sin ky) (fabs (/ (sin ky) (sin th))))
(* (sin ky) (fabs (/ (sin th) (sin kx)))))))))))
double code(double kx, double ky, double th) {
double t_1 = (sin(ky) * sin(th)) / fabs(sin(kx));
double tmp;
if (sin(th) <= -0.8) {
tmp = t_1;
} else if (sin(th) <= -0.65) {
tmp = fabs(sin(th));
} else if (sin(th) <= -0.01) {
tmp = t_1;
} else if (sin(th) <= 1e-7) {
tmp = sin(ky) * (th / hypot(sin(ky), sin(kx)));
} else if (sin(th) <= 0.87) {
tmp = sin(ky) / fabs((sin(ky) / sin(th)));
} else {
tmp = sin(ky) * fabs((sin(th) / sin(kx)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = (Math.sin(ky) * Math.sin(th)) / Math.abs(Math.sin(kx));
double tmp;
if (Math.sin(th) <= -0.8) {
tmp = t_1;
} else if (Math.sin(th) <= -0.65) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(th) <= -0.01) {
tmp = t_1;
} else if (Math.sin(th) <= 1e-7) {
tmp = Math.sin(ky) * (th / Math.hypot(Math.sin(ky), Math.sin(kx)));
} else if (Math.sin(th) <= 0.87) {
tmp = Math.sin(ky) / Math.abs((Math.sin(ky) / Math.sin(th)));
} else {
tmp = Math.sin(ky) * Math.abs((Math.sin(th) / Math.sin(kx)));
}
return tmp;
}
def code(kx, ky, th): t_1 = (math.sin(ky) * math.sin(th)) / math.fabs(math.sin(kx)) tmp = 0 if math.sin(th) <= -0.8: tmp = t_1 elif math.sin(th) <= -0.65: tmp = math.fabs(math.sin(th)) elif math.sin(th) <= -0.01: tmp = t_1 elif math.sin(th) <= 1e-7: tmp = math.sin(ky) * (th / math.hypot(math.sin(ky), math.sin(kx))) elif math.sin(th) <= 0.87: tmp = math.sin(ky) / math.fabs((math.sin(ky) / math.sin(th))) else: tmp = math.sin(ky) * math.fabs((math.sin(th) / math.sin(kx))) return tmp
function code(kx, ky, th) t_1 = Float64(Float64(sin(ky) * sin(th)) / abs(sin(kx))) tmp = 0.0 if (sin(th) <= -0.8) tmp = t_1; elseif (sin(th) <= -0.65) tmp = abs(sin(th)); elseif (sin(th) <= -0.01) tmp = t_1; elseif (sin(th) <= 1e-7) tmp = Float64(sin(ky) * Float64(th / hypot(sin(ky), sin(kx)))); elseif (sin(th) <= 0.87) tmp = Float64(sin(ky) / abs(Float64(sin(ky) / sin(th)))); else tmp = Float64(sin(ky) * abs(Float64(sin(th) / sin(kx)))); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = (sin(ky) * sin(th)) / abs(sin(kx)); tmp = 0.0; if (sin(th) <= -0.8) tmp = t_1; elseif (sin(th) <= -0.65) tmp = abs(sin(th)); elseif (sin(th) <= -0.01) tmp = t_1; elseif (sin(th) <= 1e-7) tmp = sin(ky) * (th / hypot(sin(ky), sin(kx))); elseif (sin(th) <= 0.87) tmp = sin(ky) / abs((sin(ky) / sin(th))); else tmp = sin(ky) * abs((sin(th) / sin(kx))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[(N[Sin[ky], $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Sin[th], $MachinePrecision], -0.8], t$95$1, If[LessEqual[N[Sin[th], $MachinePrecision], -0.65], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[th], $MachinePrecision], -0.01], t$95$1, If[LessEqual[N[Sin[th], $MachinePrecision], 1e-7], N[(N[Sin[ky], $MachinePrecision] * N[(th / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[th], $MachinePrecision], 0.87], N[(N[Sin[ky], $MachinePrecision] / N[Abs[N[(N[Sin[ky], $MachinePrecision] / N[Sin[th], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sin[ky], $MachinePrecision] * N[Abs[N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\sin ky \cdot \sin th}{\left|\sin kx\right|}\\
\mathbf{if}\;\sin th \leq -0.8:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\sin th \leq -0.65:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin th \leq -0.01:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\sin th \leq 10^{-7}:\\
\;\;\;\;\sin ky \cdot \frac{th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\
\mathbf{elif}\;\sin th \leq 0.87:\\
\;\;\;\;\frac{\sin ky}{\left|\frac{\sin ky}{\sin th}\right|}\\
\mathbf{else}:\\
\;\;\;\;\sin ky \cdot \left|\frac{\sin th}{\sin kx}\right|\\
\end{array}
\end{array}
if (sin.f64 th) < -0.80000000000000004 or -0.650000000000000022 < (sin.f64 th) < -0.0100000000000000002Initial program 93.7%
associate-*l/93.8%
Simplified93.8%
unpow293.8%
sin-mult86.5%
Applied egg-rr86.5%
div-sub86.5%
+-inverses86.5%
cos-086.5%
metadata-eval86.5%
Simplified86.5%
Taylor expanded in ky around 0 36.8%
add-sqr-sqrt36.8%
rem-sqrt-square36.8%
sqr-sin-a44.6%
sqrt-unprod17.4%
add-sqr-sqrt45.2%
Applied egg-rr45.2%
if -0.80000000000000004 < (sin.f64 th) < -0.650000000000000022Initial program 85.7%
associate-/r/85.9%
+-commutative85.9%
unpow285.9%
unpow285.9%
hypot-def99.8%
Simplified99.8%
Taylor expanded in kx around 0 4.3%
associate-/r/4.3%
*-inverses4.3%
*-un-lft-identity4.3%
add-sqr-sqrt0.0%
sqrt-unprod74.5%
pow274.5%
Applied egg-rr74.5%
unpow274.5%
rem-sqrt-square74.5%
Simplified74.5%
if -0.0100000000000000002 < (sin.f64 th) < 9.9999999999999995e-8Initial program 91.2%
associate-*l/87.9%
+-commutative87.9%
unpow287.9%
unpow287.9%
hypot-def91.4%
Simplified91.4%
Taylor expanded in th around 0 91.1%
expm1-log1p-u91.1%
expm1-udef23.1%
Applied egg-rr23.1%
expm1-def91.1%
expm1-log1p91.1%
associate-*r/99.5%
Simplified99.5%
if 9.9999999999999995e-8 < (sin.f64 th) < 0.869999999999999996Initial program 87.1%
associate-/r/87.1%
+-commutative87.1%
unpow287.1%
unpow287.1%
hypot-def99.6%
Simplified99.6%
Taylor expanded in kx around 0 32.1%
add-sqr-sqrt31.1%
sqrt-unprod51.8%
pow251.8%
Applied egg-rr51.8%
unpow251.8%
rem-sqrt-square58.9%
Simplified58.9%
if 0.869999999999999996 < (sin.f64 th) Initial program 99.4%
associate-*l/99.6%
associate-*r/99.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-def99.7%
Simplified99.7%
clear-num99.5%
associate-/r/99.5%
Applied egg-rr99.5%
Taylor expanded in ky around 0 36.7%
add-sqr-sqrt35.2%
sqrt-unprod60.4%
pow260.4%
associate-*l/60.7%
*-un-lft-identity60.7%
Applied egg-rr60.7%
unpow260.7%
rem-sqrt-square60.8%
Simplified60.8%
Final simplification76.5%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -0.85)
(fabs (sin th))
(if (<= (sin ky) -0.005)
(/ (sin ky) (fabs (/ (sin ky) (sin th))))
(if (<= (sin ky) -2e-158)
(/ (* ky (sin th)) (sqrt (- 0.5 (* 0.5 (cos (* kx 2.0))))))
(if (<= (sin ky) 5e-128)
(fabs (* (sin th) (/ (sin ky) (sin kx))))
(if (<= (sin ky) 5e-6)
(/ (* ky th) (hypot (sin ky) (sin kx)))
(sin th)))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.85) {
tmp = fabs(sin(th));
} else if (sin(ky) <= -0.005) {
tmp = sin(ky) / fabs((sin(ky) / sin(th)));
} else if (sin(ky) <= -2e-158) {
tmp = (ky * sin(th)) / sqrt((0.5 - (0.5 * cos((kx * 2.0)))));
} else if (sin(ky) <= 5e-128) {
tmp = fabs((sin(th) * (sin(ky) / sin(kx))));
} else if (sin(ky) <= 5e-6) {
tmp = (ky * th) / 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.85) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(ky) <= -0.005) {
tmp = Math.sin(ky) / Math.abs((Math.sin(ky) / Math.sin(th)));
} else if (Math.sin(ky) <= -2e-158) {
tmp = (ky * Math.sin(th)) / Math.sqrt((0.5 - (0.5 * Math.cos((kx * 2.0)))));
} else if (Math.sin(ky) <= 5e-128) {
tmp = Math.abs((Math.sin(th) * (Math.sin(ky) / Math.sin(kx))));
} else if (Math.sin(ky) <= 5e-6) {
tmp = (ky * th) / 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.85: tmp = math.fabs(math.sin(th)) elif math.sin(ky) <= -0.005: tmp = math.sin(ky) / math.fabs((math.sin(ky) / math.sin(th))) elif math.sin(ky) <= -2e-158: tmp = (ky * math.sin(th)) / math.sqrt((0.5 - (0.5 * math.cos((kx * 2.0))))) elif math.sin(ky) <= 5e-128: tmp = math.fabs((math.sin(th) * (math.sin(ky) / math.sin(kx)))) elif math.sin(ky) <= 5e-6: tmp = (ky * th) / 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.85) tmp = abs(sin(th)); elseif (sin(ky) <= -0.005) tmp = Float64(sin(ky) / abs(Float64(sin(ky) / sin(th)))); elseif (sin(ky) <= -2e-158) tmp = Float64(Float64(ky * sin(th)) / sqrt(Float64(0.5 - Float64(0.5 * cos(Float64(kx * 2.0)))))); elseif (sin(ky) <= 5e-128) tmp = abs(Float64(sin(th) * Float64(sin(ky) / sin(kx)))); elseif (sin(ky) <= 5e-6) tmp = Float64(Float64(ky * th) / 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.85) tmp = abs(sin(th)); elseif (sin(ky) <= -0.005) tmp = sin(ky) / abs((sin(ky) / sin(th))); elseif (sin(ky) <= -2e-158) tmp = (ky * sin(th)) / sqrt((0.5 - (0.5 * cos((kx * 2.0))))); elseif (sin(ky) <= 5e-128) tmp = abs((sin(th) * (sin(ky) / sin(kx)))); elseif (sin(ky) <= 5e-6) tmp = (ky * th) / 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.85], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], -0.005], N[(N[Sin[ky], $MachinePrecision] / N[Abs[N[(N[Sin[ky], $MachinePrecision] / N[Sin[th], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], -2e-158], N[(N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(0.5 - N[(0.5 * N[Cos[N[(kx * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 5e-128], N[Abs[N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 5e-6], N[(N[(ky * th), $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.85:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq -0.005:\\
\;\;\;\;\frac{\sin ky}{\left|\frac{\sin ky}{\sin th}\right|}\\
\mathbf{elif}\;\sin ky \leq -2 \cdot 10^{-158}:\\
\;\;\;\;\frac{ky \cdot \sin th}{\sqrt{0.5 - 0.5 \cdot \cos \left(kx \cdot 2\right)}}\\
\mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-128}:\\
\;\;\;\;\left|\sin th \cdot \frac{\sin ky}{\sin kx}\right|\\
\mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-6}:\\
\;\;\;\;\frac{ky \cdot th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.849999999999999978Initial program 99.7%
associate-/r/99.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.6%
Simplified99.6%
Taylor expanded in kx around 0 2.6%
associate-/r/2.6%
*-inverses2.6%
*-un-lft-identity2.6%
add-sqr-sqrt1.3%
sqrt-unprod39.0%
pow239.0%
Applied egg-rr39.0%
unpow239.0%
rem-sqrt-square45.6%
Simplified45.6%
if -0.849999999999999978 < (sin.f64 ky) < -0.0050000000000000001Initial program 99.6%
associate-/r/99.5%
+-commutative99.5%
unpow299.5%
unpow299.5%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 2.9%
add-sqr-sqrt1.2%
sqrt-unprod26.8%
pow226.8%
Applied egg-rr26.8%
unpow226.8%
rem-sqrt-square36.0%
Simplified36.0%
if -0.0050000000000000001 < (sin.f64 ky) < -2.00000000000000013e-158Initial program 99.5%
associate-*l/96.4%
Simplified96.4%
unpow296.4%
sin-mult89.3%
Applied egg-rr89.3%
div-sub89.3%
+-inverses89.3%
cos-089.3%
metadata-eval89.3%
Simplified89.3%
Taylor expanded in ky around 0 56.5%
Taylor expanded in ky around 0 56.5%
if -2.00000000000000013e-158 < (sin.f64 ky) < 5.0000000000000001e-128Initial program 72.4%
associate-*l/69.3%
associate-*r/72.4%
+-commutative72.4%
unpow272.4%
unpow272.4%
hypot-def99.7%
Simplified99.7%
clear-num99.5%
associate-/r/99.4%
Applied egg-rr99.4%
Taylor expanded in ky around 0 58.2%
add-sqr-sqrt47.4%
sqrt-unprod43.4%
pow243.4%
associate-*l/43.4%
*-un-lft-identity43.4%
Applied egg-rr43.4%
unpow243.4%
rem-sqrt-square70.7%
associate-*r/66.8%
associate-*l/70.6%
*-commutative70.6%
Simplified70.6%
if 5.0000000000000001e-128 < (sin.f64 ky) < 5.00000000000000041e-6Initial program 99.9%
associate-*l/95.5%
+-commutative95.5%
unpow295.5%
unpow295.5%
hypot-def95.5%
Simplified95.5%
Taylor expanded in th around 0 63.5%
Taylor expanded in ky around 0 61.9%
if 5.00000000000000041e-6 < (sin.f64 ky) Initial program 99.7%
associate-*l/99.7%
associate-*r/99.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 67.4%
Final simplification59.8%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (fabs (sin th))))
(if (<= (sin ky) -0.85)
t_1
(if (<= (sin ky) -0.4)
(/ (sin ky) (fabs (/ (sin ky) (sin th))))
(if (<= (sin ky) -0.15)
t_1
(if (<= (sin ky) 1e-42)
(/ (* (sin ky) (sin th)) (fabs (sin kx)))
(sin th)))))))
double code(double kx, double ky, double th) {
double t_1 = fabs(sin(th));
double tmp;
if (sin(ky) <= -0.85) {
tmp = t_1;
} else if (sin(ky) <= -0.4) {
tmp = sin(ky) / fabs((sin(ky) / sin(th)));
} else if (sin(ky) <= -0.15) {
tmp = t_1;
} else if (sin(ky) <= 1e-42) {
tmp = (sin(ky) * sin(th)) / fabs(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) :: t_1
real(8) :: tmp
t_1 = abs(sin(th))
if (sin(ky) <= (-0.85d0)) then
tmp = t_1
else if (sin(ky) <= (-0.4d0)) then
tmp = sin(ky) / abs((sin(ky) / sin(th)))
else if (sin(ky) <= (-0.15d0)) then
tmp = t_1
else if (sin(ky) <= 1d-42) then
tmp = (sin(ky) * sin(th)) / abs(sin(kx))
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double t_1 = Math.abs(Math.sin(th));
double tmp;
if (Math.sin(ky) <= -0.85) {
tmp = t_1;
} else if (Math.sin(ky) <= -0.4) {
tmp = Math.sin(ky) / Math.abs((Math.sin(ky) / Math.sin(th)));
} else if (Math.sin(ky) <= -0.15) {
tmp = t_1;
} else if (Math.sin(ky) <= 1e-42) {
tmp = (Math.sin(ky) * Math.sin(th)) / Math.abs(Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): t_1 = math.fabs(math.sin(th)) tmp = 0 if math.sin(ky) <= -0.85: tmp = t_1 elif math.sin(ky) <= -0.4: tmp = math.sin(ky) / math.fabs((math.sin(ky) / math.sin(th))) elif math.sin(ky) <= -0.15: tmp = t_1 elif math.sin(ky) <= 1e-42: tmp = (math.sin(ky) * math.sin(th)) / math.fabs(math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) t_1 = abs(sin(th)) tmp = 0.0 if (sin(ky) <= -0.85) tmp = t_1; elseif (sin(ky) <= -0.4) tmp = Float64(sin(ky) / abs(Float64(sin(ky) / sin(th)))); elseif (sin(ky) <= -0.15) tmp = t_1; elseif (sin(ky) <= 1e-42) tmp = Float64(Float64(sin(ky) * sin(th)) / abs(sin(kx))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = abs(sin(th)); tmp = 0.0; if (sin(ky) <= -0.85) tmp = t_1; elseif (sin(ky) <= -0.4) tmp = sin(ky) / abs((sin(ky) / sin(th))); elseif (sin(ky) <= -0.15) tmp = t_1; elseif (sin(ky) <= 1e-42) tmp = (sin(ky) * sin(th)) / abs(sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Sin[ky], $MachinePrecision], -0.85], t$95$1, If[LessEqual[N[Sin[ky], $MachinePrecision], -0.4], N[(N[Sin[ky], $MachinePrecision] / N[Abs[N[(N[Sin[ky], $MachinePrecision] / N[Sin[th], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], -0.15], t$95$1, If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-42], N[(N[(N[Sin[ky], $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left|\sin th\right|\\
\mathbf{if}\;\sin ky \leq -0.85:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\sin ky \leq -0.4:\\
\;\;\;\;\frac{\sin ky}{\left|\frac{\sin ky}{\sin th}\right|}\\
\mathbf{elif}\;\sin ky \leq -0.15:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\sin ky \leq 10^{-42}:\\
\;\;\;\;\frac{\sin ky \cdot \sin th}{\left|\sin kx\right|}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.849999999999999978 or -0.40000000000000002 < (sin.f64 ky) < -0.149999999999999994Initial program 99.8%
associate-/r/99.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.6%
Simplified99.6%
Taylor expanded in kx around 0 2.7%
associate-/r/2.7%
*-inverses2.7%
*-un-lft-identity2.7%
add-sqr-sqrt1.3%
sqrt-unprod40.1%
pow240.1%
Applied egg-rr40.1%
unpow240.1%
rem-sqrt-square48.3%
Simplified48.3%
if -0.849999999999999978 < (sin.f64 ky) < -0.40000000000000002Initial program 99.5%
associate-/r/99.4%
+-commutative99.4%
unpow299.4%
unpow299.4%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 3.0%
add-sqr-sqrt1.2%
sqrt-unprod29.2%
pow229.2%
Applied egg-rr29.2%
unpow229.2%
rem-sqrt-square37.7%
Simplified37.7%
if -0.149999999999999994 < (sin.f64 ky) < 1.00000000000000004e-42Initial program 83.2%
associate-*l/80.6%
Simplified80.6%
unpow280.6%
sin-mult64.4%
Applied egg-rr64.4%
div-sub64.4%
+-inverses64.4%
cos-064.4%
metadata-eval64.4%
Simplified64.4%
Taylor expanded in ky around 0 50.1%
add-sqr-sqrt50.1%
rem-sqrt-square50.1%
sqr-sin-a66.8%
sqrt-unprod37.9%
add-sqr-sqrt71.6%
Applied egg-rr71.6%
if 1.00000000000000004e-42 < (sin.f64 ky) Initial program 99.7%
associate-*l/98.4%
associate-*r/99.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 66.7%
Final simplification63.5%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -0.15)
(fabs (sin th))
(if (<= (sin ky) -2e-158)
(/ (* ky (sin th)) (sqrt (- 0.5 (* 0.5 (cos (* kx 2.0))))))
(if (<= (sin ky) 5e-128)
(fabs (* (sin th) (/ (sin ky) (sin kx))))
(if (<= (sin ky) 5e-6)
(/ (* ky th) (hypot (sin ky) (sin kx)))
(sin th))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.15) {
tmp = fabs(sin(th));
} else if (sin(ky) <= -2e-158) {
tmp = (ky * sin(th)) / sqrt((0.5 - (0.5 * cos((kx * 2.0)))));
} else if (sin(ky) <= 5e-128) {
tmp = fabs((sin(th) * (sin(ky) / sin(kx))));
} else if (sin(ky) <= 5e-6) {
tmp = (ky * th) / 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.15) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(ky) <= -2e-158) {
tmp = (ky * Math.sin(th)) / Math.sqrt((0.5 - (0.5 * Math.cos((kx * 2.0)))));
} else if (Math.sin(ky) <= 5e-128) {
tmp = Math.abs((Math.sin(th) * (Math.sin(ky) / Math.sin(kx))));
} else if (Math.sin(ky) <= 5e-6) {
tmp = (ky * th) / 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.15: tmp = math.fabs(math.sin(th)) elif math.sin(ky) <= -2e-158: tmp = (ky * math.sin(th)) / math.sqrt((0.5 - (0.5 * math.cos((kx * 2.0))))) elif math.sin(ky) <= 5e-128: tmp = math.fabs((math.sin(th) * (math.sin(ky) / math.sin(kx)))) elif math.sin(ky) <= 5e-6: tmp = (ky * th) / 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.15) tmp = abs(sin(th)); elseif (sin(ky) <= -2e-158) tmp = Float64(Float64(ky * sin(th)) / sqrt(Float64(0.5 - Float64(0.5 * cos(Float64(kx * 2.0)))))); elseif (sin(ky) <= 5e-128) tmp = abs(Float64(sin(th) * Float64(sin(ky) / sin(kx)))); elseif (sin(ky) <= 5e-6) tmp = Float64(Float64(ky * th) / 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.15) tmp = abs(sin(th)); elseif (sin(ky) <= -2e-158) tmp = (ky * sin(th)) / sqrt((0.5 - (0.5 * cos((kx * 2.0))))); elseif (sin(ky) <= 5e-128) tmp = abs((sin(th) * (sin(ky) / sin(kx)))); elseif (sin(ky) <= 5e-6) tmp = (ky * th) / 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.15], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], -2e-158], N[(N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(0.5 - N[(0.5 * N[Cos[N[(kx * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 5e-128], N[Abs[N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 5e-6], N[(N[(ky * th), $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.15:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq -2 \cdot 10^{-158}:\\
\;\;\;\;\frac{ky \cdot \sin th}{\sqrt{0.5 - 0.5 \cdot \cos \left(kx \cdot 2\right)}}\\
\mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-128}:\\
\;\;\;\;\left|\sin th \cdot \frac{\sin ky}{\sin kx}\right|\\
\mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-6}:\\
\;\;\;\;\frac{ky \cdot th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.149999999999999994Initial program 99.7%
associate-/r/99.5%
+-commutative99.5%
unpow299.5%
unpow299.5%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 2.8%
associate-/r/2.8%
*-inverses2.8%
*-un-lft-identity2.8%
add-sqr-sqrt1.5%
sqrt-unprod29.2%
pow229.2%
Applied egg-rr29.2%
unpow229.2%
rem-sqrt-square35.7%
Simplified35.7%
if -0.149999999999999994 < (sin.f64 ky) < -2.00000000000000013e-158Initial program 99.5%
associate-*l/96.7%
Simplified96.7%
unpow296.7%
sin-mult90.3%
Applied egg-rr90.3%
div-sub90.3%
+-inverses90.3%
cos-090.3%
metadata-eval90.3%
Simplified90.3%
Taylor expanded in ky around 0 53.1%
Taylor expanded in ky around 0 51.6%
if -2.00000000000000013e-158 < (sin.f64 ky) < 5.0000000000000001e-128Initial program 72.4%
associate-*l/69.3%
associate-*r/72.4%
+-commutative72.4%
unpow272.4%
unpow272.4%
hypot-def99.7%
Simplified99.7%
clear-num99.5%
associate-/r/99.4%
Applied egg-rr99.4%
Taylor expanded in ky around 0 58.2%
add-sqr-sqrt47.4%
sqrt-unprod43.4%
pow243.4%
associate-*l/43.4%
*-un-lft-identity43.4%
Applied egg-rr43.4%
unpow243.4%
rem-sqrt-square70.7%
associate-*r/66.8%
associate-*l/70.6%
*-commutative70.6%
Simplified70.6%
if 5.0000000000000001e-128 < (sin.f64 ky) < 5.00000000000000041e-6Initial program 99.9%
associate-*l/95.5%
+-commutative95.5%
unpow295.5%
unpow295.5%
hypot-def95.5%
Simplified95.5%
Taylor expanded in th around 0 63.5%
Taylor expanded in ky around 0 61.9%
if 5.00000000000000041e-6 < (sin.f64 ky) Initial program 99.7%
associate-*l/99.7%
associate-*r/99.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 67.4%
Final simplification58.2%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (hypot (sin ky) (sin kx))))
(if (<= (sin th) -0.01)
(/ (* ky (sin th)) t_1)
(if (<= (sin th) 1e-7)
(* (sin ky) (/ th t_1))
(if (<= (sin th) 0.87)
(/ (sin ky) (fabs (/ (sin ky) (sin th))))
(* (sin ky) (fabs (/ (sin th) (sin kx)))))))))
double code(double kx, double ky, double th) {
double t_1 = hypot(sin(ky), sin(kx));
double tmp;
if (sin(th) <= -0.01) {
tmp = (ky * sin(th)) / t_1;
} else if (sin(th) <= 1e-7) {
tmp = sin(ky) * (th / t_1);
} else if (sin(th) <= 0.87) {
tmp = sin(ky) / fabs((sin(ky) / sin(th)));
} else {
tmp = sin(ky) * fabs((sin(th) / sin(kx)));
}
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(th) <= -0.01) {
tmp = (ky * Math.sin(th)) / t_1;
} else if (Math.sin(th) <= 1e-7) {
tmp = Math.sin(ky) * (th / t_1);
} else if (Math.sin(th) <= 0.87) {
tmp = Math.sin(ky) / Math.abs((Math.sin(ky) / Math.sin(th)));
} else {
tmp = Math.sin(ky) * Math.abs((Math.sin(th) / Math.sin(kx)));
}
return tmp;
}
def code(kx, ky, th): t_1 = math.hypot(math.sin(ky), math.sin(kx)) tmp = 0 if math.sin(th) <= -0.01: tmp = (ky * math.sin(th)) / t_1 elif math.sin(th) <= 1e-7: tmp = math.sin(ky) * (th / t_1) elif math.sin(th) <= 0.87: tmp = math.sin(ky) / math.fabs((math.sin(ky) / math.sin(th))) else: tmp = math.sin(ky) * math.fabs((math.sin(th) / math.sin(kx))) return tmp
function code(kx, ky, th) t_1 = hypot(sin(ky), sin(kx)) tmp = 0.0 if (sin(th) <= -0.01) tmp = Float64(Float64(ky * sin(th)) / t_1); elseif (sin(th) <= 1e-7) tmp = Float64(sin(ky) * Float64(th / t_1)); elseif (sin(th) <= 0.87) tmp = Float64(sin(ky) / abs(Float64(sin(ky) / sin(th)))); else tmp = Float64(sin(ky) * abs(Float64(sin(th) / sin(kx)))); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = hypot(sin(ky), sin(kx)); tmp = 0.0; if (sin(th) <= -0.01) tmp = (ky * sin(th)) / t_1; elseif (sin(th) <= 1e-7) tmp = sin(ky) * (th / t_1); elseif (sin(th) <= 0.87) tmp = sin(ky) / abs((sin(ky) / sin(th))); else tmp = sin(ky) * abs((sin(th) / sin(kx))); 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[th], $MachinePrecision], -0.01], N[(N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision], If[LessEqual[N[Sin[th], $MachinePrecision], 1e-7], N[(N[Sin[ky], $MachinePrecision] * N[(th / t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[th], $MachinePrecision], 0.87], N[(N[Sin[ky], $MachinePrecision] / N[Abs[N[(N[Sin[ky], $MachinePrecision] / N[Sin[th], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sin[ky], $MachinePrecision] * N[Abs[N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{hypot}\left(\sin ky, \sin kx\right)\\
\mathbf{if}\;\sin th \leq -0.01:\\
\;\;\;\;\frac{ky \cdot \sin th}{t_1}\\
\mathbf{elif}\;\sin th \leq 10^{-7}:\\
\;\;\;\;\sin ky \cdot \frac{th}{t_1}\\
\mathbf{elif}\;\sin th \leq 0.87:\\
\;\;\;\;\frac{\sin ky}{\left|\frac{\sin ky}{\sin th}\right|}\\
\mathbf{else}:\\
\;\;\;\;\sin ky \cdot \left|\frac{\sin th}{\sin kx}\right|\\
\end{array}
\end{array}
if (sin.f64 th) < -0.0100000000000000002Initial program 92.8%
associate-*l/92.9%
+-commutative92.9%
unpow292.9%
unpow292.9%
hypot-def99.6%
Simplified99.6%
Taylor expanded in ky around 0 49.8%
if -0.0100000000000000002 < (sin.f64 th) < 9.9999999999999995e-8Initial program 91.2%
associate-*l/87.9%
+-commutative87.9%
unpow287.9%
unpow287.9%
hypot-def91.4%
Simplified91.4%
Taylor expanded in th around 0 91.1%
expm1-log1p-u91.1%
expm1-udef23.1%
Applied egg-rr23.1%
expm1-def91.1%
expm1-log1p91.1%
associate-*r/99.5%
Simplified99.5%
if 9.9999999999999995e-8 < (sin.f64 th) < 0.869999999999999996Initial program 87.1%
associate-/r/87.1%
+-commutative87.1%
unpow287.1%
unpow287.1%
hypot-def99.6%
Simplified99.6%
Taylor expanded in kx around 0 32.1%
add-sqr-sqrt31.1%
sqrt-unprod51.8%
pow251.8%
Applied egg-rr51.8%
unpow251.8%
rem-sqrt-square58.9%
Simplified58.9%
if 0.869999999999999996 < (sin.f64 th) Initial program 99.4%
associate-*l/99.6%
associate-*r/99.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-def99.7%
Simplified99.7%
clear-num99.5%
associate-/r/99.5%
Applied egg-rr99.5%
Taylor expanded in ky around 0 36.7%
add-sqr-sqrt35.2%
sqrt-unprod60.4%
pow260.4%
associate-*l/60.7%
*-un-lft-identity60.7%
Applied egg-rr60.7%
unpow260.7%
rem-sqrt-square60.8%
Simplified60.8%
Final simplification76.8%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.15) (fabs (sin th)) (if (<= (sin ky) 1e-42) (* (sin ky) (/ (sin th) (sin kx))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.15) {
tmp = fabs(sin(th));
} else if (sin(ky) <= 1e-42) {
tmp = sin(ky) * (sin(th) / 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.15d0)) then
tmp = abs(sin(th))
else if (sin(ky) <= 1d-42) then
tmp = sin(ky) * (sin(th) / 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.15) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(ky) <= 1e-42) {
tmp = Math.sin(ky) * (Math.sin(th) / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.15: tmp = math.fabs(math.sin(th)) elif math.sin(ky) <= 1e-42: tmp = math.sin(ky) * (math.sin(th) / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.15) tmp = abs(sin(th)); elseif (sin(ky) <= 1e-42) tmp = Float64(sin(ky) * Float64(sin(th) / sin(kx))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.15) tmp = abs(sin(th)); elseif (sin(ky) <= 1e-42) tmp = sin(ky) * (sin(th) / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.15], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-42], 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.15:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq 10^{-42}:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.149999999999999994Initial program 99.7%
associate-/r/99.5%
+-commutative99.5%
unpow299.5%
unpow299.5%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 2.8%
associate-/r/2.8%
*-inverses2.8%
*-un-lft-identity2.8%
add-sqr-sqrt1.5%
sqrt-unprod29.2%
pow229.2%
Applied egg-rr29.2%
unpow229.2%
rem-sqrt-square35.7%
Simplified35.7%
if -0.149999999999999994 < (sin.f64 ky) < 1.00000000000000004e-42Initial program 83.2%
associate-*l/80.6%
associate-*r/83.2%
+-commutative83.2%
unpow283.2%
unpow283.2%
hypot-def99.7%
Simplified99.7%
Taylor expanded in ky around 0 49.1%
if 1.00000000000000004e-42 < (sin.f64 ky) Initial program 99.7%
associate-*l/98.4%
associate-*r/99.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 66.7%
Final simplification50.6%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin kx) -0.01)
(/ (* ky (sin th)) (sqrt (- 0.5 (* 0.5 (cos (* kx 2.0))))))
(if (<= (sin kx) 2e-89)
(fabs (sin th))
(* (sin ky) (/ (sin th) (sin kx))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(kx) <= -0.01) {
tmp = (ky * sin(th)) / sqrt((0.5 - (0.5 * cos((kx * 2.0)))));
} else if (sin(kx) <= 2e-89) {
tmp = fabs(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.01d0)) then
tmp = (ky * sin(th)) / sqrt((0.5d0 - (0.5d0 * cos((kx * 2.0d0)))))
else if (sin(kx) <= 2d-89) then
tmp = abs(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.01) {
tmp = (ky * Math.sin(th)) / Math.sqrt((0.5 - (0.5 * Math.cos((kx * 2.0)))));
} else if (Math.sin(kx) <= 2e-89) {
tmp = Math.abs(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.01: tmp = (ky * math.sin(th)) / math.sqrt((0.5 - (0.5 * math.cos((kx * 2.0))))) elif math.sin(kx) <= 2e-89: tmp = math.fabs(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.01) tmp = Float64(Float64(ky * sin(th)) / sqrt(Float64(0.5 - Float64(0.5 * cos(Float64(kx * 2.0)))))); elseif (sin(kx) <= 2e-89) tmp = abs(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.01) tmp = (ky * sin(th)) / sqrt((0.5 - (0.5 * cos((kx * 2.0))))); elseif (sin(kx) <= 2e-89) tmp = abs(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.01], N[(N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(0.5 - N[(0.5 * N[Cos[N[(kx * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 2e-89], N[Abs[N[Sin[th], $MachinePrecision]], $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.01:\\
\;\;\;\;\frac{ky \cdot \sin th}{\sqrt{0.5 - 0.5 \cdot \cos \left(kx \cdot 2\right)}}\\
\mathbf{elif}\;\sin kx \leq 2 \cdot 10^{-89}:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{else}:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\sin kx}\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.0100000000000000002Initial program 99.2%
associate-*l/99.5%
Simplified99.5%
unpow299.5%
sin-mult99.1%
Applied egg-rr99.1%
div-sub99.1%
+-inverses99.1%
cos-099.1%
metadata-eval99.1%
Simplified99.1%
Taylor expanded in ky around 0 62.6%
Taylor expanded in ky around 0 54.5%
if -0.0100000000000000002 < (sin.f64 kx) < 2.00000000000000008e-89Initial program 81.4%
associate-/r/81.3%
+-commutative81.3%
unpow281.3%
unpow281.3%
hypot-def99.8%
Simplified99.8%
Taylor expanded in kx around 0 42.1%
associate-/r/42.1%
*-inverses42.1%
*-un-lft-identity42.1%
add-sqr-sqrt24.9%
sqrt-unprod44.0%
pow244.0%
Applied egg-rr44.0%
unpow244.0%
rem-sqrt-square49.3%
Simplified49.3%
if 2.00000000000000008e-89 < (sin.f64 kx) Initial program 99.6%
associate-*l/99.7%
associate-*r/99.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-def99.7%
Simplified99.7%
Taylor expanded in ky around 0 60.2%
Final simplification54.0%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -5e-137) (fabs (sin th)) (if (<= (sin ky) 2e-191) (* (sin ky) (/ th (sin kx))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -5e-137) {
tmp = fabs(sin(th));
} else if (sin(ky) <= 2e-191) {
tmp = sin(ky) * (th / 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-137)) then
tmp = abs(sin(th))
else if (sin(ky) <= 2d-191) then
tmp = sin(ky) * (th / 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-137) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(ky) <= 2e-191) {
tmp = Math.sin(ky) * (th / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -5e-137: tmp = math.fabs(math.sin(th)) elif math.sin(ky) <= 2e-191: tmp = math.sin(ky) * (th / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -5e-137) tmp = abs(sin(th)); elseif (sin(ky) <= 2e-191) tmp = Float64(sin(ky) * Float64(th / sin(kx))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -5e-137) tmp = abs(sin(th)); elseif (sin(ky) <= 2e-191) tmp = sin(ky) * (th / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -5e-137], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-191], N[(N[Sin[ky], $MachinePrecision] * N[(th / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -5 \cdot 10^{-137}:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-191}:\\
\;\;\;\;\sin ky \cdot \frac{th}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -5.00000000000000001e-137Initial program 99.6%
associate-/r/99.5%
+-commutative99.5%
unpow299.5%
unpow299.5%
hypot-def99.6%
Simplified99.6%
Taylor expanded in kx around 0 2.9%
associate-/r/2.9%
*-inverses2.9%
*-un-lft-identity2.9%
add-sqr-sqrt1.4%
sqrt-unprod27.7%
pow227.7%
Applied egg-rr27.7%
unpow227.7%
rem-sqrt-square33.0%
Simplified33.0%
if -5.00000000000000001e-137 < (sin.f64 ky) < 2e-191Initial program 70.7%
associate-*l/67.1%
associate-*r/70.8%
+-commutative70.8%
unpow270.8%
unpow270.8%
hypot-def99.6%
Simplified99.6%
clear-num99.5%
associate-/r/99.4%
Applied egg-rr99.4%
Taylor expanded in ky around 0 57.8%
Taylor expanded in th around 0 41.5%
if 2e-191 < (sin.f64 ky) Initial program 97.5%
associate-*l/96.6%
associate-*r/97.4%
+-commutative97.4%
unpow297.4%
unpow297.4%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 54.3%
Final simplification43.5%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -4e-97) (fabs (sin th)) (if (<= (sin ky) 1e-134) (* (sin ky) (/ (sin th) kx)) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -4e-97) {
tmp = fabs(sin(th));
} else if (sin(ky) <= 1e-134) {
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) <= (-4d-97)) then
tmp = abs(sin(th))
else if (sin(ky) <= 1d-134) 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) <= -4e-97) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(ky) <= 1e-134) {
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) <= -4e-97: tmp = math.fabs(math.sin(th)) elif math.sin(ky) <= 1e-134: 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) <= -4e-97) tmp = abs(sin(th)); elseif (sin(ky) <= 1e-134) 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) <= -4e-97) tmp = abs(sin(th)); elseif (sin(ky) <= 1e-134) 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], -4e-97], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-134], 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 -4 \cdot 10^{-97}:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq 10^{-134}:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -4.00000000000000014e-97Initial program 99.6%
associate-/r/99.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.6%
Simplified99.6%
Taylor expanded in kx around 0 2.8%
associate-/r/2.8%
*-inverses2.8%
*-un-lft-identity2.8%
add-sqr-sqrt1.4%
sqrt-unprod26.0%
pow226.0%
Applied egg-rr26.0%
unpow226.0%
rem-sqrt-square33.0%
Simplified33.0%
if -4.00000000000000014e-97 < (sin.f64 ky) < 1.00000000000000004e-134Initial program 75.5%
associate-*l/71.8%
associate-*r/75.5%
+-commutative75.5%
unpow275.5%
unpow275.5%
hypot-def99.7%
Simplified99.7%
clear-num99.5%
associate-/r/99.4%
Applied egg-rr99.4%
Taylor expanded in ky around 0 55.2%
Taylor expanded in kx around 0 43.7%
if 1.00000000000000004e-134 < (sin.f64 ky) Initial program 99.8%
associate-*l/98.7%
associate-*r/99.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 58.5%
Final simplification45.2%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.005) (fabs (sin th)) (if (<= (sin ky) 1e-42) (/ (sin th) (/ (sin kx) ky)) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.005) {
tmp = fabs(sin(th));
} else if (sin(ky) <= 1e-42) {
tmp = sin(th) / (sin(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) <= (-0.005d0)) then
tmp = abs(sin(th))
else if (sin(ky) <= 1d-42) then
tmp = sin(th) / (sin(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) <= -0.005) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(ky) <= 1e-42) {
tmp = Math.sin(th) / (Math.sin(kx) / ky);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.005: tmp = math.fabs(math.sin(th)) elif math.sin(ky) <= 1e-42: tmp = math.sin(th) / (math.sin(kx) / ky) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.005) tmp = abs(sin(th)); elseif (sin(ky) <= 1e-42) tmp = Float64(sin(th) / Float64(sin(kx) / ky)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.005) tmp = abs(sin(th)); elseif (sin(ky) <= 1e-42) tmp = sin(th) / (sin(kx) / ky); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.005], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-42], N[(N[Sin[th], $MachinePrecision] / N[(N[Sin[kx], $MachinePrecision] / ky), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.005:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq 10^{-42}:\\
\;\;\;\;\frac{\sin th}{\frac{\sin kx}{ky}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.0050000000000000001Initial program 99.6%
associate-/r/99.5%
+-commutative99.5%
unpow299.5%
unpow299.5%
hypot-def99.6%
Simplified99.6%
Taylor expanded in kx around 0 2.8%
associate-/r/2.8%
*-inverses2.8%
*-un-lft-identity2.8%
add-sqr-sqrt1.5%
sqrt-unprod27.9%
pow227.9%
Applied egg-rr27.9%
unpow227.9%
rem-sqrt-square34.2%
Simplified34.2%
if -0.0050000000000000001 < (sin.f64 ky) < 1.00000000000000004e-42Initial program 82.8%
associate-*l/80.1%
associate-*r/82.8%
+-commutative82.8%
unpow282.8%
unpow282.8%
hypot-def99.7%
Simplified99.7%
Taylor expanded in ky around 0 47.1%
associate-/l*49.8%
Simplified49.8%
if 1.00000000000000004e-42 < (sin.f64 ky) Initial program 99.7%
associate-*l/98.4%
associate-*r/99.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 66.7%
Final simplification50.3%
(FPCore (kx ky th) :precision binary64 (if (or (<= ky -1.1e-137) (not (<= ky 3.7e-6))) (fabs (sin th)) (/ ky (/ (sin kx) th))))
double code(double kx, double ky, double th) {
double tmp;
if ((ky <= -1.1e-137) || !(ky <= 3.7e-6)) {
tmp = fabs(sin(th));
} else {
tmp = ky / (sin(kx) / 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.1d-137)) .or. (.not. (ky <= 3.7d-6))) then
tmp = abs(sin(th))
else
tmp = ky / (sin(kx) / th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if ((ky <= -1.1e-137) || !(ky <= 3.7e-6)) {
tmp = Math.abs(Math.sin(th));
} else {
tmp = ky / (Math.sin(kx) / th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if (ky <= -1.1e-137) or not (ky <= 3.7e-6): tmp = math.fabs(math.sin(th)) else: tmp = ky / (math.sin(kx) / th) return tmp
function code(kx, ky, th) tmp = 0.0 if ((ky <= -1.1e-137) || !(ky <= 3.7e-6)) tmp = abs(sin(th)); else tmp = Float64(ky / Float64(sin(kx) / th)); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if ((ky <= -1.1e-137) || ~((ky <= 3.7e-6))) tmp = abs(sin(th)); else tmp = ky / (sin(kx) / th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[Or[LessEqual[ky, -1.1e-137], N[Not[LessEqual[ky, 3.7e-6]], $MachinePrecision]], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], N[(ky / N[(N[Sin[kx], $MachinePrecision] / th), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq -1.1 \cdot 10^{-137} \lor \neg \left(ky \leq 3.7 \cdot 10^{-6}\right):\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{else}:\\
\;\;\;\;\frac{ky}{\frac{\sin kx}{th}}\\
\end{array}
\end{array}
if ky < -1.1000000000000001e-137 or 3.7000000000000002e-6 < ky Initial program 99.7%
associate-/r/99.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.6%
Simplified99.6%
Taylor expanded in kx around 0 29.5%
associate-/r/29.5%
*-inverses29.5%
*-un-lft-identity29.5%
add-sqr-sqrt18.9%
sqrt-unprod32.1%
pow232.1%
Applied egg-rr32.1%
unpow232.1%
rem-sqrt-square38.1%
Simplified38.1%
if -1.1000000000000001e-137 < ky < 3.7000000000000002e-6Initial program 79.1%
associate-*l/76.0%
+-commutative76.0%
unpow276.0%
unpow276.0%
hypot-def90.3%
Simplified90.3%
Taylor expanded in th around 0 44.2%
Taylor expanded in ky around 0 33.4%
associate-/l*36.6%
Simplified36.6%
Final simplification37.5%
(FPCore (kx ky th) :precision binary64 (if (<= ky -22.0) (sin th) (if (<= ky 1.8e-189) (/ ky (/ (sin kx) th)) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= -22.0) {
tmp = sin(th);
} else if (ky <= 1.8e-189) {
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 (ky <= (-22.0d0)) then
tmp = sin(th)
else if (ky <= 1.8d-189) 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 (ky <= -22.0) {
tmp = Math.sin(th);
} else if (ky <= 1.8e-189) {
tmp = ky / (Math.sin(kx) / th);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= -22.0: tmp = math.sin(th) elif ky <= 1.8e-189: tmp = ky / (math.sin(kx) / th) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= -22.0) tmp = sin(th); elseif (ky <= 1.8e-189) 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 (ky <= -22.0) tmp = sin(th); elseif (ky <= 1.8e-189) tmp = ky / (sin(kx) / th); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, -22.0], N[Sin[th], $MachinePrecision], If[LessEqual[ky, 1.8e-189], N[(ky / N[(N[Sin[kx], $MachinePrecision] / th), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq -22:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;ky \leq 1.8 \cdot 10^{-189}:\\
\;\;\;\;\frac{ky}{\frac{\sin kx}{th}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < -22 or 1.80000000000000008e-189 < ky Initial program 98.3%
associate-*l/97.8%
associate-*r/98.3%
+-commutative98.3%
unpow298.3%
unpow298.3%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 34.1%
if -22 < ky < 1.80000000000000008e-189Initial program 79.0%
associate-*l/75.4%
+-commutative75.4%
unpow275.4%
unpow275.4%
hypot-def88.9%
Simplified88.9%
Taylor expanded in th around 0 42.5%
Taylor expanded in ky around 0 31.3%
associate-/l*35.0%
Simplified35.0%
Final simplification34.4%
(FPCore (kx ky th) :precision binary64 (if (<= kx 1.65e-12) (sin th) 0.0))
double code(double kx, double ky, double th) {
double tmp;
if (kx <= 1.65e-12) {
tmp = sin(th);
} else {
tmp = 0.0;
}
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 (kx <= 1.65d-12) then
tmp = sin(th)
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (kx <= 1.65e-12) {
tmp = Math.sin(th);
} else {
tmp = 0.0;
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if kx <= 1.65e-12: tmp = math.sin(th) else: tmp = 0.0 return tmp
function code(kx, ky, th) tmp = 0.0 if (kx <= 1.65e-12) tmp = sin(th); else tmp = 0.0; end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (kx <= 1.65e-12) tmp = sin(th); else tmp = 0.0; end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[kx, 1.65e-12], N[Sin[th], $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;kx \leq 1.65 \cdot 10^{-12}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if kx < 1.65e-12Initial program 88.8%
associate-*l/86.6%
associate-*r/88.8%
+-commutative88.8%
unpow288.8%
unpow288.8%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 30.2%
if 1.65e-12 < kx Initial program 99.4%
associate-/r/99.5%
+-commutative99.5%
unpow299.5%
unpow299.5%
hypot-def99.5%
Simplified99.5%
Taylor expanded in kx around 0 7.2%
associate-/r/7.2%
*-inverses7.2%
*-un-lft-identity7.2%
add-log-exp19.5%
Applied egg-rr19.5%
Taylor expanded in th around 0 17.8%
Final simplification27.0%
(FPCore (kx ky th) :precision binary64 (if (<= kx 1.45e-13) th 0.0))
double code(double kx, double ky, double th) {
double tmp;
if (kx <= 1.45e-13) {
tmp = th;
} else {
tmp = 0.0;
}
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 (kx <= 1.45d-13) then
tmp = th
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (kx <= 1.45e-13) {
tmp = th;
} else {
tmp = 0.0;
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if kx <= 1.45e-13: tmp = th else: tmp = 0.0 return tmp
function code(kx, ky, th) tmp = 0.0 if (kx <= 1.45e-13) tmp = th; else tmp = 0.0; end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (kx <= 1.45e-13) tmp = th; else tmp = 0.0; end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[kx, 1.45e-13], th, 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;kx \leq 1.45 \cdot 10^{-13}:\\
\;\;\;\;th\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if kx < 1.4499999999999999e-13Initial program 88.8%
associate-/r/88.7%
+-commutative88.7%
unpow288.7%
unpow288.7%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 30.1%
Taylor expanded in th around 0 17.3%
if 1.4499999999999999e-13 < kx Initial program 99.4%
associate-/r/99.5%
+-commutative99.5%
unpow299.5%
unpow299.5%
hypot-def99.5%
Simplified99.5%
Taylor expanded in kx around 0 7.2%
associate-/r/7.2%
*-inverses7.2%
*-un-lft-identity7.2%
add-log-exp19.5%
Applied egg-rr19.5%
Taylor expanded in th around 0 17.8%
Final simplification17.4%
(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 91.6%
associate-/r/91.5%
+-commutative91.5%
unpow291.5%
unpow291.5%
hypot-def99.6%
Simplified99.6%
Taylor expanded in kx around 0 24.2%
Taylor expanded in th around 0 14.2%
Final simplification14.2%
herbie shell --seed 2023213
(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)))