
(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 12 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 th) (/ (hypot (sin ky) (sin kx)) (sin ky))))
double code(double kx, double ky, double th) {
return sin(th) / (hypot(sin(ky), sin(kx)) / sin(ky));
}
public static double code(double kx, double ky, double th) {
return Math.sin(th) / (Math.hypot(Math.sin(ky), Math.sin(kx)) / Math.sin(ky));
}
def code(kx, ky, th): return math.sin(th) / (math.hypot(math.sin(ky), math.sin(kx)) / math.sin(ky))
function code(kx, ky, th) return Float64(sin(th) / Float64(hypot(sin(ky), sin(kx)) / sin(ky))) end
function tmp = code(kx, ky, th) tmp = sin(th) / (hypot(sin(ky), sin(kx)) / sin(ky)); end
code[kx_, ky_, th_] := N[(N[Sin[th], $MachinePrecision] / N[(N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin th}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right)}{\sin ky}}
\end{array}
Initial program 94.3%
unpow294.3%
sqr-neg94.3%
sin-neg94.3%
sin-neg94.3%
unpow294.3%
associate-*l/92.0%
associate-/l*94.3%
unpow294.3%
Simplified99.6%
associate-*r/96.6%
hypot-undefine92.0%
unpow292.0%
unpow292.0%
+-commutative92.0%
associate-*l/94.3%
*-commutative94.3%
clear-num94.3%
un-div-inv94.3%
+-commutative94.3%
unpow294.3%
unpow294.3%
hypot-undefine99.6%
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin th) -0.04)
(sin th)
(if (<= (sin th) 2e-16)
(/ (sin ky) (/ (hypot (sin kx) (sin ky)) th))
(/ (sin ky) (fabs (/ (sin kx) (sin th)))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(th) <= -0.04) {
tmp = sin(th);
} else if (sin(th) <= 2e-16) {
tmp = sin(ky) / (hypot(sin(kx), sin(ky)) / th);
} else {
tmp = sin(ky) / fabs((sin(kx) / sin(th)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(th) <= -0.04) {
tmp = Math.sin(th);
} else if (Math.sin(th) <= 2e-16) {
tmp = Math.sin(ky) / (Math.hypot(Math.sin(kx), Math.sin(ky)) / th);
} else {
tmp = Math.sin(ky) / Math.abs((Math.sin(kx) / Math.sin(th)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(th) <= -0.04: tmp = math.sin(th) elif math.sin(th) <= 2e-16: tmp = math.sin(ky) / (math.hypot(math.sin(kx), math.sin(ky)) / th) else: tmp = math.sin(ky) / math.fabs((math.sin(kx) / math.sin(th))) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(th) <= -0.04) tmp = sin(th); elseif (sin(th) <= 2e-16) tmp = Float64(sin(ky) / Float64(hypot(sin(kx), sin(ky)) / th)); else tmp = Float64(sin(ky) / abs(Float64(sin(kx) / sin(th)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(th) <= -0.04) tmp = sin(th); elseif (sin(th) <= 2e-16) tmp = sin(ky) / (hypot(sin(kx), sin(ky)) / th); else tmp = sin(ky) / abs((sin(kx) / sin(th))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[th], $MachinePrecision], -0.04], N[Sin[th], $MachinePrecision], If[LessEqual[N[Sin[th], $MachinePrecision], 2e-16], N[(N[Sin[ky], $MachinePrecision] / N[(N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision] / th), $MachinePrecision]), $MachinePrecision], N[(N[Sin[ky], $MachinePrecision] / N[Abs[N[(N[Sin[kx], $MachinePrecision] / N[Sin[th], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin th \leq -0.04:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;\sin th \leq 2 \cdot 10^{-16}:\\
\;\;\;\;\frac{\sin ky}{\frac{\mathsf{hypot}\left(\sin kx, \sin ky\right)}{th}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\left|\frac{\sin kx}{\sin th}\right|}\\
\end{array}
\end{array}
if (sin.f64 th) < -0.0400000000000000008Initial program 91.2%
unpow291.2%
sqr-neg91.2%
sin-neg91.2%
sin-neg91.2%
unpow291.2%
associate-*l/91.1%
associate-/l*91.1%
unpow291.1%
Simplified99.5%
Taylor expanded in kx around 0 21.3%
if -0.0400000000000000008 < (sin.f64 th) < 2e-16Initial program 96.3%
unpow296.3%
sqr-neg96.3%
sin-neg96.3%
sin-neg96.3%
unpow296.3%
associate-*l/91.3%
associate-/l*96.4%
unpow296.4%
Simplified99.7%
clear-num99.5%
un-div-inv99.7%
Applied egg-rr99.7%
Taylor expanded in th around 0 96.1%
associate-*l/96.3%
+-commutative96.3%
unpow296.3%
unpow296.3%
hypot-undefine99.7%
*-lft-identity99.7%
hypot-undefine96.3%
unpow296.3%
unpow296.3%
+-commutative96.3%
unpow296.3%
unpow296.3%
hypot-define99.7%
Simplified99.7%
if 2e-16 < (sin.f64 th) Initial program 93.9%
unpow293.9%
sqr-neg93.9%
sin-neg93.9%
sin-neg93.9%
unpow293.9%
associate-*l/93.8%
associate-/l*93.8%
unpow293.8%
Simplified99.5%
Taylor expanded in ky around 0 25.4%
clear-num25.4%
un-div-inv25.4%
Applied egg-rr25.4%
add-sqr-sqrt24.2%
sqrt-unprod45.8%
pow245.8%
Applied egg-rr45.8%
unpow245.8%
rem-sqrt-square50.2%
Simplified50.2%
Final simplification64.9%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.05) (* (sin ky) (fabs (/ (sin th) (sin kx)))) (if (<= (sin ky) 0.001) (* ky (/ (sin th) (fabs (sin kx)))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.05) {
tmp = sin(ky) * fabs((sin(th) / sin(kx)));
} else if (sin(ky) <= 0.001) {
tmp = 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) :: tmp
if (sin(ky) <= (-0.05d0)) then
tmp = sin(ky) * abs((sin(th) / sin(kx)))
else if (sin(ky) <= 0.001d0) then
tmp = 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 tmp;
if (Math.sin(ky) <= -0.05) {
tmp = Math.sin(ky) * Math.abs((Math.sin(th) / Math.sin(kx)));
} else if (Math.sin(ky) <= 0.001) {
tmp = ky * (Math.sin(th) / Math.abs(Math.sin(kx)));
} 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.fabs((math.sin(th) / math.sin(kx))) elif math.sin(ky) <= 0.001: tmp = ky * (math.sin(th) / math.fabs(math.sin(kx))) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.05) tmp = Float64(sin(ky) * abs(Float64(sin(th) / sin(kx)))); elseif (sin(ky) <= 0.001) tmp = Float64(ky * Float64(sin(th) / abs(sin(kx)))); 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) * abs((sin(th) / sin(kx))); elseif (sin(ky) <= 0.001) tmp = ky * (sin(th) / abs(sin(kx))); 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[Abs[N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 0.001], N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.05:\\
\;\;\;\;\sin ky \cdot \left|\frac{\sin th}{\sin kx}\right|\\
\mathbf{elif}\;\sin ky \leq 0.001:\\
\;\;\;\;ky \cdot \frac{\sin th}{\left|\sin kx\right|}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.050000000000000003Initial program 99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
associate-*l/99.5%
associate-/l*99.7%
unpow299.7%
Simplified99.6%
Taylor expanded in ky around 0 6.5%
add-sqr-sqrt3.6%
sqrt-unprod6.8%
pow26.8%
Applied egg-rr6.8%
unpow26.8%
rem-sqrt-square7.5%
Simplified7.5%
if -0.050000000000000003 < (sin.f64 ky) < 1e-3Initial program 88.2%
unpow288.2%
sin-mult71.7%
Applied egg-rr71.7%
div-sub71.7%
+-inverses71.7%
cos-071.7%
metadata-eval71.7%
count-271.7%
*-commutative71.7%
Simplified71.7%
Taylor expanded in ky around 0 54.6%
add-sqr-sqrt54.6%
rem-sqrt-square54.6%
sqrt-div54.6%
metadata-eval54.6%
sqr-sin-a70.5%
sqrt-unprod39.3%
add-sqr-sqrt76.0%
Applied egg-rr76.0%
fabs-div76.0%
metadata-eval76.0%
Simplified76.0%
Taylor expanded in ky around 0 76.1%
associate-/l*77.6%
Simplified77.6%
if 1e-3 < (sin.f64 ky) Initial program 99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
associate-*l/99.6%
associate-/l*99.5%
unpow299.5%
Simplified99.6%
Taylor expanded in kx around 0 58.4%
Final simplification55.1%
(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 94.3%
unpow294.3%
sqr-neg94.3%
sin-neg94.3%
sin-neg94.3%
unpow294.3%
associate-*l/92.0%
associate-/l*94.3%
unpow294.3%
Simplified99.6%
Final simplification99.6%
(FPCore (kx ky th) :precision binary64 (if (<= (sin kx) -0.01) (* ky (/ th (fabs (sin kx)))) (if (<= (sin kx) 2e-44) (sin th) (* ky (/ (sin th) (sin kx))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(kx) <= -0.01) {
tmp = ky * (th / fabs(sin(kx)));
} else if (sin(kx) <= 2e-44) {
tmp = sin(th);
} else {
tmp = 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 * (th / abs(sin(kx)))
else if (sin(kx) <= 2d-44) then
tmp = sin(th)
else
tmp = 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 * (th / Math.abs(Math.sin(kx)));
} else if (Math.sin(kx) <= 2e-44) {
tmp = Math.sin(th);
} else {
tmp = ky * (Math.sin(th) / Math.sin(kx));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(kx) <= -0.01: tmp = ky * (th / math.fabs(math.sin(kx))) elif math.sin(kx) <= 2e-44: tmp = math.sin(th) else: tmp = ky * (math.sin(th) / math.sin(kx)) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(kx) <= -0.01) tmp = Float64(ky * Float64(th / abs(sin(kx)))); elseif (sin(kx) <= 2e-44) tmp = sin(th); else tmp = Float64(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 * (th / abs(sin(kx))); elseif (sin(kx) <= 2e-44) tmp = sin(th); else tmp = ky * (sin(th) / sin(kx)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[kx], $MachinePrecision], -0.01], N[(ky * N[(th / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 2e-44], N[Sin[th], $MachinePrecision], N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin kx \leq -0.01:\\
\;\;\;\;ky \cdot \frac{th}{\left|\sin kx\right|}\\
\mathbf{elif}\;\sin kx \leq 2 \cdot 10^{-44}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;ky \cdot \frac{\sin th}{\sin kx}\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.0100000000000000002Initial program 99.3%
unpow299.3%
sin-mult99.0%
Applied egg-rr99.0%
div-sub99.0%
+-inverses99.0%
cos-099.0%
metadata-eval99.0%
count-299.0%
*-commutative99.0%
Simplified99.0%
Taylor expanded in ky around 0 48.6%
add-sqr-sqrt48.6%
rem-sqrt-square48.6%
sqrt-div48.6%
metadata-eval48.6%
sqr-sin-a48.9%
sqrt-unprod0.0%
add-sqr-sqrt48.9%
Applied egg-rr48.9%
fabs-div48.9%
metadata-eval48.9%
Simplified48.9%
Taylor expanded in th around 0 22.2%
associate-/l*22.2%
Simplified22.2%
if -0.0100000000000000002 < (sin.f64 kx) < 1.99999999999999991e-44Initial program 87.9%
unpow287.9%
sqr-neg87.9%
sin-neg87.9%
sin-neg87.9%
unpow287.9%
associate-*l/82.8%
associate-/l*87.8%
unpow287.8%
Simplified99.8%
Taylor expanded in kx around 0 39.2%
if 1.99999999999999991e-44 < (sin.f64 kx) Initial program 99.4%
unpow299.4%
sqr-neg99.4%
sin-neg99.4%
sin-neg99.4%
unpow299.4%
associate-*l/99.4%
associate-/l*99.5%
unpow299.5%
Simplified99.5%
Taylor expanded in ky around 0 52.0%
associate-/l*52.1%
Simplified52.1%
Final simplification38.6%
(FPCore (kx ky th) :precision binary64 (let* ((t_1 (* ky (/ (sin th) (sin kx))))) (if (<= (sin kx) -0.01) (fabs t_1) (if (<= (sin kx) 2e-44) (sin th) t_1))))
double code(double kx, double ky, double th) {
double t_1 = ky * (sin(th) / sin(kx));
double tmp;
if (sin(kx) <= -0.01) {
tmp = fabs(t_1);
} else if (sin(kx) <= 2e-44) {
tmp = sin(th);
} else {
tmp = 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 = ky * (sin(th) / sin(kx))
if (sin(kx) <= (-0.01d0)) then
tmp = abs(t_1)
else if (sin(kx) <= 2d-44) then
tmp = sin(th)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double t_1 = ky * (Math.sin(th) / Math.sin(kx));
double tmp;
if (Math.sin(kx) <= -0.01) {
tmp = Math.abs(t_1);
} else if (Math.sin(kx) <= 2e-44) {
tmp = Math.sin(th);
} else {
tmp = t_1;
}
return tmp;
}
def code(kx, ky, th): t_1 = ky * (math.sin(th) / math.sin(kx)) tmp = 0 if math.sin(kx) <= -0.01: tmp = math.fabs(t_1) elif math.sin(kx) <= 2e-44: tmp = math.sin(th) else: tmp = t_1 return tmp
function code(kx, ky, th) t_1 = Float64(ky * Float64(sin(th) / sin(kx))) tmp = 0.0 if (sin(kx) <= -0.01) tmp = abs(t_1); elseif (sin(kx) <= 2e-44) tmp = sin(th); else tmp = t_1; end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = ky * (sin(th) / sin(kx)); tmp = 0.0; if (sin(kx) <= -0.01) tmp = abs(t_1); elseif (sin(kx) <= 2e-44) tmp = sin(th); else tmp = t_1; end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Sin[kx], $MachinePrecision], -0.01], N[Abs[t$95$1], $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 2e-44], N[Sin[th], $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{if}\;\sin kx \leq -0.01:\\
\;\;\;\;\left|t\_1\right|\\
\mathbf{elif}\;\sin kx \leq 2 \cdot 10^{-44}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.0100000000000000002Initial program 99.3%
unpow299.3%
sin-mult99.0%
Applied egg-rr99.0%
div-sub99.0%
+-inverses99.0%
cos-099.0%
metadata-eval99.0%
count-299.0%
*-commutative99.0%
Simplified99.0%
Taylor expanded in ky around 0 48.6%
add-sqr-sqrt28.0%
sqrt-unprod23.7%
pow223.7%
associate-*l*23.7%
sqrt-div23.7%
metadata-eval23.7%
sqr-sin-a23.8%
sqrt-unprod0.0%
add-sqr-sqrt23.8%
div-inv23.8%
Applied egg-rr23.8%
unpow223.8%
rem-sqrt-square30.6%
Simplified30.6%
if -0.0100000000000000002 < (sin.f64 kx) < 1.99999999999999991e-44Initial program 87.9%
unpow287.9%
sqr-neg87.9%
sin-neg87.9%
sin-neg87.9%
unpow287.9%
associate-*l/82.8%
associate-/l*87.8%
unpow287.8%
Simplified99.8%
Taylor expanded in kx around 0 39.2%
if 1.99999999999999991e-44 < (sin.f64 kx) Initial program 99.4%
unpow299.4%
sqr-neg99.4%
sin-neg99.4%
sin-neg99.4%
unpow299.4%
associate-*l/99.4%
associate-/l*99.5%
unpow299.5%
Simplified99.5%
Taylor expanded in ky around 0 52.0%
associate-/l*52.1%
Simplified52.1%
Final simplification40.8%
(FPCore (kx ky th) :precision binary64 (if (<= ky 0.00065) (* ky (/ (sin th) (fabs (sin kx)))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 0.00065) {
tmp = 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) :: tmp
if (ky <= 0.00065d0) then
tmp = 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 tmp;
if (ky <= 0.00065) {
tmp = ky * (Math.sin(th) / Math.abs(Math.sin(kx)));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 0.00065: tmp = ky * (math.sin(th) / math.fabs(math.sin(kx))) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 0.00065) tmp = Float64(ky * Float64(sin(th) / abs(sin(kx)))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 0.00065) tmp = ky * (sin(th) / abs(sin(kx))); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 0.00065], N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 0.00065:\\
\;\;\;\;ky \cdot \frac{\sin th}{\left|\sin kx\right|}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 6.4999999999999997e-4Initial program 92.4%
unpow292.4%
sin-mult82.0%
Applied egg-rr82.0%
div-sub82.0%
+-inverses82.0%
cos-082.0%
metadata-eval82.0%
count-282.0%
*-commutative82.0%
Simplified82.0%
Taylor expanded in ky around 0 35.5%
add-sqr-sqrt35.5%
rem-sqrt-square35.5%
sqrt-div35.5%
metadata-eval35.5%
sqr-sin-a45.6%
sqrt-unprod25.4%
add-sqr-sqrt49.2%
Applied egg-rr49.2%
fabs-div49.2%
metadata-eval49.2%
Simplified49.2%
Taylor expanded in ky around 0 49.2%
associate-/l*50.2%
Simplified50.2%
if 6.4999999999999997e-4 < ky Initial program 99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
associate-*l/99.6%
associate-/l*99.7%
unpow299.7%
Simplified99.8%
Taylor expanded in kx around 0 37.3%
Final simplification46.8%
(FPCore (kx ky th)
:precision binary64
(if (<= ky 1.6e-184)
(* ky (/ (sin th) kx))
(if (or (<= ky 1.36e-99) (and (not (<= ky 1.45e-46)) (<= ky 1.1e-36)))
(* ky (/ th (fabs (sin kx))))
(sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 1.6e-184) {
tmp = ky * (sin(th) / kx);
} else if ((ky <= 1.36e-99) || (!(ky <= 1.45e-46) && (ky <= 1.1e-36))) {
tmp = ky * (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) :: tmp
if (ky <= 1.6d-184) then
tmp = ky * (sin(th) / kx)
else if ((ky <= 1.36d-99) .or. (.not. (ky <= 1.45d-46)) .and. (ky <= 1.1d-36)) then
tmp = ky * (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 tmp;
if (ky <= 1.6e-184) {
tmp = ky * (Math.sin(th) / kx);
} else if ((ky <= 1.36e-99) || (!(ky <= 1.45e-46) && (ky <= 1.1e-36))) {
tmp = ky * (th / Math.abs(Math.sin(kx)));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 1.6e-184: tmp = ky * (math.sin(th) / kx) elif (ky <= 1.36e-99) or (not (ky <= 1.45e-46) and (ky <= 1.1e-36)): tmp = ky * (th / math.fabs(math.sin(kx))) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 1.6e-184) tmp = Float64(ky * Float64(sin(th) / kx)); elseif ((ky <= 1.36e-99) || (!(ky <= 1.45e-46) && (ky <= 1.1e-36))) tmp = Float64(ky * Float64(th / abs(sin(kx)))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 1.6e-184) tmp = ky * (sin(th) / kx); elseif ((ky <= 1.36e-99) || (~((ky <= 1.45e-46)) && (ky <= 1.1e-36))) tmp = ky * (th / abs(sin(kx))); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 1.6e-184], N[(ky * N[(N[Sin[th], $MachinePrecision] / kx), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[ky, 1.36e-99], And[N[Not[LessEqual[ky, 1.45e-46]], $MachinePrecision], LessEqual[ky, 1.1e-36]]], N[(ky * N[(th / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 1.6 \cdot 10^{-184}:\\
\;\;\;\;ky \cdot \frac{\sin th}{kx}\\
\mathbf{elif}\;ky \leq 1.36 \cdot 10^{-99} \lor \neg \left(ky \leq 1.45 \cdot 10^{-46}\right) \land ky \leq 1.1 \cdot 10^{-36}:\\
\;\;\;\;ky \cdot \frac{th}{\left|\sin kx\right|}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 1.6e-184Initial program 91.6%
unpow291.6%
sin-mult81.8%
Applied egg-rr81.8%
div-sub81.8%
+-inverses81.8%
cos-081.8%
metadata-eval81.8%
count-281.8%
*-commutative81.8%
Simplified81.8%
Taylor expanded in ky around 0 29.8%
Taylor expanded in kx around 0 19.6%
associate-/l*19.6%
Simplified19.6%
if 1.6e-184 < ky < 1.35999999999999991e-99 or 1.45000000000000002e-46 < ky < 1.1e-36Initial program 93.6%
unpow293.6%
sin-mult79.4%
Applied egg-rr79.4%
div-sub79.4%
+-inverses79.4%
cos-079.4%
metadata-eval79.4%
count-279.4%
*-commutative79.4%
Simplified79.4%
Taylor expanded in ky around 0 70.7%
add-sqr-sqrt70.7%
rem-sqrt-square70.7%
sqrt-div70.5%
metadata-eval70.5%
sqr-sin-a77.3%
sqrt-unprod53.7%
add-sqr-sqrt78.2%
Applied egg-rr78.2%
fabs-div78.2%
metadata-eval78.2%
Simplified78.2%
Taylor expanded in th around 0 54.7%
associate-/l*59.8%
Simplified59.8%
if 1.35999999999999991e-99 < ky < 1.45000000000000002e-46 or 1.1e-36 < ky Initial program 99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
associate-*l/98.4%
associate-/l*99.6%
unpow299.6%
Simplified99.7%
Taylor expanded in kx around 0 37.0%
Final simplification27.8%
(FPCore (kx ky th) :precision binary64 (if (or (<= ky 5.3e-204) (and (not (<= ky 7.5e-170)) (<= ky 1.3e-125))) (* ky (/ th kx)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if ((ky <= 5.3e-204) || (!(ky <= 7.5e-170) && (ky <= 1.3e-125))) {
tmp = ky * (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 <= 5.3d-204) .or. (.not. (ky <= 7.5d-170)) .and. (ky <= 1.3d-125)) then
tmp = ky * (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 <= 5.3e-204) || (!(ky <= 7.5e-170) && (ky <= 1.3e-125))) {
tmp = ky * (th / kx);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if (ky <= 5.3e-204) or (not (ky <= 7.5e-170) and (ky <= 1.3e-125)): tmp = ky * (th / kx) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if ((ky <= 5.3e-204) || (!(ky <= 7.5e-170) && (ky <= 1.3e-125))) tmp = Float64(ky * Float64(th / kx)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if ((ky <= 5.3e-204) || (~((ky <= 7.5e-170)) && (ky <= 1.3e-125))) tmp = ky * (th / kx); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[Or[LessEqual[ky, 5.3e-204], And[N[Not[LessEqual[ky, 7.5e-170]], $MachinePrecision], LessEqual[ky, 1.3e-125]]], N[(ky * N[(th / kx), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 5.3 \cdot 10^{-204} \lor \neg \left(ky \leq 7.5 \cdot 10^{-170}\right) \land ky \leq 1.3 \cdot 10^{-125}:\\
\;\;\;\;ky \cdot \frac{th}{kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 5.2999999999999997e-204 or 7.4999999999999998e-170 < ky < 1.30000000000000003e-125Initial program 92.2%
unpow292.2%
sqr-neg92.2%
sin-neg92.2%
sin-neg92.2%
unpow292.2%
associate-*l/89.7%
associate-/l*92.2%
unpow292.2%
Simplified99.6%
Taylor expanded in ky around 0 31.6%
Taylor expanded in th around 0 19.4%
associate-/l*19.3%
Simplified19.3%
Taylor expanded in ky around 0 18.0%
associate-/l*17.9%
Simplified17.9%
Taylor expanded in kx around 0 15.0%
if 5.2999999999999997e-204 < ky < 7.4999999999999998e-170 or 1.30000000000000003e-125 < ky Initial program 97.6%
unpow297.6%
sqr-neg97.6%
sin-neg97.6%
sin-neg97.6%
unpow297.6%
associate-*l/95.6%
associate-/l*97.6%
unpow297.6%
Simplified99.6%
Taylor expanded in kx around 0 35.2%
Final simplification22.7%
(FPCore (kx ky th) :precision binary64 (if (<= kx 3200000.0) (sin th) (* ky (/ th (sin kx)))))
double code(double kx, double ky, double th) {
double tmp;
if (kx <= 3200000.0) {
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 <= 3200000.0d0) 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 <= 3200000.0) {
tmp = Math.sin(th);
} else {
tmp = ky * (th / Math.sin(kx));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if kx <= 3200000.0: tmp = math.sin(th) else: tmp = ky * (th / math.sin(kx)) return tmp
function code(kx, ky, th) tmp = 0.0 if (kx <= 3200000.0) 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 <= 3200000.0) tmp = sin(th); else tmp = ky * (th / sin(kx)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[kx, 3200000.0], N[Sin[th], $MachinePrecision], N[(ky * N[(th / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;kx \leq 3200000:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;ky \cdot \frac{th}{\sin kx}\\
\end{array}
\end{array}
if kx < 3.2e6Initial program 92.7%
unpow292.7%
sqr-neg92.7%
sin-neg92.7%
sin-neg92.7%
unpow292.7%
associate-*l/89.6%
associate-/l*92.6%
unpow292.6%
Simplified99.6%
Taylor expanded in kx around 0 26.5%
if 3.2e6 < kx Initial program 99.3%
unpow299.3%
sqr-neg99.3%
sin-neg99.3%
sin-neg99.3%
unpow299.3%
associate-*l/99.2%
associate-/l*99.4%
unpow299.4%
Simplified99.5%
Taylor expanded in ky around 0 36.2%
Taylor expanded in th around 0 21.3%
associate-/l*21.3%
Simplified21.3%
Taylor expanded in ky around 0 18.8%
associate-/l*18.9%
Simplified18.9%
Final simplification24.7%
(FPCore (kx ky th) :precision binary64 (if (<= ky 4.2e-123) (* ky (/ (sin th) kx)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 4.2e-123) {
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 <= 4.2d-123) 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 <= 4.2e-123) {
tmp = ky * (Math.sin(th) / kx);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 4.2e-123: tmp = ky * (math.sin(th) / kx) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 4.2e-123) 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 <= 4.2e-123) tmp = ky * (sin(th) / kx); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 4.2e-123], N[(ky * N[(N[Sin[th], $MachinePrecision] / kx), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 4.2 \cdot 10^{-123}:\\
\;\;\;\;ky \cdot \frac{\sin th}{kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 4.1999999999999998e-123Initial program 91.4%
unpow291.4%
sin-mult81.0%
Applied egg-rr81.0%
div-sub81.0%
+-inverses81.0%
cos-081.0%
metadata-eval81.0%
count-281.0%
*-commutative81.0%
Simplified81.0%
Taylor expanded in ky around 0 31.5%
Taylor expanded in kx around 0 20.2%
associate-/l*20.2%
Simplified20.2%
if 4.1999999999999998e-123 < ky Initial program 99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
associate-*l/97.5%
associate-/l*99.6%
unpow299.6%
Simplified99.7%
Taylor expanded in kx around 0 35.4%
Final simplification25.6%
(FPCore (kx ky th) :precision binary64 (* ky (/ th kx)))
double code(double kx, double ky, double th) {
return ky * (th / kx);
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = ky * (th / kx)
end function
public static double code(double kx, double ky, double th) {
return ky * (th / kx);
}
def code(kx, ky, th): return ky * (th / kx)
function code(kx, ky, th) return Float64(ky * Float64(th / kx)) end
function tmp = code(kx, ky, th) tmp = ky * (th / kx); end
code[kx_, ky_, th_] := N[(ky * N[(th / kx), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
ky \cdot \frac{th}{kx}
\end{array}
Initial program 94.3%
unpow294.3%
sqr-neg94.3%
sin-neg94.3%
sin-neg94.3%
unpow294.3%
associate-*l/92.0%
associate-/l*94.3%
unpow294.3%
Simplified99.6%
Taylor expanded in ky around 0 26.1%
Taylor expanded in th around 0 15.7%
associate-/l*15.6%
Simplified15.6%
Taylor expanded in ky around 0 14.2%
associate-/l*14.1%
Simplified14.1%
Taylor expanded in kx around 0 10.6%
Final simplification10.6%
herbie shell --seed 2024060
(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)))