
(FPCore (kx ky th) :precision binary64 (* (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) (sin th)))
double code(double kx, double ky, double th) {
return (sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) * sin(th);
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = (sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))) * sin(th)
end function
public static double code(double kx, double ky, double th) {
return (Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))) * Math.sin(th);
}
def code(kx, ky, th): return (math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))) * math.sin(th)
function code(kx, ky, th) return Float64(Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th)) end
function tmp = code(kx, ky, th) tmp = (sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th); end
code[kx_, ky_, th_] := N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 16 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (kx ky th) :precision binary64 (* (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) (sin th)))
double code(double kx, double ky, double th) {
return (sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) * sin(th);
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = (sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))) * sin(th)
end function
public static double code(double kx, double ky, double th) {
return (Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))) * Math.sin(th);
}
def code(kx, ky, th): return (math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))) * math.sin(th)
function code(kx, ky, th) return Float64(Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th)) end
function tmp = code(kx, ky, th) tmp = (sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th); end
code[kx_, ky_, th_] := N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th
\end{array}
(FPCore (kx ky th) :precision binary64 (* (/ (sin ky) (hypot (sin ky) (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
return (sin(ky) / hypot(sin(ky), sin(kx))) * sin(th);
}
public static double code(double kx, double ky, double th) {
return (Math.sin(ky) / Math.hypot(Math.sin(ky), Math.sin(kx))) * Math.sin(th);
}
def code(kx, ky, th): return (math.sin(ky) / math.hypot(math.sin(ky), math.sin(kx))) * math.sin(th)
function code(kx, ky, th) return Float64(Float64(sin(ky) / hypot(sin(ky), sin(kx))) * sin(th)) end
function tmp = code(kx, ky, th) tmp = (sin(ky) / hypot(sin(ky), sin(kx))) * sin(th); end
code[kx_, ky_, th_] := N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \sin th
\end{array}
Initial program 94.5%
+-commutative94.5%
unpow294.5%
unpow294.5%
hypot-def99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin th) -0.7)
(/ (sin ky) (/ (sin kx) (sin th)))
(if (<= (sin th) -0.44)
(fabs (sin th))
(if (<= (sin th) -0.05)
(* (sin ky) (+ (+ 1.0 (/ (sin th) (sin kx))) -1.0))
(if (<= (sin th) 0.0005)
(/ (sin ky) (/ (hypot (sin ky) (sin kx)) th))
(* (sin ky) (fabs (/ (sin th) (sin ky)))))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(th) <= -0.7) {
tmp = sin(ky) / (sin(kx) / sin(th));
} else if (sin(th) <= -0.44) {
tmp = fabs(sin(th));
} else if (sin(th) <= -0.05) {
tmp = sin(ky) * ((1.0 + (sin(th) / sin(kx))) + -1.0);
} else if (sin(th) <= 0.0005) {
tmp = sin(ky) / (hypot(sin(ky), sin(kx)) / th);
} else {
tmp = sin(ky) * fabs((sin(th) / sin(ky)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(th) <= -0.7) {
tmp = Math.sin(ky) / (Math.sin(kx) / Math.sin(th));
} else if (Math.sin(th) <= -0.44) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(th) <= -0.05) {
tmp = Math.sin(ky) * ((1.0 + (Math.sin(th) / Math.sin(kx))) + -1.0);
} else if (Math.sin(th) <= 0.0005) {
tmp = Math.sin(ky) / (Math.hypot(Math.sin(ky), Math.sin(kx)) / th);
} else {
tmp = Math.sin(ky) * Math.abs((Math.sin(th) / Math.sin(ky)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(th) <= -0.7: tmp = math.sin(ky) / (math.sin(kx) / math.sin(th)) elif math.sin(th) <= -0.44: tmp = math.fabs(math.sin(th)) elif math.sin(th) <= -0.05: tmp = math.sin(ky) * ((1.0 + (math.sin(th) / math.sin(kx))) + -1.0) elif math.sin(th) <= 0.0005: tmp = math.sin(ky) / (math.hypot(math.sin(ky), math.sin(kx)) / th) else: tmp = math.sin(ky) * math.fabs((math.sin(th) / math.sin(ky))) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(th) <= -0.7) tmp = Float64(sin(ky) / Float64(sin(kx) / sin(th))); elseif (sin(th) <= -0.44) tmp = abs(sin(th)); elseif (sin(th) <= -0.05) tmp = Float64(sin(ky) * Float64(Float64(1.0 + Float64(sin(th) / sin(kx))) + -1.0)); elseif (sin(th) <= 0.0005) tmp = Float64(sin(ky) / Float64(hypot(sin(ky), sin(kx)) / th)); else tmp = Float64(sin(ky) * abs(Float64(sin(th) / sin(ky)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(th) <= -0.7) tmp = sin(ky) / (sin(kx) / sin(th)); elseif (sin(th) <= -0.44) tmp = abs(sin(th)); elseif (sin(th) <= -0.05) tmp = sin(ky) * ((1.0 + (sin(th) / sin(kx))) + -1.0); elseif (sin(th) <= 0.0005) tmp = sin(ky) / (hypot(sin(ky), sin(kx)) / th); else tmp = sin(ky) * abs((sin(th) / sin(ky))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[th], $MachinePrecision], -0.7], N[(N[Sin[ky], $MachinePrecision] / N[(N[Sin[kx], $MachinePrecision] / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[th], $MachinePrecision], -0.44], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[th], $MachinePrecision], -0.05], N[(N[Sin[ky], $MachinePrecision] * N[(N[(1.0 + N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[th], $MachinePrecision], 0.0005], N[(N[Sin[ky], $MachinePrecision] / N[(N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision] / th), $MachinePrecision]), $MachinePrecision], N[(N[Sin[ky], $MachinePrecision] * N[Abs[N[(N[Sin[th], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin th \leq -0.7:\\
\;\;\;\;\frac{\sin ky}{\frac{\sin kx}{\sin th}}\\
\mathbf{elif}\;\sin th \leq -0.44:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin th \leq -0.05:\\
\;\;\;\;\sin ky \cdot \left(\left(1 + \frac{\sin th}{\sin kx}\right) + -1\right)\\
\mathbf{elif}\;\sin th \leq 0.0005:\\
\;\;\;\;\frac{\sin ky}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right)}{th}}\\
\mathbf{else}:\\
\;\;\;\;\sin ky \cdot \left|\frac{\sin th}{\sin ky}\right|\\
\end{array}
\end{array}
if (sin.f64 th) < -0.69999999999999996Initial program 98.9%
associate-*l/98.9%
*-commutative98.9%
associate-*l/98.6%
+-commutative98.6%
unpow298.6%
unpow298.6%
hypot-def99.4%
Simplified99.4%
Taylor expanded in ky around 0 18.9%
*-commutative18.9%
clear-num19.0%
un-div-inv19.0%
Applied egg-rr19.0%
if -0.69999999999999996 < (sin.f64 th) < -0.440000000000000002Initial program 91.7%
associate-*l/91.8%
*-commutative91.8%
associate-*l/91.8%
+-commutative91.8%
unpow291.8%
unpow291.8%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 11.6%
add-sqr-sqrt0.0%
sqrt-unprod47.7%
pow247.7%
*-commutative47.7%
clear-num47.7%
un-div-inv47.6%
Applied egg-rr47.6%
unpow247.6%
rem-sqrt-square47.6%
associate-/r/47.7%
*-inverses47.7%
*-lft-identity47.7%
Simplified47.7%
if -0.440000000000000002 < (sin.f64 th) < -0.050000000000000003Initial program 94.8%
associate-*l/95.0%
*-commutative95.0%
associate-*l/94.8%
+-commutative94.8%
unpow294.8%
unpow294.8%
hypot-def99.5%
Simplified99.5%
Taylor expanded in ky around 0 18.2%
expm1-log1p-u8.2%
Applied egg-rr8.2%
expm1-udef8.3%
log1p-udef8.3%
rem-exp-log18.3%
Applied egg-rr18.3%
if -0.050000000000000003 < (sin.f64 th) < 5.0000000000000001e-4Initial program 95.2%
associate-*l/93.8%
+-commutative93.8%
unpow293.8%
unpow293.8%
hypot-udef95.1%
associate-*l/99.7%
expm1-log1p-u99.7%
expm1-udef21.0%
Applied egg-rr21.0%
expm1-def99.6%
expm1-log1p99.6%
Simplified99.6%
Taylor expanded in th around 0 93.1%
associate-*l/93.3%
unpow293.3%
unpow293.3%
hypot-def97.8%
*-lft-identity97.8%
hypot-def93.3%
unpow293.3%
unpow293.3%
+-commutative93.3%
unpow293.3%
unpow293.3%
hypot-def97.8%
Simplified97.8%
if 5.0000000000000001e-4 < (sin.f64 th) Initial program 91.7%
associate-*l/91.7%
*-commutative91.7%
associate-*l/91.6%
+-commutative91.6%
unpow291.6%
unpow291.6%
hypot-def99.5%
Simplified99.5%
Taylor expanded in kx around 0 33.8%
add-sqr-sqrt32.9%
sqrt-unprod48.7%
pow248.7%
Applied egg-rr48.7%
unpow248.7%
rem-sqrt-square55.1%
Simplified55.1%
Final simplification69.6%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (hypot (sin ky) (sin kx))))
(if (<= (sin th) -0.02)
(/ (* ky (sin th)) t_1)
(if (<= (sin th) 0.0005)
(/ (sin ky) (* t_1 (+ (/ 1.0 th) (* th 0.16666666666666666))))
(* (sin ky) (fabs (/ (sin th) (sin ky))))))))
double code(double kx, double ky, double th) {
double t_1 = hypot(sin(ky), sin(kx));
double tmp;
if (sin(th) <= -0.02) {
tmp = (ky * sin(th)) / t_1;
} else if (sin(th) <= 0.0005) {
tmp = sin(ky) / (t_1 * ((1.0 / th) + (th * 0.16666666666666666)));
} else {
tmp = sin(ky) * fabs((sin(th) / sin(ky)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = Math.hypot(Math.sin(ky), Math.sin(kx));
double tmp;
if (Math.sin(th) <= -0.02) {
tmp = (ky * Math.sin(th)) / t_1;
} else if (Math.sin(th) <= 0.0005) {
tmp = Math.sin(ky) / (t_1 * ((1.0 / th) + (th * 0.16666666666666666)));
} else {
tmp = Math.sin(ky) * Math.abs((Math.sin(th) / Math.sin(ky)));
}
return tmp;
}
def code(kx, ky, th): t_1 = math.hypot(math.sin(ky), math.sin(kx)) tmp = 0 if math.sin(th) <= -0.02: tmp = (ky * math.sin(th)) / t_1 elif math.sin(th) <= 0.0005: tmp = math.sin(ky) / (t_1 * ((1.0 / th) + (th * 0.16666666666666666))) else: tmp = math.sin(ky) * math.fabs((math.sin(th) / math.sin(ky))) return tmp
function code(kx, ky, th) t_1 = hypot(sin(ky), sin(kx)) tmp = 0.0 if (sin(th) <= -0.02) tmp = Float64(Float64(ky * sin(th)) / t_1); elseif (sin(th) <= 0.0005) tmp = Float64(sin(ky) / Float64(t_1 * Float64(Float64(1.0 / th) + Float64(th * 0.16666666666666666)))); else tmp = Float64(sin(ky) * abs(Float64(sin(th) / sin(ky)))); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = hypot(sin(ky), sin(kx)); tmp = 0.0; if (sin(th) <= -0.02) tmp = (ky * sin(th)) / t_1; elseif (sin(th) <= 0.0005) tmp = sin(ky) / (t_1 * ((1.0 / th) + (th * 0.16666666666666666))); else tmp = sin(ky) * abs((sin(th) / sin(ky))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]}, If[LessEqual[N[Sin[th], $MachinePrecision], -0.02], N[(N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision], If[LessEqual[N[Sin[th], $MachinePrecision], 0.0005], N[(N[Sin[ky], $MachinePrecision] / N[(t$95$1 * N[(N[(1.0 / th), $MachinePrecision] + N[(th * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[ky], $MachinePrecision] * N[Abs[N[(N[Sin[th], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{hypot}\left(\sin ky, \sin kx\right)\\
\mathbf{if}\;\sin th \leq -0.02:\\
\;\;\;\;\frac{ky \cdot \sin th}{t_1}\\
\mathbf{elif}\;\sin th \leq 0.0005:\\
\;\;\;\;\frac{\sin ky}{t_1 \cdot \left(\frac{1}{th} + th \cdot 0.16666666666666666\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin ky \cdot \left|\frac{\sin th}{\sin ky}\right|\\
\end{array}
\end{array}
if (sin.f64 th) < -0.0200000000000000004Initial program 96.1%
associate-*l/96.2%
+-commutative96.2%
unpow296.2%
unpow296.2%
hypot-udef99.7%
associate-*l/99.6%
expm1-log1p-u99.4%
expm1-udef63.4%
Applied egg-rr63.3%
expm1-def99.3%
expm1-log1p99.4%
associate-/l*99.7%
hypot-def96.2%
unpow296.2%
unpow296.2%
+-commutative96.2%
unpow296.2%
unpow296.2%
hypot-def99.7%
Simplified99.7%
Taylor expanded in ky around 0 50.7%
if -0.0200000000000000004 < (sin.f64 th) < 5.0000000000000001e-4Initial program 95.2%
associate-*l/93.7%
+-commutative93.7%
unpow293.7%
unpow293.7%
hypot-udef95.1%
associate-*l/99.7%
expm1-log1p-u99.7%
expm1-udef21.2%
Applied egg-rr21.2%
expm1-def99.6%
expm1-log1p99.6%
Simplified99.6%
Taylor expanded in th around 0 94.6%
+-commutative94.6%
*-commutative94.6%
unpow294.6%
unpow294.6%
hypot-def99.1%
associate-*r/99.4%
*-commutative99.4%
associate-*l/99.1%
associate-*r*99.1%
Simplified99.1%
if 5.0000000000000001e-4 < (sin.f64 th) Initial program 91.7%
associate-*l/91.7%
*-commutative91.7%
associate-*l/91.6%
+-commutative91.6%
unpow291.6%
unpow291.6%
hypot-def99.5%
Simplified99.5%
Taylor expanded in kx around 0 33.8%
add-sqr-sqrt32.9%
sqrt-unprod48.7%
pow248.7%
Applied egg-rr48.7%
unpow248.7%
rem-sqrt-square55.1%
Simplified55.1%
Final simplification76.2%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -1e-52)
(fabs (sin th))
(if (<= (sin ky) 5e-245)
(/ (sin th) (/ (sin kx) ky))
(if (<= (sin ky) 1e-104) (* (sin th) (fabs (/ ky (sin kx)))) (sin th)))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -1e-52) {
tmp = fabs(sin(th));
} else if (sin(ky) <= 5e-245) {
tmp = sin(th) / (sin(kx) / ky);
} else if (sin(ky) <= 1e-104) {
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) <= (-1d-52)) then
tmp = abs(sin(th))
else if (sin(ky) <= 5d-245) then
tmp = sin(th) / (sin(kx) / ky)
else if (sin(ky) <= 1d-104) 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) <= -1e-52) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(ky) <= 5e-245) {
tmp = Math.sin(th) / (Math.sin(kx) / ky);
} else if (Math.sin(ky) <= 1e-104) {
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) <= -1e-52: tmp = math.fabs(math.sin(th)) elif math.sin(ky) <= 5e-245: tmp = math.sin(th) / (math.sin(kx) / ky) elif math.sin(ky) <= 1e-104: 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) <= -1e-52) tmp = abs(sin(th)); elseif (sin(ky) <= 5e-245) tmp = Float64(sin(th) / Float64(sin(kx) / ky)); elseif (sin(ky) <= 1e-104) 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) <= -1e-52) tmp = abs(sin(th)); elseif (sin(ky) <= 5e-245) tmp = sin(th) / (sin(kx) / ky); elseif (sin(ky) <= 1e-104) 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], -1e-52], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 5e-245], N[(N[Sin[th], $MachinePrecision] / N[(N[Sin[kx], $MachinePrecision] / ky), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-104], 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 -1 \cdot 10^{-52}:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-245}:\\
\;\;\;\;\frac{\sin th}{\frac{\sin kx}{ky}}\\
\mathbf{elif}\;\sin ky \leq 10^{-104}:\\
\;\;\;\;\sin th \cdot \left|\frac{ky}{\sin kx}\right|\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -1e-52Initial program 99.5%
associate-*l/99.6%
*-commutative99.6%
associate-*l/99.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.6%
Simplified99.6%
Taylor expanded in kx around 0 2.8%
add-sqr-sqrt1.2%
sqrt-unprod29.2%
pow229.2%
*-commutative29.2%
clear-num29.2%
un-div-inv29.2%
Applied egg-rr29.2%
unpow229.2%
rem-sqrt-square36.4%
associate-/r/36.5%
*-inverses36.5%
*-lft-identity36.5%
Simplified36.5%
if -1e-52 < (sin.f64 ky) < 4.9999999999999997e-245Initial program 79.5%
*-commutative79.5%
clear-num79.4%
+-commutative79.4%
unpow279.4%
unpow279.4%
hypot-udef99.5%
un-div-inv99.7%
Applied egg-rr99.7%
Taylor expanded in ky around 0 54.5%
if 4.9999999999999997e-245 < (sin.f64 ky) < 9.99999999999999927e-105Initial program 93.1%
Taylor expanded in ky around 0 58.9%
associate-/l*58.9%
associate-/r/58.9%
Simplified58.9%
add-sqr-sqrt51.1%
sqrt-unprod66.5%
pow266.5%
Applied egg-rr66.5%
unpow266.5%
rem-sqrt-square90.4%
Simplified90.4%
if 9.99999999999999927e-105 < (sin.f64 ky) Initial program 99.8%
Taylor expanded in kx around 0 61.8%
Final simplification56.6%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -1e-52)
(fabs (sin th))
(if (<= (sin ky) 5e-245)
(/ (sin th) (/ (sin kx) ky))
(if (<= (sin ky) 1e-104)
(* (sin th) (fabs (/ ky (sin kx))))
(/ (* (sin ky) (sin th)) (sin ky))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -1e-52) {
tmp = fabs(sin(th));
} else if (sin(ky) <= 5e-245) {
tmp = sin(th) / (sin(kx) / ky);
} else if (sin(ky) <= 1e-104) {
tmp = sin(th) * fabs((ky / sin(kx)));
} else {
tmp = (sin(ky) * sin(th)) / sin(ky);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(ky) <= (-1d-52)) then
tmp = abs(sin(th))
else if (sin(ky) <= 5d-245) then
tmp = sin(th) / (sin(kx) / ky)
else if (sin(ky) <= 1d-104) then
tmp = sin(th) * abs((ky / sin(kx)))
else
tmp = (sin(ky) * sin(th)) / sin(ky)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -1e-52) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(ky) <= 5e-245) {
tmp = Math.sin(th) / (Math.sin(kx) / ky);
} else if (Math.sin(ky) <= 1e-104) {
tmp = Math.sin(th) * Math.abs((ky / Math.sin(kx)));
} else {
tmp = (Math.sin(ky) * Math.sin(th)) / Math.sin(ky);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -1e-52: tmp = math.fabs(math.sin(th)) elif math.sin(ky) <= 5e-245: tmp = math.sin(th) / (math.sin(kx) / ky) elif math.sin(ky) <= 1e-104: tmp = math.sin(th) * math.fabs((ky / math.sin(kx))) else: tmp = (math.sin(ky) * math.sin(th)) / math.sin(ky) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -1e-52) tmp = abs(sin(th)); elseif (sin(ky) <= 5e-245) tmp = Float64(sin(th) / Float64(sin(kx) / ky)); elseif (sin(ky) <= 1e-104) tmp = Float64(sin(th) * abs(Float64(ky / sin(kx)))); else tmp = Float64(Float64(sin(ky) * sin(th)) / sin(ky)); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -1e-52) tmp = abs(sin(th)); elseif (sin(ky) <= 5e-245) tmp = sin(th) / (sin(kx) / ky); elseif (sin(ky) <= 1e-104) tmp = sin(th) * abs((ky / sin(kx))); else tmp = (sin(ky) * sin(th)) / sin(ky); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -1e-52], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 5e-245], N[(N[Sin[th], $MachinePrecision] / N[(N[Sin[kx], $MachinePrecision] / ky), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-104], N[(N[Sin[th], $MachinePrecision] * N[Abs[N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[ky], $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -1 \cdot 10^{-52}:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-245}:\\
\;\;\;\;\frac{\sin th}{\frac{\sin kx}{ky}}\\
\mathbf{elif}\;\sin ky \leq 10^{-104}:\\
\;\;\;\;\sin th \cdot \left|\frac{ky}{\sin kx}\right|\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky \cdot \sin th}{\sin ky}\\
\end{array}
\end{array}
if (sin.f64 ky) < -1e-52Initial program 99.5%
associate-*l/99.6%
*-commutative99.6%
associate-*l/99.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.6%
Simplified99.6%
Taylor expanded in kx around 0 2.8%
add-sqr-sqrt1.2%
sqrt-unprod29.2%
pow229.2%
*-commutative29.2%
clear-num29.2%
un-div-inv29.2%
Applied egg-rr29.2%
unpow229.2%
rem-sqrt-square36.4%
associate-/r/36.5%
*-inverses36.5%
*-lft-identity36.5%
Simplified36.5%
if -1e-52 < (sin.f64 ky) < 4.9999999999999997e-245Initial program 79.5%
*-commutative79.5%
clear-num79.4%
+-commutative79.4%
unpow279.4%
unpow279.4%
hypot-udef99.5%
un-div-inv99.7%
Applied egg-rr99.7%
Taylor expanded in ky around 0 54.5%
if 4.9999999999999997e-245 < (sin.f64 ky) < 9.99999999999999927e-105Initial program 93.1%
Taylor expanded in ky around 0 58.9%
associate-/l*58.9%
associate-/r/58.9%
Simplified58.9%
add-sqr-sqrt51.1%
sqrt-unprod66.5%
pow266.5%
Applied egg-rr66.5%
unpow266.5%
rem-sqrt-square90.4%
Simplified90.4%
if 9.99999999999999927e-105 < (sin.f64 ky) Initial program 99.8%
associate-*l/99.7%
*-commutative99.7%
associate-*l/99.5%
+-commutative99.5%
unpow299.5%
unpow299.5%
hypot-def99.5%
Simplified99.5%
Taylor expanded in kx around 0 61.6%
*-commutative61.6%
associate-*r/62.7%
Applied egg-rr62.7%
Final simplification56.9%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (hypot (sin ky) (sin kx))))
(if (<= (sin th) -0.02)
(/ (* ky (sin th)) t_1)
(if (<= (sin th) 0.0005)
(/ (sin ky) (/ t_1 th))
(* (sin ky) (fabs (/ (sin th) (sin ky))))))))
double code(double kx, double ky, double th) {
double t_1 = hypot(sin(ky), sin(kx));
double tmp;
if (sin(th) <= -0.02) {
tmp = (ky * sin(th)) / t_1;
} else if (sin(th) <= 0.0005) {
tmp = sin(ky) / (t_1 / th);
} else {
tmp = sin(ky) * fabs((sin(th) / sin(ky)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = Math.hypot(Math.sin(ky), Math.sin(kx));
double tmp;
if (Math.sin(th) <= -0.02) {
tmp = (ky * Math.sin(th)) / t_1;
} else if (Math.sin(th) <= 0.0005) {
tmp = Math.sin(ky) / (t_1 / th);
} else {
tmp = Math.sin(ky) * Math.abs((Math.sin(th) / Math.sin(ky)));
}
return tmp;
}
def code(kx, ky, th): t_1 = math.hypot(math.sin(ky), math.sin(kx)) tmp = 0 if math.sin(th) <= -0.02: tmp = (ky * math.sin(th)) / t_1 elif math.sin(th) <= 0.0005: tmp = math.sin(ky) / (t_1 / th) else: tmp = math.sin(ky) * math.fabs((math.sin(th) / math.sin(ky))) return tmp
function code(kx, ky, th) t_1 = hypot(sin(ky), sin(kx)) tmp = 0.0 if (sin(th) <= -0.02) tmp = Float64(Float64(ky * sin(th)) / t_1); elseif (sin(th) <= 0.0005) tmp = Float64(sin(ky) / Float64(t_1 / th)); else tmp = Float64(sin(ky) * abs(Float64(sin(th) / sin(ky)))); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = hypot(sin(ky), sin(kx)); tmp = 0.0; if (sin(th) <= -0.02) tmp = (ky * sin(th)) / t_1; elseif (sin(th) <= 0.0005) tmp = sin(ky) / (t_1 / th); else tmp = sin(ky) * abs((sin(th) / sin(ky))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]}, If[LessEqual[N[Sin[th], $MachinePrecision], -0.02], N[(N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision], If[LessEqual[N[Sin[th], $MachinePrecision], 0.0005], N[(N[Sin[ky], $MachinePrecision] / N[(t$95$1 / th), $MachinePrecision]), $MachinePrecision], N[(N[Sin[ky], $MachinePrecision] * N[Abs[N[(N[Sin[th], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{hypot}\left(\sin ky, \sin kx\right)\\
\mathbf{if}\;\sin th \leq -0.02:\\
\;\;\;\;\frac{ky \cdot \sin th}{t_1}\\
\mathbf{elif}\;\sin th \leq 0.0005:\\
\;\;\;\;\frac{\sin ky}{\frac{t_1}{th}}\\
\mathbf{else}:\\
\;\;\;\;\sin ky \cdot \left|\frac{\sin th}{\sin ky}\right|\\
\end{array}
\end{array}
if (sin.f64 th) < -0.0200000000000000004Initial program 96.1%
associate-*l/96.2%
+-commutative96.2%
unpow296.2%
unpow296.2%
hypot-udef99.7%
associate-*l/99.6%
expm1-log1p-u99.4%
expm1-udef63.4%
Applied egg-rr63.3%
expm1-def99.3%
expm1-log1p99.4%
associate-/l*99.7%
hypot-def96.2%
unpow296.2%
unpow296.2%
+-commutative96.2%
unpow296.2%
unpow296.2%
hypot-def99.7%
Simplified99.7%
Taylor expanded in ky around 0 50.7%
if -0.0200000000000000004 < (sin.f64 th) < 5.0000000000000001e-4Initial program 95.2%
associate-*l/93.7%
+-commutative93.7%
unpow293.7%
unpow293.7%
hypot-udef95.1%
associate-*l/99.7%
expm1-log1p-u99.7%
expm1-udef21.2%
Applied egg-rr21.2%
expm1-def99.6%
expm1-log1p99.6%
Simplified99.6%
Taylor expanded in th around 0 93.8%
associate-*l/94.0%
unpow294.0%
unpow294.0%
hypot-def98.5%
*-lft-identity98.5%
hypot-def94.0%
unpow294.0%
unpow294.0%
+-commutative94.0%
unpow294.0%
unpow294.0%
hypot-def98.5%
Simplified98.5%
if 5.0000000000000001e-4 < (sin.f64 th) Initial program 91.7%
associate-*l/91.7%
*-commutative91.7%
associate-*l/91.6%
+-commutative91.6%
unpow291.6%
unpow291.6%
hypot-def99.5%
Simplified99.5%
Taylor expanded in kx around 0 33.8%
add-sqr-sqrt32.9%
sqrt-unprod48.7%
pow248.7%
Applied egg-rr48.7%
unpow248.7%
rem-sqrt-square55.1%
Simplified55.1%
Final simplification75.9%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -1e-52) (fabs (sin th)) (if (<= (sin ky) 2e-109) (* ky (/ (sin th) (sin kx))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -1e-52) {
tmp = fabs(sin(th));
} else if (sin(ky) <= 2e-109) {
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 (sin(ky) <= (-1d-52)) then
tmp = abs(sin(th))
else if (sin(ky) <= 2d-109) 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 (Math.sin(ky) <= -1e-52) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(ky) <= 2e-109) {
tmp = 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) <= -1e-52: tmp = math.fabs(math.sin(th)) elif math.sin(ky) <= 2e-109: tmp = 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) <= -1e-52) tmp = abs(sin(th)); elseif (sin(ky) <= 2e-109) 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 (sin(ky) <= -1e-52) tmp = abs(sin(th)); elseif (sin(ky) <= 2e-109) tmp = ky * (sin(th) / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -1e-52], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-109], 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}\;\sin ky \leq -1 \cdot 10^{-52}:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-109}:\\
\;\;\;\;ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -1e-52Initial program 99.5%
associate-*l/99.6%
*-commutative99.6%
associate-*l/99.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.6%
Simplified99.6%
Taylor expanded in kx around 0 2.8%
add-sqr-sqrt1.2%
sqrt-unprod29.2%
pow229.2%
*-commutative29.2%
clear-num29.2%
un-div-inv29.2%
Applied egg-rr29.2%
unpow229.2%
rem-sqrt-square36.4%
associate-/r/36.5%
*-inverses36.5%
*-lft-identity36.5%
Simplified36.5%
if -1e-52 < (sin.f64 ky) < 2e-109Initial program 84.4%
*-commutative84.4%
clear-num84.3%
+-commutative84.3%
unpow284.3%
unpow284.3%
hypot-udef99.5%
un-div-inv99.7%
Applied egg-rr99.7%
clear-num99.6%
inv-pow99.6%
Applied egg-rr99.6%
unpow-199.6%
hypot-def84.4%
unpow284.4%
unpow284.4%
+-commutative84.4%
unpow284.4%
unpow284.4%
hypot-def99.6%
Simplified99.6%
Taylor expanded in ky around 0 52.9%
associate-*r/55.6%
Simplified55.6%
if 2e-109 < (sin.f64 ky) Initial program 99.8%
Taylor expanded in kx around 0 61.2%
Final simplification52.2%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -1e-52) (fabs (sin th)) (if (<= (sin ky) 2e-109) (/ ky (/ (sin kx) (sin th))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -1e-52) {
tmp = fabs(sin(th));
} else if (sin(ky) <= 2e-109) {
tmp = ky / (sin(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) <= (-1d-52)) then
tmp = abs(sin(th))
else if (sin(ky) <= 2d-109) then
tmp = ky / (sin(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) <= -1e-52) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(ky) <= 2e-109) {
tmp = ky / (Math.sin(kx) / Math.sin(th));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -1e-52: tmp = math.fabs(math.sin(th)) elif math.sin(ky) <= 2e-109: tmp = ky / (math.sin(kx) / math.sin(th)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -1e-52) tmp = abs(sin(th)); elseif (sin(ky) <= 2e-109) tmp = Float64(ky / Float64(sin(kx) / sin(th))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -1e-52) tmp = abs(sin(th)); elseif (sin(ky) <= 2e-109) tmp = ky / (sin(kx) / sin(th)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -1e-52], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-109], N[(ky / N[(N[Sin[kx], $MachinePrecision] / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -1 \cdot 10^{-52}:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-109}:\\
\;\;\;\;\frac{ky}{\frac{\sin kx}{\sin th}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -1e-52Initial program 99.5%
associate-*l/99.6%
*-commutative99.6%
associate-*l/99.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.6%
Simplified99.6%
Taylor expanded in kx around 0 2.8%
add-sqr-sqrt1.2%
sqrt-unprod29.2%
pow229.2%
*-commutative29.2%
clear-num29.2%
un-div-inv29.2%
Applied egg-rr29.2%
unpow229.2%
rem-sqrt-square36.4%
associate-/r/36.5%
*-inverses36.5%
*-lft-identity36.5%
Simplified36.5%
if -1e-52 < (sin.f64 ky) < 2e-109Initial program 84.4%
Taylor expanded in ky around 0 52.9%
associate-/l*55.6%
associate-/r/55.5%
Simplified55.5%
associate-*l/52.9%
associate-/l*55.6%
Applied egg-rr55.6%
if 2e-109 < (sin.f64 ky) Initial program 99.8%
Taylor expanded in kx around 0 61.2%
Final simplification52.1%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -1e-52) (fabs (sin th)) (if (<= (sin ky) 2e-109) (/ (sin th) (/ (sin kx) ky)) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -1e-52) {
tmp = fabs(sin(th));
} else if (sin(ky) <= 2e-109) {
tmp = sin(th) / (sin(kx) / ky);
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(ky) <= (-1d-52)) then
tmp = abs(sin(th))
else if (sin(ky) <= 2d-109) then
tmp = sin(th) / (sin(kx) / ky)
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -1e-52) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(ky) <= 2e-109) {
tmp = Math.sin(th) / (Math.sin(kx) / ky);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -1e-52: tmp = math.fabs(math.sin(th)) elif math.sin(ky) <= 2e-109: tmp = math.sin(th) / (math.sin(kx) / ky) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -1e-52) tmp = abs(sin(th)); elseif (sin(ky) <= 2e-109) tmp = Float64(sin(th) / Float64(sin(kx) / ky)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -1e-52) tmp = abs(sin(th)); elseif (sin(ky) <= 2e-109) tmp = sin(th) / (sin(kx) / ky); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -1e-52], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-109], N[(N[Sin[th], $MachinePrecision] / N[(N[Sin[kx], $MachinePrecision] / ky), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -1 \cdot 10^{-52}:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-109}:\\
\;\;\;\;\frac{\sin th}{\frac{\sin kx}{ky}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -1e-52Initial program 99.5%
associate-*l/99.6%
*-commutative99.6%
associate-*l/99.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.6%
Simplified99.6%
Taylor expanded in kx around 0 2.8%
add-sqr-sqrt1.2%
sqrt-unprod29.2%
pow229.2%
*-commutative29.2%
clear-num29.2%
un-div-inv29.2%
Applied egg-rr29.2%
unpow229.2%
rem-sqrt-square36.4%
associate-/r/36.5%
*-inverses36.5%
*-lft-identity36.5%
Simplified36.5%
if -1e-52 < (sin.f64 ky) < 2e-109Initial program 84.4%
*-commutative84.4%
clear-num84.3%
+-commutative84.3%
unpow284.3%
unpow284.3%
hypot-udef99.5%
un-div-inv99.7%
Applied egg-rr99.7%
Taylor expanded in ky around 0 55.7%
if 2e-109 < (sin.f64 ky) Initial program 99.8%
Taylor expanded in kx around 0 61.2%
Final simplification52.2%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -4e-106) (fabs (sin th)) (if (<= (sin ky) 1e-104) (/ (sin th) (/ kx ky)) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -4e-106) {
tmp = fabs(sin(th));
} else if (sin(ky) <= 1e-104) {
tmp = sin(th) / (kx / ky);
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(ky) <= (-4d-106)) then
tmp = abs(sin(th))
else if (sin(ky) <= 1d-104) then
tmp = sin(th) / (kx / ky)
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -4e-106) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(ky) <= 1e-104) {
tmp = Math.sin(th) / (kx / ky);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -4e-106: tmp = math.fabs(math.sin(th)) elif math.sin(ky) <= 1e-104: tmp = math.sin(th) / (kx / ky) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -4e-106) tmp = abs(sin(th)); elseif (sin(ky) <= 1e-104) tmp = Float64(sin(th) / Float64(kx / ky)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -4e-106) tmp = abs(sin(th)); elseif (sin(ky) <= 1e-104) tmp = sin(th) / (kx / ky); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -4e-106], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-104], N[(N[Sin[th], $MachinePrecision] / N[(kx / ky), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -4 \cdot 10^{-106}:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq 10^{-104}:\\
\;\;\;\;\frac{\sin th}{\frac{kx}{ky}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -3.99999999999999976e-106Initial program 99.5%
associate-*l/99.5%
*-commutative99.5%
associate-*l/99.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.6%
Simplified99.6%
Taylor expanded in kx around 0 2.8%
add-sqr-sqrt1.2%
sqrt-unprod27.4%
pow227.4%
*-commutative27.4%
clear-num27.4%
un-div-inv27.4%
Applied egg-rr27.4%
unpow227.4%
rem-sqrt-square34.9%
associate-/r/35.0%
*-inverses35.0%
*-lft-identity35.0%
Simplified35.0%
if -3.99999999999999976e-106 < (sin.f64 ky) < 9.99999999999999927e-105Initial program 82.7%
Taylor expanded in ky around 0 56.3%
associate-/l*59.2%
associate-/r/59.2%
Simplified59.2%
Taylor expanded in kx around 0 41.3%
*-commutative41.3%
clear-num41.3%
un-div-inv41.4%
Applied egg-rr41.4%
if 9.99999999999999927e-105 < (sin.f64 ky) Initial program 99.8%
Taylor expanded in kx around 0 61.8%
Final simplification46.8%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) 1e-104) (/ ky (/ kx (sin th))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= 1e-104) {
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) <= 1d-104) 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) <= 1e-104) {
tmp = ky / (kx / Math.sin(th));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= 1e-104: tmp = ky / (kx / math.sin(th)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= 1e-104) 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) <= 1e-104) tmp = ky / (kx / sin(th)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-104], 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 10^{-104}:\\
\;\;\;\;\frac{ky}{\frac{kx}{\sin th}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < 9.99999999999999927e-105Initial program 91.4%
Taylor expanded in ky around 0 31.8%
associate-/l*33.2%
associate-/r/33.2%
Simplified33.2%
Taylor expanded in kx around 0 21.0%
associate-/l*22.5%
Simplified22.5%
if 9.99999999999999927e-105 < (sin.f64 ky) Initial program 99.8%
Taylor expanded in kx around 0 61.8%
Final simplification36.9%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) 1e-104) (/ (sin th) (/ kx ky)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= 1e-104) {
tmp = sin(th) / (kx / ky);
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(ky) <= 1d-104) then
tmp = sin(th) / (kx / ky)
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= 1e-104) {
tmp = Math.sin(th) / (kx / ky);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= 1e-104: tmp = math.sin(th) / (kx / ky) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= 1e-104) tmp = Float64(sin(th) / Float64(kx / ky)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= 1e-104) tmp = sin(th) / (kx / ky); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-104], N[(N[Sin[th], $MachinePrecision] / N[(kx / ky), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq 10^{-104}:\\
\;\;\;\;\frac{\sin th}{\frac{kx}{ky}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < 9.99999999999999927e-105Initial program 91.4%
Taylor expanded in ky around 0 31.8%
associate-/l*33.2%
associate-/r/33.2%
Simplified33.2%
Taylor expanded in kx around 0 22.5%
*-commutative22.5%
clear-num22.5%
un-div-inv22.5%
Applied egg-rr22.5%
if 9.99999999999999927e-105 < (sin.f64 ky) Initial program 99.8%
Taylor expanded in kx around 0 61.8%
Final simplification36.9%
(FPCore (kx ky th) :precision binary64 (if (or (<= ky -650000.0) (not (<= ky 3.8e-102))) (sin th) (* (sin th) (/ ky kx))))
double code(double kx, double ky, double th) {
double tmp;
if ((ky <= -650000.0) || !(ky <= 3.8e-102)) {
tmp = sin(th);
} else {
tmp = sin(th) * (ky / 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 ((ky <= (-650000.0d0)) .or. (.not. (ky <= 3.8d-102))) then
tmp = sin(th)
else
tmp = sin(th) * (ky / kx)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if ((ky <= -650000.0) || !(ky <= 3.8e-102)) {
tmp = Math.sin(th);
} else {
tmp = Math.sin(th) * (ky / kx);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if (ky <= -650000.0) or not (ky <= 3.8e-102): tmp = math.sin(th) else: tmp = math.sin(th) * (ky / kx) return tmp
function code(kx, ky, th) tmp = 0.0 if ((ky <= -650000.0) || !(ky <= 3.8e-102)) tmp = sin(th); else tmp = Float64(sin(th) * Float64(ky / kx)); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if ((ky <= -650000.0) || ~((ky <= 3.8e-102))) tmp = sin(th); else tmp = sin(th) * (ky / kx); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[Or[LessEqual[ky, -650000.0], N[Not[LessEqual[ky, 3.8e-102]], $MachinePrecision]], N[Sin[th], $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(ky / kx), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq -650000 \lor \neg \left(ky \leq 3.8 \cdot 10^{-102}\right):\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{ky}{kx}\\
\end{array}
\end{array}
if ky < -6.5e5 or 3.80000000000000026e-102 < ky Initial program 99.7%
Taylor expanded in kx around 0 37.9%
if -6.5e5 < ky < 3.80000000000000026e-102Initial program 86.1%
Taylor expanded in ky around 0 50.2%
associate-/l*52.6%
associate-/r/52.6%
Simplified52.6%
Taylor expanded in kx around 0 34.6%
Final simplification36.6%
(FPCore (kx ky th) :precision binary64 (if (or (<= ky -650000.0) (not (<= ky 7.4e-159))) (sin th) (/ ky (/ kx th))))
double code(double kx, double ky, double th) {
double tmp;
if ((ky <= -650000.0) || !(ky <= 7.4e-159)) {
tmp = sin(th);
} else {
tmp = ky / (kx / 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 <= (-650000.0d0)) .or. (.not. (ky <= 7.4d-159))) then
tmp = sin(th)
else
tmp = ky / (kx / th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if ((ky <= -650000.0) || !(ky <= 7.4e-159)) {
tmp = Math.sin(th);
} else {
tmp = ky / (kx / th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if (ky <= -650000.0) or not (ky <= 7.4e-159): tmp = math.sin(th) else: tmp = ky / (kx / th) return tmp
function code(kx, ky, th) tmp = 0.0 if ((ky <= -650000.0) || !(ky <= 7.4e-159)) tmp = sin(th); else tmp = Float64(ky / Float64(kx / th)); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if ((ky <= -650000.0) || ~((ky <= 7.4e-159))) tmp = sin(th); else tmp = ky / (kx / th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[Or[LessEqual[ky, -650000.0], N[Not[LessEqual[ky, 7.4e-159]], $MachinePrecision]], N[Sin[th], $MachinePrecision], N[(ky / N[(kx / th), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq -650000 \lor \neg \left(ky \leq 7.4 \cdot 10^{-159}\right):\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\frac{ky}{\frac{kx}{th}}\\
\end{array}
\end{array}
if ky < -6.5e5 or 7.3999999999999998e-159 < ky Initial program 99.5%
Taylor expanded in kx around 0 36.7%
if -6.5e5 < ky < 7.3999999999999998e-159Initial program 84.6%
Taylor expanded in ky around 0 50.0%
associate-/l*52.7%
associate-/r/52.7%
Simplified52.7%
Taylor expanded in kx around 0 38.8%
Taylor expanded in th around 0 24.7%
associate-/l*27.5%
Simplified27.5%
Final simplification33.6%
(FPCore (kx ky th) :precision binary64 (if (<= ky -550000.0) th (if (<= ky 4.8e-57) (/ ky (/ kx th)) th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= -550000.0) {
tmp = th;
} else if (ky <= 4.8e-57) {
tmp = ky / (kx / th);
} else {
tmp = th;
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (ky <= (-550000.0d0)) then
tmp = th
else if (ky <= 4.8d-57) then
tmp = ky / (kx / th)
else
tmp = th
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= -550000.0) {
tmp = th;
} else if (ky <= 4.8e-57) {
tmp = ky / (kx / th);
} else {
tmp = th;
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= -550000.0: tmp = th elif ky <= 4.8e-57: tmp = ky / (kx / th) else: tmp = th return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= -550000.0) tmp = th; elseif (ky <= 4.8e-57) tmp = Float64(ky / Float64(kx / th)); else tmp = th; end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= -550000.0) tmp = th; elseif (ky <= 4.8e-57) tmp = ky / (kx / th); else tmp = th; end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, -550000.0], th, If[LessEqual[ky, 4.8e-57], N[(ky / N[(kx / th), $MachinePrecision]), $MachinePrecision], th]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq -550000:\\
\;\;\;\;th\\
\mathbf{elif}\;ky \leq 4.8 \cdot 10^{-57}:\\
\;\;\;\;\frac{ky}{\frac{kx}{th}}\\
\mathbf{else}:\\
\;\;\;\;th\\
\end{array}
\end{array}
if ky < -5.5e5 or 4.80000000000000012e-57 < ky Initial program 99.7%
associate-*l/99.7%
*-commutative99.7%
associate-*l/99.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.6%
Simplified99.6%
Taylor expanded in kx around 0 36.7%
Taylor expanded in th around 0 20.0%
if -5.5e5 < ky < 4.80000000000000012e-57Initial program 87.4%
Taylor expanded in ky around 0 46.8%
associate-/l*48.9%
associate-/r/48.9%
Simplified48.9%
Taylor expanded in kx around 0 32.7%
Taylor expanded in th around 0 21.4%
associate-/l*23.6%
Simplified23.6%
Final simplification21.5%
(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 94.5%
associate-*l/93.8%
*-commutative93.8%
associate-*l/94.4%
+-commutative94.4%
unpow294.4%
unpow294.4%
hypot-def99.6%
Simplified99.6%
Taylor expanded in kx around 0 26.1%
Taylor expanded in th around 0 14.0%
Final simplification14.0%
herbie shell --seed 2023307
(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)))