
(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.5%
remove-double-neg93.5%
sin-neg93.5%
neg-mul-193.5%
*-commutative93.5%
associate-*l*93.5%
associate-*l/92.7%
associate-/r/92.7%
associate-*l/93.5%
associate-/r/93.5%
sin-neg93.5%
neg-mul-193.5%
associate-/r*93.5%
associate-/r/93.5%
Simplified99.6%
Final simplification99.6%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -0.02)
(- (sin th))
(if (<= (sin ky) 2e-12)
(/ (sin ky) (/ (hypot (sin kx) ky) (sin th)))
(/
(sin ky)
(*
(hypot (sin kx) (sin ky))
(+ (/ 1.0 th) (* th 0.16666666666666666)))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.02) {
tmp = -sin(th);
} else if (sin(ky) <= 2e-12) {
tmp = sin(ky) / (hypot(sin(kx), ky) / sin(th));
} else {
tmp = sin(ky) / (hypot(sin(kx), sin(ky)) * ((1.0 / th) + (th * 0.16666666666666666)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -0.02) {
tmp = -Math.sin(th);
} else if (Math.sin(ky) <= 2e-12) {
tmp = Math.sin(ky) / (Math.hypot(Math.sin(kx), ky) / Math.sin(th));
} else {
tmp = Math.sin(ky) / (Math.hypot(Math.sin(kx), Math.sin(ky)) * ((1.0 / th) + (th * 0.16666666666666666)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.02: tmp = -math.sin(th) elif math.sin(ky) <= 2e-12: tmp = math.sin(ky) / (math.hypot(math.sin(kx), ky) / math.sin(th)) else: tmp = math.sin(ky) / (math.hypot(math.sin(kx), math.sin(ky)) * ((1.0 / th) + (th * 0.16666666666666666))) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.02) tmp = Float64(-sin(th)); elseif (sin(ky) <= 2e-12) tmp = Float64(sin(ky) / Float64(hypot(sin(kx), ky) / sin(th))); else tmp = Float64(sin(ky) / Float64(hypot(sin(kx), sin(ky)) * Float64(Float64(1.0 / th) + Float64(th * 0.16666666666666666)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.02) tmp = -sin(th); elseif (sin(ky) <= 2e-12) tmp = sin(ky) / (hypot(sin(kx), ky) / sin(th)); else tmp = sin(ky) / (hypot(sin(kx), sin(ky)) * ((1.0 / th) + (th * 0.16666666666666666))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.02], (-N[Sin[th], $MachinePrecision]), If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-12], N[(N[Sin[ky], $MachinePrecision] / N[(N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + ky ^ 2], $MachinePrecision] / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.02:\\
\;\;\;\;-\sin th\\
\mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-12}:\\
\;\;\;\;\frac{\sin ky}{\frac{\mathsf{hypot}\left(\sin kx, ky\right)}{\sin th}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin kx, \sin ky\right) \cdot \left(\frac{1}{th} + th \cdot 0.16666666666666666\right)}\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.0200000000000000004Initial program 99.6%
remove-double-neg99.6%
sin-neg99.6%
neg-mul-199.6%
*-commutative99.6%
associate-*l*99.6%
associate-*l/99.5%
associate-/r/99.5%
associate-*l/99.6%
associate-/r/99.5%
sin-neg99.5%
neg-mul-199.5%
associate-/r*99.5%
associate-/r/99.6%
Simplified99.5%
Taylor expanded in kx around 0 3.0%
add-cbrt-cube3.6%
pow33.6%
Applied egg-rr3.6%
rem-cbrt-cube3.0%
add-sqr-sqrt2.0%
sqrt-unprod22.7%
sqr-neg22.7%
sqrt-unprod25.2%
add-sqr-sqrt58.9%
neg-sub058.9%
Applied egg-rr58.9%
neg-sub058.9%
Simplified58.9%
if -0.0200000000000000004 < (sin.f64 ky) < 1.99999999999999996e-12Initial program 86.4%
remove-double-neg86.4%
sin-neg86.4%
neg-mul-186.4%
*-commutative86.4%
associate-*l*86.4%
associate-*l/84.7%
associate-/r/84.7%
associate-*l/86.4%
associate-/r/86.4%
sin-neg86.4%
neg-mul-186.4%
associate-/r*86.4%
associate-/r/86.4%
Simplified99.6%
associate-*l/93.9%
associate-/l*99.7%
hypot-udef86.4%
unpow286.4%
unpow286.4%
+-commutative86.4%
unpow286.4%
unpow286.4%
hypot-def99.7%
Applied egg-rr99.7%
Taylor expanded in ky around 0 98.9%
if 1.99999999999999996e-12 < (sin.f64 ky) Initial program 99.6%
remove-double-neg99.6%
sin-neg99.6%
neg-mul-199.6%
*-commutative99.6%
associate-*l*99.6%
associate-*l/99.5%
associate-/r/99.5%
associate-*l/99.6%
associate-/r/99.5%
sin-neg99.5%
neg-mul-199.5%
associate-/r*99.5%
associate-/r/99.6%
Simplified99.6%
associate-*l/99.4%
associate-/l*99.4%
hypot-udef99.5%
unpow299.5%
unpow299.5%
+-commutative99.5%
unpow299.5%
unpow299.5%
hypot-def99.4%
Applied egg-rr99.4%
Taylor expanded in th around 0 62.4%
+-commutative62.4%
*-commutative62.4%
+-commutative62.4%
unpow262.4%
unpow262.4%
hypot-def62.4%
*-commutative62.4%
associate-*r*62.4%
+-commutative62.4%
unpow262.4%
unpow262.4%
Simplified62.4%
Final simplification78.1%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -0.02)
(- (sin th))
(if (<= (sin ky) 2e-12)
(* (sin th) (/ (sin ky) (hypot ky (sin kx))))
(* (sin ky) (/ th (hypot (sin kx) (sin ky)))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.02) {
tmp = -sin(th);
} else if (sin(ky) <= 2e-12) {
tmp = sin(th) * (sin(ky) / hypot(ky, sin(kx)));
} else {
tmp = sin(ky) * (th / hypot(sin(kx), sin(ky)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -0.02) {
tmp = -Math.sin(th);
} else if (Math.sin(ky) <= 2e-12) {
tmp = Math.sin(th) * (Math.sin(ky) / Math.hypot(ky, Math.sin(kx)));
} else {
tmp = Math.sin(ky) * (th / Math.hypot(Math.sin(kx), Math.sin(ky)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.02: tmp = -math.sin(th) elif math.sin(ky) <= 2e-12: tmp = math.sin(th) * (math.sin(ky) / math.hypot(ky, math.sin(kx))) else: tmp = math.sin(ky) * (th / math.hypot(math.sin(kx), math.sin(ky))) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.02) tmp = Float64(-sin(th)); elseif (sin(ky) <= 2e-12) tmp = Float64(sin(th) * Float64(sin(ky) / hypot(ky, sin(kx)))); else tmp = Float64(sin(ky) * Float64(th / hypot(sin(kx), sin(ky)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.02) tmp = -sin(th); elseif (sin(ky) <= 2e-12) tmp = sin(th) * (sin(ky) / hypot(ky, sin(kx))); else tmp = sin(ky) * (th / hypot(sin(kx), sin(ky))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.02], (-N[Sin[th], $MachinePrecision]), If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-12], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[ky ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[ky], $MachinePrecision] * N[(th / N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.02:\\
\;\;\;\;-\sin th\\
\mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-12}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(ky, \sin kx\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin ky \cdot \frac{th}{\mathsf{hypot}\left(\sin kx, \sin ky\right)}\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.0200000000000000004Initial program 99.6%
remove-double-neg99.6%
sin-neg99.6%
neg-mul-199.6%
*-commutative99.6%
associate-*l*99.6%
associate-*l/99.5%
associate-/r/99.5%
associate-*l/99.6%
associate-/r/99.5%
sin-neg99.5%
neg-mul-199.5%
associate-/r*99.5%
associate-/r/99.6%
Simplified99.5%
Taylor expanded in kx around 0 3.0%
add-cbrt-cube3.6%
pow33.6%
Applied egg-rr3.6%
rem-cbrt-cube3.0%
add-sqr-sqrt2.0%
sqrt-unprod22.7%
sqr-neg22.7%
sqrt-unprod25.2%
add-sqr-sqrt58.9%
neg-sub058.9%
Applied egg-rr58.9%
neg-sub058.9%
Simplified58.9%
if -0.0200000000000000004 < (sin.f64 ky) < 1.99999999999999996e-12Initial program 86.4%
remove-double-neg86.4%
sin-neg86.4%
neg-mul-186.4%
*-commutative86.4%
associate-*l*86.4%
associate-*l/84.7%
associate-/r/84.7%
associate-*l/86.4%
associate-/r/86.4%
sin-neg86.4%
neg-mul-186.4%
associate-/r*86.4%
associate-/r/86.4%
Simplified99.6%
Taylor expanded in ky around 0 98.8%
if 1.99999999999999996e-12 < (sin.f64 ky) Initial program 99.6%
remove-double-neg99.6%
sin-neg99.6%
neg-mul-199.6%
*-commutative99.6%
associate-*l*99.6%
associate-*l/99.5%
associate-/r/99.5%
associate-*l/99.6%
associate-/r/99.5%
sin-neg99.5%
neg-mul-199.5%
associate-/r*99.5%
associate-/r/99.6%
Simplified99.6%
*-commutative99.6%
clear-num99.6%
un-div-inv99.6%
hypot-udef99.6%
unpow299.6%
unpow299.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.6%
Applied egg-rr99.6%
associate-/r/99.5%
Applied egg-rr99.5%
Taylor expanded in th around 0 62.0%
Final simplification78.0%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -0.02)
(- (sin th))
(if (<= (sin ky) 2e-12)
(* (sin th) (/ (sin ky) (hypot ky (sin kx))))
(/ th (/ (hypot (sin kx) (sin ky)) (sin ky))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.02) {
tmp = -sin(th);
} else if (sin(ky) <= 2e-12) {
tmp = sin(th) * (sin(ky) / hypot(ky, sin(kx)));
} else {
tmp = th / (hypot(sin(kx), sin(ky)) / sin(ky));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -0.02) {
tmp = -Math.sin(th);
} else if (Math.sin(ky) <= 2e-12) {
tmp = Math.sin(th) * (Math.sin(ky) / Math.hypot(ky, Math.sin(kx)));
} else {
tmp = th / (Math.hypot(Math.sin(kx), Math.sin(ky)) / Math.sin(ky));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.02: tmp = -math.sin(th) elif math.sin(ky) <= 2e-12: tmp = math.sin(th) * (math.sin(ky) / math.hypot(ky, math.sin(kx))) else: tmp = th / (math.hypot(math.sin(kx), math.sin(ky)) / math.sin(ky)) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.02) tmp = Float64(-sin(th)); elseif (sin(ky) <= 2e-12) tmp = Float64(sin(th) * Float64(sin(ky) / hypot(ky, sin(kx)))); else tmp = Float64(th / Float64(hypot(sin(kx), sin(ky)) / sin(ky))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.02) tmp = -sin(th); elseif (sin(ky) <= 2e-12) tmp = sin(th) * (sin(ky) / hypot(ky, sin(kx))); else tmp = th / (hypot(sin(kx), sin(ky)) / sin(ky)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.02], (-N[Sin[th], $MachinePrecision]), If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-12], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[ky ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(th / N[(N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.02:\\
\;\;\;\;-\sin th\\
\mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-12}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(ky, \sin kx\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{th}{\frac{\mathsf{hypot}\left(\sin kx, \sin ky\right)}{\sin ky}}\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.0200000000000000004Initial program 99.6%
remove-double-neg99.6%
sin-neg99.6%
neg-mul-199.6%
*-commutative99.6%
associate-*l*99.6%
associate-*l/99.5%
associate-/r/99.5%
associate-*l/99.6%
associate-/r/99.5%
sin-neg99.5%
neg-mul-199.5%
associate-/r*99.5%
associate-/r/99.6%
Simplified99.5%
Taylor expanded in kx around 0 3.0%
add-cbrt-cube3.6%
pow33.6%
Applied egg-rr3.6%
rem-cbrt-cube3.0%
add-sqr-sqrt2.0%
sqrt-unprod22.7%
sqr-neg22.7%
sqrt-unprod25.2%
add-sqr-sqrt58.9%
neg-sub058.9%
Applied egg-rr58.9%
neg-sub058.9%
Simplified58.9%
if -0.0200000000000000004 < (sin.f64 ky) < 1.99999999999999996e-12Initial program 86.4%
remove-double-neg86.4%
sin-neg86.4%
neg-mul-186.4%
*-commutative86.4%
associate-*l*86.4%
associate-*l/84.7%
associate-/r/84.7%
associate-*l/86.4%
associate-/r/86.4%
sin-neg86.4%
neg-mul-186.4%
associate-/r*86.4%
associate-/r/86.4%
Simplified99.6%
Taylor expanded in ky around 0 98.8%
if 1.99999999999999996e-12 < (sin.f64 ky) Initial program 99.6%
remove-double-neg99.6%
sin-neg99.6%
neg-mul-199.6%
*-commutative99.6%
associate-*l*99.6%
associate-*l/99.5%
associate-/r/99.5%
associate-*l/99.6%
associate-/r/99.5%
sin-neg99.5%
neg-mul-199.5%
associate-/r*99.5%
associate-/r/99.6%
Simplified99.6%
*-commutative99.6%
clear-num99.6%
un-div-inv99.6%
hypot-udef99.6%
unpow299.6%
unpow299.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.6%
Applied egg-rr99.6%
Taylor expanded in th around 0 62.1%
Final simplification78.0%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -0.02)
(- (sin th))
(if (<= (sin ky) 2e-12)
(/ (sin ky) (/ (hypot (sin kx) ky) (sin th)))
(/ th (/ (hypot (sin kx) (sin ky)) (sin ky))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.02) {
tmp = -sin(th);
} else if (sin(ky) <= 2e-12) {
tmp = sin(ky) / (hypot(sin(kx), ky) / sin(th));
} else {
tmp = th / (hypot(sin(kx), sin(ky)) / sin(ky));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -0.02) {
tmp = -Math.sin(th);
} else if (Math.sin(ky) <= 2e-12) {
tmp = Math.sin(ky) / (Math.hypot(Math.sin(kx), ky) / Math.sin(th));
} else {
tmp = th / (Math.hypot(Math.sin(kx), Math.sin(ky)) / Math.sin(ky));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.02: tmp = -math.sin(th) elif math.sin(ky) <= 2e-12: tmp = math.sin(ky) / (math.hypot(math.sin(kx), ky) / math.sin(th)) else: tmp = th / (math.hypot(math.sin(kx), math.sin(ky)) / math.sin(ky)) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.02) tmp = Float64(-sin(th)); elseif (sin(ky) <= 2e-12) tmp = Float64(sin(ky) / Float64(hypot(sin(kx), ky) / sin(th))); else tmp = Float64(th / Float64(hypot(sin(kx), sin(ky)) / sin(ky))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.02) tmp = -sin(th); elseif (sin(ky) <= 2e-12) tmp = sin(ky) / (hypot(sin(kx), ky) / sin(th)); else tmp = th / (hypot(sin(kx), sin(ky)) / sin(ky)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.02], (-N[Sin[th], $MachinePrecision]), If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-12], N[(N[Sin[ky], $MachinePrecision] / N[(N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + ky ^ 2], $MachinePrecision] / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(th / N[(N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.02:\\
\;\;\;\;-\sin th\\
\mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-12}:\\
\;\;\;\;\frac{\sin ky}{\frac{\mathsf{hypot}\left(\sin kx, ky\right)}{\sin th}}\\
\mathbf{else}:\\
\;\;\;\;\frac{th}{\frac{\mathsf{hypot}\left(\sin kx, \sin ky\right)}{\sin ky}}\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.0200000000000000004Initial program 99.6%
remove-double-neg99.6%
sin-neg99.6%
neg-mul-199.6%
*-commutative99.6%
associate-*l*99.6%
associate-*l/99.5%
associate-/r/99.5%
associate-*l/99.6%
associate-/r/99.5%
sin-neg99.5%
neg-mul-199.5%
associate-/r*99.5%
associate-/r/99.6%
Simplified99.5%
Taylor expanded in kx around 0 3.0%
add-cbrt-cube3.6%
pow33.6%
Applied egg-rr3.6%
rem-cbrt-cube3.0%
add-sqr-sqrt2.0%
sqrt-unprod22.7%
sqr-neg22.7%
sqrt-unprod25.2%
add-sqr-sqrt58.9%
neg-sub058.9%
Applied egg-rr58.9%
neg-sub058.9%
Simplified58.9%
if -0.0200000000000000004 < (sin.f64 ky) < 1.99999999999999996e-12Initial program 86.4%
remove-double-neg86.4%
sin-neg86.4%
neg-mul-186.4%
*-commutative86.4%
associate-*l*86.4%
associate-*l/84.7%
associate-/r/84.7%
associate-*l/86.4%
associate-/r/86.4%
sin-neg86.4%
neg-mul-186.4%
associate-/r*86.4%
associate-/r/86.4%
Simplified99.6%
associate-*l/93.9%
associate-/l*99.7%
hypot-udef86.4%
unpow286.4%
unpow286.4%
+-commutative86.4%
unpow286.4%
unpow286.4%
hypot-def99.7%
Applied egg-rr99.7%
Taylor expanded in ky around 0 98.9%
if 1.99999999999999996e-12 < (sin.f64 ky) Initial program 99.6%
remove-double-neg99.6%
sin-neg99.6%
neg-mul-199.6%
*-commutative99.6%
associate-*l*99.6%
associate-*l/99.5%
associate-/r/99.5%
associate-*l/99.6%
associate-/r/99.5%
sin-neg99.5%
neg-mul-199.5%
associate-/r*99.5%
associate-/r/99.6%
Simplified99.6%
*-commutative99.6%
clear-num99.6%
un-div-inv99.6%
hypot-udef99.6%
unpow299.6%
unpow299.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.6%
Applied egg-rr99.6%
Taylor expanded in th around 0 62.1%
Final simplification78.0%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -0.02)
(- (sin th))
(if (<= (sin ky) 1e-15)
(* (sin th) (fabs (/ (sin ky) (sin kx))))
(sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.02) {
tmp = -sin(th);
} else if (sin(ky) <= 1e-15) {
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.02d0)) then
tmp = -sin(th)
else if (sin(ky) <= 1d-15) 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.02) {
tmp = -Math.sin(th);
} else if (Math.sin(ky) <= 1e-15) {
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.02: tmp = -math.sin(th) elif math.sin(ky) <= 1e-15: 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.02) tmp = Float64(-sin(th)); elseif (sin(ky) <= 1e-15) 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.02) tmp = -sin(th); elseif (sin(ky) <= 1e-15) 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.02], (-N[Sin[th], $MachinePrecision]), If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-15], 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.02:\\
\;\;\;\;-\sin th\\
\mathbf{elif}\;\sin ky \leq 10^{-15}:\\
\;\;\;\;\sin th \cdot \left|\frac{\sin ky}{\sin kx}\right|\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.0200000000000000004Initial program 99.6%
remove-double-neg99.6%
sin-neg99.6%
neg-mul-199.6%
*-commutative99.6%
associate-*l*99.6%
associate-*l/99.5%
associate-/r/99.5%
associate-*l/99.6%
associate-/r/99.5%
sin-neg99.5%
neg-mul-199.5%
associate-/r*99.5%
associate-/r/99.6%
Simplified99.5%
Taylor expanded in kx around 0 3.0%
add-cbrt-cube3.6%
pow33.6%
Applied egg-rr3.6%
rem-cbrt-cube3.0%
add-sqr-sqrt2.0%
sqrt-unprod22.7%
sqr-neg22.7%
sqrt-unprod25.2%
add-sqr-sqrt58.9%
neg-sub058.9%
Applied egg-rr58.9%
neg-sub058.9%
Simplified58.9%
if -0.0200000000000000004 < (sin.f64 ky) < 1.0000000000000001e-15Initial program 86.2%
Taylor expanded in ky around 0 48.0%
add-sqr-sqrt19.2%
sqrt-unprod31.4%
pow231.4%
Applied egg-rr31.4%
unpow231.4%
rem-sqrt-square41.7%
Simplified41.7%
if 1.0000000000000001e-15 < (sin.f64 ky) Initial program 99.6%
remove-double-neg99.6%
sin-neg99.6%
neg-mul-199.6%
*-commutative99.6%
associate-*l*99.6%
associate-*l/99.5%
associate-/r/99.5%
associate-*l/99.6%
associate-/r/99.5%
sin-neg99.5%
neg-mul-199.5%
associate-/r*99.5%
associate-/r/99.6%
Simplified99.6%
Taylor expanded in kx around 0 54.6%
Final simplification49.9%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.025) (- (sin th)) (if (<= (sin ky) 5e-119) (* (sin th) (/ (sin ky) (sin kx))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.025) {
tmp = -sin(th);
} else if (sin(ky) <= 5e-119) {
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.025d0)) then
tmp = -sin(th)
else if (sin(ky) <= 5d-119) 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.025) {
tmp = -Math.sin(th);
} else if (Math.sin(ky) <= 5e-119) {
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.025: tmp = -math.sin(th) elif math.sin(ky) <= 5e-119: 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.025) tmp = Float64(-sin(th)); elseif (sin(ky) <= 5e-119) 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.025) tmp = -sin(th); elseif (sin(ky) <= 5e-119) 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.025], (-N[Sin[th], $MachinePrecision]), If[LessEqual[N[Sin[ky], $MachinePrecision], 5e-119], 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.025:\\
\;\;\;\;-\sin th\\
\mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-119}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.025000000000000001Initial program 99.6%
remove-double-neg99.6%
sin-neg99.6%
neg-mul-199.6%
*-commutative99.6%
associate-*l*99.6%
associate-*l/99.5%
associate-/r/99.5%
associate-*l/99.6%
associate-/r/99.5%
sin-neg99.5%
neg-mul-199.5%
associate-/r*99.5%
associate-/r/99.6%
Simplified99.6%
Taylor expanded in kx around 0 3.0%
add-cbrt-cube3.6%
pow33.6%
Applied egg-rr3.6%
rem-cbrt-cube3.0%
add-sqr-sqrt2.1%
sqrt-unprod23.0%
sqr-neg23.0%
sqrt-unprod25.5%
add-sqr-sqrt60.2%
neg-sub060.2%
Applied egg-rr60.2%
neg-sub060.2%
Simplified60.2%
if -0.025000000000000001 < (sin.f64 ky) < 4.99999999999999993e-119Initial program 83.9%
Taylor expanded in ky around 0 49.1%
if 4.99999999999999993e-119 < (sin.f64 ky) Initial program 99.6%
remove-double-neg99.6%
sin-neg99.6%
neg-mul-199.6%
*-commutative99.6%
associate-*l*99.6%
associate-*l/99.5%
associate-/r/99.5%
associate-*l/99.6%
associate-/r/99.5%
sin-neg99.5%
neg-mul-199.5%
associate-/r*99.5%
associate-/r/99.6%
Simplified99.6%
Taylor expanded in kx around 0 51.8%
Final simplification52.9%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -0.025)
(- (sin th))
(if (<= (sin ky) 5e-173)
(* (sin th) (/ (sin ky) (sin kx)))
(/ (* (sin ky) (sin th)) (sin ky)))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.025) {
tmp = -sin(th);
} else if (sin(ky) <= 5e-173) {
tmp = sin(th) * (sin(ky) / sin(kx));
} else {
tmp = (sin(ky) * sin(th)) / sin(ky);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(ky) <= (-0.025d0)) then
tmp = -sin(th)
else if (sin(ky) <= 5d-173) then
tmp = sin(th) * (sin(ky) / sin(kx))
else
tmp = (sin(ky) * sin(th)) / sin(ky)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -0.025) {
tmp = -Math.sin(th);
} else if (Math.sin(ky) <= 5e-173) {
tmp = Math.sin(th) * (Math.sin(ky) / Math.sin(kx));
} else {
tmp = (Math.sin(ky) * Math.sin(th)) / Math.sin(ky);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.025: tmp = -math.sin(th) elif math.sin(ky) <= 5e-173: tmp = math.sin(th) * (math.sin(ky) / math.sin(kx)) else: tmp = (math.sin(ky) * math.sin(th)) / math.sin(ky) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.025) tmp = Float64(-sin(th)); elseif (sin(ky) <= 5e-173) tmp = Float64(sin(th) * Float64(sin(ky) / sin(kx))); else tmp = Float64(Float64(sin(ky) * sin(th)) / sin(ky)); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.025) tmp = -sin(th); elseif (sin(ky) <= 5e-173) tmp = sin(th) * (sin(ky) / sin(kx)); else tmp = (sin(ky) * sin(th)) / sin(ky); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.025], (-N[Sin[th], $MachinePrecision]), If[LessEqual[N[Sin[ky], $MachinePrecision], 5e-173], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[ky], $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.025:\\
\;\;\;\;-\sin th\\
\mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-173}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky \cdot \sin th}{\sin ky}\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.025000000000000001Initial program 99.6%
remove-double-neg99.6%
sin-neg99.6%
neg-mul-199.6%
*-commutative99.6%
associate-*l*99.6%
associate-*l/99.5%
associate-/r/99.5%
associate-*l/99.6%
associate-/r/99.5%
sin-neg99.5%
neg-mul-199.5%
associate-/r*99.5%
associate-/r/99.6%
Simplified99.6%
Taylor expanded in kx around 0 3.0%
add-cbrt-cube3.6%
pow33.6%
Applied egg-rr3.6%
rem-cbrt-cube3.0%
add-sqr-sqrt2.1%
sqrt-unprod23.0%
sqr-neg23.0%
sqrt-unprod25.5%
add-sqr-sqrt60.2%
neg-sub060.2%
Applied egg-rr60.2%
neg-sub060.2%
Simplified60.2%
if -0.025000000000000001 < (sin.f64 ky) < 5.0000000000000002e-173Initial program 83.7%
Taylor expanded in ky around 0 49.8%
if 5.0000000000000002e-173 < (sin.f64 ky) Initial program 98.8%
remove-double-neg98.8%
sin-neg98.8%
neg-mul-198.8%
*-commutative98.8%
associate-*l*98.8%
associate-*l/98.8%
associate-/r/98.8%
associate-*l/98.8%
associate-/r/98.8%
sin-neg98.8%
neg-mul-198.8%
associate-/r*98.8%
associate-/r/98.8%
Simplified99.6%
associate-*l/99.5%
hypot-udef98.8%
unpow298.8%
unpow298.8%
+-commutative98.8%
unpow298.8%
unpow298.8%
hypot-def99.5%
Applied egg-rr99.5%
Taylor expanded in kx around 0 50.8%
Final simplification52.9%
(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.5%
remove-double-neg93.5%
sin-neg93.5%
neg-mul-193.5%
*-commutative93.5%
associate-*l*93.5%
associate-*l/92.7%
associate-/r/92.7%
associate-*l/93.5%
associate-/r/93.5%
sin-neg93.5%
neg-mul-193.5%
associate-/r*93.5%
associate-/r/93.5%
Simplified99.6%
expm1-log1p-u99.5%
expm1-udef39.6%
hypot-udef37.5%
unpow237.5%
unpow237.5%
+-commutative37.5%
unpow237.5%
unpow237.5%
hypot-def39.6%
Applied egg-rr39.6%
expm1-def99.5%
expm1-log1p99.6%
associate-*l/96.9%
*-lft-identity96.9%
times-frac99.5%
rem-square-sqrt47.3%
associate-*r/47.3%
/-rgt-identity47.3%
rem-square-sqrt99.5%
hypot-def93.5%
unpow293.5%
unpow293.5%
+-commutative93.5%
unpow293.5%
unpow293.5%
hypot-def99.5%
Simplified99.5%
Final simplification99.5%
(FPCore (kx ky th)
:precision binary64
(if (<= th 0.005)
(* (sin ky) (/ th (hypot (sin kx) (sin ky))))
(if (or (<= th 7.2e+120) (not (<= th 7.2e+177)))
(* (sin th) (fabs (/ (sin ky) (sin kx))))
(fabs (sin th)))))
double code(double kx, double ky, double th) {
double tmp;
if (th <= 0.005) {
tmp = sin(ky) * (th / hypot(sin(kx), sin(ky)));
} else if ((th <= 7.2e+120) || !(th <= 7.2e+177)) {
tmp = sin(th) * fabs((sin(ky) / sin(kx)));
} else {
tmp = fabs(sin(th));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (th <= 0.005) {
tmp = Math.sin(ky) * (th / Math.hypot(Math.sin(kx), Math.sin(ky)));
} else if ((th <= 7.2e+120) || !(th <= 7.2e+177)) {
tmp = Math.sin(th) * Math.abs((Math.sin(ky) / Math.sin(kx)));
} else {
tmp = Math.abs(Math.sin(th));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if th <= 0.005: tmp = math.sin(ky) * (th / math.hypot(math.sin(kx), math.sin(ky))) elif (th <= 7.2e+120) or not (th <= 7.2e+177): tmp = math.sin(th) * math.fabs((math.sin(ky) / math.sin(kx))) else: tmp = math.fabs(math.sin(th)) return tmp
function code(kx, ky, th) tmp = 0.0 if (th <= 0.005) tmp = Float64(sin(ky) * Float64(th / hypot(sin(kx), sin(ky)))); elseif ((th <= 7.2e+120) || !(th <= 7.2e+177)) tmp = Float64(sin(th) * abs(Float64(sin(ky) / sin(kx)))); else tmp = abs(sin(th)); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (th <= 0.005) tmp = sin(ky) * (th / hypot(sin(kx), sin(ky))); elseif ((th <= 7.2e+120) || ~((th <= 7.2e+177))) tmp = sin(th) * abs((sin(ky) / sin(kx))); else tmp = abs(sin(th)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[th, 0.005], N[(N[Sin[ky], $MachinePrecision] * N[(th / N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[th, 7.2e+120], N[Not[LessEqual[th, 7.2e+177]], $MachinePrecision]], N[(N[Sin[th], $MachinePrecision] * N[Abs[N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;th \leq 0.005:\\
\;\;\;\;\sin ky \cdot \frac{th}{\mathsf{hypot}\left(\sin kx, \sin ky\right)}\\
\mathbf{elif}\;th \leq 7.2 \cdot 10^{+120} \lor \neg \left(th \leq 7.2 \cdot 10^{+177}\right):\\
\;\;\;\;\sin th \cdot \left|\frac{\sin ky}{\sin kx}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\sin th\right|\\
\end{array}
\end{array}
if th < 0.0050000000000000001Initial program 93.7%
remove-double-neg93.7%
sin-neg93.7%
neg-mul-193.7%
*-commutative93.7%
associate-*l*93.7%
associate-*l/92.7%
associate-/r/92.7%
associate-*l/93.7%
associate-/r/93.7%
sin-neg93.7%
neg-mul-193.7%
associate-/r*93.7%
associate-/r/93.7%
Simplified99.6%
*-commutative99.6%
clear-num99.6%
un-div-inv99.6%
hypot-udef93.7%
unpow293.7%
unpow293.7%
+-commutative93.7%
unpow293.7%
unpow293.7%
hypot-def99.6%
Applied egg-rr99.6%
associate-/r/99.5%
Applied egg-rr99.5%
Taylor expanded in th around 0 66.6%
if 0.0050000000000000001 < th < 7.20000000000000031e120 or 7.20000000000000005e177 < th Initial program 91.3%
Taylor expanded in ky around 0 34.1%
add-sqr-sqrt12.7%
sqrt-unprod11.7%
pow211.7%
Applied egg-rr11.7%
unpow211.7%
rem-sqrt-square21.0%
Simplified21.0%
if 7.20000000000000031e120 < th < 7.20000000000000005e177Initial program 99.9%
remove-double-neg99.9%
sin-neg99.9%
neg-mul-199.9%
*-commutative99.9%
associate-*l*99.9%
associate-*l/99.9%
associate-/r/99.9%
associate-*l/99.9%
associate-/r/99.7%
sin-neg99.7%
neg-mul-199.7%
associate-/r*99.7%
associate-/r/99.9%
Simplified99.9%
Taylor expanded in kx around 0 22.6%
add-sqr-sqrt2.2%
sqrt-unprod11.4%
pow211.4%
Applied egg-rr11.4%
unpow211.4%
rem-sqrt-square11.4%
Simplified11.4%
Final simplification55.6%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.02) (- (sin th)) (if (<= (sin ky) 5e-119) (* (sin th) (/ ky (sin kx))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.02) {
tmp = -sin(th);
} else if (sin(ky) <= 5e-119) {
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 (sin(ky) <= (-0.02d0)) then
tmp = -sin(th)
else if (sin(ky) <= 5d-119) 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 (Math.sin(ky) <= -0.02) {
tmp = -Math.sin(th);
} else if (Math.sin(ky) <= 5e-119) {
tmp = Math.sin(th) * (ky / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.02: tmp = -math.sin(th) elif math.sin(ky) <= 5e-119: tmp = math.sin(th) * (ky / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.02) tmp = Float64(-sin(th)); elseif (sin(ky) <= 5e-119) 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 (sin(ky) <= -0.02) tmp = -sin(th); elseif (sin(ky) <= 5e-119) tmp = sin(th) * (ky / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.02], (-N[Sin[th], $MachinePrecision]), If[LessEqual[N[Sin[ky], $MachinePrecision], 5e-119], 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}\;\sin ky \leq -0.02:\\
\;\;\;\;-\sin th\\
\mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-119}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.0200000000000000004Initial program 99.6%
remove-double-neg99.6%
sin-neg99.6%
neg-mul-199.6%
*-commutative99.6%
associate-*l*99.6%
associate-*l/99.5%
associate-/r/99.5%
associate-*l/99.6%
associate-/r/99.5%
sin-neg99.5%
neg-mul-199.5%
associate-/r*99.5%
associate-/r/99.6%
Simplified99.5%
Taylor expanded in kx around 0 3.0%
add-cbrt-cube3.6%
pow33.6%
Applied egg-rr3.6%
rem-cbrt-cube3.0%
add-sqr-sqrt2.0%
sqrt-unprod22.7%
sqr-neg22.7%
sqrt-unprod25.2%
add-sqr-sqrt58.9%
neg-sub058.9%
Applied egg-rr58.9%
neg-sub058.9%
Simplified58.9%
if -0.0200000000000000004 < (sin.f64 ky) < 4.99999999999999993e-119Initial program 83.6%
Taylor expanded in ky around 0 49.8%
if 4.99999999999999993e-119 < (sin.f64 ky) Initial program 99.6%
remove-double-neg99.6%
sin-neg99.6%
neg-mul-199.6%
*-commutative99.6%
associate-*l*99.6%
associate-*l/99.5%
associate-/r/99.5%
associate-*l/99.6%
associate-/r/99.5%
sin-neg99.5%
neg-mul-199.5%
associate-/r*99.5%
associate-/r/99.6%
Simplified99.6%
Taylor expanded in kx around 0 51.8%
Final simplification52.9%
(FPCore (kx ky th) :precision binary64 (if (<= ky 4.9e-192) (* ky (* (sin th) (+ (* kx 0.16666666666666666) (/ 1.0 kx)))) (if (<= ky 5.5e+15) (sin th) (- (sin th)))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 4.9e-192) {
tmp = ky * (sin(th) * ((kx * 0.16666666666666666) + (1.0 / kx)));
} else if (ky <= 5.5e+15) {
tmp = sin(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 <= 4.9d-192) then
tmp = ky * (sin(th) * ((kx * 0.16666666666666666d0) + (1.0d0 / kx)))
else if (ky <= 5.5d+15) then
tmp = sin(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 <= 4.9e-192) {
tmp = ky * (Math.sin(th) * ((kx * 0.16666666666666666) + (1.0 / kx)));
} else if (ky <= 5.5e+15) {
tmp = Math.sin(th);
} else {
tmp = -Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 4.9e-192: tmp = ky * (math.sin(th) * ((kx * 0.16666666666666666) + (1.0 / kx))) elif ky <= 5.5e+15: tmp = math.sin(th) else: tmp = -math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 4.9e-192) tmp = Float64(ky * Float64(sin(th) * Float64(Float64(kx * 0.16666666666666666) + Float64(1.0 / kx)))); elseif (ky <= 5.5e+15) tmp = sin(th); else tmp = Float64(-sin(th)); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 4.9e-192) tmp = ky * (sin(th) * ((kx * 0.16666666666666666) + (1.0 / kx))); elseif (ky <= 5.5e+15) tmp = sin(th); else tmp = -sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 4.9e-192], N[(ky * N[(N[Sin[th], $MachinePrecision] * N[(N[(kx * 0.16666666666666666), $MachinePrecision] + N[(1.0 / kx), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[ky, 5.5e+15], N[Sin[th], $MachinePrecision], (-N[Sin[th], $MachinePrecision])]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 4.9 \cdot 10^{-192}:\\
\;\;\;\;ky \cdot \left(\sin th \cdot \left(kx \cdot 0.16666666666666666 + \frac{1}{kx}\right)\right)\\
\mathbf{elif}\;ky \leq 5.5 \cdot 10^{+15}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;-\sin th\\
\end{array}
\end{array}
if ky < 4.9e-192Initial program 91.0%
Taylor expanded in ky around 0 34.1%
Taylor expanded in kx around 0 12.2%
Taylor expanded in ky around 0 11.8%
if 4.9e-192 < ky < 5.5e15Initial program 92.0%
remove-double-neg92.0%
sin-neg92.0%
neg-mul-192.0%
*-commutative92.0%
associate-*l*92.0%
associate-*l/91.9%
associate-/r/91.9%
associate-*l/92.0%
associate-/r/92.1%
sin-neg92.1%
neg-mul-192.1%
associate-/r*92.1%
associate-/r/92.0%
Simplified99.6%
Taylor expanded in kx around 0 46.8%
if 5.5e15 < ky Initial program 99.6%
remove-double-neg99.6%
sin-neg99.6%
neg-mul-199.6%
*-commutative99.6%
associate-*l*99.6%
associate-*l/99.4%
associate-/r/99.4%
associate-*l/99.6%
associate-/r/99.5%
sin-neg99.5%
neg-mul-199.5%
associate-/r*99.5%
associate-/r/99.6%
Simplified99.6%
Taylor expanded in kx around 0 22.2%
add-cbrt-cube17.7%
pow317.7%
Applied egg-rr17.7%
rem-cbrt-cube22.2%
add-sqr-sqrt13.7%
sqrt-unprod25.9%
sqr-neg25.9%
sqrt-unprod16.8%
add-sqr-sqrt35.5%
neg-sub035.5%
Applied egg-rr35.5%
neg-sub035.5%
Simplified35.5%
Final simplification23.4%
(FPCore (kx ky th) :precision binary64 (if (<= ky 5.5e+15) (sin th) (- (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 5.5e+15) {
tmp = sin(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 <= 5.5d+15) then
tmp = sin(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 <= 5.5e+15) {
tmp = Math.sin(th);
} else {
tmp = -Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 5.5e+15: tmp = math.sin(th) else: tmp = -math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 5.5e+15) tmp = sin(th); else tmp = Float64(-sin(th)); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 5.5e+15) tmp = sin(th); else tmp = -sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 5.5e+15], N[Sin[th], $MachinePrecision], (-N[Sin[th], $MachinePrecision])]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 5.5 \cdot 10^{+15}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;-\sin th\\
\end{array}
\end{array}
if ky < 5.5e15Initial program 91.2%
remove-double-neg91.2%
sin-neg91.2%
neg-mul-191.2%
*-commutative91.2%
associate-*l*91.2%
associate-*l/90.1%
associate-/r/90.1%
associate-*l/91.2%
associate-/r/91.1%
sin-neg91.1%
neg-mul-191.1%
associate-/r*91.1%
associate-/r/91.2%
Simplified99.6%
Taylor expanded in kx around 0 22.3%
if 5.5e15 < ky Initial program 99.6%
remove-double-neg99.6%
sin-neg99.6%
neg-mul-199.6%
*-commutative99.6%
associate-*l*99.6%
associate-*l/99.4%
associate-/r/99.4%
associate-*l/99.6%
associate-/r/99.5%
sin-neg99.5%
neg-mul-199.5%
associate-/r*99.5%
associate-/r/99.6%
Simplified99.6%
Taylor expanded in kx around 0 22.2%
add-cbrt-cube17.7%
pow317.7%
Applied egg-rr17.7%
rem-cbrt-cube22.2%
add-sqr-sqrt13.7%
sqrt-unprod25.9%
sqr-neg25.9%
sqrt-unprod16.8%
add-sqr-sqrt35.5%
neg-sub035.5%
Applied egg-rr35.5%
neg-sub035.5%
Simplified35.5%
Final simplification26.1%
(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.5%
remove-double-neg93.5%
sin-neg93.5%
neg-mul-193.5%
*-commutative93.5%
associate-*l*93.5%
associate-*l/92.7%
associate-/r/92.7%
associate-*l/93.5%
associate-/r/93.5%
sin-neg93.5%
neg-mul-193.5%
associate-/r*93.5%
associate-/r/93.5%
Simplified99.6%
Taylor expanded in kx around 0 22.3%
Final simplification22.3%
(FPCore (kx ky th) :precision binary64 (if (or (<= ky 5.5e+15) (and (not (<= ky 2.6e+68)) (<= ky 1.6e+203))) th (- th)))
double code(double kx, double ky, double th) {
double tmp;
if ((ky <= 5.5e+15) || (!(ky <= 2.6e+68) && (ky <= 1.6e+203))) {
tmp = th;
} else {
tmp = -th;
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if ((ky <= 5.5d+15) .or. (.not. (ky <= 2.6d+68)) .and. (ky <= 1.6d+203)) then
tmp = th
else
tmp = -th
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if ((ky <= 5.5e+15) || (!(ky <= 2.6e+68) && (ky <= 1.6e+203))) {
tmp = th;
} else {
tmp = -th;
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if (ky <= 5.5e+15) or (not (ky <= 2.6e+68) and (ky <= 1.6e+203)): tmp = th else: tmp = -th return tmp
function code(kx, ky, th) tmp = 0.0 if ((ky <= 5.5e+15) || (!(ky <= 2.6e+68) && (ky <= 1.6e+203))) tmp = th; else tmp = Float64(-th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if ((ky <= 5.5e+15) || (~((ky <= 2.6e+68)) && (ky <= 1.6e+203))) tmp = th; else tmp = -th; end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[Or[LessEqual[ky, 5.5e+15], And[N[Not[LessEqual[ky, 2.6e+68]], $MachinePrecision], LessEqual[ky, 1.6e+203]]], th, (-th)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 5.5 \cdot 10^{+15} \lor \neg \left(ky \leq 2.6 \cdot 10^{+68}\right) \land ky \leq 1.6 \cdot 10^{+203}:\\
\;\;\;\;th\\
\mathbf{else}:\\
\;\;\;\;-th\\
\end{array}
\end{array}
if ky < 5.5e15 or 2.5999999999999998e68 < ky < 1.5999999999999998e203Initial program 92.4%
remove-double-neg92.4%
sin-neg92.4%
neg-mul-192.4%
*-commutative92.4%
associate-*l*92.4%
associate-*l/91.5%
associate-/r/91.5%
associate-*l/92.4%
associate-/r/92.4%
sin-neg92.4%
neg-mul-192.4%
associate-/r*92.4%
associate-/r/92.4%
Simplified99.6%
Taylor expanded in kx around 0 22.9%
Taylor expanded in th around 0 15.3%
if 5.5e15 < ky < 2.5999999999999998e68 or 1.5999999999999998e203 < ky Initial program 99.6%
remove-double-neg99.6%
sin-neg99.6%
neg-mul-199.6%
*-commutative99.6%
associate-*l*99.6%
associate-*l/99.3%
associate-/r/99.3%
associate-*l/99.6%
associate-/r/99.6%
sin-neg99.6%
neg-mul-199.6%
associate-/r*99.6%
associate-/r/99.6%
Simplified99.6%
Taylor expanded in kx around 0 19.0%
add-cbrt-cube17.4%
pow317.4%
Applied egg-rr17.4%
rem-cbrt-cube19.0%
add-sqr-sqrt12.4%
sqrt-unprod22.6%
sqr-neg22.6%
sqrt-unprod15.7%
add-sqr-sqrt36.7%
neg-sub036.7%
Applied egg-rr36.7%
neg-sub036.7%
Simplified36.7%
Taylor expanded in th around 0 24.6%
Final simplification16.8%
(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.5%
remove-double-neg93.5%
sin-neg93.5%
neg-mul-193.5%
*-commutative93.5%
associate-*l*93.5%
associate-*l/92.7%
associate-/r/92.7%
associate-*l/93.5%
associate-/r/93.5%
sin-neg93.5%
neg-mul-193.5%
associate-/r*93.5%
associate-/r/93.5%
Simplified99.6%
Taylor expanded in kx around 0 22.3%
Taylor expanded in th around 0 14.5%
Final simplification14.5%
herbie shell --seed 2024011
(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)))