
(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 18 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (kx ky th) :precision binary64 (* (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) (sin th)))
double code(double kx, double ky, double th) {
return (sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) * sin(th);
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = (sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))) * sin(th)
end function
public static double code(double kx, double ky, double th) {
return (Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))) * Math.sin(th);
}
def code(kx, ky, th): return (math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))) * math.sin(th)
function code(kx, ky, th) return Float64(Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th)) end
function tmp = code(kx, ky, th) tmp = (sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th); end
code[kx_, ky_, th_] := N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th
\end{array}
(FPCore (kx ky th) :precision binary64 (/ (sin th) (/ (hypot (sin ky) (sin kx)) (sin ky))))
double code(double kx, double ky, double th) {
return sin(th) / (hypot(sin(ky), sin(kx)) / sin(ky));
}
public static double code(double kx, double ky, double th) {
return Math.sin(th) / (Math.hypot(Math.sin(ky), Math.sin(kx)) / Math.sin(ky));
}
def code(kx, ky, th): return math.sin(th) / (math.hypot(math.sin(ky), math.sin(kx)) / math.sin(ky))
function code(kx, ky, th) return Float64(sin(th) / Float64(hypot(sin(ky), sin(kx)) / sin(ky))) end
function tmp = code(kx, ky, th) tmp = sin(th) / (hypot(sin(ky), sin(kx)) / sin(ky)); end
code[kx_, ky_, th_] := N[(N[Sin[th], $MachinePrecision] / N[(N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin th}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right)}{\sin ky}}
\end{array}
Initial program 92.9%
associate-*l/90.5%
associate-*r/92.9%
+-commutative92.9%
unpow292.9%
unpow292.9%
hypot-def99.6%
Simplified99.6%
associate-*r/95.0%
*-commutative95.0%
associate-/l*99.6%
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -0.1)
(fabs (sin th))
(if (<= (sin ky) -1e-179)
(/ (- (sin th)) (/ ky (sin ky)))
(if (<= (sin ky) 2e-53) (* (sin ky) (/ (sin th) (sin kx))) (sin th)))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.1) {
tmp = fabs(sin(th));
} else if (sin(ky) <= -1e-179) {
tmp = -sin(th) / (ky / sin(ky));
} else if (sin(ky) <= 2e-53) {
tmp = sin(ky) * (sin(th) / sin(kx));
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(ky) <= (-0.1d0)) then
tmp = abs(sin(th))
else if (sin(ky) <= (-1d-179)) then
tmp = -sin(th) / (ky / sin(ky))
else if (sin(ky) <= 2d-53) then
tmp = sin(ky) * (sin(th) / sin(kx))
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -0.1) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(ky) <= -1e-179) {
tmp = -Math.sin(th) / (ky / Math.sin(ky));
} else if (Math.sin(ky) <= 2e-53) {
tmp = Math.sin(ky) * (Math.sin(th) / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.1: tmp = math.fabs(math.sin(th)) elif math.sin(ky) <= -1e-179: tmp = -math.sin(th) / (ky / math.sin(ky)) elif math.sin(ky) <= 2e-53: tmp = math.sin(ky) * (math.sin(th) / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.1) tmp = abs(sin(th)); elseif (sin(ky) <= -1e-179) tmp = Float64(Float64(-sin(th)) / Float64(ky / sin(ky))); elseif (sin(ky) <= 2e-53) tmp = Float64(sin(ky) * Float64(sin(th) / sin(kx))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.1) tmp = abs(sin(th)); elseif (sin(ky) <= -1e-179) tmp = -sin(th) / (ky / sin(ky)); elseif (sin(ky) <= 2e-53) tmp = sin(ky) * (sin(th) / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.1], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], -1e-179], N[((-N[Sin[th], $MachinePrecision]) / N[(ky / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-53], N[(N[Sin[ky], $MachinePrecision] * 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 -0.1:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq -1 \cdot 10^{-179}:\\
\;\;\;\;\frac{-\sin th}{\frac{ky}{\sin ky}}\\
\mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-53}:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.10000000000000001Initial program 99.5%
associate-*l/99.6%
associate-*r/99.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.6%
Simplified99.6%
associate-*r/99.6%
associate-/l*99.2%
div-inv99.1%
associate-/r*99.4%
Applied egg-rr99.4%
Taylor expanded in kx around 0 2.7%
remove-double-div2.7%
add-sqr-sqrt1.4%
sqrt-unprod16.8%
pow216.8%
Applied egg-rr16.8%
unpow216.8%
rem-sqrt-square22.5%
Simplified22.5%
if -0.10000000000000001 < (sin.f64 ky) < -1e-179Initial program 91.8%
+-commutative91.8%
unpow291.8%
unpow291.8%
hypot-def99.8%
Simplified99.8%
Taylor expanded in ky around 0 99.8%
Taylor expanded in ky around -inf 42.1%
mul-1-neg42.1%
associate-/l*63.2%
distribute-neg-frac63.2%
Simplified63.2%
if -1e-179 < (sin.f64 ky) < 2.00000000000000006e-53Initial program 84.2%
associate-*l/82.7%
associate-*r/84.2%
+-commutative84.2%
unpow284.2%
unpow284.2%
hypot-def99.6%
Simplified99.6%
Taylor expanded in ky around 0 56.2%
if 2.00000000000000006e-53 < (sin.f64 ky) Initial program 99.6%
associate-*l/99.6%
associate-*r/99.5%
+-commutative99.5%
unpow299.5%
unpow299.5%
hypot-def99.5%
Simplified99.5%
Taylor expanded in kx around 0 51.1%
Final simplification47.9%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -0.1)
(fabs (sin th))
(if (<= (sin ky) -1e-179)
(/ (- (sin th)) (/ ky (sin ky)))
(if (<= (sin ky) 2e-53) (/ (sin th) (/ (sin kx) ky)) (sin th)))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.1) {
tmp = fabs(sin(th));
} else if (sin(ky) <= -1e-179) {
tmp = -sin(th) / (ky / sin(ky));
} else if (sin(ky) <= 2e-53) {
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) <= (-0.1d0)) then
tmp = abs(sin(th))
else if (sin(ky) <= (-1d-179)) then
tmp = -sin(th) / (ky / sin(ky))
else if (sin(ky) <= 2d-53) 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) <= -0.1) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(ky) <= -1e-179) {
tmp = -Math.sin(th) / (ky / Math.sin(ky));
} else if (Math.sin(ky) <= 2e-53) {
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) <= -0.1: tmp = math.fabs(math.sin(th)) elif math.sin(ky) <= -1e-179: tmp = -math.sin(th) / (ky / math.sin(ky)) elif math.sin(ky) <= 2e-53: 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) <= -0.1) tmp = abs(sin(th)); elseif (sin(ky) <= -1e-179) tmp = Float64(Float64(-sin(th)) / Float64(ky / sin(ky))); elseif (sin(ky) <= 2e-53) 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) <= -0.1) tmp = abs(sin(th)); elseif (sin(ky) <= -1e-179) tmp = -sin(th) / (ky / sin(ky)); elseif (sin(ky) <= 2e-53) 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], -0.1], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], -1e-179], N[((-N[Sin[th], $MachinePrecision]) / N[(ky / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-53], 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 -0.1:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq -1 \cdot 10^{-179}:\\
\;\;\;\;\frac{-\sin th}{\frac{ky}{\sin ky}}\\
\mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-53}:\\
\;\;\;\;\frac{\sin th}{\frac{\sin kx}{ky}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.10000000000000001Initial program 99.5%
associate-*l/99.6%
associate-*r/99.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.6%
Simplified99.6%
associate-*r/99.6%
associate-/l*99.2%
div-inv99.1%
associate-/r*99.4%
Applied egg-rr99.4%
Taylor expanded in kx around 0 2.7%
remove-double-div2.7%
add-sqr-sqrt1.4%
sqrt-unprod16.8%
pow216.8%
Applied egg-rr16.8%
unpow216.8%
rem-sqrt-square22.5%
Simplified22.5%
if -0.10000000000000001 < (sin.f64 ky) < -1e-179Initial program 91.8%
+-commutative91.8%
unpow291.8%
unpow291.8%
hypot-def99.8%
Simplified99.8%
Taylor expanded in ky around 0 99.8%
Taylor expanded in ky around -inf 42.1%
mul-1-neg42.1%
associate-/l*63.2%
distribute-neg-frac63.2%
Simplified63.2%
if -1e-179 < (sin.f64 ky) < 2.00000000000000006e-53Initial program 84.2%
associate-*l/82.7%
associate-*r/84.2%
+-commutative84.2%
unpow284.2%
unpow284.2%
hypot-def99.6%
Simplified99.6%
Taylor expanded in ky around 0 54.0%
associate-/l*56.2%
Simplified56.2%
if 2.00000000000000006e-53 < (sin.f64 ky) Initial program 99.6%
associate-*l/99.6%
associate-*r/99.5%
+-commutative99.5%
unpow299.5%
unpow299.5%
hypot-def99.5%
Simplified99.5%
Taylor expanded in kx around 0 51.1%
Final simplification47.9%
(FPCore (kx ky th) :precision binary64 (* (sin ky) (/ (sin th) (hypot (sin ky) (sin kx)))))
double code(double kx, double ky, double th) {
return sin(ky) * (sin(th) / hypot(sin(ky), sin(kx)));
}
public static double code(double kx, double ky, double th) {
return Math.sin(ky) * (Math.sin(th) / Math.hypot(Math.sin(ky), Math.sin(kx)));
}
def code(kx, ky, th): return math.sin(ky) * (math.sin(th) / math.hypot(math.sin(ky), math.sin(kx)))
function code(kx, ky, th) return Float64(sin(ky) * Float64(sin(th) / hypot(sin(ky), sin(kx)))) end
function tmp = code(kx, ky, th) tmp = sin(ky) * (sin(th) / hypot(sin(ky), sin(kx))); end
code[kx_, ky_, th_] := N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}
\end{array}
Initial program 92.9%
associate-*l/90.5%
associate-*r/92.9%
+-commutative92.9%
unpow292.9%
unpow292.9%
hypot-def99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (/ ky (hypot ky (sin kx)))))
(if (<= th -1.0)
(* (sin th) t_1)
(if (<= th 180000.0)
(/
(/ (sin ky) (hypot (sin ky) (sin kx)))
(+ (/ 1.0 th) (* th 0.16666666666666666)))
(/ t_1 (/ 1.0 (sin th)))))))
double code(double kx, double ky, double th) {
double t_1 = ky / hypot(ky, sin(kx));
double tmp;
if (th <= -1.0) {
tmp = sin(th) * t_1;
} else if (th <= 180000.0) {
tmp = (sin(ky) / hypot(sin(ky), sin(kx))) / ((1.0 / th) + (th * 0.16666666666666666));
} else {
tmp = t_1 / (1.0 / sin(th));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = ky / Math.hypot(ky, Math.sin(kx));
double tmp;
if (th <= -1.0) {
tmp = Math.sin(th) * t_1;
} else if (th <= 180000.0) {
tmp = (Math.sin(ky) / Math.hypot(Math.sin(ky), Math.sin(kx))) / ((1.0 / th) + (th * 0.16666666666666666));
} else {
tmp = t_1 / (1.0 / Math.sin(th));
}
return tmp;
}
def code(kx, ky, th): t_1 = ky / math.hypot(ky, math.sin(kx)) tmp = 0 if th <= -1.0: tmp = math.sin(th) * t_1 elif th <= 180000.0: tmp = (math.sin(ky) / math.hypot(math.sin(ky), math.sin(kx))) / ((1.0 / th) + (th * 0.16666666666666666)) else: tmp = t_1 / (1.0 / math.sin(th)) return tmp
function code(kx, ky, th) t_1 = Float64(ky / hypot(ky, sin(kx))) tmp = 0.0 if (th <= -1.0) tmp = Float64(sin(th) * t_1); elseif (th <= 180000.0) tmp = Float64(Float64(sin(ky) / hypot(sin(ky), sin(kx))) / Float64(Float64(1.0 / th) + Float64(th * 0.16666666666666666))); else tmp = Float64(t_1 / Float64(1.0 / sin(th))); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = ky / hypot(ky, sin(kx)); tmp = 0.0; if (th <= -1.0) tmp = sin(th) * t_1; elseif (th <= 180000.0) tmp = (sin(ky) / hypot(sin(ky), sin(kx))) / ((1.0 / th) + (th * 0.16666666666666666)); else tmp = t_1 / (1.0 / sin(th)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(ky / N[Sqrt[ky ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[th, -1.0], N[(N[Sin[th], $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[th, 180000.0], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 / th), $MachinePrecision] + N[(th * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 / N[(1.0 / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{ky}{\mathsf{hypot}\left(ky, \sin kx\right)}\\
\mathbf{if}\;th \leq -1:\\
\;\;\;\;\sin th \cdot t_1\\
\mathbf{elif}\;th \leq 180000:\\
\;\;\;\;\frac{\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}}{\frac{1}{th} + th \cdot 0.16666666666666666}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_1}{\frac{1}{\sin th}}\\
\end{array}
\end{array}
if th < -1Initial program 93.0%
+-commutative93.0%
unpow293.0%
unpow293.0%
hypot-def99.6%
Simplified99.6%
Taylor expanded in ky around 0 54.7%
Taylor expanded in ky around 0 66.3%
if -1 < th < 1.8e5Initial program 93.3%
associate-*l/88.5%
associate-*r/93.4%
+-commutative93.4%
unpow293.4%
unpow293.4%
hypot-def99.6%
Simplified99.6%
associate-*r/90.8%
associate-/l*99.6%
div-inv99.5%
associate-/r*99.5%
Applied egg-rr99.5%
Taylor expanded in th around 0 96.9%
*-commutative23.6%
Simplified96.9%
if 1.8e5 < th Initial program 92.1%
associate-*l/92.2%
associate-*r/92.1%
+-commutative92.1%
unpow292.1%
unpow292.1%
hypot-def99.5%
Simplified99.5%
associate-*r/99.6%
associate-/l*99.2%
div-inv99.1%
associate-/r*99.5%
Applied egg-rr99.5%
Taylor expanded in ky around 0 65.0%
Taylor expanded in ky around 0 66.3%
Final simplification82.1%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (/ ky (hypot ky (sin kx)))))
(if (<= th -1.0)
(* (sin th) t_1)
(if (<= th 14.5)
(* th (/ (sin ky) (hypot (sin ky) (sin kx))))
(/ t_1 (/ 1.0 (sin th)))))))
double code(double kx, double ky, double th) {
double t_1 = ky / hypot(ky, sin(kx));
double tmp;
if (th <= -1.0) {
tmp = sin(th) * t_1;
} else if (th <= 14.5) {
tmp = th * (sin(ky) / hypot(sin(ky), sin(kx)));
} else {
tmp = t_1 / (1.0 / sin(th));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = ky / Math.hypot(ky, Math.sin(kx));
double tmp;
if (th <= -1.0) {
tmp = Math.sin(th) * t_1;
} else if (th <= 14.5) {
tmp = th * (Math.sin(ky) / Math.hypot(Math.sin(ky), Math.sin(kx)));
} else {
tmp = t_1 / (1.0 / Math.sin(th));
}
return tmp;
}
def code(kx, ky, th): t_1 = ky / math.hypot(ky, math.sin(kx)) tmp = 0 if th <= -1.0: tmp = math.sin(th) * t_1 elif th <= 14.5: tmp = th * (math.sin(ky) / math.hypot(math.sin(ky), math.sin(kx))) else: tmp = t_1 / (1.0 / math.sin(th)) return tmp
function code(kx, ky, th) t_1 = Float64(ky / hypot(ky, sin(kx))) tmp = 0.0 if (th <= -1.0) tmp = Float64(sin(th) * t_1); elseif (th <= 14.5) tmp = Float64(th * Float64(sin(ky) / hypot(sin(ky), sin(kx)))); else tmp = Float64(t_1 / Float64(1.0 / sin(th))); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = ky / hypot(ky, sin(kx)); tmp = 0.0; if (th <= -1.0) tmp = sin(th) * t_1; elseif (th <= 14.5) tmp = th * (sin(ky) / hypot(sin(ky), sin(kx))); else tmp = t_1 / (1.0 / sin(th)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(ky / N[Sqrt[ky ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[th, -1.0], N[(N[Sin[th], $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[th, 14.5], N[(th * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 / N[(1.0 / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{ky}{\mathsf{hypot}\left(ky, \sin kx\right)}\\
\mathbf{if}\;th \leq -1:\\
\;\;\;\;\sin th \cdot t_1\\
\mathbf{elif}\;th \leq 14.5:\\
\;\;\;\;th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_1}{\frac{1}{\sin th}}\\
\end{array}
\end{array}
if th < -1Initial program 93.0%
+-commutative93.0%
unpow293.0%
unpow293.0%
hypot-def99.6%
Simplified99.6%
Taylor expanded in ky around 0 54.7%
Taylor expanded in ky around 0 66.3%
if -1 < th < 14.5Initial program 93.3%
associate-/r/93.3%
+-commutative93.3%
unpow293.3%
unpow293.3%
hypot-def99.6%
Simplified99.6%
Taylor expanded in th around 0 91.0%
associate-*r/91.1%
unpow291.1%
unpow291.1%
hypot-def97.4%
*-rgt-identity97.4%
hypot-def91.1%
unpow291.1%
unpow291.1%
+-commutative91.1%
unpow291.1%
unpow291.1%
hypot-def97.4%
Simplified97.4%
associate-/r/97.3%
hypot-udef91.0%
+-commutative91.0%
hypot-udef97.3%
expm1-log1p-u97.3%
expm1-log1p-u97.3%
Applied egg-rr97.3%
if 14.5 < th Initial program 92.2%
associate-*l/92.3%
associate-*r/92.2%
+-commutative92.2%
unpow292.2%
unpow292.2%
hypot-def99.6%
Simplified99.6%
associate-*r/99.6%
associate-/l*99.2%
div-inv99.1%
associate-/r*99.5%
Applied egg-rr99.5%
Taylor expanded in ky around 0 64.3%
Taylor expanded in ky around 0 65.3%
Final simplification81.9%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (/ ky (hypot ky (sin kx)))))
(if (<= th -1.0)
(* (sin th) t_1)
(if (<= th 14.5)
(/ (sin ky) (/ (hypot (sin kx) (sin ky)) th))
(/ t_1 (/ 1.0 (sin th)))))))
double code(double kx, double ky, double th) {
double t_1 = ky / hypot(ky, sin(kx));
double tmp;
if (th <= -1.0) {
tmp = sin(th) * t_1;
} else if (th <= 14.5) {
tmp = sin(ky) / (hypot(sin(kx), sin(ky)) / th);
} else {
tmp = t_1 / (1.0 / sin(th));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = ky / Math.hypot(ky, Math.sin(kx));
double tmp;
if (th <= -1.0) {
tmp = Math.sin(th) * t_1;
} else if (th <= 14.5) {
tmp = Math.sin(ky) / (Math.hypot(Math.sin(kx), Math.sin(ky)) / th);
} else {
tmp = t_1 / (1.0 / Math.sin(th));
}
return tmp;
}
def code(kx, ky, th): t_1 = ky / math.hypot(ky, math.sin(kx)) tmp = 0 if th <= -1.0: tmp = math.sin(th) * t_1 elif th <= 14.5: tmp = math.sin(ky) / (math.hypot(math.sin(kx), math.sin(ky)) / th) else: tmp = t_1 / (1.0 / math.sin(th)) return tmp
function code(kx, ky, th) t_1 = Float64(ky / hypot(ky, sin(kx))) tmp = 0.0 if (th <= -1.0) tmp = Float64(sin(th) * t_1); elseif (th <= 14.5) tmp = Float64(sin(ky) / Float64(hypot(sin(kx), sin(ky)) / th)); else tmp = Float64(t_1 / Float64(1.0 / sin(th))); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = ky / hypot(ky, sin(kx)); tmp = 0.0; if (th <= -1.0) tmp = sin(th) * t_1; elseif (th <= 14.5) tmp = sin(ky) / (hypot(sin(kx), sin(ky)) / th); else tmp = t_1 / (1.0 / sin(th)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(ky / N[Sqrt[ky ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[th, -1.0], N[(N[Sin[th], $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[th, 14.5], N[(N[Sin[ky], $MachinePrecision] / N[(N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision] / th), $MachinePrecision]), $MachinePrecision], N[(t$95$1 / N[(1.0 / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{ky}{\mathsf{hypot}\left(ky, \sin kx\right)}\\
\mathbf{if}\;th \leq -1:\\
\;\;\;\;\sin th \cdot t_1\\
\mathbf{elif}\;th \leq 14.5:\\
\;\;\;\;\frac{\sin ky}{\frac{\mathsf{hypot}\left(\sin kx, \sin ky\right)}{th}}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_1}{\frac{1}{\sin th}}\\
\end{array}
\end{array}
if th < -1Initial program 93.0%
+-commutative93.0%
unpow293.0%
unpow293.0%
hypot-def99.6%
Simplified99.6%
Taylor expanded in ky around 0 54.7%
Taylor expanded in ky around 0 66.3%
if -1 < th < 14.5Initial program 93.3%
associate-/r/93.3%
+-commutative93.3%
unpow293.3%
unpow293.3%
hypot-def99.6%
Simplified99.6%
Taylor expanded in th around 0 91.0%
associate-*r/91.1%
unpow291.1%
unpow291.1%
hypot-def97.4%
*-rgt-identity97.4%
hypot-def91.1%
unpow291.1%
unpow291.1%
+-commutative91.1%
unpow291.1%
unpow291.1%
hypot-def97.4%
Simplified97.4%
if 14.5 < th Initial program 92.2%
associate-*l/92.3%
associate-*r/92.2%
+-commutative92.2%
unpow292.2%
unpow292.2%
hypot-def99.6%
Simplified99.6%
associate-*r/99.6%
associate-/l*99.2%
div-inv99.1%
associate-/r*99.5%
Applied egg-rr99.5%
Taylor expanded in ky around 0 64.3%
Taylor expanded in ky around 0 65.3%
Final simplification81.9%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -4e-123) (fabs (sin th)) (if (<= (sin ky) 2e-53) (* (sin th) (/ ky (sin kx))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -4e-123) {
tmp = fabs(sin(th));
} else if (sin(ky) <= 2e-53) {
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) <= (-4d-123)) then
tmp = abs(sin(th))
else if (sin(ky) <= 2d-53) 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) <= -4e-123) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(ky) <= 2e-53) {
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) <= -4e-123: tmp = math.fabs(math.sin(th)) elif math.sin(ky) <= 2e-53: 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) <= -4e-123) tmp = abs(sin(th)); elseif (sin(ky) <= 2e-53) 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) <= -4e-123) tmp = abs(sin(th)); elseif (sin(ky) <= 2e-53) 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], -4e-123], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-53], 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 -4 \cdot 10^{-123}:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-53}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -4.0000000000000002e-123Initial program 99.6%
associate-*l/95.1%
associate-*r/99.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.6%
Simplified99.6%
associate-*r/95.0%
associate-/l*99.4%
div-inv99.2%
associate-/r*99.5%
Applied egg-rr99.5%
Taylor expanded in kx around 0 3.0%
remove-double-div3.0%
add-sqr-sqrt1.4%
sqrt-unprod19.1%
pow219.1%
Applied egg-rr19.1%
unpow219.1%
rem-sqrt-square26.8%
Simplified26.8%
if -4.0000000000000002e-123 < (sin.f64 ky) < 2.00000000000000006e-53Initial program 83.5%
+-commutative83.5%
unpow283.5%
unpow283.5%
hypot-def99.5%
Simplified99.5%
Taylor expanded in ky around 0 53.4%
if 2.00000000000000006e-53 < (sin.f64 ky) Initial program 99.6%
associate-*l/99.6%
associate-*r/99.5%
+-commutative99.5%
unpow299.5%
unpow299.5%
hypot-def99.5%
Simplified99.5%
Taylor expanded in kx around 0 51.1%
Final simplification44.8%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -4e-123) (fabs (sin th)) (if (<= (sin ky) 2e-53) (/ ky (/ (sin kx) (sin th))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -4e-123) {
tmp = fabs(sin(th));
} else if (sin(ky) <= 2e-53) {
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) <= (-4d-123)) then
tmp = abs(sin(th))
else if (sin(ky) <= 2d-53) 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) <= -4e-123) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(ky) <= 2e-53) {
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) <= -4e-123: tmp = math.fabs(math.sin(th)) elif math.sin(ky) <= 2e-53: 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) <= -4e-123) tmp = abs(sin(th)); elseif (sin(ky) <= 2e-53) 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) <= -4e-123) tmp = abs(sin(th)); elseif (sin(ky) <= 2e-53) 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], -4e-123], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-53], 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 -4 \cdot 10^{-123}:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-53}:\\
\;\;\;\;\frac{ky}{\frac{\sin kx}{\sin th}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -4.0000000000000002e-123Initial program 99.6%
associate-*l/95.1%
associate-*r/99.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.6%
Simplified99.6%
associate-*r/95.0%
associate-/l*99.4%
div-inv99.2%
associate-/r*99.5%
Applied egg-rr99.5%
Taylor expanded in kx around 0 3.0%
remove-double-div3.0%
add-sqr-sqrt1.4%
sqrt-unprod19.1%
pow219.1%
Applied egg-rr19.1%
unpow219.1%
rem-sqrt-square26.8%
Simplified26.8%
if -4.0000000000000002e-123 < (sin.f64 ky) < 2.00000000000000006e-53Initial program 83.5%
associate-/r/83.5%
+-commutative83.5%
unpow283.5%
unpow283.5%
hypot-def99.5%
Simplified99.5%
Taylor expanded in ky around 0 53.5%
Taylor expanded in ky around 0 53.5%
if 2.00000000000000006e-53 < (sin.f64 ky) Initial program 99.6%
associate-*l/99.6%
associate-*r/99.5%
+-commutative99.5%
unpow299.5%
unpow299.5%
hypot-def99.5%
Simplified99.5%
Taylor expanded in kx around 0 51.1%
Final simplification44.8%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -4e-123) (fabs (sin th)) (if (<= (sin ky) 2e-53) (/ (sin th) (/ (sin kx) ky)) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -4e-123) {
tmp = fabs(sin(th));
} else if (sin(ky) <= 2e-53) {
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) <= (-4d-123)) then
tmp = abs(sin(th))
else if (sin(ky) <= 2d-53) 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) <= -4e-123) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(ky) <= 2e-53) {
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) <= -4e-123: tmp = math.fabs(math.sin(th)) elif math.sin(ky) <= 2e-53: 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) <= -4e-123) tmp = abs(sin(th)); elseif (sin(ky) <= 2e-53) 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) <= -4e-123) tmp = abs(sin(th)); elseif (sin(ky) <= 2e-53) 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], -4e-123], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-53], 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 -4 \cdot 10^{-123}:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-53}:\\
\;\;\;\;\frac{\sin th}{\frac{\sin kx}{ky}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -4.0000000000000002e-123Initial program 99.6%
associate-*l/95.1%
associate-*r/99.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.6%
Simplified99.6%
associate-*r/95.0%
associate-/l*99.4%
div-inv99.2%
associate-/r*99.5%
Applied egg-rr99.5%
Taylor expanded in kx around 0 3.0%
remove-double-div3.0%
add-sqr-sqrt1.4%
sqrt-unprod19.1%
pow219.1%
Applied egg-rr19.1%
unpow219.1%
rem-sqrt-square26.8%
Simplified26.8%
if -4.0000000000000002e-123 < (sin.f64 ky) < 2.00000000000000006e-53Initial program 83.5%
associate-*l/80.9%
associate-*r/83.6%
+-commutative83.6%
unpow283.6%
unpow283.6%
hypot-def99.6%
Simplified99.6%
Taylor expanded in ky around 0 51.7%
associate-/l*53.5%
Simplified53.5%
if 2.00000000000000006e-53 < (sin.f64 ky) Initial program 99.6%
associate-*l/99.6%
associate-*r/99.5%
+-commutative99.5%
unpow299.5%
unpow299.5%
hypot-def99.5%
Simplified99.5%
Taylor expanded in kx around 0 51.1%
Final simplification44.8%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) 5e-15) (* (sin th) (/ ky (hypot ky (sin kx)))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= 5e-15) {
tmp = sin(th) * (ky / hypot(ky, sin(kx)));
} else {
tmp = sin(th);
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= 5e-15) {
tmp = Math.sin(th) * (ky / Math.hypot(ky, Math.sin(kx)));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= 5e-15: tmp = math.sin(th) * (ky / math.hypot(ky, math.sin(kx))) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= 5e-15) tmp = Float64(sin(th) * Float64(ky / hypot(ky, sin(kx)))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= 5e-15) tmp = sin(th) * (ky / hypot(ky, sin(kx))); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], 5e-15], N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Sqrt[ky ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq 5 \cdot 10^{-15}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\mathsf{hypot}\left(ky, \sin kx\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < 4.99999999999999999e-15Initial program 90.8%
+-commutative90.8%
unpow290.8%
unpow290.8%
hypot-def99.6%
Simplified99.6%
Taylor expanded in ky around 0 71.4%
Taylor expanded in ky around 0 76.8%
if 4.99999999999999999e-15 < (sin.f64 ky) Initial program 99.6%
associate-*l/99.7%
associate-*r/99.5%
+-commutative99.5%
unpow299.5%
unpow299.5%
hypot-def99.5%
Simplified99.5%
Taylor expanded in kx around 0 52.1%
Final simplification70.7%
(FPCore (kx ky th) :precision binary64 (if (<= ky -3.4e-131) (fabs (sin th)) (if (<= ky 1.3e-53) (/ th (/ (sin kx) ky)) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= -3.4e-131) {
tmp = fabs(sin(th));
} else if (ky <= 1.3e-53) {
tmp = 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 (ky <= (-3.4d-131)) then
tmp = abs(sin(th))
else if (ky <= 1.3d-53) then
tmp = 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 (ky <= -3.4e-131) {
tmp = Math.abs(Math.sin(th));
} else if (ky <= 1.3e-53) {
tmp = th / (Math.sin(kx) / ky);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= -3.4e-131: tmp = math.fabs(math.sin(th)) elif ky <= 1.3e-53: tmp = th / (math.sin(kx) / ky) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= -3.4e-131) tmp = abs(sin(th)); elseif (ky <= 1.3e-53) tmp = Float64(th / Float64(sin(kx) / ky)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= -3.4e-131) tmp = abs(sin(th)); elseif (ky <= 1.3e-53) tmp = th / (sin(kx) / ky); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, -3.4e-131], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[ky, 1.3e-53], N[(th / N[(N[Sin[kx], $MachinePrecision] / ky), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq -3.4 \cdot 10^{-131}:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;ky \leq 1.3 \cdot 10^{-53}:\\
\;\;\;\;\frac{th}{\frac{\sin kx}{ky}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < -3.39999999999999995e-131Initial program 99.6%
associate-*l/95.6%
associate-*r/99.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.6%
Simplified99.6%
associate-*r/95.6%
associate-/l*99.5%
div-inv99.5%
associate-/r*99.5%
Applied egg-rr99.5%
Taylor expanded in kx around 0 22.7%
remove-double-div22.7%
add-sqr-sqrt13.5%
sqrt-unprod21.4%
pow221.4%
Applied egg-rr21.4%
unpow221.4%
rem-sqrt-square32.5%
Simplified32.5%
if -3.39999999999999995e-131 < ky < 1.29999999999999998e-53Initial program 83.2%
associate-/r/83.2%
+-commutative83.2%
unpow283.2%
unpow283.2%
hypot-def99.5%
Simplified99.5%
Taylor expanded in th around 0 42.0%
associate-*r/42.0%
unpow242.0%
unpow242.0%
hypot-def50.1%
*-rgt-identity50.1%
hypot-def42.0%
unpow242.0%
unpow242.0%
+-commutative42.0%
unpow242.0%
unpow242.0%
hypot-def50.1%
Simplified50.1%
Taylor expanded in ky around 0 31.7%
*-commutative31.7%
associate-/l*33.6%
Simplified33.6%
if 1.29999999999999998e-53 < ky Initial program 99.6%
associate-*l/99.6%
associate-*r/99.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.5%
Simplified99.5%
Taylor expanded in kx around 0 30.5%
Final simplification32.4%
(FPCore (kx ky th) :precision binary64 (if (<= ky -3.1) (sin th) (if (<= ky 1.3e-53) (* th (/ ky (sin kx))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= -3.1) {
tmp = sin(th);
} else if (ky <= 1.3e-53) {
tmp = 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 (ky <= (-3.1d0)) then
tmp = sin(th)
else if (ky <= 1.3d-53) then
tmp = 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 (ky <= -3.1) {
tmp = Math.sin(th);
} else if (ky <= 1.3e-53) {
tmp = th * (ky / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= -3.1: tmp = math.sin(th) elif ky <= 1.3e-53: tmp = th * (ky / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= -3.1) tmp = sin(th); elseif (ky <= 1.3e-53) tmp = Float64(th * Float64(ky / sin(kx))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= -3.1) tmp = sin(th); elseif (ky <= 1.3e-53) tmp = th * (ky / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, -3.1], N[Sin[th], $MachinePrecision], If[LessEqual[ky, 1.3e-53], N[(th * N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq -3.1:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;ky \leq 1.3 \cdot 10^{-53}:\\
\;\;\;\;th \cdot \frac{ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < -3.10000000000000009 or 1.29999999999999998e-53 < ky Initial program 99.6%
associate-*l/99.6%
associate-*r/99.5%
+-commutative99.5%
unpow299.5%
unpow299.5%
hypot-def99.5%
Simplified99.5%
Taylor expanded in kx around 0 29.7%
if -3.10000000000000009 < ky < 1.29999999999999998e-53Initial program 86.0%
associate-/r/86.0%
+-commutative86.0%
unpow286.0%
unpow286.0%
hypot-def99.5%
Simplified99.5%
Taylor expanded in th around 0 41.6%
associate-*r/41.7%
unpow241.7%
unpow241.7%
hypot-def48.4%
*-rgt-identity48.4%
hypot-def41.7%
unpow241.7%
unpow241.7%
+-commutative41.7%
unpow241.7%
unpow241.7%
hypot-def48.4%
Simplified48.4%
Taylor expanded in ky around 0 27.2%
associate-/l*28.6%
associate-/r/28.6%
Simplified28.6%
Final simplification29.2%
(FPCore (kx ky th) :precision binary64 (if (<= ky -3.1) (sin th) (if (<= ky 6.1e-52) (/ th (/ (sin kx) ky)) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= -3.1) {
tmp = sin(th);
} else if (ky <= 6.1e-52) {
tmp = 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 (ky <= (-3.1d0)) then
tmp = sin(th)
else if (ky <= 6.1d-52) then
tmp = 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 (ky <= -3.1) {
tmp = Math.sin(th);
} else if (ky <= 6.1e-52) {
tmp = th / (Math.sin(kx) / ky);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= -3.1: tmp = math.sin(th) elif ky <= 6.1e-52: tmp = th / (math.sin(kx) / ky) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= -3.1) tmp = sin(th); elseif (ky <= 6.1e-52) tmp = Float64(th / Float64(sin(kx) / ky)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= -3.1) tmp = sin(th); elseif (ky <= 6.1e-52) tmp = th / (sin(kx) / ky); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, -3.1], N[Sin[th], $MachinePrecision], If[LessEqual[ky, 6.1e-52], N[(th / N[(N[Sin[kx], $MachinePrecision] / ky), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq -3.1:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;ky \leq 6.1 \cdot 10^{-52}:\\
\;\;\;\;\frac{th}{\frac{\sin kx}{ky}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < -3.10000000000000009 or 6.0999999999999999e-52 < ky Initial program 99.6%
associate-*l/99.6%
associate-*r/99.5%
+-commutative99.5%
unpow299.5%
unpow299.5%
hypot-def99.5%
Simplified99.5%
Taylor expanded in kx around 0 29.7%
if -3.10000000000000009 < ky < 6.0999999999999999e-52Initial program 86.0%
associate-/r/86.0%
+-commutative86.0%
unpow286.0%
unpow286.0%
hypot-def99.5%
Simplified99.5%
Taylor expanded in th around 0 41.6%
associate-*r/41.7%
unpow241.7%
unpow241.7%
hypot-def48.4%
*-rgt-identity48.4%
hypot-def41.7%
unpow241.7%
unpow241.7%
+-commutative41.7%
unpow241.7%
unpow241.7%
hypot-def48.4%
Simplified48.4%
Taylor expanded in ky around 0 27.2%
*-commutative27.2%
associate-/l*28.7%
Simplified28.7%
Final simplification29.2%
(FPCore (kx ky th) :precision binary64 (if (<= ky -3.1) (sin th) (if (<= ky 1.42e-259) (sqrt (* th th)) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= -3.1) {
tmp = sin(th);
} else if (ky <= 1.42e-259) {
tmp = sqrt((th * 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 <= (-3.1d0)) then
tmp = sin(th)
else if (ky <= 1.42d-259) then
tmp = sqrt((th * 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 <= -3.1) {
tmp = Math.sin(th);
} else if (ky <= 1.42e-259) {
tmp = Math.sqrt((th * th));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= -3.1: tmp = math.sin(th) elif ky <= 1.42e-259: tmp = math.sqrt((th * th)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= -3.1) tmp = sin(th); elseif (ky <= 1.42e-259) tmp = sqrt(Float64(th * th)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= -3.1) tmp = sin(th); elseif (ky <= 1.42e-259) tmp = sqrt((th * th)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, -3.1], N[Sin[th], $MachinePrecision], If[LessEqual[ky, 1.42e-259], N[Sqrt[N[(th * th), $MachinePrecision]], $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq -3.1:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;ky \leq 1.42 \cdot 10^{-259}:\\
\;\;\;\;\sqrt{th \cdot th}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < -3.10000000000000009 or 1.42e-259 < ky Initial program 94.1%
associate-*l/93.5%
associate-*r/94.1%
+-commutative94.1%
unpow294.1%
unpow294.1%
hypot-def99.5%
Simplified99.5%
Taylor expanded in kx around 0 27.7%
if -3.10000000000000009 < ky < 1.42e-259Initial program 90.2%
associate-*l/83.4%
associate-*r/90.2%
+-commutative90.2%
unpow290.2%
unpow290.2%
hypot-def99.7%
Simplified99.7%
associate-*r/87.3%
associate-/l*99.6%
div-inv99.6%
associate-/r*99.6%
Applied egg-rr99.6%
Taylor expanded in kx around 0 4.0%
Taylor expanded in th around 0 4.2%
remove-double-div4.2%
add-sqr-sqrt2.0%
sqrt-unprod17.4%
Applied egg-rr17.4%
Final simplification24.6%
(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 92.9%
associate-*l/90.5%
associate-*r/92.9%
+-commutative92.9%
unpow292.9%
unpow292.9%
hypot-def99.6%
Simplified99.6%
Taylor expanded in kx around 0 20.6%
Final simplification20.6%
(FPCore (kx ky th) :precision binary64 (/ 1.0 (+ (/ 1.0 th) (* th 0.16666666666666666))))
double code(double kx, double ky, double th) {
return 1.0 / ((1.0 / th) + (th * 0.16666666666666666));
}
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 / ((1.0d0 / th) + (th * 0.16666666666666666d0))
end function
public static double code(double kx, double ky, double th) {
return 1.0 / ((1.0 / th) + (th * 0.16666666666666666));
}
def code(kx, ky, th): return 1.0 / ((1.0 / th) + (th * 0.16666666666666666))
function code(kx, ky, th) return Float64(1.0 / Float64(Float64(1.0 / th) + Float64(th * 0.16666666666666666))) end
function tmp = code(kx, ky, th) tmp = 1.0 / ((1.0 / th) + (th * 0.16666666666666666)); end
code[kx_, ky_, th_] := N[(1.0 / N[(N[(1.0 / th), $MachinePrecision] + N[(th * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\frac{1}{th} + th \cdot 0.16666666666666666}
\end{array}
Initial program 92.9%
associate-*l/90.5%
associate-*r/92.9%
+-commutative92.9%
unpow292.9%
unpow292.9%
hypot-def99.6%
Simplified99.6%
associate-*r/95.0%
associate-/l*99.5%
div-inv99.4%
associate-/r*99.5%
Applied egg-rr99.5%
Taylor expanded in kx around 0 20.6%
Taylor expanded in th around 0 14.4%
*-commutative14.4%
Simplified14.4%
Final simplification14.4%
(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 92.9%
associate-*l/90.5%
associate-*r/92.9%
+-commutative92.9%
unpow292.9%
unpow292.9%
hypot-def99.6%
Simplified99.6%
associate-*r/95.0%
associate-/l*99.5%
div-inv99.4%
associate-/r*99.5%
Applied egg-rr99.5%
Taylor expanded in kx around 0 20.6%
Taylor expanded in th around 0 13.8%
Final simplification13.8%
herbie shell --seed 2023200
(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)))