
(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 17 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 93.1%
remove-double-neg93.1%
sin-neg93.1%
neg-mul-193.1%
*-commutative93.1%
associate-*l*93.1%
associate-*l/92.0%
associate-/r/92.0%
associate-*l/93.1%
associate-/r/93.0%
sin-neg93.0%
neg-mul-193.0%
associate-/r*93.0%
associate-/r/93.1%
Simplified99.7%
*-commutative99.7%
clear-num99.6%
un-div-inv99.7%
hypot-udef93.1%
unpow293.1%
unpow293.1%
+-commutative93.1%
unpow293.1%
unpow293.1%
hypot-def99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -0.3475)
(sqrt (pow (sin th) 2.0))
(if (<= (sin ky) 2e-191)
(* (sin th) (/ (sin ky) (fabs (sin kx))))
(if (<= (sin ky) 0.005)
(/ 1.0 (/ (hypot (sin kx) (sin ky)) (* (sin th) ky)))
(sin th)))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.3475) {
tmp = sqrt(pow(sin(th), 2.0));
} else if (sin(ky) <= 2e-191) {
tmp = sin(th) * (sin(ky) / fabs(sin(kx)));
} else if (sin(ky) <= 0.005) {
tmp = 1.0 / (hypot(sin(kx), sin(ky)) / (sin(th) * ky));
} else {
tmp = sin(th);
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -0.3475) {
tmp = Math.sqrt(Math.pow(Math.sin(th), 2.0));
} else if (Math.sin(ky) <= 2e-191) {
tmp = Math.sin(th) * (Math.sin(ky) / Math.abs(Math.sin(kx)));
} else if (Math.sin(ky) <= 0.005) {
tmp = 1.0 / (Math.hypot(Math.sin(kx), Math.sin(ky)) / (Math.sin(th) * ky));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.3475: tmp = math.sqrt(math.pow(math.sin(th), 2.0)) elif math.sin(ky) <= 2e-191: tmp = math.sin(th) * (math.sin(ky) / math.fabs(math.sin(kx))) elif math.sin(ky) <= 0.005: tmp = 1.0 / (math.hypot(math.sin(kx), math.sin(ky)) / (math.sin(th) * ky)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.3475) tmp = sqrt((sin(th) ^ 2.0)); elseif (sin(ky) <= 2e-191) tmp = Float64(sin(th) * Float64(sin(ky) / abs(sin(kx)))); elseif (sin(ky) <= 0.005) tmp = Float64(1.0 / Float64(hypot(sin(kx), sin(ky)) / Float64(sin(th) * ky))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.3475) tmp = sqrt((sin(th) ^ 2.0)); elseif (sin(ky) <= 2e-191) tmp = sin(th) * (sin(ky) / abs(sin(kx))); elseif (sin(ky) <= 0.005) tmp = 1.0 / (hypot(sin(kx), sin(ky)) / (sin(th) * ky)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.3475], N[Sqrt[N[Power[N[Sin[th], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-191], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 0.005], N[(1.0 / N[(N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision] / N[(N[Sin[th], $MachinePrecision] * ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.3475:\\
\;\;\;\;\sqrt{{\sin th}^{2}}\\
\mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-191}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\left|\sin kx\right|}\\
\mathbf{elif}\;\sin ky \leq 0.005:\\
\;\;\;\;\frac{1}{\frac{\mathsf{hypot}\left(\sin kx, \sin ky\right)}{\sin th \cdot ky}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.347499999999999976Initial program 99.6%
remove-double-neg99.6%
sin-neg99.6%
neg-mul-199.6%
*-commutative99.6%
associate-*l*99.6%
associate-*l/99.6%
associate-/r/99.6%
associate-*l/99.6%
associate-/r/99.4%
sin-neg99.4%
neg-mul-199.4%
associate-/r*99.4%
associate-/r/99.6%
Simplified99.7%
associate-*l/99.6%
clear-num99.3%
hypot-udef99.3%
unpow299.3%
unpow299.3%
+-commutative99.3%
unpow299.3%
unpow299.3%
hypot-def99.3%
Applied egg-rr99.3%
Taylor expanded in kx around 0 3.0%
remove-double-div3.0%
add-sqr-sqrt1.6%
sqrt-unprod23.7%
pow223.7%
Applied egg-rr23.7%
if -0.347499999999999976 < (sin.f64 ky) < 2e-191Initial program 85.0%
+-commutative85.0%
unpow285.0%
unpow285.0%
hypot-udef99.7%
add-cube-cbrt98.2%
pow398.1%
hypot-udef83.7%
unpow283.7%
unpow283.7%
+-commutative83.7%
unpow283.7%
unpow283.7%
hypot-def98.1%
Applied egg-rr98.1%
Taylor expanded in ky around 0 40.5%
sqr-pow31.6%
fabs-sqr31.6%
sqr-pow67.1%
rem-cube-cbrt67.9%
Applied egg-rr67.9%
if 2e-191 < (sin.f64 ky) < 0.0050000000000000001Initial program 93.5%
remove-double-neg93.5%
sin-neg93.5%
neg-mul-193.5%
*-commutative93.5%
associate-*l*93.5%
associate-*l/90.7%
associate-/r/90.7%
associate-*l/93.5%
associate-/r/93.4%
sin-neg93.4%
neg-mul-193.4%
associate-/r*93.4%
associate-/r/93.5%
Simplified99.6%
associate-*l/95.9%
clear-num95.8%
hypot-udef90.5%
unpow290.5%
unpow290.5%
+-commutative90.5%
unpow290.5%
unpow290.5%
hypot-def95.8%
Applied egg-rr95.8%
Taylor expanded in ky around 0 91.7%
if 0.0050000000000000001 < (sin.f64 ky) Initial program 99.7%
remove-double-neg99.7%
sin-neg99.7%
neg-mul-199.7%
*-commutative99.7%
associate-*l*99.7%
associate-*l/99.6%
associate-/r/99.6%
associate-*l/99.7%
associate-/r/99.5%
sin-neg99.5%
neg-mul-199.5%
associate-/r*99.5%
associate-/r/99.7%
Simplified99.7%
Taylor expanded in kx around 0 70.3%
Final simplification64.6%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -0.3475)
(sqrt (pow (sin th) 2.0))
(if (<= (sin ky) 1e-50)
(* (sin th) (/ (sin ky) (fabs (sin kx))))
(/ 1.0 (/ (sin ky) (* (sin th) (sin ky)))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.3475) {
tmp = sqrt(pow(sin(th), 2.0));
} else if (sin(ky) <= 1e-50) {
tmp = sin(th) * (sin(ky) / fabs(sin(kx)));
} else {
tmp = 1.0 / (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.3475d0)) then
tmp = sqrt((sin(th) ** 2.0d0))
else if (sin(ky) <= 1d-50) then
tmp = sin(th) * (sin(ky) / abs(sin(kx)))
else
tmp = 1.0d0 / (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.3475) {
tmp = Math.sqrt(Math.pow(Math.sin(th), 2.0));
} else if (Math.sin(ky) <= 1e-50) {
tmp = Math.sin(th) * (Math.sin(ky) / Math.abs(Math.sin(kx)));
} else {
tmp = 1.0 / (Math.sin(ky) / (Math.sin(th) * Math.sin(ky)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.3475: tmp = math.sqrt(math.pow(math.sin(th), 2.0)) elif math.sin(ky) <= 1e-50: tmp = math.sin(th) * (math.sin(ky) / math.fabs(math.sin(kx))) else: tmp = 1.0 / (math.sin(ky) / (math.sin(th) * math.sin(ky))) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.3475) tmp = sqrt((sin(th) ^ 2.0)); elseif (sin(ky) <= 1e-50) tmp = Float64(sin(th) * Float64(sin(ky) / abs(sin(kx)))); else tmp = Float64(1.0 / Float64(sin(ky) / Float64(sin(th) * sin(ky)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.3475) tmp = sqrt((sin(th) ^ 2.0)); elseif (sin(ky) <= 1e-50) tmp = sin(th) * (sin(ky) / abs(sin(kx))); else tmp = 1.0 / (sin(ky) / (sin(th) * sin(ky))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.3475], N[Sqrt[N[Power[N[Sin[th], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-50], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[Sin[ky], $MachinePrecision] / N[(N[Sin[th], $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.3475:\\
\;\;\;\;\sqrt{{\sin th}^{2}}\\
\mathbf{elif}\;\sin ky \leq 10^{-50}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\left|\sin kx\right|}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\sin ky}{\sin th \cdot \sin ky}}\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.347499999999999976Initial program 99.6%
remove-double-neg99.6%
sin-neg99.6%
neg-mul-199.6%
*-commutative99.6%
associate-*l*99.6%
associate-*l/99.6%
associate-/r/99.6%
associate-*l/99.6%
associate-/r/99.4%
sin-neg99.4%
neg-mul-199.4%
associate-/r*99.4%
associate-/r/99.6%
Simplified99.7%
associate-*l/99.6%
clear-num99.3%
hypot-udef99.3%
unpow299.3%
unpow299.3%
+-commutative99.3%
unpow299.3%
unpow299.3%
hypot-def99.3%
Applied egg-rr99.3%
Taylor expanded in kx around 0 3.0%
remove-double-div3.0%
add-sqr-sqrt1.6%
sqrt-unprod23.7%
pow223.7%
Applied egg-rr23.7%
if -0.347499999999999976 < (sin.f64 ky) < 1.00000000000000001e-50Initial program 86.7%
+-commutative86.7%
unpow286.7%
unpow286.7%
hypot-udef99.7%
add-cube-cbrt98.1%
pow398.1%
hypot-udef85.4%
unpow285.4%
unpow285.4%
+-commutative85.4%
unpow285.4%
unpow285.4%
hypot-def98.1%
Applied egg-rr98.1%
Taylor expanded in ky around 0 40.5%
sqr-pow29.5%
fabs-sqr29.5%
sqr-pow66.8%
rem-cube-cbrt67.6%
Applied egg-rr67.6%
if 1.00000000000000001e-50 < (sin.f64 ky) Initial program 99.7%
remove-double-neg99.7%
sin-neg99.7%
neg-mul-199.7%
*-commutative99.7%
associate-*l*99.7%
associate-*l/99.6%
associate-/r/99.6%
associate-*l/99.7%
associate-/r/99.5%
sin-neg99.5%
neg-mul-199.5%
associate-/r*99.5%
associate-/r/99.7%
Simplified99.7%
associate-*l/99.6%
clear-num99.4%
hypot-udef99.4%
unpow299.4%
unpow299.4%
+-commutative99.4%
unpow299.4%
unpow299.4%
hypot-def99.4%
Applied egg-rr99.4%
Taylor expanded in kx around 0 67.8%
Final simplification59.4%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -0.05)
(sqrt (pow (sin th) 2.0))
(if (<= (sin ky) 1e-50)
(* (sin th) (fabs (/ ky (sin kx))))
(/ 1.0 (/ (sin ky) (* (sin th) (sin ky)))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.05) {
tmp = sqrt(pow(sin(th), 2.0));
} else if (sin(ky) <= 1e-50) {
tmp = sin(th) * fabs((ky / sin(kx)));
} else {
tmp = 1.0 / (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.05d0)) then
tmp = sqrt((sin(th) ** 2.0d0))
else if (sin(ky) <= 1d-50) then
tmp = sin(th) * abs((ky / sin(kx)))
else
tmp = 1.0d0 / (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.05) {
tmp = Math.sqrt(Math.pow(Math.sin(th), 2.0));
} else if (Math.sin(ky) <= 1e-50) {
tmp = Math.sin(th) * Math.abs((ky / Math.sin(kx)));
} else {
tmp = 1.0 / (Math.sin(ky) / (Math.sin(th) * Math.sin(ky)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.05: tmp = math.sqrt(math.pow(math.sin(th), 2.0)) elif math.sin(ky) <= 1e-50: tmp = math.sin(th) * math.fabs((ky / math.sin(kx))) else: tmp = 1.0 / (math.sin(ky) / (math.sin(th) * math.sin(ky))) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.05) tmp = sqrt((sin(th) ^ 2.0)); elseif (sin(ky) <= 1e-50) tmp = Float64(sin(th) * abs(Float64(ky / sin(kx)))); else tmp = Float64(1.0 / Float64(sin(ky) / Float64(sin(th) * sin(ky)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.05) tmp = sqrt((sin(th) ^ 2.0)); elseif (sin(ky) <= 1e-50) tmp = sin(th) * abs((ky / sin(kx))); else tmp = 1.0 / (sin(ky) / (sin(th) * sin(ky))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.05], N[Sqrt[N[Power[N[Sin[th], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-50], N[(N[Sin[th], $MachinePrecision] * N[Abs[N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[Sin[ky], $MachinePrecision] / N[(N[Sin[th], $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.05:\\
\;\;\;\;\sqrt{{\sin th}^{2}}\\
\mathbf{elif}\;\sin ky \leq 10^{-50}:\\
\;\;\;\;\sin th \cdot \left|\frac{ky}{\sin kx}\right|\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\sin ky}{\sin th \cdot \sin ky}}\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.050000000000000003Initial program 99.5%
remove-double-neg99.5%
sin-neg99.5%
neg-mul-199.5%
*-commutative99.5%
associate-*l*99.5%
associate-*l/99.6%
associate-/r/99.6%
associate-*l/99.5%
associate-/r/99.5%
sin-neg99.5%
neg-mul-199.5%
associate-/r*99.5%
associate-/r/99.5%
Simplified99.6%
associate-*l/99.6%
clear-num99.3%
hypot-udef99.3%
unpow299.3%
unpow299.3%
+-commutative99.3%
unpow299.3%
unpow299.3%
hypot-def99.3%
Applied egg-rr99.3%
Taylor expanded in kx around 0 3.2%
remove-double-div3.2%
add-sqr-sqrt1.6%
sqrt-unprod20.0%
pow220.0%
Applied egg-rr20.0%
if -0.050000000000000003 < (sin.f64 ky) < 1.00000000000000001e-50Initial program 85.2%
Taylor expanded in ky around 0 44.5%
add-sqr-sqrt23.5%
sqrt-unprod39.8%
pow239.8%
Applied egg-rr39.8%
unpow239.8%
rem-sqrt-square48.5%
Simplified48.5%
Taylor expanded in ky around 0 48.5%
if 1.00000000000000001e-50 < (sin.f64 ky) Initial program 99.7%
remove-double-neg99.7%
sin-neg99.7%
neg-mul-199.7%
*-commutative99.7%
associate-*l*99.7%
associate-*l/99.6%
associate-/r/99.6%
associate-*l/99.7%
associate-/r/99.5%
sin-neg99.5%
neg-mul-199.5%
associate-/r*99.5%
associate-/r/99.7%
Simplified99.7%
associate-*l/99.6%
clear-num99.4%
hypot-udef99.4%
unpow299.4%
unpow299.4%
+-commutative99.4%
unpow299.4%
unpow299.4%
hypot-def99.4%
Applied egg-rr99.4%
Taylor expanded in kx around 0 67.8%
Final simplification47.5%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.05) (sqrt (pow (sin th) 2.0)) (if (<= (sin ky) 1e-50) (* (sin th) (fabs (/ ky (sin kx)))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.05) {
tmp = sqrt(pow(sin(th), 2.0));
} else if (sin(ky) <= 1e-50) {
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 (sin(ky) <= (-0.05d0)) then
tmp = sqrt((sin(th) ** 2.0d0))
else if (sin(ky) <= 1d-50) 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 (Math.sin(ky) <= -0.05) {
tmp = Math.sqrt(Math.pow(Math.sin(th), 2.0));
} else if (Math.sin(ky) <= 1e-50) {
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 math.sin(ky) <= -0.05: tmp = math.sqrt(math.pow(math.sin(th), 2.0)) elif math.sin(ky) <= 1e-50: 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 (sin(ky) <= -0.05) tmp = sqrt((sin(th) ^ 2.0)); elseif (sin(ky) <= 1e-50) 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 (sin(ky) <= -0.05) tmp = sqrt((sin(th) ^ 2.0)); elseif (sin(ky) <= 1e-50) tmp = sin(th) * abs((ky / sin(kx))); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.05], N[Sqrt[N[Power[N[Sin[th], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-50], 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}\;\sin ky \leq -0.05:\\
\;\;\;\;\sqrt{{\sin th}^{2}}\\
\mathbf{elif}\;\sin ky \leq 10^{-50}:\\
\;\;\;\;\sin th \cdot \left|\frac{ky}{\sin kx}\right|\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.050000000000000003Initial program 99.5%
remove-double-neg99.5%
sin-neg99.5%
neg-mul-199.5%
*-commutative99.5%
associate-*l*99.5%
associate-*l/99.6%
associate-/r/99.6%
associate-*l/99.5%
associate-/r/99.5%
sin-neg99.5%
neg-mul-199.5%
associate-/r*99.5%
associate-/r/99.5%
Simplified99.6%
associate-*l/99.6%
clear-num99.3%
hypot-udef99.3%
unpow299.3%
unpow299.3%
+-commutative99.3%
unpow299.3%
unpow299.3%
hypot-def99.3%
Applied egg-rr99.3%
Taylor expanded in kx around 0 3.2%
remove-double-div3.2%
add-sqr-sqrt1.6%
sqrt-unprod20.0%
pow220.0%
Applied egg-rr20.0%
if -0.050000000000000003 < (sin.f64 ky) < 1.00000000000000001e-50Initial program 85.2%
Taylor expanded in ky around 0 44.5%
add-sqr-sqrt23.5%
sqrt-unprod39.8%
pow239.8%
Applied egg-rr39.8%
unpow239.8%
rem-sqrt-square48.5%
Simplified48.5%
Taylor expanded in ky around 0 48.5%
if 1.00000000000000001e-50 < (sin.f64 ky) Initial program 99.7%
remove-double-neg99.7%
sin-neg99.7%
neg-mul-199.7%
*-commutative99.7%
associate-*l*99.7%
associate-*l/99.6%
associate-/r/99.6%
associate-*l/99.7%
associate-/r/99.5%
sin-neg99.5%
neg-mul-199.5%
associate-/r*99.5%
associate-/r/99.7%
Simplified99.7%
Taylor expanded in kx around 0 68.1%
Final simplification47.6%
(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.1%
remove-double-neg93.1%
sin-neg93.1%
neg-mul-193.1%
*-commutative93.1%
associate-*l*93.1%
associate-*l/92.0%
associate-/r/92.0%
associate-*l/93.1%
associate-/r/93.0%
sin-neg93.0%
neg-mul-193.0%
associate-/r*93.0%
associate-/r/93.1%
Simplified99.7%
expm1-log1p-u99.6%
expm1-udef37.8%
hypot-udef35.9%
unpow235.9%
unpow235.9%
+-commutative35.9%
unpow235.9%
unpow235.9%
hypot-def37.8%
Applied egg-rr37.8%
expm1-def99.6%
expm1-log1p99.7%
*-commutative99.7%
associate-*r/95.9%
associate-*l/99.6%
*-commutative99.6%
hypot-def93.1%
unpow293.1%
unpow293.1%
+-commutative93.1%
unpow293.1%
unpow293.1%
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 93.1%
remove-double-neg93.1%
sin-neg93.1%
neg-mul-193.1%
*-commutative93.1%
associate-*l*93.1%
associate-*l/92.0%
associate-/r/92.0%
associate-*l/93.1%
associate-/r/93.0%
sin-neg93.0%
neg-mul-193.0%
associate-/r*93.0%
associate-/r/93.1%
Simplified99.7%
Final simplification99.7%
(FPCore (kx ky th)
:precision binary64
(if (<= ky 0.0045)
(/
(sin th)
(* (hypot (sin kx) (sin ky)) (+ (* ky 0.16666666666666666) (/ 1.0 ky))))
(/ 1.0 (/ (hypot (sin ky) (sin kx)) (* th (sin ky))))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 0.0045) {
tmp = sin(th) / (hypot(sin(kx), sin(ky)) * ((ky * 0.16666666666666666) + (1.0 / ky)));
} else {
tmp = 1.0 / (hypot(sin(ky), sin(kx)) / (th * sin(ky)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= 0.0045) {
tmp = Math.sin(th) / (Math.hypot(Math.sin(kx), Math.sin(ky)) * ((ky * 0.16666666666666666) + (1.0 / ky)));
} else {
tmp = 1.0 / (Math.hypot(Math.sin(ky), Math.sin(kx)) / (th * Math.sin(ky)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 0.0045: tmp = math.sin(th) / (math.hypot(math.sin(kx), math.sin(ky)) * ((ky * 0.16666666666666666) + (1.0 / ky))) else: tmp = 1.0 / (math.hypot(math.sin(ky), math.sin(kx)) / (th * math.sin(ky))) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 0.0045) tmp = Float64(sin(th) / Float64(hypot(sin(kx), sin(ky)) * Float64(Float64(ky * 0.16666666666666666) + Float64(1.0 / ky)))); else tmp = Float64(1.0 / Float64(hypot(sin(ky), sin(kx)) / Float64(th * sin(ky)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 0.0045) tmp = sin(th) / (hypot(sin(kx), sin(ky)) * ((ky * 0.16666666666666666) + (1.0 / ky))); else tmp = 1.0 / (hypot(sin(ky), sin(kx)) / (th * sin(ky))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 0.0045], N[(N[Sin[th], $MachinePrecision] / N[(N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision] * N[(N[(ky * 0.16666666666666666), $MachinePrecision] + N[(1.0 / ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision] / N[(th * N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 0.0045:\\
\;\;\;\;\frac{\sin th}{\mathsf{hypot}\left(\sin kx, \sin ky\right) \cdot \left(ky \cdot 0.16666666666666666 + \frac{1}{ky}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right)}{th \cdot \sin ky}}\\
\end{array}
\end{array}
if ky < 0.00449999999999999966Initial program 90.6%
remove-double-neg90.6%
sin-neg90.6%
neg-mul-190.6%
*-commutative90.6%
associate-*l*90.6%
associate-*l/88.9%
associate-/r/88.9%
associate-*l/90.6%
associate-/r/90.4%
sin-neg90.4%
neg-mul-190.4%
associate-/r*90.4%
associate-/r/90.6%
Simplified99.7%
*-commutative99.7%
clear-num99.6%
un-div-inv99.7%
hypot-udef90.5%
unpow290.5%
unpow290.5%
+-commutative90.5%
unpow290.5%
unpow290.5%
hypot-def99.7%
Applied egg-rr99.7%
div-inv99.5%
Applied egg-rr99.5%
Taylor expanded in ky around 0 68.6%
if 0.00449999999999999966 < 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.6%
associate-/r/99.6%
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%
associate-*l/99.6%
clear-num99.4%
hypot-udef99.4%
unpow299.4%
unpow299.4%
+-commutative99.4%
unpow299.4%
unpow299.4%
hypot-def99.4%
Applied egg-rr99.4%
Taylor expanded in th around 0 59.9%
associate-*l/59.9%
unpow259.9%
unpow259.9%
hypot-def59.9%
*-lft-identity59.9%
hypot-def59.9%
unpow259.9%
unpow259.9%
+-commutative59.9%
unpow259.9%
unpow259.9%
hypot-def59.9%
*-commutative59.9%
Simplified59.9%
Final simplification66.1%
(FPCore (kx ky th) :precision binary64 (if (<= th 5.7e-14) (/ 1.0 (/ (hypot (sin ky) (sin kx)) (* th (sin ky)))) (/ 1.0 (/ (hypot (sin kx) (sin ky)) (* (sin th) ky)))))
double code(double kx, double ky, double th) {
double tmp;
if (th <= 5.7e-14) {
tmp = 1.0 / (hypot(sin(ky), sin(kx)) / (th * sin(ky)));
} else {
tmp = 1.0 / (hypot(sin(kx), sin(ky)) / (sin(th) * ky));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (th <= 5.7e-14) {
tmp = 1.0 / (Math.hypot(Math.sin(ky), Math.sin(kx)) / (th * Math.sin(ky)));
} else {
tmp = 1.0 / (Math.hypot(Math.sin(kx), Math.sin(ky)) / (Math.sin(th) * ky));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if th <= 5.7e-14: tmp = 1.0 / (math.hypot(math.sin(ky), math.sin(kx)) / (th * math.sin(ky))) else: tmp = 1.0 / (math.hypot(math.sin(kx), math.sin(ky)) / (math.sin(th) * ky)) return tmp
function code(kx, ky, th) tmp = 0.0 if (th <= 5.7e-14) tmp = Float64(1.0 / Float64(hypot(sin(ky), sin(kx)) / Float64(th * sin(ky)))); else tmp = Float64(1.0 / Float64(hypot(sin(kx), sin(ky)) / Float64(sin(th) * ky))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (th <= 5.7e-14) tmp = 1.0 / (hypot(sin(ky), sin(kx)) / (th * sin(ky))); else tmp = 1.0 / (hypot(sin(kx), sin(ky)) / (sin(th) * ky)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[th, 5.7e-14], N[(1.0 / N[(N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision] / N[(th * N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision] / N[(N[Sin[th], $MachinePrecision] * ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;th \leq 5.7 \cdot 10^{-14}:\\
\;\;\;\;\frac{1}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right)}{th \cdot \sin ky}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\mathsf{hypot}\left(\sin kx, \sin ky\right)}{\sin th \cdot ky}}\\
\end{array}
\end{array}
if th < 5.69999999999999969e-14Initial program 93.2%
remove-double-neg93.2%
sin-neg93.2%
neg-mul-193.2%
*-commutative93.2%
associate-*l*93.2%
associate-*l/91.6%
associate-/r/91.6%
associate-*l/93.2%
associate-/r/93.1%
sin-neg93.1%
neg-mul-193.1%
associate-/r*93.1%
associate-/r/93.2%
Simplified99.6%
associate-*l/94.6%
clear-num94.4%
hypot-udef91.4%
unpow291.4%
unpow291.4%
+-commutative91.4%
unpow291.4%
unpow291.4%
hypot-def94.4%
Applied egg-rr94.4%
Taylor expanded in th around 0 66.4%
associate-*l/67.2%
unpow267.2%
unpow267.2%
hypot-def68.2%
*-lft-identity68.2%
hypot-def67.2%
unpow267.2%
unpow267.2%
+-commutative67.2%
unpow267.2%
unpow267.2%
hypot-def68.2%
*-commutative68.2%
Simplified68.2%
if 5.69999999999999969e-14 < th Initial program 93.0%
remove-double-neg93.0%
sin-neg93.0%
neg-mul-193.0%
*-commutative93.0%
associate-*l*93.0%
associate-*l/92.9%
associate-/r/92.9%
associate-*l/93.0%
associate-/r/92.7%
sin-neg92.7%
neg-mul-192.7%
associate-/r*92.7%
associate-/r/93.0%
Simplified99.8%
associate-*l/99.7%
clear-num99.3%
hypot-udef92.5%
unpow292.5%
unpow292.5%
+-commutative92.5%
unpow292.5%
unpow292.5%
hypot-def99.3%
Applied egg-rr99.3%
Taylor expanded in ky around 0 55.2%
Final simplification65.0%
(FPCore (kx ky th) :precision binary64 (if (<= ky 0.00315) (/ (sin th) (* (hypot (sin kx) (sin ky)) (/ 1.0 ky))) (/ 1.0 (/ (hypot (sin ky) (sin kx)) (* th (sin ky))))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 0.00315) {
tmp = sin(th) / (hypot(sin(kx), sin(ky)) * (1.0 / ky));
} else {
tmp = 1.0 / (hypot(sin(ky), sin(kx)) / (th * sin(ky)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= 0.00315) {
tmp = Math.sin(th) / (Math.hypot(Math.sin(kx), Math.sin(ky)) * (1.0 / ky));
} else {
tmp = 1.0 / (Math.hypot(Math.sin(ky), Math.sin(kx)) / (th * Math.sin(ky)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 0.00315: tmp = math.sin(th) / (math.hypot(math.sin(kx), math.sin(ky)) * (1.0 / ky)) else: tmp = 1.0 / (math.hypot(math.sin(ky), math.sin(kx)) / (th * math.sin(ky))) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 0.00315) tmp = Float64(sin(th) / Float64(hypot(sin(kx), sin(ky)) * Float64(1.0 / ky))); else tmp = Float64(1.0 / Float64(hypot(sin(ky), sin(kx)) / Float64(th * sin(ky)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 0.00315) tmp = sin(th) / (hypot(sin(kx), sin(ky)) * (1.0 / ky)); else tmp = 1.0 / (hypot(sin(ky), sin(kx)) / (th * sin(ky))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 0.00315], N[(N[Sin[th], $MachinePrecision] / N[(N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision] * N[(1.0 / ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision] / N[(th * N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 0.00315:\\
\;\;\;\;\frac{\sin th}{\mathsf{hypot}\left(\sin kx, \sin ky\right) \cdot \frac{1}{ky}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right)}{th \cdot \sin ky}}\\
\end{array}
\end{array}
if ky < 0.00315Initial program 90.6%
remove-double-neg90.6%
sin-neg90.6%
neg-mul-190.6%
*-commutative90.6%
associate-*l*90.6%
associate-*l/88.9%
associate-/r/88.9%
associate-*l/90.6%
associate-/r/90.4%
sin-neg90.4%
neg-mul-190.4%
associate-/r*90.4%
associate-/r/90.6%
Simplified99.7%
*-commutative99.7%
clear-num99.6%
un-div-inv99.7%
hypot-udef90.5%
unpow290.5%
unpow290.5%
+-commutative90.5%
unpow290.5%
unpow290.5%
hypot-def99.7%
Applied egg-rr99.7%
div-inv99.5%
Applied egg-rr99.5%
Taylor expanded in ky around 0 67.9%
if 0.00315 < 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.6%
associate-/r/99.6%
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%
associate-*l/99.6%
clear-num99.4%
hypot-udef99.4%
unpow299.4%
unpow299.4%
+-commutative99.4%
unpow299.4%
unpow299.4%
hypot-def99.4%
Applied egg-rr99.4%
Taylor expanded in th around 0 59.9%
associate-*l/59.9%
unpow259.9%
unpow259.9%
hypot-def59.9%
*-lft-identity59.9%
hypot-def59.9%
unpow259.9%
unpow259.9%
+-commutative59.9%
unpow259.9%
unpow259.9%
hypot-def59.9%
*-commutative59.9%
Simplified59.9%
Final simplification65.6%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.255) (fabs (sin th)) (if (<= (sin ky) 2e-139) (* (sin th) (/ ky (sin kx))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.255) {
tmp = fabs(sin(th));
} else if (sin(ky) <= 2e-139) {
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.255d0)) then
tmp = abs(sin(th))
else if (sin(ky) <= 2d-139) 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.255) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(ky) <= 2e-139) {
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.255: tmp = math.fabs(math.sin(th)) elif math.sin(ky) <= 2e-139: 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.255) tmp = abs(sin(th)); elseif (sin(ky) <= 2e-139) 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.255) tmp = abs(sin(th)); elseif (sin(ky) <= 2e-139) 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.255], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-139], 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.255:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-139}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.255Initial program 99.6%
remove-double-neg99.6%
sin-neg99.6%
neg-mul-199.6%
*-commutative99.6%
associate-*l*99.6%
associate-*l/99.6%
associate-/r/99.6%
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%
associate-*l/99.6%
clear-num99.3%
hypot-udef99.3%
unpow299.3%
unpow299.3%
+-commutative99.3%
unpow299.3%
unpow299.3%
hypot-def99.3%
Applied egg-rr99.3%
Taylor expanded in kx around 0 3.0%
remove-double-div3.0%
add-sqr-sqrt1.7%
sqrt-unprod21.8%
pow221.8%
Applied egg-rr21.8%
unpow221.8%
rem-sqrt-square29.6%
Simplified29.6%
if -0.255 < (sin.f64 ky) < 2.00000000000000006e-139Initial program 83.1%
Taylor expanded in ky around 0 44.0%
if 2.00000000000000006e-139 < (sin.f64 ky) Initial program 99.7%
remove-double-neg99.7%
sin-neg99.7%
neg-mul-199.7%
*-commutative99.7%
associate-*l*99.7%
associate-*l/99.2%
associate-/r/99.2%
associate-*l/99.7%
associate-/r/99.5%
sin-neg99.5%
neg-mul-199.5%
associate-/r*99.5%
associate-/r/99.7%
Simplified99.7%
Taylor expanded in kx around 0 63.4%
Final simplification48.7%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.255) (sqrt (pow (sin th) 2.0)) (if (<= (sin ky) 2e-139) (* (sin th) (/ ky (sin kx))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.255) {
tmp = sqrt(pow(sin(th), 2.0));
} else if (sin(ky) <= 2e-139) {
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.255d0)) then
tmp = sqrt((sin(th) ** 2.0d0))
else if (sin(ky) <= 2d-139) 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.255) {
tmp = Math.sqrt(Math.pow(Math.sin(th), 2.0));
} else if (Math.sin(ky) <= 2e-139) {
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.255: tmp = math.sqrt(math.pow(math.sin(th), 2.0)) elif math.sin(ky) <= 2e-139: 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.255) tmp = sqrt((sin(th) ^ 2.0)); elseif (sin(ky) <= 2e-139) 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.255) tmp = sqrt((sin(th) ^ 2.0)); elseif (sin(ky) <= 2e-139) 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.255], N[Sqrt[N[Power[N[Sin[th], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-139], 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.255:\\
\;\;\;\;\sqrt{{\sin th}^{2}}\\
\mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-139}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.255Initial program 99.6%
remove-double-neg99.6%
sin-neg99.6%
neg-mul-199.6%
*-commutative99.6%
associate-*l*99.6%
associate-*l/99.6%
associate-/r/99.6%
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%
associate-*l/99.6%
clear-num99.3%
hypot-udef99.3%
unpow299.3%
unpow299.3%
+-commutative99.3%
unpow299.3%
unpow299.3%
hypot-def99.3%
Applied egg-rr99.3%
Taylor expanded in kx around 0 3.0%
remove-double-div3.0%
add-sqr-sqrt1.7%
sqrt-unprod21.8%
pow221.8%
Applied egg-rr21.8%
if -0.255 < (sin.f64 ky) < 2.00000000000000006e-139Initial program 83.1%
Taylor expanded in ky around 0 44.0%
if 2.00000000000000006e-139 < (sin.f64 ky) Initial program 99.7%
remove-double-neg99.7%
sin-neg99.7%
neg-mul-199.7%
*-commutative99.7%
associate-*l*99.7%
associate-*l/99.2%
associate-/r/99.2%
associate-*l/99.7%
associate-/r/99.5%
sin-neg99.5%
neg-mul-199.5%
associate-/r*99.5%
associate-/r/99.7%
Simplified99.7%
Taylor expanded in kx around 0 63.4%
Final simplification47.1%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.05) (fabs (sin th)) (if (<= (sin ky) 2e-139) (/ ky (/ kx (sin th))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.05) {
tmp = fabs(sin(th));
} else if (sin(ky) <= 2e-139) {
tmp = ky / (kx / 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 (sin(ky) <= (-0.05d0)) then
tmp = abs(sin(th))
else if (sin(ky) <= 2d-139) then
tmp = ky / (kx / 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 (Math.sin(ky) <= -0.05) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(ky) <= 2e-139) {
tmp = ky / (kx / Math.sin(th));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.05: tmp = math.fabs(math.sin(th)) elif math.sin(ky) <= 2e-139: tmp = ky / (kx / math.sin(th)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.05) tmp = abs(sin(th)); elseif (sin(ky) <= 2e-139) tmp = Float64(ky / Float64(kx / sin(th))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.05) tmp = abs(sin(th)); elseif (sin(ky) <= 2e-139) tmp = ky / (kx / sin(th)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.05], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-139], N[(ky / N[(kx / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.05:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-139}:\\
\;\;\;\;\frac{ky}{\frac{kx}{\sin th}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.050000000000000003Initial program 99.5%
remove-double-neg99.5%
sin-neg99.5%
neg-mul-199.5%
*-commutative99.5%
associate-*l*99.5%
associate-*l/99.6%
associate-/r/99.6%
associate-*l/99.5%
associate-/r/99.5%
sin-neg99.5%
neg-mul-199.5%
associate-/r*99.5%
associate-/r/99.5%
Simplified99.6%
associate-*l/99.6%
clear-num99.3%
hypot-udef99.3%
unpow299.3%
unpow299.3%
+-commutative99.3%
unpow299.3%
unpow299.3%
hypot-def99.3%
Applied egg-rr99.3%
Taylor expanded in kx around 0 3.2%
remove-double-div3.2%
add-sqr-sqrt1.6%
sqrt-unprod20.0%
pow220.0%
Applied egg-rr20.0%
unpow220.0%
rem-sqrt-square28.4%
Simplified28.4%
if -0.050000000000000003 < (sin.f64 ky) < 2.00000000000000006e-139Initial program 81.6%
Taylor expanded in ky around 0 47.8%
Taylor expanded in kx around 0 29.0%
Taylor expanded in ky around 0 28.9%
associate-/l*33.0%
Simplified33.0%
if 2.00000000000000006e-139 < (sin.f64 ky) Initial program 99.7%
remove-double-neg99.7%
sin-neg99.7%
neg-mul-199.7%
*-commutative99.7%
associate-*l*99.7%
associate-*l/99.2%
associate-/r/99.2%
associate-*l/99.7%
associate-/r/99.5%
sin-neg99.5%
neg-mul-199.5%
associate-/r*99.5%
associate-/r/99.7%
Simplified99.7%
Taylor expanded in kx around 0 63.4%
Final simplification44.0%
(FPCore (kx ky th) :precision binary64 (if (<= ky 5.2e-139) (/ ky (/ kx (sin th))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 5.2e-139) {
tmp = ky / (kx / 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.2d-139) then
tmp = ky / (kx / 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.2e-139) {
tmp = ky / (kx / Math.sin(th));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 5.2e-139: tmp = ky / (kx / math.sin(th)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 5.2e-139) tmp = Float64(ky / Float64(kx / sin(th))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 5.2e-139) tmp = ky / (kx / sin(th)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 5.2e-139], N[(ky / N[(kx / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 5.2 \cdot 10^{-139}:\\
\;\;\;\;\frac{ky}{\frac{kx}{\sin th}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 5.1999999999999996e-139Initial program 88.5%
Taylor expanded in ky around 0 32.3%
Taylor expanded in kx around 0 19.4%
Taylor expanded in ky around 0 19.2%
associate-/l*21.7%
Simplified21.7%
if 5.1999999999999996e-139 < 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.2%
associate-/r/99.2%
associate-*l/99.6%
associate-/r/99.6%
sin-neg99.6%
neg-mul-199.6%
associate-/r*99.6%
associate-/r/99.6%
Simplified99.7%
Taylor expanded in kx around 0 42.3%
Final simplification30.2%
(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.1%
remove-double-neg93.1%
sin-neg93.1%
neg-mul-193.1%
*-commutative93.1%
associate-*l*93.1%
associate-*l/92.0%
associate-/r/92.0%
associate-*l/93.1%
associate-/r/93.0%
sin-neg93.0%
neg-mul-193.0%
associate-/r*93.0%
associate-/r/93.1%
Simplified99.7%
Taylor expanded in kx around 0 28.5%
Final simplification28.5%
(FPCore (kx ky th) :precision binary64 (/ 1.0 (+ (* th 0.16666666666666666) (/ 1.0 th))))
double code(double kx, double ky, double th) {
return 1.0 / ((th * 0.16666666666666666) + (1.0 / th));
}
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 / ((th * 0.16666666666666666d0) + (1.0d0 / th))
end function
public static double code(double kx, double ky, double th) {
return 1.0 / ((th * 0.16666666666666666) + (1.0 / th));
}
def code(kx, ky, th): return 1.0 / ((th * 0.16666666666666666) + (1.0 / th))
function code(kx, ky, th) return Float64(1.0 / Float64(Float64(th * 0.16666666666666666) + Float64(1.0 / th))) end
function tmp = code(kx, ky, th) tmp = 1.0 / ((th * 0.16666666666666666) + (1.0 / th)); end
code[kx_, ky_, th_] := N[(1.0 / N[(N[(th * 0.16666666666666666), $MachinePrecision] + N[(1.0 / th), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{th \cdot 0.16666666666666666 + \frac{1}{th}}
\end{array}
Initial program 93.1%
remove-double-neg93.1%
sin-neg93.1%
neg-mul-193.1%
*-commutative93.1%
associate-*l*93.1%
associate-*l/92.0%
associate-/r/92.0%
associate-*l/93.1%
associate-/r/93.0%
sin-neg93.0%
neg-mul-193.0%
associate-/r*93.0%
associate-/r/93.1%
Simplified99.7%
associate-*l/95.9%
clear-num95.6%
hypot-udef91.7%
unpow291.7%
unpow291.7%
+-commutative91.7%
unpow291.7%
unpow291.7%
hypot-def95.6%
Applied egg-rr95.6%
Taylor expanded in kx around 0 28.4%
Taylor expanded in th around 0 18.8%
Final simplification18.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.1%
remove-double-neg93.1%
sin-neg93.1%
neg-mul-193.1%
*-commutative93.1%
associate-*l*93.1%
associate-*l/92.0%
associate-/r/92.0%
associate-*l/93.1%
associate-/r/93.0%
sin-neg93.0%
neg-mul-193.0%
associate-/r*93.0%
associate-/r/93.1%
Simplified99.7%
associate-*l/95.9%
clear-num95.6%
hypot-udef91.7%
unpow291.7%
unpow291.7%
+-commutative91.7%
unpow291.7%
unpow291.7%
hypot-def95.6%
Applied egg-rr95.6%
Taylor expanded in kx around 0 28.4%
Taylor expanded in th around 0 18.2%
Final simplification18.2%
herbie shell --seed 2023322
(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)))