
(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 93.7%
remove-double-neg93.7%
sin-neg93.7%
neg-mul-193.7%
*-commutative93.7%
associate-*l*93.7%
associate-*l/91.1%
associate-/r/91.1%
associate-*l/93.7%
associate-/r/93.6%
sin-neg93.6%
neg-mul-193.6%
associate-/r*93.6%
associate-/r/93.7%
Simplified99.7%
Final simplification99.7%
(FPCore (kx ky th) :precision binary64 (if (<= (sin kx) -0.01) (fabs (* (sin ky) (/ (sin th) (sin kx)))) (if (<= (sin kx) 1e-110) (sin th) (* (sin th) (/ (sin ky) (sin kx))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(kx) <= -0.01) {
tmp = fabs((sin(ky) * (sin(th) / sin(kx))));
} else if (sin(kx) <= 1e-110) {
tmp = sin(th);
} else {
tmp = sin(th) * (sin(ky) / 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 = abs((sin(ky) * (sin(th) / sin(kx))))
else if (sin(kx) <= 1d-110) then
tmp = sin(th)
else
tmp = sin(th) * (sin(ky) / 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 = Math.abs((Math.sin(ky) * (Math.sin(th) / Math.sin(kx))));
} else if (Math.sin(kx) <= 1e-110) {
tmp = Math.sin(th);
} else {
tmp = Math.sin(th) * (Math.sin(ky) / Math.sin(kx));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(kx) <= -0.01: tmp = math.fabs((math.sin(ky) * (math.sin(th) / math.sin(kx)))) elif math.sin(kx) <= 1e-110: tmp = math.sin(th) else: tmp = math.sin(th) * (math.sin(ky) / math.sin(kx)) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(kx) <= -0.01) tmp = abs(Float64(sin(ky) * Float64(sin(th) / sin(kx)))); elseif (sin(kx) <= 1e-110) tmp = sin(th); else tmp = Float64(sin(th) * Float64(sin(ky) / sin(kx))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(kx) <= -0.01) tmp = abs((sin(ky) * (sin(th) / sin(kx)))); elseif (sin(kx) <= 1e-110) tmp = sin(th); else tmp = sin(th) * (sin(ky) / sin(kx)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[kx], $MachinePrecision], -0.01], 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], 1e-110], N[Sin[th], $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin kx \leq -0.01:\\
\;\;\;\;\left|\sin ky \cdot \frac{\sin th}{\sin kx}\right|\\
\mathbf{elif}\;\sin kx \leq 10^{-110}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.0100000000000000002Initial program 99.5%
Taylor expanded in ky around 0 16.4%
associate-*l/16.4%
clear-num16.4%
Applied egg-rr16.4%
associate-/r/16.4%
Simplified16.4%
add-sqr-sqrt15.2%
sqrt-unprod30.7%
pow230.7%
associate-*r*30.7%
*-commutative30.7%
associate-*l/30.7%
*-un-lft-identity30.7%
Applied egg-rr30.7%
unpow230.7%
rem-sqrt-square37.4%
associate-*r/37.4%
*-rgt-identity37.4%
times-frac37.3%
rem-square-sqrt17.9%
associate-*r/17.9%
/-rgt-identity17.9%
rem-square-sqrt37.3%
Simplified37.3%
if -0.0100000000000000002 < (sin.f64 kx) < 1.0000000000000001e-110Initial program 85.1%
Taylor expanded in kx around 0 34.8%
if 1.0000000000000001e-110 < (sin.f64 kx) Initial program 99.4%
Taylor expanded in ky around 0 63.2%
Final simplification45.0%
(FPCore (kx ky th) :precision binary64 (if (<= (sin kx) -0.01) (fabs (/ (* (sin ky) (sin th)) (sin kx))) (if (<= (sin kx) 1e-110) (sin th) (* (sin th) (/ (sin ky) (sin kx))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(kx) <= -0.01) {
tmp = fabs(((sin(ky) * sin(th)) / sin(kx)));
} else if (sin(kx) <= 1e-110) {
tmp = sin(th);
} else {
tmp = sin(th) * (sin(ky) / 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 = abs(((sin(ky) * sin(th)) / sin(kx)))
else if (sin(kx) <= 1d-110) then
tmp = sin(th)
else
tmp = sin(th) * (sin(ky) / 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 = Math.abs(((Math.sin(ky) * Math.sin(th)) / Math.sin(kx)));
} else if (Math.sin(kx) <= 1e-110) {
tmp = Math.sin(th);
} else {
tmp = Math.sin(th) * (Math.sin(ky) / Math.sin(kx));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(kx) <= -0.01: tmp = math.fabs(((math.sin(ky) * math.sin(th)) / math.sin(kx))) elif math.sin(kx) <= 1e-110: tmp = math.sin(th) else: tmp = math.sin(th) * (math.sin(ky) / math.sin(kx)) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(kx) <= -0.01) tmp = abs(Float64(Float64(sin(ky) * sin(th)) / sin(kx))); elseif (sin(kx) <= 1e-110) tmp = sin(th); else tmp = Float64(sin(th) * Float64(sin(ky) / sin(kx))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(kx) <= -0.01) tmp = abs(((sin(ky) * sin(th)) / sin(kx))); elseif (sin(kx) <= 1e-110) tmp = sin(th); else tmp = sin(th) * (sin(ky) / sin(kx)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[kx], $MachinePrecision], -0.01], N[Abs[N[(N[(N[Sin[ky], $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 1e-110], N[Sin[th], $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin kx \leq -0.01:\\
\;\;\;\;\left|\frac{\sin ky \cdot \sin th}{\sin kx}\right|\\
\mathbf{elif}\;\sin kx \leq 10^{-110}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.0100000000000000002Initial program 99.5%
Taylor expanded in ky around 0 16.4%
add-sqr-sqrt15.2%
sqrt-unprod30.7%
pow230.7%
*-commutative30.7%
Applied egg-rr30.7%
unpow230.7%
rem-sqrt-square37.4%
associate-*r/37.4%
*-commutative37.4%
Simplified37.4%
if -0.0100000000000000002 < (sin.f64 kx) < 1.0000000000000001e-110Initial program 85.1%
Taylor expanded in kx around 0 34.8%
if 1.0000000000000001e-110 < (sin.f64 kx) Initial program 99.4%
Taylor expanded in ky around 0 63.2%
Final simplification45.0%
(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 93.7%
expm1-log1p-u93.5%
expm1-udef43.5%
Applied egg-rr45.5%
expm1-def99.6%
expm1-log1p99.7%
associate-*l/96.4%
*-lft-identity96.4%
times-frac99.6%
rem-square-sqrt47.7%
associate-*r/47.7%
/-rgt-identity47.7%
rem-square-sqrt99.6%
hypot-def93.6%
unpow293.6%
unpow293.6%
+-commutative93.6%
unpow293.6%
unpow293.6%
hypot-def99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (kx ky th)
:precision binary64
(if (<= th 0.066)
(/
(sin ky)
(* (hypot (sin kx) (sin ky)) (+ (/ 1.0 th) (* th 0.16666666666666666))))
(* (sin th) (fabs (/ (sin ky) (sin kx))))))
double code(double kx, double ky, double th) {
double tmp;
if (th <= 0.066) {
tmp = sin(ky) / (hypot(sin(kx), sin(ky)) * ((1.0 / th) + (th * 0.16666666666666666)));
} else {
tmp = sin(th) * fabs((sin(ky) / sin(kx)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (th <= 0.066) {
tmp = Math.sin(ky) / (Math.hypot(Math.sin(kx), Math.sin(ky)) * ((1.0 / th) + (th * 0.16666666666666666)));
} else {
tmp = Math.sin(th) * Math.abs((Math.sin(ky) / Math.sin(kx)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if th <= 0.066: tmp = math.sin(ky) / (math.hypot(math.sin(kx), math.sin(ky)) * ((1.0 / th) + (th * 0.16666666666666666))) else: tmp = math.sin(th) * math.fabs((math.sin(ky) / math.sin(kx))) return tmp
function code(kx, ky, th) tmp = 0.0 if (th <= 0.066) tmp = Float64(sin(ky) / Float64(hypot(sin(kx), sin(ky)) * Float64(Float64(1.0 / th) + Float64(th * 0.16666666666666666)))); else tmp = Float64(sin(th) * abs(Float64(sin(ky) / sin(kx)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (th <= 0.066) tmp = sin(ky) / (hypot(sin(kx), sin(ky)) * ((1.0 / th) + (th * 0.16666666666666666))); else tmp = sin(th) * abs((sin(ky) / sin(kx))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[th, 0.066], N[(N[Sin[ky], $MachinePrecision] / N[(N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision] * N[(N[(1.0 / th), $MachinePrecision] + N[(th * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[Abs[N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;th \leq 0.066:\\
\;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin kx, \sin ky\right) \cdot \left(\frac{1}{th} + th \cdot 0.16666666666666666\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \left|\frac{\sin ky}{\sin kx}\right|\\
\end{array}
\end{array}
if th < 0.066000000000000003Initial program 94.6%
associate-*l/91.3%
associate-/l*94.5%
unpow294.5%
unpow294.5%
hypot-def99.6%
Applied egg-rr99.6%
Taylor expanded in th around 0 62.8%
+-commutative62.8%
unpow262.8%
unpow262.8%
hypot-def65.1%
associate-*r*65.1%
unpow265.1%
unpow265.1%
hypot-def65.3%
distribute-rgt-out65.3%
Simplified65.3%
if 0.066000000000000003 < th Initial program 90.7%
Taylor expanded in ky around 0 27.0%
add-sqr-sqrt14.1%
sqrt-unprod20.2%
pow220.2%
Applied egg-rr20.2%
unpow220.2%
rem-sqrt-square27.6%
Simplified27.6%
Final simplification56.2%
(FPCore (kx ky th) :precision binary64 (if (<= th 0.0078) (* (sin ky) (/ th (hypot (sin kx) (sin ky)))) (* (sin th) (fabs (/ (sin ky) (sin kx))))))
double code(double kx, double ky, double th) {
double tmp;
if (th <= 0.0078) {
tmp = sin(ky) * (th / hypot(sin(kx), sin(ky)));
} else {
tmp = sin(th) * fabs((sin(ky) / sin(kx)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (th <= 0.0078) {
tmp = Math.sin(ky) * (th / Math.hypot(Math.sin(kx), Math.sin(ky)));
} else {
tmp = Math.sin(th) * Math.abs((Math.sin(ky) / Math.sin(kx)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if th <= 0.0078: tmp = math.sin(ky) * (th / math.hypot(math.sin(kx), math.sin(ky))) else: tmp = math.sin(th) * math.fabs((math.sin(ky) / math.sin(kx))) return tmp
function code(kx, ky, th) tmp = 0.0 if (th <= 0.0078) tmp = Float64(sin(ky) * Float64(th / hypot(sin(kx), sin(ky)))); else tmp = Float64(sin(th) * abs(Float64(sin(ky) / sin(kx)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (th <= 0.0078) tmp = sin(ky) * (th / hypot(sin(kx), sin(ky))); else tmp = sin(th) * abs((sin(ky) / sin(kx))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[th, 0.0078], N[(N[Sin[ky], $MachinePrecision] * N[(th / N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[Abs[N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;th \leq 0.0078:\\
\;\;\;\;\sin ky \cdot \frac{th}{\mathsf{hypot}\left(\sin kx, \sin ky\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \left|\frac{\sin ky}{\sin kx}\right|\\
\end{array}
\end{array}
if th < 0.0077999999999999996Initial program 94.6%
associate-*l/91.3%
associate-/l*94.5%
unpow294.5%
unpow294.5%
hypot-def99.6%
Applied egg-rr99.6%
clear-num99.4%
associate-/r/99.5%
clear-num99.6%
Applied egg-rr99.6%
Taylor expanded in th around 0 64.8%
if 0.0077999999999999996 < th Initial program 90.7%
Taylor expanded in ky around 0 27.0%
add-sqr-sqrt14.1%
sqrt-unprod20.2%
pow220.2%
Applied egg-rr20.2%
unpow220.2%
rem-sqrt-square27.6%
Simplified27.6%
Final simplification55.8%
(FPCore (kx ky th) :precision binary64 (if (<= th 0.034) (* (/ (sin ky) (hypot (sin ky) (sin kx))) th) (* (sin th) (fabs (/ (sin ky) (sin kx))))))
double code(double kx, double ky, double th) {
double tmp;
if (th <= 0.034) {
tmp = (sin(ky) / hypot(sin(ky), sin(kx))) * th;
} else {
tmp = sin(th) * fabs((sin(ky) / sin(kx)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (th <= 0.034) {
tmp = (Math.sin(ky) / Math.hypot(Math.sin(ky), Math.sin(kx))) * th;
} else {
tmp = Math.sin(th) * Math.abs((Math.sin(ky) / Math.sin(kx)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if th <= 0.034: tmp = (math.sin(ky) / math.hypot(math.sin(ky), math.sin(kx))) * th else: tmp = math.sin(th) * math.fabs((math.sin(ky) / math.sin(kx))) return tmp
function code(kx, ky, th) tmp = 0.0 if (th <= 0.034) tmp = Float64(Float64(sin(ky) / hypot(sin(ky), sin(kx))) * th); else tmp = Float64(sin(th) * abs(Float64(sin(ky) / sin(kx)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (th <= 0.034) tmp = (sin(ky) / hypot(sin(ky), sin(kx))) * th; else tmp = sin(th) * abs((sin(ky) / sin(kx))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[th, 0.034], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * th), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[Abs[N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;th \leq 0.034:\\
\;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot th\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \left|\frac{\sin ky}{\sin kx}\right|\\
\end{array}
\end{array}
if th < 0.034000000000000002Initial program 94.6%
remove-double-neg94.6%
sin-neg94.6%
neg-mul-194.6%
*-commutative94.6%
associate-*l*94.6%
associate-*l/91.3%
associate-/r/91.3%
associate-*l/94.6%
associate-/r/94.5%
sin-neg94.5%
neg-mul-194.5%
associate-/r*94.5%
associate-/r/94.6%
Simplified99.7%
Taylor expanded in th around 0 64.8%
if 0.034000000000000002 < th Initial program 90.7%
Taylor expanded in ky around 0 27.0%
add-sqr-sqrt14.1%
sqrt-unprod20.2%
pow220.2%
Applied egg-rr20.2%
unpow220.2%
rem-sqrt-square27.6%
Simplified27.6%
Final simplification55.8%
(FPCore (kx ky th) :precision binary64 (if (<= kx 9e-111) (sin th) (* (sin th) (fabs (/ (sin ky) (sin kx))))))
double code(double kx, double ky, double th) {
double tmp;
if (kx <= 9e-111) {
tmp = sin(th);
} else {
tmp = sin(th) * fabs((sin(ky) / 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 <= 9d-111) then
tmp = sin(th)
else
tmp = sin(th) * abs((sin(ky) / sin(kx)))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (kx <= 9e-111) {
tmp = Math.sin(th);
} else {
tmp = Math.sin(th) * Math.abs((Math.sin(ky) / Math.sin(kx)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if kx <= 9e-111: tmp = math.sin(th) else: tmp = math.sin(th) * math.fabs((math.sin(ky) / math.sin(kx))) return tmp
function code(kx, ky, th) tmp = 0.0 if (kx <= 9e-111) tmp = sin(th); else tmp = Float64(sin(th) * abs(Float64(sin(ky) / sin(kx)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (kx <= 9e-111) tmp = sin(th); else tmp = sin(th) * abs((sin(ky) / sin(kx))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[kx, 9e-111], N[Sin[th], $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[Abs[N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;kx \leq 9 \cdot 10^{-111}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \left|\frac{\sin ky}{\sin kx}\right|\\
\end{array}
\end{array}
if kx < 8.99999999999999987e-111Initial program 90.3%
Taylor expanded in kx around 0 24.7%
if 8.99999999999999987e-111 < kx Initial program 99.6%
Taylor expanded in ky around 0 40.9%
add-sqr-sqrt18.2%
sqrt-unprod34.9%
pow234.9%
Applied egg-rr34.9%
unpow234.9%
rem-sqrt-square41.8%
Simplified41.8%
Final simplification30.9%
(FPCore (kx ky th) :precision binary64 (if (<= kx 1.3e-110) (sin th) (* (sin th) (expm1 (/ ky (sin kx))))))
double code(double kx, double ky, double th) {
double tmp;
if (kx <= 1.3e-110) {
tmp = sin(th);
} else {
tmp = sin(th) * expm1((ky / sin(kx)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (kx <= 1.3e-110) {
tmp = Math.sin(th);
} else {
tmp = Math.sin(th) * Math.expm1((ky / Math.sin(kx)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if kx <= 1.3e-110: tmp = math.sin(th) else: tmp = math.sin(th) * math.expm1((ky / math.sin(kx))) return tmp
function code(kx, ky, th) tmp = 0.0 if (kx <= 1.3e-110) tmp = sin(th); else tmp = Float64(sin(th) * expm1(Float64(ky / sin(kx)))); end return tmp end
code[kx_, ky_, th_] := If[LessEqual[kx, 1.3e-110], N[Sin[th], $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(Exp[N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;kx \leq 1.3 \cdot 10^{-110}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \mathsf{expm1}\left(\frac{ky}{\sin kx}\right)\\
\end{array}
\end{array}
if kx < 1.29999999999999995e-110Initial program 90.3%
Taylor expanded in kx around 0 24.7%
if 1.29999999999999995e-110 < kx Initial program 99.6%
remove-double-neg99.6%
sin-neg99.6%
neg-mul-199.6%
*-commutative99.6%
associate-*l*99.6%
associate-*l/97.5%
associate-/r/97.5%
associate-*l/99.6%
associate-/r/99.4%
sin-neg99.4%
neg-mul-199.4%
associate-/r*99.4%
associate-/r/99.6%
Simplified99.6%
expm1-log1p-u99.5%
hypot-udef99.5%
unpow299.5%
unpow299.5%
+-commutative99.5%
unpow299.5%
unpow299.5%
hypot-def99.5%
Applied egg-rr99.5%
Taylor expanded in ky around 0 37.7%
Final simplification29.4%
(FPCore (kx ky th) :precision binary64 (if (<= kx 8.2e-111) (sin th) (* (sin th) (/ (sin ky) (sin kx)))))
double code(double kx, double ky, double th) {
double tmp;
if (kx <= 8.2e-111) {
tmp = sin(th);
} else {
tmp = sin(th) * (sin(ky) / 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 <= 8.2d-111) then
tmp = sin(th)
else
tmp = sin(th) * (sin(ky) / sin(kx))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (kx <= 8.2e-111) {
tmp = Math.sin(th);
} else {
tmp = Math.sin(th) * (Math.sin(ky) / Math.sin(kx));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if kx <= 8.2e-111: tmp = math.sin(th) else: tmp = math.sin(th) * (math.sin(ky) / math.sin(kx)) return tmp
function code(kx, ky, th) tmp = 0.0 if (kx <= 8.2e-111) tmp = sin(th); else tmp = Float64(sin(th) * Float64(sin(ky) / sin(kx))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (kx <= 8.2e-111) tmp = sin(th); else tmp = sin(th) * (sin(ky) / sin(kx)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[kx, 8.2e-111], N[Sin[th], $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;kx \leq 8.2 \cdot 10^{-111}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\
\end{array}
\end{array}
if kx < 8.19999999999999936e-111Initial program 90.3%
Taylor expanded in kx around 0 24.7%
if 8.19999999999999936e-111 < kx Initial program 99.6%
Taylor expanded in ky around 0 40.9%
Final simplification30.6%
(FPCore (kx ky th) :precision binary64 (if (<= kx 1.3e-110) (sin th) (* (sin th) (/ ky (sin kx)))))
double code(double kx, double ky, double th) {
double tmp;
if (kx <= 1.3e-110) {
tmp = sin(th);
} else {
tmp = sin(th) * (ky / 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 <= 1.3d-110) then
tmp = sin(th)
else
tmp = sin(th) * (ky / sin(kx))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (kx <= 1.3e-110) {
tmp = Math.sin(th);
} else {
tmp = Math.sin(th) * (ky / Math.sin(kx));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if kx <= 1.3e-110: tmp = math.sin(th) else: tmp = math.sin(th) * (ky / math.sin(kx)) return tmp
function code(kx, ky, th) tmp = 0.0 if (kx <= 1.3e-110) tmp = sin(th); else tmp = Float64(sin(th) * Float64(ky / sin(kx))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (kx <= 1.3e-110) tmp = sin(th); else tmp = sin(th) * (ky / sin(kx)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[kx, 1.3e-110], N[Sin[th], $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;kx \leq 1.3 \cdot 10^{-110}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
\end{array}
\end{array}
if kx < 1.29999999999999995e-110Initial program 90.3%
Taylor expanded in kx around 0 24.7%
if 1.29999999999999995e-110 < kx Initial program 99.6%
remove-double-neg99.6%
sin-neg99.6%
neg-mul-199.6%
*-commutative99.6%
associate-*l*99.6%
associate-*l/97.5%
associate-/r/97.5%
associate-*l/99.6%
associate-/r/99.4%
sin-neg99.4%
neg-mul-199.4%
associate-/r*99.4%
associate-/r/99.6%
Simplified99.6%
Taylor expanded in ky around 0 36.7%
Final simplification29.0%
(FPCore (kx ky th) :precision binary64 (if (<= ky 1.6e-154) (/ ky (* (sin kx) (+ (/ 1.0 th) (* th 0.16666666666666666)))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 1.6e-154) {
tmp = ky / (sin(kx) * ((1.0 / th) + (th * 0.16666666666666666)));
} 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-154) then
tmp = ky / (sin(kx) * ((1.0d0 / th) + (th * 0.16666666666666666d0)))
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-154) {
tmp = ky / (Math.sin(kx) * ((1.0 / th) + (th * 0.16666666666666666)));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 1.6e-154: tmp = ky / (math.sin(kx) * ((1.0 / th) + (th * 0.16666666666666666))) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 1.6e-154) tmp = Float64(ky / Float64(sin(kx) * Float64(Float64(1.0 / th) + Float64(th * 0.16666666666666666)))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 1.6e-154) tmp = ky / (sin(kx) * ((1.0 / th) + (th * 0.16666666666666666))); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 1.6e-154], N[(ky / N[(N[Sin[kx], $MachinePrecision] * N[(N[(1.0 / th), $MachinePrecision] + N[(th * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 1.6 \cdot 10^{-154}:\\
\;\;\;\;\frac{ky}{\sin kx \cdot \left(\frac{1}{th} + th \cdot 0.16666666666666666\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 1.60000000000000002e-154Initial program 90.1%
associate-*l/87.7%
associate-/l*90.1%
unpow290.1%
unpow290.1%
hypot-def99.5%
Applied egg-rr99.5%
Taylor expanded in th around 0 47.4%
+-commutative47.4%
unpow247.4%
unpow247.4%
hypot-def50.4%
associate-*r*50.4%
unpow250.4%
unpow250.4%
hypot-def50.8%
distribute-rgt-out50.8%
Simplified50.8%
Taylor expanded in ky around 0 24.3%
if 1.60000000000000002e-154 < ky Initial program 99.7%
Taylor expanded in kx around 0 33.1%
Final simplification27.6%
(FPCore (kx ky th) :precision binary64 (if (<= kx 8.2e-46) (sin th) (+ 1.0 (+ (sin th) -1.0))))
double code(double kx, double ky, double th) {
double tmp;
if (kx <= 8.2e-46) {
tmp = sin(th);
} else {
tmp = 1.0 + (sin(th) + -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 <= 8.2d-46) then
tmp = sin(th)
else
tmp = 1.0d0 + (sin(th) + (-1.0d0))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (kx <= 8.2e-46) {
tmp = Math.sin(th);
} else {
tmp = 1.0 + (Math.sin(th) + -1.0);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if kx <= 8.2e-46: tmp = math.sin(th) else: tmp = 1.0 + (math.sin(th) + -1.0) return tmp
function code(kx, ky, th) tmp = 0.0 if (kx <= 8.2e-46) tmp = sin(th); else tmp = Float64(1.0 + Float64(sin(th) + -1.0)); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (kx <= 8.2e-46) tmp = sin(th); else tmp = 1.0 + (sin(th) + -1.0); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[kx, 8.2e-46], N[Sin[th], $MachinePrecision], N[(1.0 + N[(N[Sin[th], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;kx \leq 8.2 \cdot 10^{-46}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;1 + \left(\sin th + -1\right)\\
\end{array}
\end{array}
if kx < 8.1999999999999998e-46Initial program 90.8%
Taylor expanded in kx around 0 24.8%
if 8.1999999999999998e-46 < kx Initial program 99.6%
Taylor expanded in kx around 0 9.0%
expm1-log1p-u9.0%
Applied egg-rr9.0%
expm1-udef23.2%
sub-neg23.2%
log1p-udef23.2%
rem-exp-log23.2%
metadata-eval23.2%
Applied egg-rr23.2%
associate-+l+23.2%
Simplified23.2%
Final simplification24.3%
(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 93.7%
Taylor expanded in kx around 0 19.6%
Final simplification19.6%
(FPCore (kx ky th) :precision binary64 (/ 1.0 (+ (/ 1.0 th) (* th 0.16666666666666666))))
double code(double kx, double ky, double th) {
return 1.0 / ((1.0 / th) + (th * 0.16666666666666666));
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = 1.0d0 / ((1.0d0 / th) + (th * 0.16666666666666666d0))
end function
public static double code(double kx, double ky, double th) {
return 1.0 / ((1.0 / th) + (th * 0.16666666666666666));
}
def code(kx, ky, th): return 1.0 / ((1.0 / th) + (th * 0.16666666666666666))
function code(kx, ky, th) return Float64(1.0 / Float64(Float64(1.0 / th) + Float64(th * 0.16666666666666666))) end
function tmp = code(kx, ky, th) tmp = 1.0 / ((1.0 / th) + (th * 0.16666666666666666)); end
code[kx_, ky_, th_] := N[(1.0 / N[(N[(1.0 / th), $MachinePrecision] + N[(th * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\frac{1}{th} + th \cdot 0.16666666666666666}
\end{array}
Initial program 93.7%
associate-*l/91.1%
associate-/l*93.6%
unpow293.6%
unpow293.6%
hypot-def99.5%
Applied egg-rr99.5%
Taylor expanded in th around 0 48.6%
+-commutative48.6%
unpow248.6%
unpow248.6%
hypot-def50.5%
associate-*r*50.5%
unpow250.5%
unpow250.5%
hypot-def50.8%
distribute-rgt-out50.8%
Simplified50.8%
Taylor expanded in kx around 0 11.5%
Final simplification11.5%
(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 93.7%
Taylor expanded in kx around 0 19.6%
Taylor expanded in th around 0 10.9%
Final simplification10.9%
herbie shell --seed 2024031
(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)))