
(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 th) (/ (hypot (sin kx) (sin ky)) (sin ky))))
double code(double kx, double ky, double th) {
return sin(th) / (hypot(sin(kx), sin(ky)) / sin(ky));
}
public static double code(double kx, double ky, double th) {
return Math.sin(th) / (Math.hypot(Math.sin(kx), Math.sin(ky)) / Math.sin(ky));
}
def code(kx, ky, th): return math.sin(th) / (math.hypot(math.sin(kx), math.sin(ky)) / math.sin(ky))
function code(kx, ky, th) return Float64(sin(th) / Float64(hypot(sin(kx), sin(ky)) / sin(ky))) end
function tmp = code(kx, ky, th) tmp = sin(th) / (hypot(sin(kx), sin(ky)) / sin(ky)); end
code[kx_, ky_, th_] := N[(N[Sin[th], $MachinePrecision] / N[(N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin th}{\frac{\mathsf{hypot}\left(\sin kx, \sin ky\right)}{\sin ky}}
\end{array}
Initial program 92.8%
*-commutative92.8%
clear-num92.7%
un-div-inv92.8%
unpow292.8%
unpow292.8%
hypot-def99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin th) -0.005)
(* (sin th) (fabs (/ (sin ky) (sin kx))))
(if (<= (sin th) 0.002)
(/ (sin ky) (/ (hypot (sin ky) (sin kx)) th))
(/ (sin ky) (fabs (/ (sin kx) (sin th)))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(th) <= -0.005) {
tmp = sin(th) * fabs((sin(ky) / sin(kx)));
} else if (sin(th) <= 0.002) {
tmp = sin(ky) / (hypot(sin(ky), sin(kx)) / 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.005) {
tmp = Math.sin(th) * Math.abs((Math.sin(ky) / Math.sin(kx)));
} else if (Math.sin(th) <= 0.002) {
tmp = Math.sin(ky) / (Math.hypot(Math.sin(ky), Math.sin(kx)) / 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.005: tmp = math.sin(th) * math.fabs((math.sin(ky) / math.sin(kx))) elif math.sin(th) <= 0.002: tmp = math.sin(ky) / (math.hypot(math.sin(ky), math.sin(kx)) / 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.005) tmp = Float64(sin(th) * abs(Float64(sin(ky) / sin(kx)))); elseif (sin(th) <= 0.002) tmp = Float64(sin(ky) / Float64(hypot(sin(ky), sin(kx)) / 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.005) tmp = sin(th) * abs((sin(ky) / sin(kx))); elseif (sin(th) <= 0.002) tmp = sin(ky) / (hypot(sin(ky), sin(kx)) / 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.005], N[(N[Sin[th], $MachinePrecision] * N[Abs[N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[th], $MachinePrecision], 0.002], N[(N[Sin[ky], $MachinePrecision] / N[(N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $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.005:\\
\;\;\;\;\sin th \cdot \left|\frac{\sin ky}{\sin kx}\right|\\
\mathbf{elif}\;\sin th \leq 0.002:\\
\;\;\;\;\frac{\sin ky}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right)}{th}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\left|\frac{\sin kx}{\sin th}\right|}\\
\end{array}
\end{array}
if (sin.f64 th) < -0.0050000000000000001Initial program 91.5%
Taylor expanded in ky around 0 22.3%
add-sqr-sqrt12.4%
sqrt-unprod19.5%
pow219.5%
Applied egg-rr19.5%
unpow219.5%
rem-sqrt-square25.5%
Simplified25.5%
if -0.0050000000000000001 < (sin.f64 th) < 2e-3Initial program 93.2%
associate-*l/90.8%
associate-/l*93.1%
unpow293.1%
unpow293.1%
hypot-def99.8%
Applied egg-rr99.8%
Taylor expanded in th around 0 91.8%
associate-*l/92.0%
unpow292.0%
unpow292.0%
hypot-def98.5%
*-lft-identity98.5%
hypot-def92.0%
unpow292.0%
unpow292.0%
+-commutative92.0%
unpow292.0%
unpow292.0%
hypot-def98.5%
Simplified98.5%
if 2e-3 < (sin.f64 th) Initial program 93.3%
Taylor expanded in ky around 0 25.2%
associate-*l/25.2%
associate-/l*25.2%
Applied egg-rr25.2%
add-sqr-sqrt24.2%
sqrt-unprod37.5%
pow237.5%
Applied egg-rr37.5%
unpow237.5%
rem-sqrt-square42.9%
Simplified42.9%
Final simplification64.6%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.04) (/ (sin ky) (fabs (/ (sin kx) (sin th)))) (if (<= (sin ky) 5e-7) (* (sin th) (fabs (/ (sin ky) (sin kx)))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.04) {
tmp = sin(ky) / fabs((sin(kx) / sin(th)));
} else if (sin(ky) <= 5e-7) {
tmp = sin(th) * fabs((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.04d0)) then
tmp = sin(ky) / abs((sin(kx) / sin(th)))
else if (sin(ky) <= 5d-7) then
tmp = sin(th) * abs((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.04) {
tmp = Math.sin(ky) / Math.abs((Math.sin(kx) / Math.sin(th)));
} else if (Math.sin(ky) <= 5e-7) {
tmp = Math.sin(th) * Math.abs((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.04: tmp = math.sin(ky) / math.fabs((math.sin(kx) / math.sin(th))) elif math.sin(ky) <= 5e-7: tmp = math.sin(th) * math.fabs((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.04) tmp = Float64(sin(ky) / abs(Float64(sin(kx) / sin(th)))); elseif (sin(ky) <= 5e-7) tmp = Float64(sin(th) * abs(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.04) tmp = sin(ky) / abs((sin(kx) / sin(th))); elseif (sin(ky) <= 5e-7) tmp = sin(th) * abs((sin(ky) / sin(kx))); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.04], N[(N[Sin[ky], $MachinePrecision] / N[Abs[N[(N[Sin[kx], $MachinePrecision] / N[Sin[th], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 5e-7], N[(N[Sin[th], $MachinePrecision] * N[Abs[N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.04:\\
\;\;\;\;\frac{\sin ky}{\left|\frac{\sin kx}{\sin th}\right|}\\
\mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-7}:\\
\;\;\;\;\sin th \cdot \left|\frac{\sin ky}{\sin kx}\right|\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.0400000000000000008Initial program 99.8%
Taylor expanded in ky around 0 6.3%
associate-*l/6.3%
associate-/l*6.3%
Applied egg-rr6.3%
add-sqr-sqrt3.6%
sqrt-unprod6.9%
pow26.9%
Applied egg-rr6.9%
unpow26.9%
rem-sqrt-square7.2%
Simplified7.2%
if -0.0400000000000000008 < (sin.f64 ky) < 4.99999999999999977e-7Initial program 85.5%
Taylor expanded in ky around 0 45.5%
add-sqr-sqrt20.7%
sqrt-unprod41.4%
pow241.4%
Applied egg-rr41.4%
unpow241.4%
rem-sqrt-square50.3%
Simplified50.3%
if 4.99999999999999977e-7 < (sin.f64 ky) Initial program 99.6%
Taylor expanded in kx around 0 58.9%
Final simplification42.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 92.8%
expm1-log1p-u92.7%
expm1-udef42.2%
Applied egg-rr44.1%
expm1-def99.6%
expm1-log1p99.6%
*-commutative99.6%
associate-*r/96.4%
associate-*l/99.6%
*-commutative99.6%
hypot-def92.8%
unpow292.8%
unpow292.8%
+-commutative92.8%
unpow292.8%
unpow292.8%
hypot-def99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (kx ky th) :precision binary64 (* (sin th) (/ (sin ky) (hypot (sin ky) (sin kx)))))
double code(double kx, double ky, double th) {
return sin(th) * (sin(ky) / hypot(sin(ky), sin(kx)));
}
public static double code(double kx, double ky, double th) {
return Math.sin(th) * (Math.sin(ky) / Math.hypot(Math.sin(ky), Math.sin(kx)));
}
def code(kx, ky, th): return math.sin(th) * (math.sin(ky) / math.hypot(math.sin(ky), math.sin(kx)))
function code(kx, ky, th) return Float64(sin(th) * Float64(sin(ky) / hypot(sin(ky), sin(kx)))) end
function tmp = code(kx, ky, th) tmp = sin(th) * (sin(ky) / hypot(sin(ky), sin(kx))); end
code[kx_, ky_, th_] := N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}
\end{array}
Initial program 92.8%
remove-double-neg92.8%
sin-neg92.8%
neg-mul-192.8%
*-commutative92.8%
associate-*l*92.8%
associate-*l/91.6%
associate-/r/91.6%
associate-*l/92.8%
associate-/r/92.8%
sin-neg92.8%
neg-mul-192.8%
associate-/r*92.8%
associate-/r/92.8%
Simplified99.6%
Final simplification99.6%
(FPCore (kx ky th)
:precision binary64
(if (<= th 0.22)
(/
(sin ky)
(* (hypot (sin ky) (sin kx)) (+ (/ 1.0 th) (* th 0.16666666666666666))))
(/ (* (sin th) ky) (hypot (sin kx) (sin ky)))))
double code(double kx, double ky, double th) {
double tmp;
if (th <= 0.22) {
tmp = sin(ky) / (hypot(sin(ky), sin(kx)) * ((1.0 / th) + (th * 0.16666666666666666)));
} else {
tmp = (sin(th) * ky) / hypot(sin(kx), sin(ky));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (th <= 0.22) {
tmp = Math.sin(ky) / (Math.hypot(Math.sin(ky), Math.sin(kx)) * ((1.0 / th) + (th * 0.16666666666666666)));
} else {
tmp = (Math.sin(th) * ky) / Math.hypot(Math.sin(kx), Math.sin(ky));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if th <= 0.22: tmp = math.sin(ky) / (math.hypot(math.sin(ky), math.sin(kx)) * ((1.0 / th) + (th * 0.16666666666666666))) else: tmp = (math.sin(th) * ky) / math.hypot(math.sin(kx), math.sin(ky)) return tmp
function code(kx, ky, th) tmp = 0.0 if (th <= 0.22) tmp = Float64(sin(ky) / Float64(hypot(sin(ky), sin(kx)) * Float64(Float64(1.0 / th) + Float64(th * 0.16666666666666666)))); else tmp = Float64(Float64(sin(th) * ky) / hypot(sin(kx), sin(ky))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (th <= 0.22) tmp = sin(ky) / (hypot(sin(ky), sin(kx)) * ((1.0 / th) + (th * 0.16666666666666666))); else tmp = (sin(th) * ky) / hypot(sin(kx), sin(ky)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[th, 0.22], N[(N[Sin[ky], $MachinePrecision] / N[(N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision] * N[(N[(1.0 / th), $MachinePrecision] + N[(th * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[th], $MachinePrecision] * ky), $MachinePrecision] / N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;th \leq 0.22:\\
\;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \left(\frac{1}{th} + th \cdot 0.16666666666666666\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin th \cdot ky}{\mathsf{hypot}\left(\sin kx, \sin ky\right)}\\
\end{array}
\end{array}
if th < 0.220000000000000001Initial program 92.8%
associate-*l/91.2%
associate-/l*92.7%
unpow292.7%
unpow292.7%
hypot-def99.6%
Applied egg-rr99.6%
Taylor expanded in th around 0 61.3%
+-commutative61.3%
unpow261.3%
unpow261.3%
hypot-def65.5%
associate-*r*65.5%
unpow265.5%
unpow265.5%
hypot-def65.6%
distribute-rgt-out65.6%
Simplified65.6%
if 0.220000000000000001 < th Initial program 92.9%
expm1-log1p-u92.6%
expm1-udef65.9%
Applied egg-rr68.7%
expm1-def99.4%
expm1-log1p99.5%
associate-*l/99.5%
Simplified99.5%
Taylor expanded in ky around 0 45.4%
Final simplification59.8%
(FPCore (kx ky th) :precision binary64 (if (<= th 0.05) (/ (sin ky) (/ (hypot (sin ky) (sin kx)) th)) (/ (* (sin th) ky) (hypot (sin kx) (sin ky)))))
double code(double kx, double ky, double th) {
double tmp;
if (th <= 0.05) {
tmp = sin(ky) / (hypot(sin(ky), sin(kx)) / th);
} else {
tmp = (sin(th) * ky) / hypot(sin(kx), sin(ky));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (th <= 0.05) {
tmp = Math.sin(ky) / (Math.hypot(Math.sin(ky), Math.sin(kx)) / th);
} else {
tmp = (Math.sin(th) * ky) / Math.hypot(Math.sin(kx), Math.sin(ky));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if th <= 0.05: tmp = math.sin(ky) / (math.hypot(math.sin(ky), math.sin(kx)) / th) else: tmp = (math.sin(th) * ky) / math.hypot(math.sin(kx), math.sin(ky)) return tmp
function code(kx, ky, th) tmp = 0.0 if (th <= 0.05) tmp = Float64(sin(ky) / Float64(hypot(sin(ky), sin(kx)) / th)); else tmp = Float64(Float64(sin(th) * ky) / hypot(sin(kx), sin(ky))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (th <= 0.05) tmp = sin(ky) / (hypot(sin(ky), sin(kx)) / th); else tmp = (sin(th) * ky) / hypot(sin(kx), sin(ky)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[th, 0.05], N[(N[Sin[ky], $MachinePrecision] / N[(N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision] / th), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[th], $MachinePrecision] * ky), $MachinePrecision] / N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;th \leq 0.05:\\
\;\;\;\;\frac{\sin ky}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right)}{th}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin th \cdot ky}{\mathsf{hypot}\left(\sin kx, \sin ky\right)}\\
\end{array}
\end{array}
if th < 0.050000000000000003Initial program 92.8%
associate-*l/91.2%
associate-/l*92.7%
unpow292.7%
unpow292.7%
hypot-def99.6%
Applied egg-rr99.6%
Taylor expanded in th around 0 60.6%
associate-*l/60.8%
unpow260.8%
unpow260.8%
hypot-def65.0%
*-lft-identity65.0%
hypot-def60.8%
unpow260.8%
unpow260.8%
+-commutative60.8%
unpow260.8%
unpow260.8%
hypot-def65.0%
Simplified65.0%
if 0.050000000000000003 < th Initial program 92.9%
expm1-log1p-u92.6%
expm1-udef65.9%
Applied egg-rr68.7%
expm1-def99.4%
expm1-log1p99.5%
associate-*l/99.5%
Simplified99.5%
Taylor expanded in ky around 0 45.4%
Final simplification59.4%
(FPCore (kx ky th) :precision binary64 (if (<= ky 4.5e-7) (* (sin th) (fabs (/ (sin ky) (sin kx)))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 4.5e-7) {
tmp = sin(th) * fabs((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 (ky <= 4.5d-7) then
tmp = sin(th) * abs((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 (ky <= 4.5e-7) {
tmp = Math.sin(th) * Math.abs((Math.sin(ky) / Math.sin(kx)));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 4.5e-7: tmp = math.sin(th) * math.fabs((math.sin(ky) / math.sin(kx))) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 4.5e-7) tmp = Float64(sin(th) * abs(Float64(sin(ky) / sin(kx)))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 4.5e-7) tmp = sin(th) * abs((sin(ky) / sin(kx))); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 4.5e-7], N[(N[Sin[th], $MachinePrecision] * N[Abs[N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 4.5 \cdot 10^{-7}:\\
\;\;\;\;\sin th \cdot \left|\frac{\sin ky}{\sin kx}\right|\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 4.4999999999999998e-7Initial program 90.4%
Taylor expanded in ky around 0 32.1%
add-sqr-sqrt15.0%
sqrt-unprod29.9%
pow229.9%
Applied egg-rr29.9%
unpow229.9%
rem-sqrt-square35.9%
Simplified35.9%
if 4.4999999999999998e-7 < ky Initial program 99.8%
Taylor expanded in kx around 0 29.0%
Final simplification34.1%
(FPCore (kx ky th) :precision binary64 (if (<= ky 2.5e-6) (* (sin th) (fabs (/ ky (sin kx)))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 2.5e-6) {
tmp = sin(th) * fabs((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 <= 2.5d-6) then
tmp = sin(th) * abs((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 <= 2.5e-6) {
tmp = Math.sin(th) * Math.abs((ky / Math.sin(kx)));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 2.5e-6: tmp = math.sin(th) * math.fabs((ky / math.sin(kx))) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 2.5e-6) tmp = Float64(sin(th) * abs(Float64(ky / sin(kx)))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 2.5e-6) tmp = sin(th) * abs((ky / sin(kx))); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 2.5e-6], N[(N[Sin[th], $MachinePrecision] * N[Abs[N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 2.5 \cdot 10^{-6}:\\
\;\;\;\;\sin th \cdot \left|\frac{ky}{\sin kx}\right|\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 2.5000000000000002e-6Initial program 90.4%
Taylor expanded in ky around 0 28.2%
associate-/l*30.6%
associate-/r/30.6%
Simplified30.6%
add-sqr-sqrt14.1%
sqrt-unprod28.0%
pow228.0%
Applied egg-rr28.0%
unpow228.0%
rem-sqrt-square34.0%
Simplified34.0%
if 2.5000000000000002e-6 < ky Initial program 99.8%
Taylor expanded in kx around 0 29.0%
Final simplification32.7%
(FPCore (kx ky th) :precision binary64 (if (<= ky 4.9e-106) (* (sin th) (/ ky (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 4.9e-106) {
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 <= 4.9d-106) 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 <= 4.9e-106) {
tmp = Math.sin(th) * (ky / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 4.9e-106: 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 <= 4.9e-106) 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 <= 4.9e-106) tmp = sin(th) * (ky / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 4.9e-106], 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 4.9 \cdot 10^{-106}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 4.90000000000000016e-106Initial program 89.3%
Taylor expanded in ky around 0 28.3%
associate-/l*31.0%
associate-/r/31.0%
Simplified31.0%
if 4.90000000000000016e-106 < ky Initial program 99.7%
Taylor expanded in kx around 0 31.5%
Final simplification31.2%
(FPCore (kx ky th) :precision binary64 (if (<= ky 6.6e-107) (* ky (/ (sin th) (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 6.6e-107) {
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 <= 6.6d-107) 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 <= 6.6e-107) {
tmp = ky * (Math.sin(th) / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 6.6e-107: 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 <= 6.6e-107) 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 <= 6.6e-107) tmp = ky * (sin(th) / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 6.6e-107], 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 6.6 \cdot 10^{-107}:\\
\;\;\;\;ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 6.60000000000000007e-107Initial program 89.3%
Taylor expanded in ky around 0 28.3%
associate-/l*31.0%
associate-/r/31.0%
Simplified31.0%
*-commutative31.0%
clear-num31.0%
un-div-inv31.0%
Applied egg-rr31.0%
associate-/r/31.0%
Simplified31.0%
if 6.60000000000000007e-107 < ky Initial program 99.7%
Taylor expanded in kx around 0 31.5%
Final simplification31.2%
(FPCore (kx ky th) :precision binary64 (if (<= ky 6.2e-106) (/ (sin th) (/ (sin kx) ky)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 6.2e-106) {
tmp = sin(th) / (sin(kx) / ky);
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (ky <= 6.2d-106) then
tmp = sin(th) / (sin(kx) / ky)
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= 6.2e-106) {
tmp = Math.sin(th) / (Math.sin(kx) / ky);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 6.2e-106: tmp = math.sin(th) / (math.sin(kx) / ky) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 6.2e-106) tmp = Float64(sin(th) / Float64(sin(kx) / ky)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 6.2e-106) tmp = sin(th) / (sin(kx) / ky); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 6.2e-106], N[(N[Sin[th], $MachinePrecision] / N[(N[Sin[kx], $MachinePrecision] / ky), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 6.2 \cdot 10^{-106}:\\
\;\;\;\;\frac{\sin th}{\frac{\sin kx}{ky}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 6.19999999999999971e-106Initial program 89.3%
*-commutative89.3%
clear-num89.2%
un-div-inv89.3%
unpow289.3%
unpow289.3%
hypot-def99.7%
Applied egg-rr99.7%
Taylor expanded in ky around 0 31.0%
if 6.19999999999999971e-106 < ky Initial program 99.7%
Taylor expanded in kx around 0 31.5%
Final simplification31.2%
(FPCore (kx ky th) :precision binary64 (if (<= ky 1.52e-105) (* ky (/ (sin th) kx)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 1.52e-105) {
tmp = ky * (sin(th) / kx);
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (ky <= 1.52d-105) then
tmp = ky * (sin(th) / kx)
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= 1.52e-105) {
tmp = ky * (Math.sin(th) / kx);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 1.52e-105: tmp = ky * (math.sin(th) / kx) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 1.52e-105) tmp = Float64(ky * Float64(sin(th) / kx)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 1.52e-105) tmp = ky * (sin(th) / kx); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 1.52e-105], N[(ky * N[(N[Sin[th], $MachinePrecision] / kx), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 1.52 \cdot 10^{-105}:\\
\;\;\;\;ky \cdot \frac{\sin th}{kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 1.52e-105Initial program 89.3%
Taylor expanded in ky around 0 28.3%
associate-/l*31.0%
associate-/r/31.0%
Simplified31.0%
Taylor expanded in kx around 0 21.6%
Taylor expanded in ky around 0 18.8%
associate-*r/21.6%
Simplified21.6%
if 1.52e-105 < ky Initial program 99.7%
Taylor expanded in kx around 0 31.5%
Final simplification25.0%
(FPCore (kx ky th) :precision binary64 (if (<= ky 1.2e-105) (/ (sin th) (/ kx ky)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 1.2e-105) {
tmp = sin(th) / (kx / ky);
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (ky <= 1.2d-105) then
tmp = sin(th) / (kx / ky)
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= 1.2e-105) {
tmp = Math.sin(th) / (kx / ky);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 1.2e-105: tmp = math.sin(th) / (kx / ky) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 1.2e-105) tmp = Float64(sin(th) / Float64(kx / ky)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 1.2e-105) tmp = sin(th) / (kx / ky); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 1.2e-105], N[(N[Sin[th], $MachinePrecision] / N[(kx / ky), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 1.2 \cdot 10^{-105}:\\
\;\;\;\;\frac{\sin th}{\frac{kx}{ky}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 1.20000000000000007e-105Initial program 89.3%
Taylor expanded in ky around 0 28.3%
associate-/l*31.0%
associate-/r/31.0%
Simplified31.0%
Taylor expanded in kx around 0 21.6%
*-commutative21.6%
clear-num21.6%
un-div-inv21.6%
Applied egg-rr21.6%
if 1.20000000000000007e-105 < ky Initial program 99.7%
Taylor expanded in kx around 0 31.5%
Final simplification25.0%
(FPCore (kx ky th) :precision binary64 (if (<= ky 3.1e-107) (/ ky (/ kx th)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 3.1e-107) {
tmp = ky / (kx / th);
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (ky <= 3.1d-107) then
tmp = ky / (kx / th)
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= 3.1e-107) {
tmp = ky / (kx / th);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 3.1e-107: tmp = ky / (kx / th) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 3.1e-107) tmp = Float64(ky / Float64(kx / th)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 3.1e-107) tmp = ky / (kx / th); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 3.1e-107], N[(ky / N[(kx / th), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 3.1 \cdot 10^{-107}:\\
\;\;\;\;\frac{ky}{\frac{kx}{th}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 3.10000000000000022e-107Initial program 89.3%
Taylor expanded in ky around 0 28.3%
associate-/l*31.0%
associate-/r/31.0%
Simplified31.0%
Taylor expanded in kx around 0 21.6%
Taylor expanded in th around 0 14.9%
associate-/l*17.7%
Simplified17.7%
if 3.10000000000000022e-107 < ky Initial program 99.7%
Taylor expanded in kx around 0 31.5%
Final simplification22.4%
(FPCore (kx ky th) :precision binary64 (/ ky (/ kx th)))
double code(double kx, double ky, double th) {
return ky / (kx / th);
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = ky / (kx / th)
end function
public static double code(double kx, double ky, double th) {
return ky / (kx / th);
}
def code(kx, ky, th): return ky / (kx / th)
function code(kx, ky, th) return Float64(ky / Float64(kx / th)) end
function tmp = code(kx, ky, th) tmp = ky / (kx / th); end
code[kx_, ky_, th_] := N[(ky / N[(kx / th), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{ky}{\frac{kx}{th}}
\end{array}
Initial program 92.8%
Taylor expanded in ky around 0 21.9%
associate-/l*23.7%
associate-/r/23.7%
Simplified23.7%
Taylor expanded in kx around 0 15.8%
Taylor expanded in th around 0 11.1%
associate-/l*12.9%
Simplified12.9%
Final simplification12.9%
herbie shell --seed 2023337
(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)))