
(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 91.1%
remove-double-neg91.1%
sin-neg91.1%
neg-mul-191.1%
*-commutative91.1%
associate-*l*91.1%
associate-*l/88.5%
associate-/r/88.5%
associate-*l/91.1%
associate-/r/91.0%
sin-neg91.0%
neg-mul-191.0%
associate-/r*91.0%
associate-/r/91.1%
Simplified99.7%
Final simplification99.7%
(FPCore (kx ky th) :precision binary64 (let* ((t_1 (* (sin th) (/ (sin ky) (sin kx))))) (if (<= (sin kx) -0.01) (fabs t_1) (if (<= (sin kx) 5e-206) (sin th) t_1))))
double code(double kx, double ky, double th) {
double t_1 = sin(th) * (sin(ky) / sin(kx));
double tmp;
if (sin(kx) <= -0.01) {
tmp = fabs(t_1);
} else if (sin(kx) <= 5e-206) {
tmp = sin(th);
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: t_1
real(8) :: tmp
t_1 = sin(th) * (sin(ky) / sin(kx))
if (sin(kx) <= (-0.01d0)) then
tmp = abs(t_1)
else if (sin(kx) <= 5d-206) then
tmp = sin(th)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double t_1 = Math.sin(th) * (Math.sin(ky) / Math.sin(kx));
double tmp;
if (Math.sin(kx) <= -0.01) {
tmp = Math.abs(t_1);
} else if (Math.sin(kx) <= 5e-206) {
tmp = Math.sin(th);
} else {
tmp = t_1;
}
return tmp;
}
def code(kx, ky, th): t_1 = math.sin(th) * (math.sin(ky) / math.sin(kx)) tmp = 0 if math.sin(kx) <= -0.01: tmp = math.fabs(t_1) elif math.sin(kx) <= 5e-206: tmp = math.sin(th) else: tmp = t_1 return tmp
function code(kx, ky, th) t_1 = Float64(sin(th) * Float64(sin(ky) / sin(kx))) tmp = 0.0 if (sin(kx) <= -0.01) tmp = abs(t_1); elseif (sin(kx) <= 5e-206) tmp = sin(th); else tmp = t_1; end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = sin(th) * (sin(ky) / sin(kx)); tmp = 0.0; if (sin(kx) <= -0.01) tmp = abs(t_1); elseif (sin(kx) <= 5e-206) tmp = sin(th); else tmp = t_1; end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Sin[kx], $MachinePrecision], -0.01], N[Abs[t$95$1], $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 5e-206], N[Sin[th], $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \sin th \cdot \frac{\sin ky}{\sin kx}\\
\mathbf{if}\;\sin kx \leq -0.01:\\
\;\;\;\;\left|t_1\right|\\
\mathbf{elif}\;\sin kx \leq 5 \cdot 10^{-206}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.0100000000000000002Initial program 99.5%
Taylor expanded in ky around 0 17.7%
add-sqr-sqrt9.3%
sqrt-unprod26.3%
pow226.3%
Applied egg-rr26.3%
unpow226.3%
rem-sqrt-square29.0%
Simplified29.0%
add-sqr-sqrt23.2%
sqrt-unprod31.0%
pow231.0%
*-commutative31.0%
add-sqr-sqrt17.6%
fabs-sqr17.6%
add-sqr-sqrt31.0%
Applied egg-rr31.0%
unpow231.0%
rem-sqrt-square40.1%
Simplified40.1%
if -0.0100000000000000002 < (sin.f64 kx) < 5e-206Initial program 79.3%
Taylor expanded in kx around 0 41.5%
if 5e-206 < (sin.f64 kx) Initial program 97.2%
Taylor expanded in ky around 0 45.7%
Final simplification42.7%
(FPCore (kx ky th) :precision binary64 (* (sin ky) (/ (sin th) (hypot (sin ky) (sin kx)))))
double code(double kx, double ky, double th) {
return sin(ky) * (sin(th) / hypot(sin(ky), sin(kx)));
}
public static double code(double kx, double ky, double th) {
return Math.sin(ky) * (Math.sin(th) / Math.hypot(Math.sin(ky), Math.sin(kx)));
}
def code(kx, ky, th): return math.sin(ky) * (math.sin(th) / math.hypot(math.sin(ky), math.sin(kx)))
function code(kx, ky, th) return Float64(sin(ky) * Float64(sin(th) / hypot(sin(ky), sin(kx)))) end
function tmp = code(kx, ky, th) tmp = sin(ky) * (sin(th) / hypot(sin(ky), sin(kx))); end
code[kx_, ky_, th_] := N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}
\end{array}
Initial program 91.1%
expm1-log1p-u90.9%
expm1-udef38.4%
Applied egg-rr41.7%
expm1-def99.6%
expm1-log1p99.7%
*-commutative99.7%
associate-*r/95.4%
associate-*l/99.6%
*-commutative99.6%
hypot-def91.0%
unpow291.0%
unpow291.0%
+-commutative91.0%
unpow291.0%
unpow291.0%
hypot-def99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (hypot (sin kx) (sin ky))))
(if (<= th 0.0195)
(/ (sin ky) (* t_1 (+ (/ 1.0 th) (* th 0.16666666666666666))))
(/ (* ky (sin th)) t_1))))
double code(double kx, double ky, double th) {
double t_1 = hypot(sin(kx), sin(ky));
double tmp;
if (th <= 0.0195) {
tmp = sin(ky) / (t_1 * ((1.0 / th) + (th * 0.16666666666666666)));
} else {
tmp = (ky * sin(th)) / t_1;
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = Math.hypot(Math.sin(kx), Math.sin(ky));
double tmp;
if (th <= 0.0195) {
tmp = Math.sin(ky) / (t_1 * ((1.0 / th) + (th * 0.16666666666666666)));
} else {
tmp = (ky * Math.sin(th)) / t_1;
}
return tmp;
}
def code(kx, ky, th): t_1 = math.hypot(math.sin(kx), math.sin(ky)) tmp = 0 if th <= 0.0195: tmp = math.sin(ky) / (t_1 * ((1.0 / th) + (th * 0.16666666666666666))) else: tmp = (ky * math.sin(th)) / t_1 return tmp
function code(kx, ky, th) t_1 = hypot(sin(kx), sin(ky)) tmp = 0.0 if (th <= 0.0195) tmp = Float64(sin(ky) / Float64(t_1 * Float64(Float64(1.0 / th) + Float64(th * 0.16666666666666666)))); else tmp = Float64(Float64(ky * sin(th)) / t_1); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = hypot(sin(kx), sin(ky)); tmp = 0.0; if (th <= 0.0195) tmp = sin(ky) / (t_1 * ((1.0 / th) + (th * 0.16666666666666666))); else tmp = (ky * sin(th)) / t_1; end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]}, If[LessEqual[th, 0.0195], 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[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{hypot}\left(\sin kx, \sin ky\right)\\
\mathbf{if}\;th \leq 0.0195:\\
\;\;\;\;\frac{\sin ky}{t_1 \cdot \left(\frac{1}{th} + th \cdot 0.16666666666666666\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{ky \cdot \sin th}{t_1}\\
\end{array}
\end{array}
if th < 0.0195Initial program 93.1%
associate-*l/89.8%
associate-/l*93.0%
unpow293.0%
unpow293.0%
hypot-def99.6%
Applied egg-rr99.6%
Taylor expanded in th around 0 68.2%
+-commutative68.2%
unpow268.2%
unpow268.2%
hypot-def71.1%
associate-*r*71.1%
unpow271.1%
unpow271.1%
hypot-def71.1%
distribute-rgt-out71.1%
Simplified71.1%
if 0.0195 < th Initial program 84.2%
expm1-log1p-u83.7%
expm1-udef59.7%
Applied egg-rr70.1%
expm1-def99.5%
expm1-log1p99.7%
associate-*l/99.6%
Simplified99.6%
Taylor expanded in ky around 0 52.8%
Final simplification66.9%
(FPCore (kx ky th) :precision binary64 (if (<= th 0.003) (/ (sin ky) (/ (hypot (sin kx) (sin ky)) th)) (* (sin th) (fabs (/ (sin ky) (sin kx))))))
double code(double kx, double ky, double th) {
double tmp;
if (th <= 0.003) {
tmp = sin(ky) / (hypot(sin(kx), sin(ky)) / th);
} else {
tmp = sin(th) * fabs((sin(ky) / sin(kx)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (th <= 0.003) {
tmp = Math.sin(ky) / (Math.hypot(Math.sin(kx), Math.sin(ky)) / th);
} else {
tmp = Math.sin(th) * Math.abs((Math.sin(ky) / Math.sin(kx)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if th <= 0.003: tmp = math.sin(ky) / (math.hypot(math.sin(kx), math.sin(ky)) / th) else: tmp = math.sin(th) * math.fabs((math.sin(ky) / math.sin(kx))) return tmp
function code(kx, ky, th) tmp = 0.0 if (th <= 0.003) tmp = Float64(sin(ky) / Float64(hypot(sin(kx), sin(ky)) / th)); else tmp = Float64(sin(th) * abs(Float64(sin(ky) / sin(kx)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (th <= 0.003) tmp = sin(ky) / (hypot(sin(kx), sin(ky)) / th); else tmp = sin(th) * abs((sin(ky) / sin(kx))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[th, 0.003], N[(N[Sin[ky], $MachinePrecision] / N[(N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision] / th), $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[Abs[N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;th \leq 0.003:\\
\;\;\;\;\frac{\sin ky}{\frac{\mathsf{hypot}\left(\sin kx, \sin ky\right)}{th}}\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \left|\frac{\sin ky}{\sin kx}\right|\\
\end{array}
\end{array}
if th < 0.0030000000000000001Initial program 93.1%
associate-*l/89.8%
associate-/l*93.0%
unpow293.0%
unpow293.0%
hypot-def99.6%
Applied egg-rr99.6%
Taylor expanded in th around 0 67.6%
associate-*l/67.7%
unpow267.7%
unpow267.7%
hypot-def70.6%
*-lft-identity70.6%
Simplified70.6%
if 0.0030000000000000001 < th Initial program 84.2%
Taylor expanded in ky around 0 18.0%
add-sqr-sqrt9.5%
sqrt-unprod16.6%
pow216.6%
Applied egg-rr16.6%
unpow216.6%
rem-sqrt-square19.0%
Simplified19.0%
Final simplification58.9%
(FPCore (kx ky th) :precision binary64 (let* ((t_1 (hypot (sin kx) (sin ky)))) (if (<= th 0.01) (/ (sin ky) (/ t_1 th)) (/ (* ky (sin th)) t_1))))
double code(double kx, double ky, double th) {
double t_1 = hypot(sin(kx), sin(ky));
double tmp;
if (th <= 0.01) {
tmp = sin(ky) / (t_1 / th);
} else {
tmp = (ky * sin(th)) / t_1;
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = Math.hypot(Math.sin(kx), Math.sin(ky));
double tmp;
if (th <= 0.01) {
tmp = Math.sin(ky) / (t_1 / th);
} else {
tmp = (ky * Math.sin(th)) / t_1;
}
return tmp;
}
def code(kx, ky, th): t_1 = math.hypot(math.sin(kx), math.sin(ky)) tmp = 0 if th <= 0.01: tmp = math.sin(ky) / (t_1 / th) else: tmp = (ky * math.sin(th)) / t_1 return tmp
function code(kx, ky, th) t_1 = hypot(sin(kx), sin(ky)) tmp = 0.0 if (th <= 0.01) tmp = Float64(sin(ky) / Float64(t_1 / th)); else tmp = Float64(Float64(ky * sin(th)) / t_1); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = hypot(sin(kx), sin(ky)); tmp = 0.0; if (th <= 0.01) tmp = sin(ky) / (t_1 / th); else tmp = (ky * sin(th)) / t_1; end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]}, If[LessEqual[th, 0.01], N[(N[Sin[ky], $MachinePrecision] / N[(t$95$1 / th), $MachinePrecision]), $MachinePrecision], N[(N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{hypot}\left(\sin kx, \sin ky\right)\\
\mathbf{if}\;th \leq 0.01:\\
\;\;\;\;\frac{\sin ky}{\frac{t_1}{th}}\\
\mathbf{else}:\\
\;\;\;\;\frac{ky \cdot \sin th}{t_1}\\
\end{array}
\end{array}
if th < 0.0100000000000000002Initial program 93.1%
associate-*l/89.8%
associate-/l*93.0%
unpow293.0%
unpow293.0%
hypot-def99.6%
Applied egg-rr99.6%
Taylor expanded in th around 0 67.6%
associate-*l/67.7%
unpow267.7%
unpow267.7%
hypot-def70.6%
*-lft-identity70.6%
Simplified70.6%
if 0.0100000000000000002 < th Initial program 84.2%
expm1-log1p-u83.7%
expm1-udef59.7%
Applied egg-rr70.1%
expm1-def99.5%
expm1-log1p99.7%
associate-*l/99.6%
Simplified99.6%
Taylor expanded in ky around 0 52.8%
Final simplification66.5%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) 2e-41) (* (sin th) (expm1 (/ ky (sin kx)))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= 2e-41) {
tmp = sin(th) * expm1((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) <= 2e-41) {
tmp = Math.sin(th) * Math.expm1((ky / Math.sin(kx)));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= 2e-41: tmp = math.sin(th) * math.expm1((ky / math.sin(kx))) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= 2e-41) tmp = Float64(sin(th) * expm1(Float64(ky / sin(kx)))); else tmp = sin(th); end return tmp end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-41], N[(N[Sin[th], $MachinePrecision] * N[(Exp[N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq 2 \cdot 10^{-41}:\\
\;\;\;\;\sin th \cdot \mathsf{expm1}\left(\frac{ky}{\sin kx}\right)\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < 2.00000000000000001e-41Initial program 87.4%
remove-double-neg87.4%
sin-neg87.4%
neg-mul-187.4%
*-commutative87.4%
associate-*l*87.4%
associate-*l/83.9%
associate-/r/83.9%
associate-*l/87.4%
associate-/r/87.4%
sin-neg87.4%
neg-mul-187.4%
associate-/r*87.4%
associate-/r/87.4%
Simplified99.7%
expm1-log1p-u99.7%
hypot-udef87.3%
unpow287.3%
unpow287.3%
+-commutative87.3%
unpow287.3%
unpow287.3%
hypot-def99.7%
Applied egg-rr99.7%
Taylor expanded in ky around 0 44.6%
if 2.00000000000000001e-41 < (sin.f64 ky) Initial program 99.7%
Taylor expanded in kx around 0 55.9%
Final simplification48.0%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) 2e-41) (* (sin th) (/ (sin ky) (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= 2e-41) {
tmp = sin(th) * (sin(ky) / sin(kx));
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(ky) <= 2d-41) then
tmp = sin(th) * (sin(ky) / sin(kx))
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= 2e-41) {
tmp = Math.sin(th) * (Math.sin(ky) / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= 2e-41: tmp = math.sin(th) * (math.sin(ky) / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= 2e-41) tmp = Float64(sin(th) * Float64(sin(ky) / sin(kx))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= 2e-41) tmp = sin(th) * (sin(ky) / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-41], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq 2 \cdot 10^{-41}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < 2.00000000000000001e-41Initial program 87.4%
Taylor expanded in ky around 0 31.4%
if 2.00000000000000001e-41 < (sin.f64 ky) Initial program 99.7%
Taylor expanded in kx around 0 55.9%
Final simplification38.7%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) 2e-41) (* (sin ky) (/ (sin th) (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= 2e-41) {
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) <= 2d-41) 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) <= 2e-41) {
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) <= 2e-41: 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) <= 2e-41) 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) <= 2e-41) 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], 2e-41], 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 2 \cdot 10^{-41}:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < 2.00000000000000001e-41Initial program 87.4%
Taylor expanded in ky around 0 31.4%
Taylor expanded in ky around inf 29.8%
*-commutative29.8%
*-rgt-identity29.8%
times-frac31.4%
/-rgt-identity31.4%
Simplified31.4%
if 2.00000000000000001e-41 < (sin.f64 ky) Initial program 99.7%
Taylor expanded in kx around 0 55.9%
Final simplification38.7%
(FPCore (kx ky th) :precision binary64 (if (<= ky 3.7e-29) (* (sin th) (fabs (/ (sin ky) (sin kx)))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 3.7e-29) {
tmp = sin(th) * fabs((sin(ky) / sin(kx)));
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (ky <= 3.7d-29) then
tmp = sin(th) * abs((sin(ky) / sin(kx)))
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= 3.7e-29) {
tmp = Math.sin(th) * Math.abs((Math.sin(ky) / Math.sin(kx)));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 3.7e-29: tmp = math.sin(th) * math.fabs((math.sin(ky) / math.sin(kx))) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 3.7e-29) tmp = Float64(sin(th) * abs(Float64(sin(ky) / sin(kx)))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 3.7e-29) tmp = sin(th) * abs((sin(ky) / sin(kx))); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 3.7e-29], N[(N[Sin[th], $MachinePrecision] * N[Abs[N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 3.7 \cdot 10^{-29}:\\
\;\;\;\;\sin th \cdot \left|\frac{\sin ky}{\sin kx}\right|\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 3.6999999999999997e-29Initial program 87.6%
Taylor expanded in ky around 0 31.0%
add-sqr-sqrt14.7%
sqrt-unprod26.6%
pow226.6%
Applied egg-rr26.6%
unpow226.6%
rem-sqrt-square29.9%
Simplified29.9%
if 3.6999999999999997e-29 < ky Initial program 99.8%
Taylor expanded in kx around 0 32.7%
Final simplification30.7%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) 1e-101) (* (sin th) (/ 1.0 (+ (* 0.16666666666666666 (* ky kx)) (/ kx ky)))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= 1e-101) {
tmp = sin(th) * (1.0 / ((0.16666666666666666 * (ky * kx)) + (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-101) then
tmp = sin(th) * (1.0d0 / ((0.16666666666666666d0 * (ky * kx)) + (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-101) {
tmp = Math.sin(th) * (1.0 / ((0.16666666666666666 * (ky * kx)) + (kx / ky)));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= 1e-101: tmp = math.sin(th) * (1.0 / ((0.16666666666666666 * (ky * kx)) + (kx / ky))) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= 1e-101) tmp = Float64(sin(th) * Float64(1.0 / Float64(Float64(0.16666666666666666 * Float64(ky * kx)) + 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-101) tmp = sin(th) * (1.0 / ((0.16666666666666666 * (ky * kx)) + (kx / ky))); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-101], N[(N[Sin[th], $MachinePrecision] * N[(1.0 / N[(N[(0.16666666666666666 * N[(ky * kx), $MachinePrecision]), $MachinePrecision] + N[(kx / ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq 10^{-101}:\\
\;\;\;\;\sin th \cdot \frac{1}{0.16666666666666666 \cdot \left(ky \cdot kx\right) + \frac{kx}{ky}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < 1.00000000000000005e-101Initial program 86.8%
Taylor expanded in ky around 0 30.2%
Taylor expanded in kx around 0 22.4%
clear-num22.4%
inv-pow22.4%
Applied egg-rr22.4%
unpow-122.4%
Simplified22.4%
Taylor expanded in ky around 0 22.6%
if 1.00000000000000005e-101 < (sin.f64 ky) Initial program 99.7%
Taylor expanded in kx around 0 53.0%
Final simplification32.7%
(FPCore (kx ky th) :precision binary64 (if (<= ky 5.8e-39) (* (sin th) (/ ky (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 5.8e-39) {
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 (ky <= 5.8d-39) 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 (ky <= 5.8e-39) {
tmp = Math.sin(th) * (ky / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 5.8e-39: tmp = math.sin(th) * (ky / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 5.8e-39) 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 (ky <= 5.8e-39) tmp = sin(th) * (ky / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 5.8e-39], 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}\;ky \leq 5.8 \cdot 10^{-39}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 5.79999999999999975e-39Initial program 87.5%
Taylor expanded in ky around 0 27.4%
associate-/l*29.0%
associate-/r/29.0%
Simplified29.0%
if 5.79999999999999975e-39 < ky Initial program 99.8%
Taylor expanded in kx around 0 33.6%
Final simplification30.3%
(FPCore (kx ky th) :precision binary64 (if (<= ky 3e-41) (/ (sin th) (/ (sin kx) ky)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 3e-41) {
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 (ky <= 3d-41) 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 (ky <= 3e-41) {
tmp = Math.sin(th) / (Math.sin(kx) / ky);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 3e-41: tmp = math.sin(th) / (math.sin(kx) / ky) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 3e-41) 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 (ky <= 3e-41) tmp = sin(th) / (sin(kx) / ky); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 3e-41], 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}\;ky \leq 3 \cdot 10^{-41}:\\
\;\;\;\;\frac{\sin th}{\frac{\sin kx}{ky}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 2.99999999999999989e-41Initial program 87.5%
*-commutative87.5%
clear-num87.4%
un-div-inv87.5%
unpow287.5%
unpow287.5%
hypot-def99.6%
Applied egg-rr99.6%
Taylor expanded in ky around 0 29.0%
if 2.99999999999999989e-41 < ky Initial program 99.8%
Taylor expanded in kx around 0 33.6%
Final simplification30.4%
(FPCore (kx ky th) :precision binary64 (if (<= ky 1e-101) (* (sin th) (/ ky kx)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 1e-101) {
tmp = sin(th) * (ky / 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 <= 1d-101) then
tmp = sin(th) * (ky / 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 <= 1e-101) {
tmp = Math.sin(th) * (ky / kx);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 1e-101: tmp = math.sin(th) * (ky / kx) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 1e-101) tmp = Float64(sin(th) * Float64(ky / kx)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 1e-101) tmp = sin(th) * (ky / kx); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 1e-101], N[(N[Sin[th], $MachinePrecision] * N[(ky / kx), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 10^{-101}:\\
\;\;\;\;\sin th \cdot \frac{ky}{kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 1.00000000000000005e-101Initial program 86.9%
Taylor expanded in ky around 0 30.0%
Taylor expanded in kx around 0 22.2%
Taylor expanded in ky around 0 22.0%
if 1.00000000000000005e-101 < ky Initial program 99.8%
Taylor expanded in kx around 0 33.0%
Final simplification25.6%
(FPCore (kx ky th) :precision binary64 (if (<= ky 2e-101) (/ ky (/ kx th)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 2e-101) {
tmp = ky / (kx / 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 <= 2d-101) then
tmp = ky / (kx / 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 <= 2e-101) {
tmp = ky / (kx / th);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 2e-101: tmp = ky / (kx / th) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 2e-101) tmp = Float64(ky / Float64(kx / th)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 2e-101) tmp = ky / (kx / th); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 2e-101], N[(ky / N[(kx / th), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 2 \cdot 10^{-101}:\\
\;\;\;\;\frac{ky}{\frac{kx}{th}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 2.0000000000000001e-101Initial program 86.9%
Taylor expanded in ky around 0 30.0%
Taylor expanded in kx around 0 22.2%
Taylor expanded in ky around 0 22.0%
Taylor expanded in th around 0 15.7%
associate-/l*16.8%
Simplified16.8%
if 2.0000000000000001e-101 < ky Initial program 99.8%
Taylor expanded in kx around 0 33.0%
Final simplification22.1%
(FPCore (kx ky th) :precision binary64 (/ ky (/ kx th)))
double code(double kx, double ky, double th) {
return ky / (kx / th);
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = ky / (kx / th)
end function
public static double code(double kx, double ky, double th) {
return ky / (kx / th);
}
def code(kx, ky, th): return ky / (kx / th)
function code(kx, ky, th) return Float64(ky / Float64(kx / th)) end
function tmp = code(kx, ky, th) tmp = ky / (kx / th); end
code[kx_, ky_, th_] := N[(ky / N[(kx / th), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{ky}{\frac{kx}{th}}
\end{array}
Initial program 91.1%
Taylor expanded in ky around 0 24.6%
Taylor expanded in kx around 0 17.4%
Taylor expanded in ky around 0 17.0%
Taylor expanded in th around 0 12.0%
associate-/l*13.1%
Simplified13.1%
Final simplification13.1%
herbie shell --seed 2023319
(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)))