
(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 14 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.9%
remove-double-neg93.9%
sin-neg93.9%
neg-mul-193.9%
*-commutative93.9%
associate-*l*93.9%
associate-*l/91.4%
associate-/r/91.4%
associate-*l/93.9%
associate-/r/93.9%
sin-neg93.9%
neg-mul-193.9%
associate-/r*93.9%
associate-/r/93.9%
Simplified99.7%
Final simplification99.7%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -0.002)
(/ 1.0 (sqrt (pow (sin th) -2.0)))
(if (or (<= (sin ky) 5e-132)
(and (not (<= (sin ky) 5e-121)) (<= (sin ky) 5e-44)))
(* (sin th) (fabs (/ (sin ky) (sin kx))))
(sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.002) {
tmp = 1.0 / sqrt(pow(sin(th), -2.0));
} else if ((sin(ky) <= 5e-132) || (!(sin(ky) <= 5e-121) && (sin(ky) <= 5e-44))) {
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.002d0)) then
tmp = 1.0d0 / sqrt((sin(th) ** (-2.0d0)))
else if ((sin(ky) <= 5d-132) .or. (.not. (sin(ky) <= 5d-121)) .and. (sin(ky) <= 5d-44)) 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.002) {
tmp = 1.0 / Math.sqrt(Math.pow(Math.sin(th), -2.0));
} else if ((Math.sin(ky) <= 5e-132) || (!(Math.sin(ky) <= 5e-121) && (Math.sin(ky) <= 5e-44))) {
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.002: tmp = 1.0 / math.sqrt(math.pow(math.sin(th), -2.0)) elif (math.sin(ky) <= 5e-132) or (not (math.sin(ky) <= 5e-121) and (math.sin(ky) <= 5e-44)): 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.002) tmp = Float64(1.0 / sqrt((sin(th) ^ -2.0))); elseif ((sin(ky) <= 5e-132) || (!(sin(ky) <= 5e-121) && (sin(ky) <= 5e-44))) 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.002) tmp = 1.0 / sqrt((sin(th) ^ -2.0)); elseif ((sin(ky) <= 5e-132) || (~((sin(ky) <= 5e-121)) && (sin(ky) <= 5e-44))) 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.002], N[(1.0 / N[Sqrt[N[Power[N[Sin[th], $MachinePrecision], -2.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[N[Sin[ky], $MachinePrecision], 5e-132], And[N[Not[LessEqual[N[Sin[ky], $MachinePrecision], 5e-121]], $MachinePrecision], LessEqual[N[Sin[ky], $MachinePrecision], 5e-44]]], 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.002:\\
\;\;\;\;\frac{1}{\sqrt{{\sin th}^{-2}}}\\
\mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-132} \lor \neg \left(\sin ky \leq 5 \cdot 10^{-121}\right) \land \sin ky \leq 5 \cdot 10^{-44}:\\
\;\;\;\;\sin th \cdot \left|\frac{\sin ky}{\sin kx}\right|\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -2e-3Initial program 99.8%
remove-double-neg99.8%
sin-neg99.8%
neg-mul-199.8%
*-commutative99.8%
associate-*l*99.8%
associate-*l/99.6%
associate-/r/99.6%
associate-*l/99.8%
associate-/r/99.8%
sin-neg99.8%
neg-mul-199.8%
associate-/r*99.8%
associate-/r/99.8%
Simplified99.8%
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 2.4%
add-sqr-sqrt1.5%
sqrt-unprod19.8%
inv-pow19.8%
inv-pow19.8%
pow-prod-up19.8%
metadata-eval19.8%
Applied egg-rr19.8%
if -2e-3 < (sin.f64 ky) < 4.9999999999999999e-132 or 4.99999999999999989e-121 < (sin.f64 ky) < 5.00000000000000039e-44Initial program 87.0%
Taylor expanded in ky around 0 41.8%
add-sqr-sqrt19.5%
sqrt-unprod33.7%
pow233.7%
Applied egg-rr33.7%
unpow233.7%
rem-sqrt-square41.7%
Simplified41.7%
if 4.9999999999999999e-132 < (sin.f64 ky) < 4.99999999999999989e-121 or 5.00000000000000039e-44 < (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/98.6%
associate-/r/98.6%
associate-*l/99.7%
associate-/r/99.6%
sin-neg99.6%
neg-mul-199.6%
associate-/r*99.6%
associate-/r/99.7%
Simplified99.7%
Taylor expanded in kx around 0 56.7%
Final simplification41.3%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -0.002)
(/ 1.0 (sqrt (pow (sin th) -2.0)))
(if (or (<= (sin ky) 1e-135)
(and (not (<= (sin ky) 5e-121)) (<= (sin ky) 5e-99)))
(fabs (* (sin th) (/ ky (sin kx))))
(sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.002) {
tmp = 1.0 / sqrt(pow(sin(th), -2.0));
} else if ((sin(ky) <= 1e-135) || (!(sin(ky) <= 5e-121) && (sin(ky) <= 5e-99))) {
tmp = fabs((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.002d0)) then
tmp = 1.0d0 / sqrt((sin(th) ** (-2.0d0)))
else if ((sin(ky) <= 1d-135) .or. (.not. (sin(ky) <= 5d-121)) .and. (sin(ky) <= 5d-99)) then
tmp = abs((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.002) {
tmp = 1.0 / Math.sqrt(Math.pow(Math.sin(th), -2.0));
} else if ((Math.sin(ky) <= 1e-135) || (!(Math.sin(ky) <= 5e-121) && (Math.sin(ky) <= 5e-99))) {
tmp = Math.abs((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.002: tmp = 1.0 / math.sqrt(math.pow(math.sin(th), -2.0)) elif (math.sin(ky) <= 1e-135) or (not (math.sin(ky) <= 5e-121) and (math.sin(ky) <= 5e-99)): tmp = math.fabs((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.002) tmp = Float64(1.0 / sqrt((sin(th) ^ -2.0))); elseif ((sin(ky) <= 1e-135) || (!(sin(ky) <= 5e-121) && (sin(ky) <= 5e-99))) tmp = abs(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.002) tmp = 1.0 / sqrt((sin(th) ^ -2.0)); elseif ((sin(ky) <= 1e-135) || (~((sin(ky) <= 5e-121)) && (sin(ky) <= 5e-99))) tmp = abs((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.002], N[(1.0 / N[Sqrt[N[Power[N[Sin[th], $MachinePrecision], -2.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[N[Sin[ky], $MachinePrecision], 1e-135], And[N[Not[LessEqual[N[Sin[ky], $MachinePrecision], 5e-121]], $MachinePrecision], LessEqual[N[Sin[ky], $MachinePrecision], 5e-99]]], N[Abs[N[(N[Sin[th], $MachinePrecision] * 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.002:\\
\;\;\;\;\frac{1}{\sqrt{{\sin th}^{-2}}}\\
\mathbf{elif}\;\sin ky \leq 10^{-135} \lor \neg \left(\sin ky \leq 5 \cdot 10^{-121}\right) \land \sin ky \leq 5 \cdot 10^{-99}:\\
\;\;\;\;\left|\sin th \cdot \frac{ky}{\sin kx}\right|\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -2e-3Initial program 99.8%
remove-double-neg99.8%
sin-neg99.8%
neg-mul-199.8%
*-commutative99.8%
associate-*l*99.8%
associate-*l/99.6%
associate-/r/99.6%
associate-*l/99.8%
associate-/r/99.8%
sin-neg99.8%
neg-mul-199.8%
associate-/r*99.8%
associate-/r/99.8%
Simplified99.8%
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 2.4%
add-sqr-sqrt1.5%
sqrt-unprod19.8%
inv-pow19.8%
inv-pow19.8%
pow-prod-up19.8%
metadata-eval19.8%
Applied egg-rr19.8%
if -2e-3 < (sin.f64 ky) < 1e-135 or 4.99999999999999989e-121 < (sin.f64 ky) < 4.99999999999999969e-99Initial program 86.2%
Taylor expanded in ky around 0 40.8%
Taylor expanded in ky around inf 37.7%
*-commutative37.7%
associate-/l*40.8%
associate-/r/40.8%
Simplified40.8%
*-commutative40.8%
associate-*r/37.7%
associate-*l/40.8%
rem-log-exp22.7%
add-sqr-sqrt22.5%
sqrt-unprod23.0%
pow223.0%
*-commutative23.0%
rem-log-exp31.8%
Applied egg-rr31.8%
unpow231.8%
rem-sqrt-square50.2%
Simplified50.2%
Taylor expanded in ky around 0 50.2%
if 1e-135 < (sin.f64 ky) < 4.99999999999999989e-121 or 4.99999999999999969e-99 < (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/98.7%
associate-/r/98.7%
associate-*l/99.7%
associate-/r/99.6%
sin-neg99.6%
neg-mul-199.6%
associate-/r*99.6%
associate-/r/99.7%
Simplified99.7%
Taylor expanded in kx around 0 54.8%
Final simplification44.8%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin th) -0.48)
(* (sin th) (fabs (/ (sin ky) (sin kx))))
(if (<= (sin th) -0.01)
(sin th)
(if (<= (sin th) 0.02)
(/ (sin ky) (/ (hypot (sin kx) (sin ky)) th))
(* (sin ky) (fabs (/ (sin th) (sin kx))))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(th) <= -0.48) {
tmp = sin(th) * fabs((sin(ky) / sin(kx)));
} else if (sin(th) <= -0.01) {
tmp = sin(th);
} else if (sin(th) <= 0.02) {
tmp = sin(ky) / (hypot(sin(kx), sin(ky)) / th);
} else {
tmp = sin(ky) * fabs((sin(th) / sin(kx)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(th) <= -0.48) {
tmp = Math.sin(th) * Math.abs((Math.sin(ky) / Math.sin(kx)));
} else if (Math.sin(th) <= -0.01) {
tmp = Math.sin(th);
} else if (Math.sin(th) <= 0.02) {
tmp = Math.sin(ky) / (Math.hypot(Math.sin(kx), Math.sin(ky)) / th);
} else {
tmp = Math.sin(ky) * Math.abs((Math.sin(th) / Math.sin(kx)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(th) <= -0.48: tmp = math.sin(th) * math.fabs((math.sin(ky) / math.sin(kx))) elif math.sin(th) <= -0.01: tmp = math.sin(th) elif math.sin(th) <= 0.02: tmp = math.sin(ky) / (math.hypot(math.sin(kx), math.sin(ky)) / th) else: tmp = math.sin(ky) * math.fabs((math.sin(th) / math.sin(kx))) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(th) <= -0.48) tmp = Float64(sin(th) * abs(Float64(sin(ky) / sin(kx)))); elseif (sin(th) <= -0.01) tmp = sin(th); elseif (sin(th) <= 0.02) tmp = Float64(sin(ky) / Float64(hypot(sin(kx), sin(ky)) / th)); else tmp = Float64(sin(ky) * abs(Float64(sin(th) / sin(kx)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(th) <= -0.48) tmp = sin(th) * abs((sin(ky) / sin(kx))); elseif (sin(th) <= -0.01) tmp = sin(th); elseif (sin(th) <= 0.02) tmp = sin(ky) / (hypot(sin(kx), sin(ky)) / th); else tmp = sin(ky) * abs((sin(th) / sin(kx))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[th], $MachinePrecision], -0.48], N[(N[Sin[th], $MachinePrecision] * N[Abs[N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[th], $MachinePrecision], -0.01], N[Sin[th], $MachinePrecision], If[LessEqual[N[Sin[th], $MachinePrecision], 0.02], N[(N[Sin[ky], $MachinePrecision] / N[(N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision] / th), $MachinePrecision]), $MachinePrecision], N[(N[Sin[ky], $MachinePrecision] * N[Abs[N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin th \leq -0.48:\\
\;\;\;\;\sin th \cdot \left|\frac{\sin ky}{\sin kx}\right|\\
\mathbf{elif}\;\sin th \leq -0.01:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;\sin th \leq 0.02:\\
\;\;\;\;\frac{\sin ky}{\frac{\mathsf{hypot}\left(\sin kx, \sin ky\right)}{th}}\\
\mathbf{else}:\\
\;\;\;\;\sin ky \cdot \left|\frac{\sin th}{\sin kx}\right|\\
\end{array}
\end{array}
if (sin.f64 th) < -0.47999999999999998Initial program 97.5%
Taylor expanded in ky around 0 14.4%
add-sqr-sqrt4.8%
sqrt-unprod13.8%
pow213.8%
Applied egg-rr13.8%
unpow213.8%
rem-sqrt-square21.6%
Simplified21.6%
if -0.47999999999999998 < (sin.f64 th) < -0.0100000000000000002Initial program 92.2%
remove-double-neg92.2%
sin-neg92.2%
neg-mul-192.2%
*-commutative92.2%
associate-*l*92.2%
associate-*l/92.3%
associate-/r/92.3%
associate-*l/92.2%
associate-/r/92.3%
sin-neg92.3%
neg-mul-192.3%
associate-/r*92.3%
associate-/r/92.2%
Simplified99.6%
Taylor expanded in kx around 0 28.5%
if -0.0100000000000000002 < (sin.f64 th) < 0.0200000000000000004Initial program 92.4%
remove-double-neg92.4%
sin-neg92.4%
neg-mul-192.4%
*-commutative92.4%
associate-*l*92.4%
associate-*l/87.6%
associate-/r/87.6%
associate-*l/92.4%
associate-/r/92.4%
sin-neg92.4%
neg-mul-192.4%
associate-/r*92.4%
associate-/r/92.4%
Simplified99.7%
expm1-log1p-u99.7%
expm1-udef22.7%
hypot-udef21.2%
unpow221.2%
unpow221.2%
+-commutative21.2%
unpow221.2%
unpow221.2%
hypot-def22.7%
Applied egg-rr22.7%
expm1-def99.7%
expm1-log1p99.7%
associate-/r/99.7%
hypot-def92.4%
unpow292.4%
unpow292.4%
+-commutative92.4%
unpow292.4%
unpow292.4%
hypot-def99.7%
Simplified99.7%
Taylor expanded in th around 0 91.0%
associate-*l/91.2%
+-commutative91.2%
unpow291.2%
unpow291.2%
hypot-def98.4%
*-lft-identity98.4%
hypot-def91.2%
unpow291.2%
unpow291.2%
+-commutative91.2%
unpow291.2%
unpow291.2%
hypot-def98.4%
Simplified98.4%
if 0.0200000000000000004 < (sin.f64 th) Initial program 95.0%
Taylor expanded in ky around 0 20.5%
Taylor expanded in ky around inf 20.4%
*-commutative20.4%
associate-/l*20.5%
associate-/r/20.4%
Simplified20.4%
add-sqr-sqrt19.2%
sqrt-unprod40.1%
pow240.1%
Applied egg-rr40.1%
unpow240.1%
rem-sqrt-square42.2%
Simplified42.2%
Final simplification67.4%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (* (sin th) (/ (sin ky) (sin kx)))))
(if (<= (sin kx) 5e-306)
(fabs t_1)
(if (<= (sin kx) 5e-19) (/ 1.0 (/ (sin ky) (* (sin ky) (sin th)))) t_1))))
double code(double kx, double ky, double th) {
double t_1 = sin(th) * (sin(ky) / sin(kx));
double tmp;
if (sin(kx) <= 5e-306) {
tmp = fabs(t_1);
} else if (sin(kx) <= 5e-19) {
tmp = 1.0 / (sin(ky) / (sin(ky) * sin(th)));
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: tmp
t_1 = sin(th) * (sin(ky) / sin(kx))
if (sin(kx) <= 5d-306) then
tmp = abs(t_1)
else if (sin(kx) <= 5d-19) then
tmp = 1.0d0 / (sin(ky) / (sin(ky) * sin(th)))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double t_1 = Math.sin(th) * (Math.sin(ky) / Math.sin(kx));
double tmp;
if (Math.sin(kx) <= 5e-306) {
tmp = Math.abs(t_1);
} else if (Math.sin(kx) <= 5e-19) {
tmp = 1.0 / (Math.sin(ky) / (Math.sin(ky) * Math.sin(th)));
} else {
tmp = t_1;
}
return tmp;
}
def code(kx, ky, th): t_1 = math.sin(th) * (math.sin(ky) / math.sin(kx)) tmp = 0 if math.sin(kx) <= 5e-306: tmp = math.fabs(t_1) elif math.sin(kx) <= 5e-19: tmp = 1.0 / (math.sin(ky) / (math.sin(ky) * math.sin(th))) else: tmp = t_1 return tmp
function code(kx, ky, th) t_1 = Float64(sin(th) * Float64(sin(ky) / sin(kx))) tmp = 0.0 if (sin(kx) <= 5e-306) tmp = abs(t_1); elseif (sin(kx) <= 5e-19) tmp = Float64(1.0 / Float64(sin(ky) / Float64(sin(ky) * sin(th)))); else tmp = t_1; end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = sin(th) * (sin(ky) / sin(kx)); tmp = 0.0; if (sin(kx) <= 5e-306) tmp = abs(t_1); elseif (sin(kx) <= 5e-19) tmp = 1.0 / (sin(ky) / (sin(ky) * sin(th))); else tmp = t_1; end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Sin[kx], $MachinePrecision], 5e-306], N[Abs[t$95$1], $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 5e-19], N[(1.0 / N[(N[Sin[ky], $MachinePrecision] / N[(N[Sin[ky], $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \sin th \cdot \frac{\sin ky}{\sin kx}\\
\mathbf{if}\;\sin kx \leq 5 \cdot 10^{-306}:\\
\;\;\;\;\left|t_1\right|\\
\mathbf{elif}\;\sin kx \leq 5 \cdot 10^{-19}:\\
\;\;\;\;\frac{1}{\frac{\sin ky}{\sin ky \cdot \sin th}}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if (sin.f64 kx) < 4.99999999999999998e-306Initial program 94.7%
Taylor expanded in ky around 0 12.9%
Taylor expanded in ky around inf 13.0%
*-commutative13.0%
associate-/l*12.9%
associate-/r/12.9%
Simplified12.9%
*-commutative12.9%
associate-*r/13.0%
associate-*l/12.9%
rem-log-exp13.1%
add-sqr-sqrt12.6%
sqrt-unprod15.4%
pow215.4%
*-commutative15.4%
rem-log-exp21.1%
Applied egg-rr21.1%
unpow221.1%
rem-sqrt-square29.0%
Simplified29.0%
if 4.99999999999999998e-306 < (sin.f64 kx) < 5.0000000000000004e-19Initial program 86.8%
remove-double-neg86.8%
sin-neg86.8%
neg-mul-186.8%
*-commutative86.8%
associate-*l*86.8%
associate-*l/82.4%
associate-/r/82.4%
associate-*l/86.8%
associate-/r/86.7%
sin-neg86.7%
neg-mul-186.7%
associate-/r*86.7%
associate-/r/86.8%
Simplified99.9%
associate-*l/92.5%
clear-num92.1%
hypot-udef82.0%
unpow282.0%
unpow282.0%
+-commutative82.0%
unpow282.0%
unpow282.0%
hypot-def92.1%
Applied egg-rr92.1%
Taylor expanded in kx around 0 38.0%
if 5.0000000000000004e-19 < (sin.f64 kx) Initial program 99.5%
Taylor expanded in ky around 0 55.0%
Final simplification36.7%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin kx) 5e-306)
(fabs (* (sin ky) (/ (sin th) (sin kx))))
(if (<= (sin kx) 5e-19)
(/ 1.0 (/ (sin ky) (* (sin ky) (sin th))))
(* (sin th) (/ (sin ky) (sin kx))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(kx) <= 5e-306) {
tmp = fabs((sin(ky) * (sin(th) / sin(kx))));
} else if (sin(kx) <= 5e-19) {
tmp = 1.0 / (sin(ky) / (sin(ky) * sin(th)));
} else {
tmp = sin(th) * (sin(ky) / sin(kx));
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(kx) <= 5d-306) then
tmp = abs((sin(ky) * (sin(th) / sin(kx))))
else if (sin(kx) <= 5d-19) then
tmp = 1.0d0 / (sin(ky) / (sin(ky) * sin(th)))
else
tmp = sin(th) * (sin(ky) / sin(kx))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(kx) <= 5e-306) {
tmp = Math.abs((Math.sin(ky) * (Math.sin(th) / Math.sin(kx))));
} else if (Math.sin(kx) <= 5e-19) {
tmp = 1.0 / (Math.sin(ky) / (Math.sin(ky) * Math.sin(th)));
} else {
tmp = Math.sin(th) * (Math.sin(ky) / Math.sin(kx));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(kx) <= 5e-306: tmp = math.fabs((math.sin(ky) * (math.sin(th) / math.sin(kx)))) elif math.sin(kx) <= 5e-19: tmp = 1.0 / (math.sin(ky) / (math.sin(ky) * math.sin(th))) else: tmp = math.sin(th) * (math.sin(ky) / math.sin(kx)) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(kx) <= 5e-306) tmp = abs(Float64(sin(ky) * Float64(sin(th) / sin(kx)))); elseif (sin(kx) <= 5e-19) tmp = Float64(1.0 / Float64(sin(ky) / Float64(sin(ky) * sin(th)))); else tmp = Float64(sin(th) * Float64(sin(ky) / sin(kx))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(kx) <= 5e-306) tmp = abs((sin(ky) * (sin(th) / sin(kx)))); elseif (sin(kx) <= 5e-19) tmp = 1.0 / (sin(ky) / (sin(ky) * sin(th))); else tmp = sin(th) * (sin(ky) / sin(kx)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[kx], $MachinePrecision], 5e-306], N[Abs[N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 5e-19], N[(1.0 / N[(N[Sin[ky], $MachinePrecision] / N[(N[Sin[ky], $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin kx \leq 5 \cdot 10^{-306}:\\
\;\;\;\;\left|\sin ky \cdot \frac{\sin th}{\sin kx}\right|\\
\mathbf{elif}\;\sin kx \leq 5 \cdot 10^{-19}:\\
\;\;\;\;\frac{1}{\frac{\sin ky}{\sin ky \cdot \sin th}}\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\
\end{array}
\end{array}
if (sin.f64 kx) < 4.99999999999999998e-306Initial program 94.7%
Taylor expanded in ky around 0 12.9%
add-sqr-sqrt11.8%
sqrt-unprod21.1%
pow221.1%
*-commutative21.1%
Applied egg-rr21.1%
unpow221.1%
rem-sqrt-square29.0%
associate-*r/27.8%
associate-/l*29.0%
associate-/r/29.1%
Simplified29.1%
if 4.99999999999999998e-306 < (sin.f64 kx) < 5.0000000000000004e-19Initial program 86.8%
remove-double-neg86.8%
sin-neg86.8%
neg-mul-186.8%
*-commutative86.8%
associate-*l*86.8%
associate-*l/82.4%
associate-/r/82.4%
associate-*l/86.8%
associate-/r/86.7%
sin-neg86.7%
neg-mul-186.7%
associate-/r*86.7%
associate-/r/86.8%
Simplified99.9%
associate-*l/92.5%
clear-num92.1%
hypot-udef82.0%
unpow282.0%
unpow282.0%
+-commutative82.0%
unpow282.0%
unpow282.0%
hypot-def92.1%
Applied egg-rr92.1%
Taylor expanded in kx around 0 38.0%
if 5.0000000000000004e-19 < (sin.f64 kx) Initial program 99.5%
Taylor expanded in ky around 0 55.0%
Final simplification36.7%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.002) (fabs (sin th)) (if (<= (sin ky) 5e-139) (* (sin th) (/ ky (sin kx))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.002) {
tmp = fabs(sin(th));
} else if (sin(ky) <= 5e-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.002d0)) then
tmp = abs(sin(th))
else if (sin(ky) <= 5d-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.002) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(ky) <= 5e-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.002: tmp = math.fabs(math.sin(th)) elif math.sin(ky) <= 5e-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.002) tmp = abs(sin(th)); elseif (sin(ky) <= 5e-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.002) tmp = abs(sin(th)); elseif (sin(ky) <= 5e-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.002], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 5e-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.002:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-139}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -2e-3Initial program 99.8%
remove-double-neg99.8%
sin-neg99.8%
neg-mul-199.8%
*-commutative99.8%
associate-*l*99.8%
associate-*l/99.6%
associate-/r/99.6%
associate-*l/99.8%
associate-/r/99.8%
sin-neg99.8%
neg-mul-199.8%
associate-/r*99.8%
associate-/r/99.8%
Simplified99.8%
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 2.4%
remove-double-div2.4%
add-sqr-sqrt1.5%
sqrt-unprod19.8%
pow219.8%
Applied egg-rr19.8%
unpow219.8%
rem-sqrt-square26.2%
Simplified26.2%
if -2e-3 < (sin.f64 ky) < 5.00000000000000034e-139Initial program 85.7%
Taylor expanded in ky around 0 41.3%
if 5.00000000000000034e-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/98.7%
associate-/r/98.7%
associate-*l/99.7%
associate-/r/99.6%
sin-neg99.6%
neg-mul-199.6%
associate-/r*99.6%
associate-/r/99.7%
Simplified99.7%
Taylor expanded in kx around 0 53.7%
Final simplification42.2%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.002) (/ 1.0 (sqrt (pow (sin th) -2.0))) (if (<= (sin ky) 5e-139) (* (sin th) (/ ky (sin kx))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.002) {
tmp = 1.0 / sqrt(pow(sin(th), -2.0));
} else if (sin(ky) <= 5e-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.002d0)) then
tmp = 1.0d0 / sqrt((sin(th) ** (-2.0d0)))
else if (sin(ky) <= 5d-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.002) {
tmp = 1.0 / Math.sqrt(Math.pow(Math.sin(th), -2.0));
} else if (Math.sin(ky) <= 5e-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.002: tmp = 1.0 / math.sqrt(math.pow(math.sin(th), -2.0)) elif math.sin(ky) <= 5e-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.002) tmp = Float64(1.0 / sqrt((sin(th) ^ -2.0))); elseif (sin(ky) <= 5e-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.002) tmp = 1.0 / sqrt((sin(th) ^ -2.0)); elseif (sin(ky) <= 5e-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.002], N[(1.0 / N[Sqrt[N[Power[N[Sin[th], $MachinePrecision], -2.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 5e-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.002:\\
\;\;\;\;\frac{1}{\sqrt{{\sin th}^{-2}}}\\
\mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-139}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -2e-3Initial program 99.8%
remove-double-neg99.8%
sin-neg99.8%
neg-mul-199.8%
*-commutative99.8%
associate-*l*99.8%
associate-*l/99.6%
associate-/r/99.6%
associate-*l/99.8%
associate-/r/99.8%
sin-neg99.8%
neg-mul-199.8%
associate-/r*99.8%
associate-/r/99.8%
Simplified99.8%
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 2.4%
add-sqr-sqrt1.5%
sqrt-unprod19.8%
inv-pow19.8%
inv-pow19.8%
pow-prod-up19.8%
metadata-eval19.8%
Applied egg-rr19.8%
if -2e-3 < (sin.f64 ky) < 5.00000000000000034e-139Initial program 85.7%
Taylor expanded in ky around 0 41.3%
if 5.00000000000000034e-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/98.7%
associate-/r/98.7%
associate-*l/99.7%
associate-/r/99.6%
sin-neg99.6%
neg-mul-199.6%
associate-/r*99.6%
associate-/r/99.7%
Simplified99.7%
Taylor expanded in kx around 0 53.7%
Final simplification40.7%
(FPCore (kx ky th) :precision binary64 (let* ((t_1 (hypot (sin kx) (sin ky)))) (if (<= th 0.21) (/ (sin ky) (/ t_1 th)) (/ 1.0 (/ t_1 (* ky (sin th)))))))
double code(double kx, double ky, double th) {
double t_1 = hypot(sin(kx), sin(ky));
double tmp;
if (th <= 0.21) {
tmp = sin(ky) / (t_1 / th);
} else {
tmp = 1.0 / (t_1 / (ky * sin(th)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = Math.hypot(Math.sin(kx), Math.sin(ky));
double tmp;
if (th <= 0.21) {
tmp = Math.sin(ky) / (t_1 / th);
} else {
tmp = 1.0 / (t_1 / (ky * Math.sin(th)));
}
return tmp;
}
def code(kx, ky, th): t_1 = math.hypot(math.sin(kx), math.sin(ky)) tmp = 0 if th <= 0.21: tmp = math.sin(ky) / (t_1 / th) else: tmp = 1.0 / (t_1 / (ky * math.sin(th))) return tmp
function code(kx, ky, th) t_1 = hypot(sin(kx), sin(ky)) tmp = 0.0 if (th <= 0.21) tmp = Float64(sin(ky) / Float64(t_1 / th)); else tmp = Float64(1.0 / Float64(t_1 / Float64(ky * sin(th)))); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = hypot(sin(kx), sin(ky)); tmp = 0.0; if (th <= 0.21) tmp = sin(ky) / (t_1 / th); else tmp = 1.0 / (t_1 / (ky * sin(th))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]}, If[LessEqual[th, 0.21], N[(N[Sin[ky], $MachinePrecision] / N[(t$95$1 / th), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(t$95$1 / N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{hypot}\left(\sin kx, \sin ky\right)\\
\mathbf{if}\;th \leq 0.21:\\
\;\;\;\;\frac{\sin ky}{\frac{t_1}{th}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{t_1}{ky \cdot \sin th}}\\
\end{array}
\end{array}
if th < 0.209999999999999992Initial program 93.4%
remove-double-neg93.4%
sin-neg93.4%
neg-mul-193.4%
*-commutative93.4%
associate-*l*93.4%
associate-*l/90.2%
associate-/r/90.2%
associate-*l/93.4%
associate-/r/93.3%
sin-neg93.3%
neg-mul-193.3%
associate-/r*93.3%
associate-/r/93.4%
Simplified99.7%
expm1-log1p-u99.7%
expm1-udef36.3%
hypot-udef35.2%
unpow235.2%
unpow235.2%
+-commutative35.2%
unpow235.2%
unpow235.2%
hypot-def36.3%
Applied egg-rr36.3%
expm1-def99.7%
expm1-log1p99.7%
associate-/r/99.6%
hypot-def93.3%
unpow293.3%
unpow293.3%
+-commutative93.3%
unpow293.3%
unpow293.3%
hypot-def99.6%
Simplified99.6%
Taylor expanded in th around 0 61.4%
associate-*l/61.5%
+-commutative61.5%
unpow261.5%
unpow261.5%
hypot-def66.3%
*-lft-identity66.3%
hypot-def61.5%
unpow261.5%
unpow261.5%
+-commutative61.5%
unpow261.5%
unpow261.5%
hypot-def66.3%
Simplified66.3%
if 0.209999999999999992 < th Initial program 95.9%
remove-double-neg95.9%
sin-neg95.9%
neg-mul-195.9%
*-commutative95.9%
associate-*l*95.9%
associate-*l/95.9%
associate-/r/95.9%
associate-*l/95.9%
associate-/r/95.9%
sin-neg95.9%
neg-mul-195.9%
associate-/r*95.9%
associate-/r/95.9%
Simplified99.7%
associate-*l/99.7%
clear-num99.4%
hypot-udef95.7%
unpow295.7%
unpow295.7%
+-commutative95.7%
unpow295.7%
unpow295.7%
hypot-def99.4%
Applied egg-rr99.4%
Taylor expanded in ky around 0 54.2%
Final simplification63.8%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.002) (fabs (sin th)) (if (<= (sin ky) 5e-139) (/ ky (/ kx (sin th))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.002) {
tmp = fabs(sin(th));
} else if (sin(ky) <= 5e-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.002d0)) then
tmp = abs(sin(th))
else if (sin(ky) <= 5d-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.002) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(ky) <= 5e-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.002: tmp = math.fabs(math.sin(th)) elif math.sin(ky) <= 5e-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.002) tmp = abs(sin(th)); elseif (sin(ky) <= 5e-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.002) tmp = abs(sin(th)); elseif (sin(ky) <= 5e-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.002], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 5e-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.002:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-139}:\\
\;\;\;\;\frac{ky}{\frac{kx}{\sin th}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -2e-3Initial program 99.8%
remove-double-neg99.8%
sin-neg99.8%
neg-mul-199.8%
*-commutative99.8%
associate-*l*99.8%
associate-*l/99.6%
associate-/r/99.6%
associate-*l/99.8%
associate-/r/99.8%
sin-neg99.8%
neg-mul-199.8%
associate-/r*99.8%
associate-/r/99.8%
Simplified99.8%
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 2.4%
remove-double-div2.4%
add-sqr-sqrt1.5%
sqrt-unprod19.8%
pow219.8%
Applied egg-rr19.8%
unpow219.8%
rem-sqrt-square26.2%
Simplified26.2%
if -2e-3 < (sin.f64 ky) < 5.00000000000000034e-139Initial program 85.7%
Taylor expanded in ky around 0 41.3%
Taylor expanded in kx around 0 27.4%
associate-/l*30.5%
Simplified30.5%
Taylor expanded in ky around 0 27.4%
associate-/l*30.5%
Simplified30.5%
if 5.00000000000000034e-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/98.7%
associate-/r/98.7%
associate-*l/99.7%
associate-/r/99.6%
sin-neg99.6%
neg-mul-199.6%
associate-/r*99.6%
associate-/r/99.7%
Simplified99.7%
Taylor expanded in kx around 0 53.7%
Final simplification37.8%
(FPCore (kx ky th) :precision binary64 (if (<= ky 1.02e-138) (/ ky (/ kx (sin th))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 1.02e-138) {
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 <= 1.02d-138) 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 <= 1.02e-138) {
tmp = ky / (kx / Math.sin(th));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 1.02e-138: tmp = ky / (kx / math.sin(th)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 1.02e-138) 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 <= 1.02e-138) tmp = ky / (kx / sin(th)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 1.02e-138], N[(ky / N[(kx / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 1.02 \cdot 10^{-138}:\\
\;\;\;\;\frac{ky}{\frac{kx}{\sin th}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 1.02000000000000007e-138Initial program 90.9%
Taylor expanded in ky around 0 28.7%
Taylor expanded in kx around 0 19.0%
associate-/l*21.0%
Simplified21.0%
Taylor expanded in ky around 0 18.6%
associate-/l*20.6%
Simplified20.6%
if 1.02000000000000007e-138 < ky Initial program 99.6%
remove-double-neg99.6%
sin-neg99.6%
neg-mul-199.6%
*-commutative99.6%
associate-*l*99.6%
associate-*l/98.6%
associate-/r/98.6%
associate-*l/99.6%
associate-/r/99.7%
sin-neg99.7%
neg-mul-199.7%
associate-/r*99.7%
associate-/r/99.6%
Simplified99.7%
Taylor expanded in kx around 0 35.6%
Final simplification25.8%
(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.9%
remove-double-neg93.9%
sin-neg93.9%
neg-mul-193.9%
*-commutative93.9%
associate-*l*93.9%
associate-*l/91.4%
associate-/r/91.4%
associate-*l/93.9%
associate-/r/93.9%
sin-neg93.9%
neg-mul-193.9%
associate-/r*93.9%
associate-/r/93.9%
Simplified99.7%
Taylor expanded in kx around 0 23.5%
Final simplification23.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.9%
remove-double-neg93.9%
sin-neg93.9%
neg-mul-193.9%
*-commutative93.9%
associate-*l*93.9%
associate-*l/91.4%
associate-/r/91.4%
associate-*l/93.9%
associate-/r/93.9%
sin-neg93.9%
neg-mul-193.9%
associate-/r*93.9%
associate-/r/93.9%
Simplified99.7%
associate-*l/96.0%
clear-num95.4%
hypot-udef90.8%
unpow290.8%
unpow290.8%
+-commutative90.8%
unpow290.8%
unpow290.8%
hypot-def95.4%
Applied egg-rr95.4%
Taylor expanded in kx around 0 23.5%
Taylor expanded in th around 0 14.2%
Final simplification14.2%
(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.9%
remove-double-neg93.9%
sin-neg93.9%
neg-mul-193.9%
*-commutative93.9%
associate-*l*93.9%
associate-*l/91.4%
associate-/r/91.4%
associate-*l/93.9%
associate-/r/93.9%
sin-neg93.9%
neg-mul-193.9%
associate-/r*93.9%
associate-/r/93.9%
Simplified99.7%
associate-*l/96.0%
clear-num95.4%
hypot-udef90.8%
unpow290.8%
unpow290.8%
+-commutative90.8%
unpow290.8%
unpow290.8%
hypot-def95.4%
Applied egg-rr95.4%
Taylor expanded in kx around 0 23.5%
Taylor expanded in th around 0 13.4%
Final simplification13.4%
herbie shell --seed 2024020
(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)))