
(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 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 91.6%
+-commutative91.6%
unpow291.6%
unpow291.6%
hypot-undefine99.7%
Applied egg-rr99.7%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -0.1)
(/ 1.0 (sqrt (pow (sin th) -2.0)))
(if (<= (sin ky) 2e-148)
(* (sin th) (/ (sin ky) (sin kx)))
(if (<= (sin ky) 2e-19) (fabs (* ky (/ (sin th) (sin kx)))) (sin th)))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.1) {
tmp = 1.0 / sqrt(pow(sin(th), -2.0));
} else if (sin(ky) <= 2e-148) {
tmp = sin(th) * (sin(ky) / sin(kx));
} else if (sin(ky) <= 2e-19) {
tmp = fabs((ky * (sin(th) / sin(kx))));
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(ky) <= (-0.1d0)) then
tmp = 1.0d0 / sqrt((sin(th) ** (-2.0d0)))
else if (sin(ky) <= 2d-148) then
tmp = sin(th) * (sin(ky) / sin(kx))
else if (sin(ky) <= 2d-19) then
tmp = abs((ky * (sin(th) / sin(kx))))
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -0.1) {
tmp = 1.0 / Math.sqrt(Math.pow(Math.sin(th), -2.0));
} else if (Math.sin(ky) <= 2e-148) {
tmp = Math.sin(th) * (Math.sin(ky) / Math.sin(kx));
} else if (Math.sin(ky) <= 2e-19) {
tmp = Math.abs((ky * (Math.sin(th) / Math.sin(kx))));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.1: tmp = 1.0 / math.sqrt(math.pow(math.sin(th), -2.0)) elif math.sin(ky) <= 2e-148: tmp = math.sin(th) * (math.sin(ky) / math.sin(kx)) elif math.sin(ky) <= 2e-19: tmp = math.fabs((ky * (math.sin(th) / math.sin(kx)))) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.1) tmp = Float64(1.0 / sqrt((sin(th) ^ -2.0))); elseif (sin(ky) <= 2e-148) tmp = Float64(sin(th) * Float64(sin(ky) / sin(kx))); elseif (sin(ky) <= 2e-19) tmp = abs(Float64(ky * Float64(sin(th) / sin(kx)))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.1) tmp = 1.0 / sqrt((sin(th) ^ -2.0)); elseif (sin(ky) <= 2e-148) tmp = sin(th) * (sin(ky) / sin(kx)); elseif (sin(ky) <= 2e-19) tmp = abs((ky * (sin(th) / sin(kx)))); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.1], N[(1.0 / N[Sqrt[N[Power[N[Sin[th], $MachinePrecision], -2.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-148], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-19], N[Abs[N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sin[th], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.1:\\
\;\;\;\;\frac{1}{\sqrt{{\sin th}^{-2}}}\\
\mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-148}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\
\mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-19}:\\
\;\;\;\;\left|ky \cdot \frac{\sin th}{\sin kx}\right|\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.10000000000000001Initial program 99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
associate-*l/99.6%
associate-/l*99.6%
unpow299.6%
Simplified99.7%
Taylor expanded in kx around 0 3.0%
associate-*r/3.0%
clear-num3.0%
Applied egg-rr3.0%
add-sqr-sqrt1.8%
sqrt-unprod22.0%
pow222.0%
associate-/r*22.0%
*-inverses22.0%
Applied egg-rr22.0%
unpow222.0%
unpow-122.0%
unpow-122.0%
pow-sqr22.0%
metadata-eval22.0%
Simplified22.0%
if -0.10000000000000001 < (sin.f64 ky) < 1.99999999999999987e-148Initial program 80.7%
Taylor expanded in ky around 0 53.8%
if 1.99999999999999987e-148 < (sin.f64 ky) < 2e-19Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/95.9%
associate-/l*99.8%
unpow299.8%
Simplified99.8%
Taylor expanded in ky around 0 46.2%
add-sqr-sqrt25.7%
sqrt-unprod29.3%
pow229.3%
*-commutative29.3%
associate-/l*29.4%
Applied egg-rr29.4%
unpow229.4%
rem-sqrt-square38.2%
associate-*r/38.4%
associate-*l/38.2%
*-commutative38.2%
Simplified38.2%
if 2e-19 < (sin.f64 ky) Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/99.6%
associate-/l*99.5%
unpow299.5%
Simplified99.5%
Taylor expanded in kx around 0 61.1%
Final simplification46.1%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -0.05)
(/ 1.0 (sqrt (pow (sin th) -2.0)))
(if (<= (sin ky) 4e-151)
(* (sin th) (/ ky (sin kx)))
(if (<= (sin ky) 2e-19) (fabs (* ky (/ (sin th) (sin kx)))) (sin th)))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.05) {
tmp = 1.0 / sqrt(pow(sin(th), -2.0));
} else if (sin(ky) <= 4e-151) {
tmp = sin(th) * (ky / sin(kx));
} else if (sin(ky) <= 2e-19) {
tmp = fabs((ky * (sin(th) / sin(kx))));
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(ky) <= (-0.05d0)) then
tmp = 1.0d0 / sqrt((sin(th) ** (-2.0d0)))
else if (sin(ky) <= 4d-151) then
tmp = sin(th) * (ky / sin(kx))
else if (sin(ky) <= 2d-19) then
tmp = abs((ky * (sin(th) / sin(kx))))
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -0.05) {
tmp = 1.0 / Math.sqrt(Math.pow(Math.sin(th), -2.0));
} else if (Math.sin(ky) <= 4e-151) {
tmp = Math.sin(th) * (ky / Math.sin(kx));
} else if (Math.sin(ky) <= 2e-19) {
tmp = Math.abs((ky * (Math.sin(th) / Math.sin(kx))));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.05: tmp = 1.0 / math.sqrt(math.pow(math.sin(th), -2.0)) elif math.sin(ky) <= 4e-151: tmp = math.sin(th) * (ky / math.sin(kx)) elif math.sin(ky) <= 2e-19: tmp = math.fabs((ky * (math.sin(th) / math.sin(kx)))) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.05) tmp = Float64(1.0 / sqrt((sin(th) ^ -2.0))); elseif (sin(ky) <= 4e-151) tmp = Float64(sin(th) * Float64(ky / sin(kx))); elseif (sin(ky) <= 2e-19) tmp = abs(Float64(ky * Float64(sin(th) / sin(kx)))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.05) tmp = 1.0 / sqrt((sin(th) ^ -2.0)); elseif (sin(ky) <= 4e-151) tmp = sin(th) * (ky / sin(kx)); elseif (sin(ky) <= 2e-19) tmp = abs((ky * (sin(th) / sin(kx)))); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.05], N[(1.0 / N[Sqrt[N[Power[N[Sin[th], $MachinePrecision], -2.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 4e-151], N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-19], N[Abs[N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sin[th], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.05:\\
\;\;\;\;\frac{1}{\sqrt{{\sin th}^{-2}}}\\
\mathbf{elif}\;\sin ky \leq 4 \cdot 10^{-151}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
\mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-19}:\\
\;\;\;\;\left|ky \cdot \frac{\sin th}{\sin kx}\right|\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.050000000000000003Initial program 99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
associate-*l/99.6%
associate-/l*99.6%
unpow299.6%
Simplified99.7%
Taylor expanded in kx around 0 2.9%
associate-*r/2.9%
clear-num2.9%
Applied egg-rr2.9%
add-sqr-sqrt1.8%
sqrt-unprod21.4%
pow221.4%
associate-/r*21.4%
*-inverses21.4%
Applied egg-rr21.4%
unpow221.4%
unpow-121.4%
unpow-121.4%
pow-sqr21.4%
metadata-eval21.4%
Simplified21.4%
if -0.050000000000000003 < (sin.f64 ky) < 3.9999999999999998e-151Initial program 80.4%
Taylor expanded in ky around 0 54.7%
if 3.9999999999999998e-151 < (sin.f64 ky) < 2e-19Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/95.9%
associate-/l*99.8%
unpow299.8%
Simplified99.8%
Taylor expanded in ky around 0 46.2%
add-sqr-sqrt25.7%
sqrt-unprod29.3%
pow229.3%
*-commutative29.3%
associate-/l*29.4%
Applied egg-rr29.4%
unpow229.4%
rem-sqrt-square38.2%
associate-*r/38.4%
associate-*l/38.2%
*-commutative38.2%
Simplified38.2%
if 2e-19 < (sin.f64 ky) Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/99.6%
associate-/l*99.5%
unpow299.5%
Simplified99.5%
Taylor expanded in kx around 0 61.1%
Final simplification46.1%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.05) (/ 1.0 (sqrt (pow (sin th) -2.0))) (if (<= (sin ky) 2e-19) (/ (* ky (sin th)) (fabs (sin kx))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.05) {
tmp = 1.0 / sqrt(pow(sin(th), -2.0));
} else if (sin(ky) <= 2e-19) {
tmp = (ky * sin(th)) / fabs(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 = 1.0d0 / sqrt((sin(th) ** (-2.0d0)))
else if (sin(ky) <= 2d-19) then
tmp = (ky * sin(th)) / abs(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 = 1.0 / Math.sqrt(Math.pow(Math.sin(th), -2.0));
} else if (Math.sin(ky) <= 2e-19) {
tmp = (ky * Math.sin(th)) / Math.abs(Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.05: tmp = 1.0 / math.sqrt(math.pow(math.sin(th), -2.0)) elif math.sin(ky) <= 2e-19: tmp = (ky * math.sin(th)) / math.fabs(math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.05) tmp = Float64(1.0 / sqrt((sin(th) ^ -2.0))); elseif (sin(ky) <= 2e-19) tmp = Float64(Float64(ky * sin(th)) / abs(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 = 1.0 / sqrt((sin(th) ^ -2.0)); elseif (sin(ky) <= 2e-19) tmp = (ky * sin(th)) / abs(sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.05], N[(1.0 / N[Sqrt[N[Power[N[Sin[th], $MachinePrecision], -2.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-19], N[(N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.05:\\
\;\;\;\;\frac{1}{\sqrt{{\sin th}^{-2}}}\\
\mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-19}:\\
\;\;\;\;\frac{ky \cdot \sin th}{\left|\sin kx\right|}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.050000000000000003Initial program 99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
associate-*l/99.6%
associate-/l*99.6%
unpow299.6%
Simplified99.7%
Taylor expanded in kx around 0 2.9%
associate-*r/2.9%
clear-num2.9%
Applied egg-rr2.9%
add-sqr-sqrt1.8%
sqrt-unprod21.4%
pow221.4%
associate-/r*21.4%
*-inverses21.4%
Applied egg-rr21.4%
unpow221.4%
unpow-121.4%
unpow-121.4%
pow-sqr21.4%
metadata-eval21.4%
Simplified21.4%
if -0.050000000000000003 < (sin.f64 ky) < 2e-19Initial program 84.0%
unpow284.0%
sqr-neg84.0%
sin-neg84.0%
sin-neg84.0%
unpow284.0%
associate-*l/78.9%
associate-/l*84.0%
unpow284.0%
Simplified99.7%
Taylor expanded in ky around 0 51.1%
add-sqr-sqrt39.1%
sqrt-prod70.2%
rem-sqrt-square76.0%
Applied egg-rr76.0%
if 2e-19 < (sin.f64 ky) Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/99.6%
associate-/l*99.5%
unpow299.5%
Simplified99.5%
Taylor expanded in kx around 0 61.1%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.05) (* (sin ky) (/ (sin th) (fabs (sin ky)))) (* (sin th) (/ ky (hypot ky (sin kx))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.05) {
tmp = sin(ky) * (sin(th) / fabs(sin(ky)));
} else {
tmp = sin(th) * (ky / hypot(ky, sin(kx)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -0.05) {
tmp = Math.sin(ky) * (Math.sin(th) / Math.abs(Math.sin(ky)));
} else {
tmp = Math.sin(th) * (ky / Math.hypot(ky, Math.sin(kx)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.05: tmp = math.sin(ky) * (math.sin(th) / math.fabs(math.sin(ky))) else: tmp = math.sin(th) * (ky / math.hypot(ky, math.sin(kx))) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.05) tmp = Float64(sin(ky) * Float64(sin(th) / abs(sin(ky)))); else tmp = Float64(sin(th) * Float64(ky / hypot(ky, sin(kx)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.05) tmp = sin(ky) * (sin(th) / abs(sin(ky))); else tmp = sin(th) * (ky / hypot(ky, sin(kx))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.05], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Abs[N[Sin[ky], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Sqrt[ky ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.05:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\left|\sin ky\right|}\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\mathsf{hypot}\left(ky, \sin kx\right)}\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.050000000000000003Initial program 99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
associate-*l/99.6%
associate-/l*99.6%
unpow299.6%
Simplified99.7%
Taylor expanded in kx around 0 2.9%
add-sqr-sqrt0.0%
sqrt-prod65.7%
rem-sqrt-square65.7%
Applied egg-rr65.7%
if -0.050000000000000003 < (sin.f64 ky) Initial program 88.9%
+-commutative88.9%
unpow288.9%
unpow288.9%
hypot-undefine99.7%
Applied egg-rr99.7%
Taylor expanded in ky around 0 72.1%
Taylor expanded in ky around 0 81.3%
Final simplification77.4%
(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 91.6%
unpow291.6%
sqr-neg91.6%
sin-neg91.6%
sin-neg91.6%
unpow291.6%
associate-*l/88.9%
associate-/l*91.6%
unpow291.6%
Simplified99.7%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.05) (/ 1.0 (sqrt (pow (sin th) -2.0))) (if (<= (sin ky) 1e-90) (* (sin th) (/ ky (sin kx))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.05) {
tmp = 1.0 / sqrt(pow(sin(th), -2.0));
} else if (sin(ky) <= 1e-90) {
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.05d0)) then
tmp = 1.0d0 / sqrt((sin(th) ** (-2.0d0)))
else if (sin(ky) <= 1d-90) 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.05) {
tmp = 1.0 / Math.sqrt(Math.pow(Math.sin(th), -2.0));
} else if (Math.sin(ky) <= 1e-90) {
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.05: tmp = 1.0 / math.sqrt(math.pow(math.sin(th), -2.0)) elif math.sin(ky) <= 1e-90: 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.05) tmp = Float64(1.0 / sqrt((sin(th) ^ -2.0))); elseif (sin(ky) <= 1e-90) 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.05) tmp = 1.0 / sqrt((sin(th) ^ -2.0)); elseif (sin(ky) <= 1e-90) 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.05], N[(1.0 / N[Sqrt[N[Power[N[Sin[th], $MachinePrecision], -2.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-90], 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.05:\\
\;\;\;\;\frac{1}{\sqrt{{\sin th}^{-2}}}\\
\mathbf{elif}\;\sin ky \leq 10^{-90}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.050000000000000003Initial program 99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
associate-*l/99.6%
associate-/l*99.6%
unpow299.6%
Simplified99.7%
Taylor expanded in kx around 0 2.9%
associate-*r/2.9%
clear-num2.9%
Applied egg-rr2.9%
add-sqr-sqrt1.8%
sqrt-unprod21.4%
pow221.4%
associate-/r*21.4%
*-inverses21.4%
Applied egg-rr21.4%
unpow221.4%
unpow-121.4%
unpow-121.4%
pow-sqr21.4%
metadata-eval21.4%
Simplified21.4%
if -0.050000000000000003 < (sin.f64 ky) < 9.99999999999999995e-91Initial program 82.7%
Taylor expanded in ky around 0 54.0%
if 9.99999999999999995e-91 < (sin.f64 ky) Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/98.3%
associate-/l*99.6%
unpow299.6%
Simplified99.6%
Taylor expanded in kx around 0 57.4%
Final simplification46.6%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.05) (fabs (sin th)) (if (<= (sin ky) 1e-90) (* (sin th) (/ ky (sin kx))) (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) <= 1e-90) {
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.05d0)) then
tmp = abs(sin(th))
else if (sin(ky) <= 1d-90) 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.05) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(ky) <= 1e-90) {
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.05: tmp = math.fabs(math.sin(th)) elif math.sin(ky) <= 1e-90: 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.05) tmp = abs(sin(th)); elseif (sin(ky) <= 1e-90) 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.05) tmp = abs(sin(th)); elseif (sin(ky) <= 1e-90) 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.05], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-90], 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.05:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq 10^{-90}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.050000000000000003Initial program 99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
associate-*l/99.6%
associate-/l*99.6%
unpow299.6%
Simplified99.7%
Taylor expanded in kx around 0 2.9%
add-sqr-sqrt1.8%
sqrt-unprod21.7%
pow221.7%
Applied egg-rr21.7%
unpow221.7%
rem-sqrt-square26.2%
associate-*r/26.2%
*-rgt-identity26.2%
times-frac26.2%
/-rgt-identity26.2%
*-inverses26.2%
*-lft-identity26.2%
Simplified26.2%
if -0.050000000000000003 < (sin.f64 ky) < 9.99999999999999995e-91Initial program 82.7%
Taylor expanded in ky around 0 54.0%
if 9.99999999999999995e-91 < (sin.f64 ky) Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/98.3%
associate-/l*99.6%
unpow299.6%
Simplified99.6%
Taylor expanded in kx around 0 57.4%
Final simplification47.8%
(FPCore (kx ky th) :precision binary64 (if (<= th 2.7e-5) (* (/ (sin ky) (hypot (sin ky) (sin kx))) th) (* (sin th) (/ ky (hypot ky (sin kx))))))
double code(double kx, double ky, double th) {
double tmp;
if (th <= 2.7e-5) {
tmp = (sin(ky) / hypot(sin(ky), sin(kx))) * th;
} else {
tmp = sin(th) * (ky / hypot(ky, sin(kx)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (th <= 2.7e-5) {
tmp = (Math.sin(ky) / Math.hypot(Math.sin(ky), Math.sin(kx))) * th;
} else {
tmp = Math.sin(th) * (ky / Math.hypot(ky, Math.sin(kx)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if th <= 2.7e-5: tmp = (math.sin(ky) / math.hypot(math.sin(ky), math.sin(kx))) * th else: tmp = math.sin(th) * (ky / math.hypot(ky, math.sin(kx))) return tmp
function code(kx, ky, th) tmp = 0.0 if (th <= 2.7e-5) tmp = Float64(Float64(sin(ky) / hypot(sin(ky), sin(kx))) * th); else tmp = Float64(sin(th) * Float64(ky / hypot(ky, sin(kx)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (th <= 2.7e-5) tmp = (sin(ky) / hypot(sin(ky), sin(kx))) * th; else tmp = sin(th) * (ky / hypot(ky, sin(kx))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[th, 2.7e-5], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * th), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Sqrt[ky ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;th \leq 2.7 \cdot 10^{-5}:\\
\;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot th\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\mathsf{hypot}\left(ky, \sin kx\right)}\\
\end{array}
\end{array}
if th < 2.6999999999999999e-5Initial program 93.0%
+-commutative93.0%
unpow293.0%
unpow293.0%
hypot-undefine99.8%
Applied egg-rr99.8%
Taylor expanded in th around 0 70.8%
if 2.6999999999999999e-5 < th Initial program 86.0%
+-commutative86.0%
unpow286.0%
unpow286.0%
hypot-undefine99.6%
Applied egg-rr99.6%
Taylor expanded in ky around 0 46.7%
Taylor expanded in ky around 0 64.9%
Final simplification69.6%
(FPCore (kx ky th) :precision binary64 (if (<= th 2.3e-5) (* (sin ky) (/ th (hypot (sin ky) (sin kx)))) (* (sin th) (/ ky (hypot ky (sin kx))))))
double code(double kx, double ky, double th) {
double tmp;
if (th <= 2.3e-5) {
tmp = sin(ky) * (th / hypot(sin(ky), sin(kx)));
} else {
tmp = sin(th) * (ky / hypot(ky, sin(kx)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (th <= 2.3e-5) {
tmp = Math.sin(ky) * (th / Math.hypot(Math.sin(ky), Math.sin(kx)));
} else {
tmp = Math.sin(th) * (ky / Math.hypot(ky, Math.sin(kx)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if th <= 2.3e-5: tmp = math.sin(ky) * (th / math.hypot(math.sin(ky), math.sin(kx))) else: tmp = math.sin(th) * (ky / math.hypot(ky, math.sin(kx))) return tmp
function code(kx, ky, th) tmp = 0.0 if (th <= 2.3e-5) tmp = Float64(sin(ky) * Float64(th / hypot(sin(ky), sin(kx)))); else tmp = Float64(sin(th) * Float64(ky / hypot(ky, sin(kx)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (th <= 2.3e-5) tmp = sin(ky) * (th / hypot(sin(ky), sin(kx))); else tmp = sin(th) * (ky / hypot(ky, sin(kx))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[th, 2.3e-5], N[(N[Sin[ky], $MachinePrecision] * N[(th / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Sqrt[ky ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;th \leq 2.3 \cdot 10^{-5}:\\
\;\;\;\;\sin ky \cdot \frac{th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\mathsf{hypot}\left(ky, \sin kx\right)}\\
\end{array}
\end{array}
if th < 2.3e-5Initial program 93.0%
unpow293.0%
sqr-neg93.0%
sin-neg93.0%
sin-neg93.0%
unpow293.0%
associate-*l/89.8%
associate-/l*93.0%
unpow293.0%
Simplified99.7%
Taylor expanded in th around 0 70.7%
if 2.3e-5 < th Initial program 86.0%
+-commutative86.0%
unpow286.0%
unpow286.0%
hypot-undefine99.6%
Applied egg-rr99.6%
Taylor expanded in ky around 0 46.7%
Taylor expanded in ky around 0 64.9%
Final simplification69.6%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.05) (/ (sin ky) (/ (hypot (sin ky) kx) th)) (* (sin th) (/ ky (hypot ky (sin kx))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.05) {
tmp = sin(ky) / (hypot(sin(ky), kx) / th);
} else {
tmp = sin(th) * (ky / hypot(ky, sin(kx)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -0.05) {
tmp = Math.sin(ky) / (Math.hypot(Math.sin(ky), kx) / th);
} else {
tmp = Math.sin(th) * (ky / Math.hypot(ky, Math.sin(kx)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.05: tmp = math.sin(ky) / (math.hypot(math.sin(ky), kx) / th) else: tmp = math.sin(th) * (ky / math.hypot(ky, math.sin(kx))) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.05) tmp = Float64(sin(ky) / Float64(hypot(sin(ky), kx) / th)); else tmp = Float64(sin(th) * Float64(ky / hypot(ky, sin(kx)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.05) tmp = sin(ky) / (hypot(sin(ky), kx) / th); else tmp = sin(th) * (ky / hypot(ky, sin(kx))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.05], N[(N[Sin[ky], $MachinePrecision] / N[(N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + kx ^ 2], $MachinePrecision] / th), $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Sqrt[ky ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.05:\\
\;\;\;\;\frac{\sin ky}{\frac{\mathsf{hypot}\left(\sin ky, kx\right)}{th}}\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\mathsf{hypot}\left(ky, \sin kx\right)}\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.050000000000000003Initial program 99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
associate-*l/99.6%
associate-/l*99.6%
unpow299.6%
Simplified99.7%
clear-num99.5%
un-div-inv99.6%
Applied egg-rr99.6%
Taylor expanded in th around 0 59.2%
Taylor expanded in kx around 0 33.8%
if -0.050000000000000003 < (sin.f64 ky) Initial program 88.9%
+-commutative88.9%
unpow288.9%
unpow288.9%
hypot-undefine99.7%
Applied egg-rr99.7%
Taylor expanded in ky around 0 72.1%
Taylor expanded in ky around 0 81.3%
Final simplification69.3%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.1) (/ 1.0 (sqrt (pow (sin th) -2.0))) (* (sin th) (/ ky (hypot ky (sin kx))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.1) {
tmp = 1.0 / sqrt(pow(sin(th), -2.0));
} else {
tmp = sin(th) * (ky / hypot(ky, sin(kx)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -0.1) {
tmp = 1.0 / Math.sqrt(Math.pow(Math.sin(th), -2.0));
} else {
tmp = Math.sin(th) * (ky / Math.hypot(ky, Math.sin(kx)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.1: tmp = 1.0 / math.sqrt(math.pow(math.sin(th), -2.0)) else: tmp = math.sin(th) * (ky / math.hypot(ky, math.sin(kx))) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.1) tmp = Float64(1.0 / sqrt((sin(th) ^ -2.0))); else tmp = Float64(sin(th) * Float64(ky / hypot(ky, sin(kx)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.1) tmp = 1.0 / sqrt((sin(th) ^ -2.0)); else tmp = sin(th) * (ky / hypot(ky, sin(kx))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.1], N[(1.0 / N[Sqrt[N[Power[N[Sin[th], $MachinePrecision], -2.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Sqrt[ky ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.1:\\
\;\;\;\;\frac{1}{\sqrt{{\sin th}^{-2}}}\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\mathsf{hypot}\left(ky, \sin kx\right)}\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.10000000000000001Initial program 99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
associate-*l/99.6%
associate-/l*99.6%
unpow299.6%
Simplified99.7%
Taylor expanded in kx around 0 3.0%
associate-*r/3.0%
clear-num3.0%
Applied egg-rr3.0%
add-sqr-sqrt1.8%
sqrt-unprod22.0%
pow222.0%
associate-/r*22.0%
*-inverses22.0%
Applied egg-rr22.0%
unpow222.0%
unpow-122.0%
unpow-122.0%
pow-sqr22.0%
metadata-eval22.0%
Simplified22.0%
if -0.10000000000000001 < (sin.f64 ky) Initial program 89.0%
+-commutative89.0%
unpow289.0%
unpow289.0%
hypot-undefine99.7%
Applied egg-rr99.7%
Taylor expanded in ky around 0 71.4%
Taylor expanded in ky around 0 81.0%
Final simplification66.5%
(FPCore (kx ky th) :precision binary64 (if (<= ky 4.2e-90) (* ky (/ (sin th) (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 4.2e-90) {
tmp = ky * (sin(th) / sin(kx));
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (ky <= 4.2d-90) then
tmp = ky * (sin(th) / sin(kx))
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= 4.2e-90) {
tmp = ky * (Math.sin(th) / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 4.2e-90: tmp = ky * (math.sin(th) / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 4.2e-90) tmp = Float64(ky * Float64(sin(th) / sin(kx))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 4.2e-90) tmp = ky * (sin(th) / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 4.2e-90], N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 4.2 \cdot 10^{-90}:\\
\;\;\;\;ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 4.1999999999999998e-90Initial program 88.4%
unpow288.4%
sqr-neg88.4%
sin-neg88.4%
sin-neg88.4%
unpow288.4%
associate-*l/85.1%
associate-/l*88.3%
unpow288.3%
Simplified99.7%
Taylor expanded in ky around 0 35.6%
associate-/l*37.2%
Simplified37.2%
if 4.1999999999999998e-90 < ky Initial program 99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
associate-*l/98.4%
associate-/l*99.6%
unpow299.6%
Simplified99.6%
Taylor expanded in kx around 0 34.3%
(FPCore (kx ky th) :precision binary64 (if (<= ky 4.2e-90) (/ (* ky (sin th)) kx) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 4.2e-90) {
tmp = (ky * sin(th)) / kx;
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (ky <= 4.2d-90) then
tmp = (ky * sin(th)) / kx
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= 4.2e-90) {
tmp = (ky * Math.sin(th)) / kx;
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 4.2e-90: tmp = (ky * math.sin(th)) / kx else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 4.2e-90) tmp = Float64(Float64(ky * sin(th)) / kx); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 4.2e-90) tmp = (ky * sin(th)) / kx; else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 4.2e-90], N[(N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision] / kx), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 4.2 \cdot 10^{-90}:\\
\;\;\;\;\frac{ky \cdot \sin th}{kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 4.1999999999999998e-90Initial program 88.4%
unpow288.4%
sqr-neg88.4%
sin-neg88.4%
sin-neg88.4%
unpow288.4%
associate-*l/85.1%
associate-/l*88.3%
unpow288.3%
Simplified99.7%
Taylor expanded in ky around 0 35.6%
Taylor expanded in kx around 0 26.9%
if 4.1999999999999998e-90 < ky Initial program 99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
associate-*l/98.4%
associate-/l*99.6%
unpow299.6%
Simplified99.6%
Taylor expanded in kx around 0 34.3%
(FPCore (kx ky th) :precision binary64 (if (<= ky 1.52e-90) (* ky (/ th (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 1.52e-90) {
tmp = ky * (th / sin(kx));
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (ky <= 1.52d-90) then
tmp = ky * (th / sin(kx))
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= 1.52e-90) {
tmp = ky * (th / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 1.52e-90: tmp = ky * (th / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 1.52e-90) tmp = Float64(ky * Float64(th / sin(kx))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 1.52e-90) tmp = ky * (th / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 1.52e-90], N[(ky * N[(th / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 1.52 \cdot 10^{-90}:\\
\;\;\;\;ky \cdot \frac{th}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 1.51999999999999991e-90Initial program 88.4%
unpow288.4%
sqr-neg88.4%
sin-neg88.4%
sin-neg88.4%
unpow288.4%
associate-*l/85.1%
associate-/l*88.3%
unpow288.3%
Simplified99.7%
clear-num99.5%
un-div-inv99.7%
Applied egg-rr99.7%
Taylor expanded in th around 0 58.9%
Taylor expanded in ky around 0 24.6%
associate-/l*26.0%
Simplified26.0%
if 1.51999999999999991e-90 < ky Initial program 99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
associate-*l/98.4%
associate-/l*99.6%
unpow299.6%
Simplified99.6%
Taylor expanded in kx around 0 34.3%
(FPCore (kx ky th) :precision binary64 (sin th))
double code(double kx, double ky, double th) {
return sin(th);
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = sin(th)
end function
public static double code(double kx, double ky, double th) {
return Math.sin(th);
}
def code(kx, ky, th): return math.sin(th)
function code(kx, ky, th) return sin(th) end
function tmp = code(kx, ky, th) tmp = sin(th); end
code[kx_, ky_, th_] := N[Sin[th], $MachinePrecision]
\begin{array}{l}
\\
\sin th
\end{array}
Initial program 91.6%
unpow291.6%
sqr-neg91.6%
sin-neg91.6%
sin-neg91.6%
unpow291.6%
associate-*l/88.9%
associate-/l*91.6%
unpow291.6%
Simplified99.7%
Taylor expanded in kx around 0 20.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 91.6%
unpow291.6%
sqr-neg91.6%
sin-neg91.6%
sin-neg91.6%
unpow291.6%
associate-*l/88.9%
associate-/l*91.6%
unpow291.6%
Simplified99.7%
Taylor expanded in kx around 0 20.7%
Taylor expanded in th around 0 12.9%
herbie shell --seed 2024123
(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)))