
(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 95.0%
+-commutative95.0%
unpow295.0%
unpow295.0%
hypot-undefine99.6%
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -0.05)
(* (sin ky) (/ (sin th) (sin kx)))
(if (<= (sin ky) 0.05)
(* (sin th) (/ (/ 1.0 (hypot (sin ky) (sin kx))) (/ 1.0 ky)))
(sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.05) {
tmp = sin(ky) * (sin(th) / sin(kx));
} else if (sin(ky) <= 0.05) {
tmp = sin(th) * ((1.0 / hypot(sin(ky), sin(kx))) / (1.0 / ky));
} else {
tmp = sin(th);
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -0.05) {
tmp = Math.sin(ky) * (Math.sin(th) / Math.sin(kx));
} else if (Math.sin(ky) <= 0.05) {
tmp = Math.sin(th) * ((1.0 / Math.hypot(Math.sin(ky), Math.sin(kx))) / (1.0 / ky));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.05: tmp = math.sin(ky) * (math.sin(th) / math.sin(kx)) elif math.sin(ky) <= 0.05: tmp = math.sin(th) * ((1.0 / math.hypot(math.sin(ky), math.sin(kx))) / (1.0 / ky)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.05) tmp = Float64(sin(ky) * Float64(sin(th) / sin(kx))); elseif (sin(ky) <= 0.05) tmp = Float64(sin(th) * Float64(Float64(1.0 / hypot(sin(ky), sin(kx))) / Float64(1.0 / ky))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.05) tmp = sin(ky) * (sin(th) / sin(kx)); elseif (sin(ky) <= 0.05) tmp = sin(th) * ((1.0 / hypot(sin(ky), sin(kx))) / (1.0 / ky)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.05], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 0.05], N[(N[Sin[th], $MachinePrecision] * N[(N[(1.0 / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] / N[(1.0 / ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.05:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{elif}\;\sin ky \leq 0.05:\\
\;\;\;\;\sin th \cdot \frac{\frac{1}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}}{\frac{1}{ky}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.050000000000000003Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/99.6%
associate-/l*99.6%
unpow299.6%
Simplified99.6%
Taylor expanded in ky around 0 7.0%
if -0.050000000000000003 < (sin.f64 ky) < 0.050000000000000003Initial program 90.6%
clear-num90.5%
inv-pow90.5%
+-commutative90.5%
unpow290.5%
unpow290.5%
hypot-undefine99.5%
Applied egg-rr99.5%
unpow-199.5%
div-inv99.5%
associate-/r*99.6%
Applied egg-rr99.6%
Taylor expanded in ky around 0 99.1%
if 0.050000000000000003 < (sin.f64 ky) Initial program 99.5%
unpow299.5%
sqr-neg99.5%
sin-neg99.5%
sin-neg99.5%
unpow299.5%
associate-*l/99.4%
associate-/l*99.6%
unpow299.6%
Simplified99.6%
Taylor expanded in kx around 0 54.2%
Final simplification65.6%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin kx) -0.07)
(* (sin th) (fabs (/ (sin ky) (sin kx))))
(if (<= (sin kx) 1e-86)
(/ (sin th) (fma 0.5 (pow (/ kx (sin ky)) 2.0) 1.0))
(/ (sin th) (/ (sin kx) (sin ky))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(kx) <= -0.07) {
tmp = sin(th) * fabs((sin(ky) / sin(kx)));
} else if (sin(kx) <= 1e-86) {
tmp = sin(th) / fma(0.5, pow((kx / sin(ky)), 2.0), 1.0);
} else {
tmp = sin(th) / (sin(kx) / sin(ky));
}
return tmp;
}
function code(kx, ky, th) tmp = 0.0 if (sin(kx) <= -0.07) tmp = Float64(sin(th) * abs(Float64(sin(ky) / sin(kx)))); elseif (sin(kx) <= 1e-86) tmp = Float64(sin(th) / fma(0.5, (Float64(kx / sin(ky)) ^ 2.0), 1.0)); else tmp = Float64(sin(th) / Float64(sin(kx) / sin(ky))); end return tmp end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[kx], $MachinePrecision], -0.07], N[(N[Sin[th], $MachinePrecision] * N[Abs[N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 1e-86], N[(N[Sin[th], $MachinePrecision] / N[(0.5 * N[Power[N[(kx / N[Sin[ky], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] / N[(N[Sin[kx], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin kx \leq -0.07:\\
\;\;\;\;\sin th \cdot \left|\frac{\sin ky}{\sin kx}\right|\\
\mathbf{elif}\;\sin kx \leq 10^{-86}:\\
\;\;\;\;\frac{\sin th}{\mathsf{fma}\left(0.5, {\left(\frac{kx}{\sin ky}\right)}^{2}, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin th}{\frac{\sin kx}{\sin ky}}\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.070000000000000007Initial program 99.5%
clear-num99.3%
inv-pow99.3%
+-commutative99.3%
unpow299.3%
unpow299.3%
hypot-undefine99.3%
Applied egg-rr99.3%
Taylor expanded in ky around 0 15.5%
expm1-log1p-u15.2%
expm1-undefine15.8%
unpow-115.8%
clear-num15.8%
Applied egg-rr15.8%
expm1-define15.2%
Simplified15.2%
add-sqr-sqrt8.2%
sqrt-unprod31.1%
pow231.1%
expm1-log1p-u33.4%
Applied egg-rr33.4%
unpow233.4%
rem-sqrt-square36.2%
Simplified36.2%
if -0.070000000000000007 < (sin.f64 kx) < 1.00000000000000008e-86Initial program 88.6%
+-commutative88.6%
unpow288.6%
unpow288.6%
hypot-undefine99.9%
Applied egg-rr99.9%
*-commutative99.9%
clear-num99.8%
un-div-inv99.8%
Applied egg-rr99.8%
Taylor expanded in kx around 0 37.7%
+-commutative37.7%
fma-define37.7%
unpow237.7%
unpow237.7%
times-frac42.4%
unpow242.4%
Simplified42.4%
if 1.00000000000000008e-86 < (sin.f64 kx) Initial program 99.4%
clear-num99.4%
inv-pow99.4%
+-commutative99.4%
unpow299.4%
unpow299.4%
hypot-undefine99.4%
Applied egg-rr99.4%
Taylor expanded in ky around 0 57.5%
*-commutative57.5%
unpow-157.5%
un-div-inv57.6%
Applied egg-rr57.6%
Final simplification46.0%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (/ (sin th) (sin kx))))
(if (<= (sin kx) -0.02)
(* ky (fabs t_1))
(if (<= (sin kx) 5e-136) (sin th) (* (sin ky) t_1)))))
double code(double kx, double ky, double th) {
double t_1 = sin(th) / sin(kx);
double tmp;
if (sin(kx) <= -0.02) {
tmp = ky * fabs(t_1);
} else if (sin(kx) <= 5e-136) {
tmp = sin(th);
} else {
tmp = sin(ky) * t_1;
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: t_1
real(8) :: tmp
t_1 = sin(th) / sin(kx)
if (sin(kx) <= (-0.02d0)) then
tmp = ky * abs(t_1)
else if (sin(kx) <= 5d-136) then
tmp = sin(th)
else
tmp = sin(ky) * t_1
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double t_1 = Math.sin(th) / Math.sin(kx);
double tmp;
if (Math.sin(kx) <= -0.02) {
tmp = ky * Math.abs(t_1);
} else if (Math.sin(kx) <= 5e-136) {
tmp = Math.sin(th);
} else {
tmp = Math.sin(ky) * t_1;
}
return tmp;
}
def code(kx, ky, th): t_1 = math.sin(th) / math.sin(kx) tmp = 0 if math.sin(kx) <= -0.02: tmp = ky * math.fabs(t_1) elif math.sin(kx) <= 5e-136: tmp = math.sin(th) else: tmp = math.sin(ky) * t_1 return tmp
function code(kx, ky, th) t_1 = Float64(sin(th) / sin(kx)) tmp = 0.0 if (sin(kx) <= -0.02) tmp = Float64(ky * abs(t_1)); elseif (sin(kx) <= 5e-136) tmp = sin(th); else tmp = Float64(sin(ky) * t_1); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = sin(th) / sin(kx); tmp = 0.0; if (sin(kx) <= -0.02) tmp = ky * abs(t_1); elseif (sin(kx) <= 5e-136) tmp = sin(th); else tmp = sin(ky) * t_1; end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Sin[kx], $MachinePrecision], -0.02], N[(ky * N[Abs[t$95$1], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 5e-136], N[Sin[th], $MachinePrecision], N[(N[Sin[ky], $MachinePrecision] * t$95$1), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\sin th}{\sin kx}\\
\mathbf{if}\;\sin kx \leq -0.02:\\
\;\;\;\;ky \cdot \left|t\_1\right|\\
\mathbf{elif}\;\sin kx \leq 5 \cdot 10^{-136}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\sin ky \cdot t\_1\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.0200000000000000004Initial program 99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
associate-*l/99.4%
associate-/l*99.4%
unpow299.4%
Simplified99.4%
Taylor expanded in ky around 0 16.3%
associate-/l*16.3%
Simplified16.3%
add-sqr-sqrt7.3%
sqrt-unprod34.5%
pow234.5%
Applied egg-rr34.5%
unpow234.5%
rem-sqrt-square35.3%
Simplified35.3%
if -0.0200000000000000004 < (sin.f64 kx) < 5.0000000000000002e-136Initial program 87.0%
unpow287.0%
sqr-neg87.0%
sin-neg87.0%
sin-neg87.0%
unpow287.0%
associate-*l/83.3%
associate-/l*86.9%
unpow286.9%
Simplified99.8%
Taylor expanded in kx around 0 37.8%
if 5.0000000000000002e-136 < (sin.f64 kx) Initial program 99.4%
unpow299.4%
sqr-neg99.4%
sin-neg99.4%
sin-neg99.4%
unpow299.4%
associate-*l/98.9%
associate-/l*99.5%
unpow299.5%
Simplified99.6%
Taylor expanded in ky around 0 55.3%
Final simplification43.6%
(FPCore (kx ky th) :precision binary64 (if (<= (sin kx) -0.02) (* ky (fabs (/ (sin th) (sin kx)))) (if (<= (sin kx) 5e-136) (sin th) (/ (sin th) (/ (sin kx) (sin ky))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(kx) <= -0.02) {
tmp = ky * fabs((sin(th) / sin(kx)));
} else if (sin(kx) <= 5e-136) {
tmp = sin(th);
} else {
tmp = sin(th) / (sin(kx) / sin(ky));
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(kx) <= (-0.02d0)) then
tmp = ky * abs((sin(th) / sin(kx)))
else if (sin(kx) <= 5d-136) then
tmp = sin(th)
else
tmp = sin(th) / (sin(kx) / sin(ky))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(kx) <= -0.02) {
tmp = ky * Math.abs((Math.sin(th) / Math.sin(kx)));
} else if (Math.sin(kx) <= 5e-136) {
tmp = Math.sin(th);
} else {
tmp = Math.sin(th) / (Math.sin(kx) / Math.sin(ky));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(kx) <= -0.02: tmp = ky * math.fabs((math.sin(th) / math.sin(kx))) elif math.sin(kx) <= 5e-136: tmp = math.sin(th) else: tmp = math.sin(th) / (math.sin(kx) / math.sin(ky)) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(kx) <= -0.02) tmp = Float64(ky * abs(Float64(sin(th) / sin(kx)))); elseif (sin(kx) <= 5e-136) tmp = sin(th); else tmp = Float64(sin(th) / Float64(sin(kx) / sin(ky))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(kx) <= -0.02) tmp = ky * abs((sin(th) / sin(kx))); elseif (sin(kx) <= 5e-136) tmp = sin(th); else tmp = sin(th) / (sin(kx) / sin(ky)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[kx], $MachinePrecision], -0.02], N[(ky * N[Abs[N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 5e-136], N[Sin[th], $MachinePrecision], N[(N[Sin[th], $MachinePrecision] / N[(N[Sin[kx], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin kx \leq -0.02:\\
\;\;\;\;ky \cdot \left|\frac{\sin th}{\sin kx}\right|\\
\mathbf{elif}\;\sin kx \leq 5 \cdot 10^{-136}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin th}{\frac{\sin kx}{\sin ky}}\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.0200000000000000004Initial program 99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
associate-*l/99.4%
associate-/l*99.4%
unpow299.4%
Simplified99.4%
Taylor expanded in ky around 0 16.3%
associate-/l*16.3%
Simplified16.3%
add-sqr-sqrt7.3%
sqrt-unprod34.5%
pow234.5%
Applied egg-rr34.5%
unpow234.5%
rem-sqrt-square35.3%
Simplified35.3%
if -0.0200000000000000004 < (sin.f64 kx) < 5.0000000000000002e-136Initial program 87.0%
unpow287.0%
sqr-neg87.0%
sin-neg87.0%
sin-neg87.0%
unpow287.0%
associate-*l/83.3%
associate-/l*86.9%
unpow286.9%
Simplified99.8%
Taylor expanded in kx around 0 37.8%
if 5.0000000000000002e-136 < (sin.f64 kx) Initial program 99.4%
clear-num99.4%
inv-pow99.4%
+-commutative99.4%
unpow299.4%
unpow299.4%
hypot-undefine99.4%
Applied egg-rr99.4%
Taylor expanded in ky around 0 55.2%
*-commutative55.2%
unpow-155.2%
un-div-inv55.3%
Applied egg-rr55.3%
Final simplification43.6%
(FPCore (kx ky th) :precision binary64 (if (<= (sin kx) -0.02) (fabs (* (sin ky) (/ (sin th) (sin kx)))) (if (<= (sin kx) 5e-136) (sin th) (/ (sin th) (/ (sin kx) (sin ky))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(kx) <= -0.02) {
tmp = fabs((sin(ky) * (sin(th) / sin(kx))));
} else if (sin(kx) <= 5e-136) {
tmp = sin(th);
} else {
tmp = sin(th) / (sin(kx) / sin(ky));
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(kx) <= (-0.02d0)) then
tmp = abs((sin(ky) * (sin(th) / sin(kx))))
else if (sin(kx) <= 5d-136) then
tmp = sin(th)
else
tmp = sin(th) / (sin(kx) / sin(ky))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(kx) <= -0.02) {
tmp = Math.abs((Math.sin(ky) * (Math.sin(th) / Math.sin(kx))));
} else if (Math.sin(kx) <= 5e-136) {
tmp = Math.sin(th);
} else {
tmp = Math.sin(th) / (Math.sin(kx) / Math.sin(ky));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(kx) <= -0.02: tmp = math.fabs((math.sin(ky) * (math.sin(th) / math.sin(kx)))) elif math.sin(kx) <= 5e-136: tmp = math.sin(th) else: tmp = math.sin(th) / (math.sin(kx) / math.sin(ky)) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(kx) <= -0.02) tmp = abs(Float64(sin(ky) * Float64(sin(th) / sin(kx)))); elseif (sin(kx) <= 5e-136) tmp = sin(th); else tmp = Float64(sin(th) / Float64(sin(kx) / sin(ky))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(kx) <= -0.02) tmp = abs((sin(ky) * (sin(th) / sin(kx)))); elseif (sin(kx) <= 5e-136) tmp = sin(th); else tmp = sin(th) / (sin(kx) / sin(ky)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[kx], $MachinePrecision], -0.02], N[Abs[N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 5e-136], N[Sin[th], $MachinePrecision], N[(N[Sin[th], $MachinePrecision] / N[(N[Sin[kx], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin kx \leq -0.02:\\
\;\;\;\;\left|\sin ky \cdot \frac{\sin th}{\sin kx}\right|\\
\mathbf{elif}\;\sin kx \leq 5 \cdot 10^{-136}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin th}{\frac{\sin kx}{\sin ky}}\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.0200000000000000004Initial program 99.6%
clear-num99.3%
inv-pow99.3%
+-commutative99.3%
unpow299.3%
unpow299.3%
hypot-undefine99.4%
Applied egg-rr99.4%
Taylor expanded in ky around 0 15.9%
add-sqr-sqrt14.3%
sqrt-unprod32.3%
pow232.3%
*-commutative32.3%
unpow-132.3%
clear-num32.3%
Applied egg-rr32.3%
unpow232.3%
rem-sqrt-square41.9%
associate-*r/41.9%
*-commutative41.9%
associate-/l*41.9%
Simplified41.9%
if -0.0200000000000000004 < (sin.f64 kx) < 5.0000000000000002e-136Initial program 87.0%
unpow287.0%
sqr-neg87.0%
sin-neg87.0%
sin-neg87.0%
unpow287.0%
associate-*l/83.3%
associate-/l*86.9%
unpow286.9%
Simplified99.8%
Taylor expanded in kx around 0 37.8%
if 5.0000000000000002e-136 < (sin.f64 kx) Initial program 99.4%
clear-num99.4%
inv-pow99.4%
+-commutative99.4%
unpow299.4%
unpow299.4%
hypot-undefine99.4%
Applied egg-rr99.4%
Taylor expanded in ky around 0 55.2%
*-commutative55.2%
unpow-155.2%
un-div-inv55.3%
Applied egg-rr55.3%
Final simplification45.4%
(FPCore (kx ky th) :precision binary64 (if (<= (sin kx) -0.02) (* (sin th) (fabs (/ (sin ky) (sin kx)))) (if (<= (sin kx) 5e-136) (sin th) (/ (sin th) (/ (sin kx) (sin ky))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(kx) <= -0.02) {
tmp = sin(th) * fabs((sin(ky) / sin(kx)));
} else if (sin(kx) <= 5e-136) {
tmp = sin(th);
} else {
tmp = sin(th) / (sin(kx) / sin(ky));
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(kx) <= (-0.02d0)) then
tmp = sin(th) * abs((sin(ky) / sin(kx)))
else if (sin(kx) <= 5d-136) then
tmp = sin(th)
else
tmp = sin(th) / (sin(kx) / sin(ky))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(kx) <= -0.02) {
tmp = Math.sin(th) * Math.abs((Math.sin(ky) / Math.sin(kx)));
} else if (Math.sin(kx) <= 5e-136) {
tmp = Math.sin(th);
} else {
tmp = Math.sin(th) / (Math.sin(kx) / Math.sin(ky));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(kx) <= -0.02: tmp = math.sin(th) * math.fabs((math.sin(ky) / math.sin(kx))) elif math.sin(kx) <= 5e-136: tmp = math.sin(th) else: tmp = math.sin(th) / (math.sin(kx) / math.sin(ky)) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(kx) <= -0.02) tmp = Float64(sin(th) * abs(Float64(sin(ky) / sin(kx)))); elseif (sin(kx) <= 5e-136) tmp = sin(th); else tmp = Float64(sin(th) / Float64(sin(kx) / sin(ky))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(kx) <= -0.02) tmp = sin(th) * abs((sin(ky) / sin(kx))); elseif (sin(kx) <= 5e-136) tmp = sin(th); else tmp = sin(th) / (sin(kx) / sin(ky)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[kx], $MachinePrecision], -0.02], N[(N[Sin[th], $MachinePrecision] * N[Abs[N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 5e-136], N[Sin[th], $MachinePrecision], N[(N[Sin[th], $MachinePrecision] / N[(N[Sin[kx], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin kx \leq -0.02:\\
\;\;\;\;\sin th \cdot \left|\frac{\sin ky}{\sin kx}\right|\\
\mathbf{elif}\;\sin kx \leq 5 \cdot 10^{-136}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin th}{\frac{\sin kx}{\sin ky}}\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.0200000000000000004Initial program 99.6%
clear-num99.3%
inv-pow99.3%
+-commutative99.3%
unpow299.3%
unpow299.3%
hypot-undefine99.4%
Applied egg-rr99.4%
Taylor expanded in ky around 0 15.9%
expm1-log1p-u15.7%
expm1-undefine16.2%
unpow-116.2%
clear-num16.2%
Applied egg-rr16.2%
expm1-define15.7%
Simplified15.7%
add-sqr-sqrt9.1%
sqrt-unprod30.5%
pow230.5%
expm1-log1p-u32.6%
Applied egg-rr32.6%
unpow232.6%
rem-sqrt-square35.1%
Simplified35.1%
if -0.0200000000000000004 < (sin.f64 kx) < 5.0000000000000002e-136Initial program 87.0%
unpow287.0%
sqr-neg87.0%
sin-neg87.0%
sin-neg87.0%
unpow287.0%
associate-*l/83.3%
associate-/l*86.9%
unpow286.9%
Simplified99.8%
Taylor expanded in kx around 0 37.8%
if 5.0000000000000002e-136 < (sin.f64 kx) Initial program 99.4%
clear-num99.4%
inv-pow99.4%
+-commutative99.4%
unpow299.4%
unpow299.4%
hypot-undefine99.4%
Applied egg-rr99.4%
Taylor expanded in ky around 0 55.2%
*-commutative55.2%
unpow-155.2%
un-div-inv55.3%
Applied egg-rr55.3%
Final simplification43.6%
(FPCore (kx ky th) :precision binary64 (* (sin ky) (/ (sin th) (hypot (sin ky) (sin kx)))))
double code(double kx, double ky, double th) {
return sin(ky) * (sin(th) / hypot(sin(ky), sin(kx)));
}
public static double code(double kx, double ky, double th) {
return Math.sin(ky) * (Math.sin(th) / Math.hypot(Math.sin(ky), Math.sin(kx)));
}
def code(kx, ky, th): return math.sin(ky) * (math.sin(th) / math.hypot(math.sin(ky), math.sin(kx)))
function code(kx, ky, th) return Float64(sin(ky) * Float64(sin(th) / hypot(sin(ky), sin(kx)))) end
function tmp = code(kx, ky, th) tmp = sin(ky) * (sin(th) / hypot(sin(ky), sin(kx))); end
code[kx_, ky_, th_] := N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}
\end{array}
Initial program 95.0%
unpow295.0%
sqr-neg95.0%
sin-neg95.0%
sin-neg95.0%
unpow295.0%
associate-*l/93.5%
associate-/l*95.0%
unpow295.0%
Simplified99.6%
Final simplification99.6%
(FPCore (kx ky th) :precision binary64 (if (<= (sin kx) -0.02) (* ky (fabs (/ (sin th) (sin kx)))) (if (<= (sin kx) 2e-94) (sin th) (/ (sin th) (/ (sin kx) ky)))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(kx) <= -0.02) {
tmp = ky * fabs((sin(th) / sin(kx)));
} else if (sin(kx) <= 2e-94) {
tmp = sin(th);
} else {
tmp = sin(th) / (sin(kx) / ky);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(kx) <= (-0.02d0)) then
tmp = ky * abs((sin(th) / sin(kx)))
else if (sin(kx) <= 2d-94) then
tmp = sin(th)
else
tmp = sin(th) / (sin(kx) / ky)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(kx) <= -0.02) {
tmp = ky * Math.abs((Math.sin(th) / Math.sin(kx)));
} else if (Math.sin(kx) <= 2e-94) {
tmp = Math.sin(th);
} else {
tmp = Math.sin(th) / (Math.sin(kx) / ky);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(kx) <= -0.02: tmp = ky * math.fabs((math.sin(th) / math.sin(kx))) elif math.sin(kx) <= 2e-94: tmp = math.sin(th) else: tmp = math.sin(th) / (math.sin(kx) / ky) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(kx) <= -0.02) tmp = Float64(ky * abs(Float64(sin(th) / sin(kx)))); elseif (sin(kx) <= 2e-94) tmp = sin(th); else tmp = Float64(sin(th) / Float64(sin(kx) / ky)); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(kx) <= -0.02) tmp = ky * abs((sin(th) / sin(kx))); elseif (sin(kx) <= 2e-94) tmp = sin(th); else tmp = sin(th) / (sin(kx) / ky); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[kx], $MachinePrecision], -0.02], N[(ky * N[Abs[N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 2e-94], N[Sin[th], $MachinePrecision], N[(N[Sin[th], $MachinePrecision] / N[(N[Sin[kx], $MachinePrecision] / ky), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin kx \leq -0.02:\\
\;\;\;\;ky \cdot \left|\frac{\sin th}{\sin kx}\right|\\
\mathbf{elif}\;\sin kx \leq 2 \cdot 10^{-94}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin th}{\frac{\sin kx}{ky}}\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.0200000000000000004Initial program 99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
associate-*l/99.4%
associate-/l*99.4%
unpow299.4%
Simplified99.4%
Taylor expanded in ky around 0 16.3%
associate-/l*16.3%
Simplified16.3%
add-sqr-sqrt7.3%
sqrt-unprod34.5%
pow234.5%
Applied egg-rr34.5%
unpow234.5%
rem-sqrt-square35.3%
Simplified35.3%
if -0.0200000000000000004 < (sin.f64 kx) < 1.9999999999999999e-94Initial program 87.9%
unpow287.9%
sqr-neg87.9%
sin-neg87.9%
sin-neg87.9%
unpow287.9%
associate-*l/84.5%
associate-/l*87.9%
unpow287.9%
Simplified99.8%
Taylor expanded in kx around 0 37.4%
if 1.9999999999999999e-94 < (sin.f64 kx) Initial program 99.4%
+-commutative99.4%
unpow299.4%
unpow299.4%
hypot-undefine99.4%
Applied egg-rr99.4%
*-commutative99.4%
clear-num99.4%
un-div-inv99.5%
Applied egg-rr99.5%
Taylor expanded in ky around 0 50.3%
Final simplification41.3%
(FPCore (kx ky th) :precision binary64 (if (<= ky 2.8e-29) (* ky (/ (sin th) (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 2.8e-29) {
tmp = 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 (ky <= 2.8d-29) then
tmp = 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 (ky <= 2.8e-29) {
tmp = ky * (Math.sin(th) / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 2.8e-29: tmp = ky * (math.sin(th) / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 2.8e-29) tmp = Float64(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 (ky <= 2.8e-29) tmp = ky * (sin(th) / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 2.8e-29], N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 2.8 \cdot 10^{-29}:\\
\;\;\;\;ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 2.8000000000000002e-29Initial program 93.3%
unpow293.3%
sqr-neg93.3%
sin-neg93.3%
sin-neg93.3%
unpow293.3%
associate-*l/91.3%
associate-/l*93.3%
unpow293.3%
Simplified99.6%
Taylor expanded in ky around 0 34.0%
associate-/l*34.7%
Simplified34.7%
if 2.8000000000000002e-29 < ky Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/99.5%
associate-/l*99.6%
unpow299.6%
Simplified99.6%
Taylor expanded in kx around 0 30.3%
Final simplification33.5%
(FPCore (kx ky th) :precision binary64 (if (<= ky 9.5e-29) (* (sin th) (/ ky (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 9.5e-29) {
tmp = sin(th) * (ky / sin(kx));
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (ky <= 9.5d-29) then
tmp = sin(th) * (ky / sin(kx))
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= 9.5e-29) {
tmp = Math.sin(th) * (ky / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 9.5e-29: tmp = math.sin(th) * (ky / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 9.5e-29) tmp = Float64(sin(th) * Float64(ky / sin(kx))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 9.5e-29) tmp = sin(th) * (ky / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 9.5e-29], N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 9.5 \cdot 10^{-29}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 9.50000000000000023e-29Initial program 93.3%
Taylor expanded in ky around 0 34.7%
if 9.50000000000000023e-29 < ky Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/99.5%
associate-/l*99.6%
unpow299.6%
Simplified99.6%
Taylor expanded in kx around 0 30.3%
Final simplification33.5%
(FPCore (kx ky th) :precision binary64 (if (<= ky 3.3e-32) (/ (sin th) (/ (sin kx) ky)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 3.3e-32) {
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 (ky <= 3.3d-32) 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 (ky <= 3.3e-32) {
tmp = Math.sin(th) / (Math.sin(kx) / ky);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 3.3e-32: tmp = math.sin(th) / (math.sin(kx) / ky) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 3.3e-32) 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 (ky <= 3.3e-32) tmp = sin(th) / (sin(kx) / ky); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 3.3e-32], 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}\;ky \leq 3.3 \cdot 10^{-32}:\\
\;\;\;\;\frac{\sin th}{\frac{\sin kx}{ky}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 3.30000000000000025e-32Initial program 93.3%
+-commutative93.3%
unpow293.3%
unpow293.3%
hypot-undefine99.6%
Applied egg-rr99.6%
*-commutative99.6%
clear-num99.5%
un-div-inv99.6%
Applied egg-rr99.6%
Taylor expanded in ky around 0 34.7%
if 3.30000000000000025e-32 < ky Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/99.5%
associate-/l*99.6%
unpow299.6%
Simplified99.6%
Taylor expanded in kx around 0 30.3%
Final simplification33.5%
(FPCore (kx ky th) :precision binary64 (if (<= kx 3e-93) (sin th) (* ky (/ th (sin kx)))))
double code(double kx, double ky, double th) {
double tmp;
if (kx <= 3e-93) {
tmp = sin(th);
} else {
tmp = ky * (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 (kx <= 3d-93) then
tmp = sin(th)
else
tmp = ky * (th / sin(kx))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (kx <= 3e-93) {
tmp = Math.sin(th);
} else {
tmp = ky * (th / Math.sin(kx));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if kx <= 3e-93: tmp = math.sin(th) else: tmp = ky * (th / math.sin(kx)) return tmp
function code(kx, ky, th) tmp = 0.0 if (kx <= 3e-93) tmp = sin(th); else tmp = Float64(ky * Float64(th / sin(kx))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (kx <= 3e-93) tmp = sin(th); else tmp = ky * (th / sin(kx)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[kx, 3e-93], N[Sin[th], $MachinePrecision], N[(ky * N[(th / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;kx \leq 3 \cdot 10^{-93}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;ky \cdot \frac{th}{\sin kx}\\
\end{array}
\end{array}
if kx < 3.0000000000000001e-93Initial program 92.6%
unpow292.6%
sqr-neg92.6%
sin-neg92.6%
sin-neg92.6%
unpow292.6%
associate-*l/90.6%
associate-/l*92.6%
unpow292.6%
Simplified99.7%
Taylor expanded in kx around 0 25.4%
if 3.0000000000000001e-93 < kx Initial program 99.5%
unpow299.5%
sqr-neg99.5%
sin-neg99.5%
sin-neg99.5%
unpow299.5%
associate-*l/98.8%
associate-/l*99.5%
unpow299.5%
Simplified99.5%
Taylor expanded in ky around 0 41.7%
associate-/l*42.4%
Simplified42.4%
Taylor expanded in th around 0 27.4%
Final simplification26.1%
(FPCore (kx ky th) :precision binary64 (if (<= ky 1.06e-67) (* ky (/ (sin th) kx)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 1.06e-67) {
tmp = 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 (ky <= 1.06d-67) then
tmp = 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 (ky <= 1.06e-67) {
tmp = ky * (Math.sin(th) / kx);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 1.06e-67: tmp = ky * (math.sin(th) / kx) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 1.06e-67) tmp = Float64(ky * Float64(sin(th) / kx)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 1.06e-67) tmp = ky * (sin(th) / kx); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 1.06e-67], N[(ky * N[(N[Sin[th], $MachinePrecision] / kx), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 1.06 \cdot 10^{-67}:\\
\;\;\;\;ky \cdot \frac{\sin th}{kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 1.06e-67Initial program 93.2%
unpow293.2%
sqr-neg93.2%
sin-neg93.2%
sin-neg93.2%
unpow293.2%
associate-*l/91.1%
associate-/l*93.2%
unpow293.2%
Simplified99.6%
Taylor expanded in ky around 0 33.8%
associate-/l*34.6%
Simplified34.6%
Taylor expanded in kx around 0 24.2%
if 1.06e-67 < ky Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/99.5%
associate-/l*99.6%
unpow299.6%
Simplified99.6%
Taylor expanded in kx around 0 30.0%
Final simplification25.9%
(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 95.0%
unpow295.0%
sqr-neg95.0%
sin-neg95.0%
sin-neg95.0%
unpow295.0%
associate-*l/93.5%
associate-/l*95.0%
unpow295.0%
Simplified99.6%
Taylor expanded in kx around 0 22.4%
Final simplification22.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 95.0%
Taylor expanded in kx around 0 16.9%
Taylor expanded in th around 0 8.7%
*-commutative8.7%
+-commutative8.7%
fma-define8.7%
unpow28.7%
unpow28.7%
times-frac8.9%
unpow28.9%
Simplified8.9%
Taylor expanded in kx around 0 11.0%
Final simplification11.0%
herbie shell --seed 2024058
(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)))