
(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 14 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 92.8%
+-commutative92.8%
unpow292.8%
unpow292.8%
hypot-undefine99.7%
Applied egg-rr99.7%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.48) (/ 1.0 (sqrt (pow (sin th) -2.0))) (if (<= (sin ky) 4e-59) (* (sin th) (/ (sin ky) (sin kx))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.48) {
tmp = 1.0 / sqrt(pow(sin(th), -2.0));
} else if (sin(ky) <= 4e-59) {
tmp = sin(th) * (sin(ky) / sin(kx));
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(ky) <= (-0.48d0)) then
tmp = 1.0d0 / sqrt((sin(th) ** (-2.0d0)))
else if (sin(ky) <= 4d-59) then
tmp = sin(th) * (sin(ky) / sin(kx))
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -0.48) {
tmp = 1.0 / Math.sqrt(Math.pow(Math.sin(th), -2.0));
} else if (Math.sin(ky) <= 4e-59) {
tmp = Math.sin(th) * (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.48: tmp = 1.0 / math.sqrt(math.pow(math.sin(th), -2.0)) elif math.sin(ky) <= 4e-59: tmp = math.sin(th) * (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.48) tmp = Float64(1.0 / sqrt((sin(th) ^ -2.0))); elseif (sin(ky) <= 4e-59) tmp = Float64(sin(th) * Float64(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.48) tmp = 1.0 / sqrt((sin(th) ^ -2.0)); elseif (sin(ky) <= 4e-59) tmp = sin(th) * (sin(ky) / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.48], N[(1.0 / N[Sqrt[N[Power[N[Sin[th], $MachinePrecision], -2.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 4e-59], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.48:\\
\;\;\;\;\frac{1}{\sqrt{{\sin th}^{-2}}}\\
\mathbf{elif}\;\sin ky \leq 4 \cdot 10^{-59}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.47999999999999998Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/99.6%
associate-/l*99.7%
unpow299.7%
Simplified99.6%
Taylor expanded in kx around 0 2.8%
associate-*r/2.8%
clear-num2.8%
Applied egg-rr2.8%
associate-/r*2.8%
*-inverses2.8%
log1p-expm1-u3.6%
Applied egg-rr3.6%
log1p-expm1-u2.8%
add-sqr-sqrt1.2%
sqrt-unprod25.3%
inv-pow25.3%
inv-pow25.3%
pow-prod-up25.3%
metadata-eval25.3%
Applied egg-rr25.3%
if -0.47999999999999998 < (sin.f64 ky) < 4.0000000000000001e-59Initial program 85.7%
Taylor expanded in ky around 0 36.5%
if 4.0000000000000001e-59 < (sin.f64 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 58.1%
Final simplification41.7%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.48) (/ 1.0 (sqrt (pow (sin th) -2.0))) (if (<= (sin ky) 4e-59) (* (sin ky) (/ (sin th) (sin kx))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.48) {
tmp = 1.0 / sqrt(pow(sin(th), -2.0));
} else if (sin(ky) <= 4e-59) {
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.48d0)) then
tmp = 1.0d0 / sqrt((sin(th) ** (-2.0d0)))
else if (sin(ky) <= 4d-59) 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.48) {
tmp = 1.0 / Math.sqrt(Math.pow(Math.sin(th), -2.0));
} else if (Math.sin(ky) <= 4e-59) {
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.48: tmp = 1.0 / math.sqrt(math.pow(math.sin(th), -2.0)) elif math.sin(ky) <= 4e-59: 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.48) tmp = Float64(1.0 / sqrt((sin(th) ^ -2.0))); elseif (sin(ky) <= 4e-59) 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.48) tmp = 1.0 / sqrt((sin(th) ^ -2.0)); elseif (sin(ky) <= 4e-59) 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.48], N[(1.0 / N[Sqrt[N[Power[N[Sin[th], $MachinePrecision], -2.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 4e-59], 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.48:\\
\;\;\;\;\frac{1}{\sqrt{{\sin th}^{-2}}}\\
\mathbf{elif}\;\sin ky \leq 4 \cdot 10^{-59}:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.47999999999999998Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/99.6%
associate-/l*99.7%
unpow299.7%
Simplified99.6%
Taylor expanded in kx around 0 2.8%
associate-*r/2.8%
clear-num2.8%
Applied egg-rr2.8%
associate-/r*2.8%
*-inverses2.8%
log1p-expm1-u3.6%
Applied egg-rr3.6%
log1p-expm1-u2.8%
add-sqr-sqrt1.2%
sqrt-unprod25.3%
inv-pow25.3%
inv-pow25.3%
pow-prod-up25.3%
metadata-eval25.3%
Applied egg-rr25.3%
if -0.47999999999999998 < (sin.f64 ky) < 4.0000000000000001e-59Initial program 85.7%
unpow285.7%
sqr-neg85.7%
sin-neg85.7%
sin-neg85.7%
unpow285.7%
associate-*l/82.5%
associate-/l*85.6%
unpow285.6%
Simplified99.7%
Taylor expanded in ky around 0 36.4%
if 4.0000000000000001e-59 < (sin.f64 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 58.1%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.05) (* (sin ky) (/ (sin th) (fabs (sin ky)))) (* (sin th) (/ ky (hypot ky (sin kx))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.05) {
tmp = sin(ky) * (sin(th) / fabs(sin(ky)));
} else {
tmp = sin(th) * (ky / hypot(ky, sin(kx)));
}
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.abs(Math.sin(ky)));
} else {
tmp = Math.sin(th) * (ky / Math.hypot(ky, Math.sin(kx)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.05: tmp = math.sin(ky) * (math.sin(th) / math.fabs(math.sin(ky))) else: tmp = math.sin(th) * (ky / math.hypot(ky, math.sin(kx))) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.05) tmp = Float64(sin(ky) * Float64(sin(th) / abs(sin(ky)))); else tmp = Float64(sin(th) * Float64(ky / hypot(ky, sin(kx)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.05) tmp = sin(ky) * (sin(th) / abs(sin(ky))); else tmp = sin(th) * (ky / hypot(ky, sin(kx))); 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[Abs[N[Sin[ky], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Sqrt[ky ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.05:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\left|\sin ky\right|}\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\mathsf{hypot}\left(ky, \sin kx\right)}\\
\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.7%
unpow299.7%
Simplified99.7%
Taylor expanded in kx around 0 2.7%
add-sqr-sqrt0.0%
sqrt-prod69.7%
rem-sqrt-square69.7%
Applied egg-rr69.7%
if -0.050000000000000003 < (sin.f64 ky) Initial program 90.7%
+-commutative90.7%
unpow290.7%
unpow290.7%
hypot-undefine99.8%
Applied egg-rr99.8%
Taylor expanded in ky around 0 64.3%
Taylor expanded in ky around 0 76.8%
Final simplification75.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 92.8%
unpow292.8%
sqr-neg92.8%
sin-neg92.8%
sin-neg92.8%
unpow292.8%
associate-*l/91.2%
associate-/l*92.7%
unpow292.7%
Simplified99.6%
(FPCore (kx ky th) :precision binary64 (if (<= th 0.032) (/ th (/ (hypot (sin ky) (sin kx)) (sin ky))) (* (sin th) (/ ky (hypot ky (sin kx))))))
double code(double kx, double ky, double th) {
double tmp;
if (th <= 0.032) {
tmp = th / (hypot(sin(ky), sin(kx)) / sin(ky));
} else {
tmp = sin(th) * (ky / hypot(ky, sin(kx)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (th <= 0.032) {
tmp = th / (Math.hypot(Math.sin(ky), Math.sin(kx)) / Math.sin(ky));
} else {
tmp = Math.sin(th) * (ky / Math.hypot(ky, Math.sin(kx)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if th <= 0.032: tmp = th / (math.hypot(math.sin(ky), math.sin(kx)) / math.sin(ky)) else: tmp = math.sin(th) * (ky / math.hypot(ky, math.sin(kx))) return tmp
function code(kx, ky, th) tmp = 0.0 if (th <= 0.032) tmp = Float64(th / Float64(hypot(sin(ky), sin(kx)) / sin(ky))); else tmp = Float64(sin(th) * Float64(ky / hypot(ky, sin(kx)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (th <= 0.032) tmp = th / (hypot(sin(ky), sin(kx)) / sin(ky)); else tmp = sin(th) * (ky / hypot(ky, sin(kx))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[th, 0.032], N[(th / N[(N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Sqrt[ky ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;th \leq 0.032:\\
\;\;\;\;\frac{th}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right)}{\sin ky}}\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\mathsf{hypot}\left(ky, \sin kx\right)}\\
\end{array}
\end{array}
if th < 0.032000000000000001Initial program 92.5%
unpow292.5%
sqr-neg92.5%
sin-neg92.5%
sin-neg92.5%
unpow292.5%
associate-*l/90.4%
associate-/l*92.4%
unpow292.4%
Simplified99.6%
associate-*r/94.3%
hypot-undefine90.4%
unpow290.4%
unpow290.4%
+-commutative90.4%
associate-*l/92.5%
*-commutative92.5%
clear-num92.4%
un-div-inv92.4%
+-commutative92.4%
unpow292.4%
unpow292.4%
hypot-undefine99.7%
Applied egg-rr99.7%
Taylor expanded in th around 0 65.2%
if 0.032000000000000001 < th Initial program 94.3%
+-commutative94.3%
unpow294.3%
unpow294.3%
hypot-undefine99.7%
Applied egg-rr99.7%
Taylor expanded in ky around 0 55.7%
Taylor expanded in ky around 0 69.6%
Final simplification66.1%
(FPCore (kx ky th) :precision binary64 (if (<= th 0.032) (* (sin ky) (/ th (hypot (sin ky) (sin kx)))) (* (sin th) (/ ky (hypot ky (sin kx))))))
double code(double kx, double ky, double th) {
double tmp;
if (th <= 0.032) {
tmp = sin(ky) * (th / hypot(sin(ky), sin(kx)));
} else {
tmp = sin(th) * (ky / hypot(ky, sin(kx)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (th <= 0.032) {
tmp = Math.sin(ky) * (th / Math.hypot(Math.sin(ky), Math.sin(kx)));
} else {
tmp = Math.sin(th) * (ky / Math.hypot(ky, Math.sin(kx)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if th <= 0.032: tmp = math.sin(ky) * (th / math.hypot(math.sin(ky), math.sin(kx))) else: tmp = math.sin(th) * (ky / math.hypot(ky, math.sin(kx))) return tmp
function code(kx, ky, th) tmp = 0.0 if (th <= 0.032) tmp = Float64(sin(ky) * Float64(th / hypot(sin(ky), sin(kx)))); else tmp = Float64(sin(th) * Float64(ky / hypot(ky, sin(kx)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (th <= 0.032) tmp = sin(ky) * (th / hypot(sin(ky), sin(kx))); else tmp = sin(th) * (ky / hypot(ky, sin(kx))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[th, 0.032], N[(N[Sin[ky], $MachinePrecision] * N[(th / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Sqrt[ky ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;th \leq 0.032:\\
\;\;\;\;\sin ky \cdot \frac{th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\mathsf{hypot}\left(ky, \sin kx\right)}\\
\end{array}
\end{array}
if th < 0.032000000000000001Initial program 92.5%
unpow292.5%
sqr-neg92.5%
sin-neg92.5%
sin-neg92.5%
unpow292.5%
associate-*l/90.4%
associate-/l*92.4%
unpow292.4%
Simplified99.6%
Taylor expanded in th around 0 65.1%
if 0.032000000000000001 < th Initial program 94.3%
+-commutative94.3%
unpow294.3%
unpow294.3%
hypot-undefine99.7%
Applied egg-rr99.7%
Taylor expanded in ky around 0 55.7%
Taylor expanded in ky around 0 69.6%
Final simplification66.1%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.05) (/ 1.0 (sqrt (pow (sin th) -2.0))) (* (sin th) (/ ky (hypot ky (sin kx))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.05) {
tmp = 1.0 / sqrt(pow(sin(th), -2.0));
} else {
tmp = sin(th) * (ky / hypot(ky, sin(kx)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -0.05) {
tmp = 1.0 / Math.sqrt(Math.pow(Math.sin(th), -2.0));
} else {
tmp = Math.sin(th) * (ky / Math.hypot(ky, Math.sin(kx)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.05: tmp = 1.0 / math.sqrt(math.pow(math.sin(th), -2.0)) else: tmp = math.sin(th) * (ky / math.hypot(ky, math.sin(kx))) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.05) tmp = Float64(1.0 / sqrt((sin(th) ^ -2.0))); else tmp = Float64(sin(th) * Float64(ky / hypot(ky, sin(kx)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.05) tmp = 1.0 / sqrt((sin(th) ^ -2.0)); else tmp = sin(th) * (ky / hypot(ky, sin(kx))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.05], N[(1.0 / N[Sqrt[N[Power[N[Sin[th], $MachinePrecision], -2.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Sqrt[ky ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.05:\\
\;\;\;\;\frac{1}{\sqrt{{\sin th}^{-2}}}\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\mathsf{hypot}\left(ky, \sin kx\right)}\\
\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.7%
unpow299.7%
Simplified99.7%
Taylor expanded in kx around 0 2.7%
associate-*r/2.7%
clear-num2.7%
Applied egg-rr2.7%
associate-/r*2.7%
*-inverses2.7%
log1p-expm1-u3.5%
Applied egg-rr3.5%
log1p-expm1-u2.7%
add-sqr-sqrt1.1%
sqrt-unprod28.5%
inv-pow28.5%
inv-pow28.5%
pow-prod-up28.5%
metadata-eval28.5%
Applied egg-rr28.5%
if -0.050000000000000003 < (sin.f64 ky) Initial program 90.7%
+-commutative90.7%
unpow290.7%
unpow290.7%
hypot-undefine99.8%
Applied egg-rr99.8%
Taylor expanded in ky around 0 64.3%
Taylor expanded in ky around 0 76.8%
Final simplification65.4%
(FPCore (kx ky th) :precision binary64 (if (<= ky 1.02e-58) (* (sin th) (/ ky (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 1.02e-58) {
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 <= 1.02d-58) 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 <= 1.02e-58) {
tmp = Math.sin(th) * (ky / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 1.02e-58: 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 <= 1.02e-58) 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 <= 1.02e-58) tmp = sin(th) * (ky / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 1.02e-58], 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 1.02 \cdot 10^{-58}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 1.0199999999999999e-58Initial program 89.3%
Taylor expanded in ky around 0 27.7%
if 1.0199999999999999e-58 < ky Initial program 99.8%
unpow299.8%
sqr-neg99.8%
sin-neg99.8%
sin-neg99.8%
unpow299.8%
associate-*l/99.6%
associate-/l*99.7%
unpow299.7%
Simplified99.7%
Taylor expanded in kx around 0 38.4%
Final simplification31.3%
(FPCore (kx ky th) :precision binary64 (if (<= ky 2.65e-59) (* ky (/ (sin th) (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 2.65e-59) {
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.65d-59) 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.65e-59) {
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.65e-59: 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.65e-59) 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.65e-59) tmp = ky * (sin(th) / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 2.65e-59], 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.65 \cdot 10^{-59}:\\
\;\;\;\;ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 2.6500000000000002e-59Initial program 89.3%
unpow289.3%
sqr-neg89.3%
sin-neg89.3%
sin-neg89.3%
unpow289.3%
associate-*l/86.9%
associate-/l*89.2%
unpow289.2%
Simplified99.6%
Taylor expanded in ky around 0 26.1%
associate-/l*27.6%
Simplified27.6%
if 2.6500000000000002e-59 < ky Initial program 99.8%
unpow299.8%
sqr-neg99.8%
sin-neg99.8%
sin-neg99.8%
unpow299.8%
associate-*l/99.6%
associate-/l*99.7%
unpow299.7%
Simplified99.7%
Taylor expanded in kx around 0 38.4%
(FPCore (kx ky th) :precision binary64 (if (<= kx 5.5e-171) (sin th) (/ 1.0 (/ ky (* ky (sin th))))))
double code(double kx, double ky, double th) {
double tmp;
if (kx <= 5.5e-171) {
tmp = sin(th);
} else {
tmp = 1.0 / (ky / (ky * 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 (kx <= 5.5d-171) then
tmp = sin(th)
else
tmp = 1.0d0 / (ky / (ky * sin(th)))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (kx <= 5.5e-171) {
tmp = Math.sin(th);
} else {
tmp = 1.0 / (ky / (ky * Math.sin(th)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if kx <= 5.5e-171: tmp = math.sin(th) else: tmp = 1.0 / (ky / (ky * math.sin(th))) return tmp
function code(kx, ky, th) tmp = 0.0 if (kx <= 5.5e-171) tmp = sin(th); else tmp = Float64(1.0 / Float64(ky / Float64(ky * sin(th)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (kx <= 5.5e-171) tmp = sin(th); else tmp = 1.0 / (ky / (ky * sin(th))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[kx, 5.5e-171], N[Sin[th], $MachinePrecision], N[(1.0 / N[(ky / N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;kx \leq 5.5 \cdot 10^{-171}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{ky}{ky \cdot \sin th}}\\
\end{array}
\end{array}
if kx < 5.50000000000000037e-171Initial program 89.8%
unpow289.8%
sqr-neg89.8%
sin-neg89.8%
sin-neg89.8%
unpow289.8%
associate-*l/88.5%
associate-/l*89.7%
unpow289.7%
Simplified99.7%
Taylor expanded in kx around 0 29.0%
if 5.50000000000000037e-171 < kx Initial program 98.6%
unpow298.6%
sqr-neg98.6%
sin-neg98.6%
sin-neg98.6%
unpow298.6%
associate-*l/96.4%
associate-/l*98.5%
unpow298.5%
Simplified99.6%
Taylor expanded in kx around 0 18.3%
associate-*r/25.8%
clear-num25.8%
Applied egg-rr25.8%
Taylor expanded in ky around 0 12.7%
Taylor expanded in ky around 0 25.8%
(FPCore (kx ky th) :precision binary64 (if (<= kx 0.35) (sin th) (+ (+ (sin th) 1.0) -1.0)))
double code(double kx, double ky, double th) {
double tmp;
if (kx <= 0.35) {
tmp = sin(th);
} else {
tmp = (sin(th) + 1.0) + -1.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 <= 0.35d0) then
tmp = sin(th)
else
tmp = (sin(th) + 1.0d0) + (-1.0d0)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (kx <= 0.35) {
tmp = Math.sin(th);
} else {
tmp = (Math.sin(th) + 1.0) + -1.0;
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if kx <= 0.35: tmp = math.sin(th) else: tmp = (math.sin(th) + 1.0) + -1.0 return tmp
function code(kx, ky, th) tmp = 0.0 if (kx <= 0.35) tmp = sin(th); else tmp = Float64(Float64(sin(th) + 1.0) + -1.0); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (kx <= 0.35) tmp = sin(th); else tmp = (sin(th) + 1.0) + -1.0; end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[kx, 0.35], N[Sin[th], $MachinePrecision], N[(N[(N[Sin[th], $MachinePrecision] + 1.0), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;kx \leq 0.35:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\left(\sin th + 1\right) + -1\\
\end{array}
\end{array}
if kx < 0.34999999999999998Initial program 91.2%
unpow291.2%
sqr-neg91.2%
sin-neg91.2%
sin-neg91.2%
unpow291.2%
associate-*l/89.2%
associate-/l*91.1%
unpow291.1%
Simplified99.7%
Taylor expanded in kx around 0 29.1%
if 0.34999999999999998 < kx Initial 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 kx around 0 9.7%
expm1-log1p-u9.7%
expm1-undefine12.5%
Applied egg-rr12.5%
expm1-define9.7%
associate-*r/15.4%
associate-*l/9.7%
*-inverses9.7%
*-lft-identity9.7%
Simplified9.7%
expm1-undefine12.5%
log1p-undefine12.5%
rem-exp-log12.5%
+-commutative12.5%
Applied egg-rr12.5%
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 92.8%
unpow292.8%
sqr-neg92.8%
sin-neg92.8%
sin-neg92.8%
unpow292.8%
associate-*l/91.2%
associate-/l*92.7%
unpow292.7%
Simplified99.6%
Taylor expanded in kx around 0 25.3%
(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 92.8%
unpow292.8%
sqr-neg92.8%
sin-neg92.8%
sin-neg92.8%
unpow292.8%
associate-*l/91.2%
associate-/l*92.7%
unpow292.7%
Simplified99.6%
Taylor expanded in kx around 0 25.3%
Taylor expanded in th around 0 15.8%
herbie shell --seed 2024144
(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)))