
(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 21 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 91.8%
+-commutative91.8%
unpow291.8%
unpow291.8%
hypot-def99.7%
Simplified99.7%
*-commutative99.7%
clear-num99.6%
un-div-inv99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (hypot (sin ky) (sin kx))))
(if (or (<= (sin th) -0.04) (not (<= (sin th) 5e-31)))
(/ (sin th) (* t_1 (+ (* ky 0.16666666666666666) (/ 1.0 ky))))
(/ th (/ t_1 (sin ky))))))
double code(double kx, double ky, double th) {
double t_1 = hypot(sin(ky), sin(kx));
double tmp;
if ((sin(th) <= -0.04) || !(sin(th) <= 5e-31)) {
tmp = sin(th) / (t_1 * ((ky * 0.16666666666666666) + (1.0 / ky)));
} else {
tmp = th / (t_1 / 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.04) || !(Math.sin(th) <= 5e-31)) {
tmp = Math.sin(th) / (t_1 * ((ky * 0.16666666666666666) + (1.0 / ky)));
} else {
tmp = th / (t_1 / 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.04) or not (math.sin(th) <= 5e-31): tmp = math.sin(th) / (t_1 * ((ky * 0.16666666666666666) + (1.0 / ky))) else: tmp = th / (t_1 / math.sin(ky)) return tmp
function code(kx, ky, th) t_1 = hypot(sin(ky), sin(kx)) tmp = 0.0 if ((sin(th) <= -0.04) || !(sin(th) <= 5e-31)) tmp = Float64(sin(th) / Float64(t_1 * Float64(Float64(ky * 0.16666666666666666) + Float64(1.0 / ky)))); else tmp = Float64(th / Float64(t_1 / 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.04) || ~((sin(th) <= 5e-31))) tmp = sin(th) / (t_1 * ((ky * 0.16666666666666666) + (1.0 / ky))); else tmp = th / (t_1 / 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[Or[LessEqual[N[Sin[th], $MachinePrecision], -0.04], N[Not[LessEqual[N[Sin[th], $MachinePrecision], 5e-31]], $MachinePrecision]], N[(N[Sin[th], $MachinePrecision] / N[(t$95$1 * N[(N[(ky * 0.16666666666666666), $MachinePrecision] + N[(1.0 / ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(th / N[(t$95$1 / N[Sin[ky], $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.04 \lor \neg \left(\sin th \leq 5 \cdot 10^{-31}\right):\\
\;\;\;\;\frac{\sin th}{t_1 \cdot \left(ky \cdot 0.16666666666666666 + \frac{1}{ky}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{th}{\frac{t_1}{\sin ky}}\\
\end{array}
\end{array}
if (sin.f64 th) < -0.0400000000000000008 or 5e-31 < (sin.f64 th) Initial program 88.7%
+-commutative88.7%
unpow288.7%
unpow288.7%
hypot-def99.6%
Simplified99.6%
*-commutative99.6%
clear-num99.6%
un-div-inv99.6%
Applied egg-rr99.6%
div-inv99.4%
Applied egg-rr99.4%
Taylor expanded in ky around 0 50.8%
if -0.0400000000000000008 < (sin.f64 th) < 5e-31Initial program 94.3%
associate-*l/92.2%
Simplified92.2%
Taylor expanded in th around 0 90.5%
associate-/l*92.6%
+-commutative92.6%
unpow292.6%
unpow292.6%
hypot-udef98.0%
associate-/r/98.0%
Applied egg-rr98.0%
expm1-log1p-u98.0%
expm1-udef21.4%
*-commutative21.4%
clear-num21.4%
un-div-inv21.4%
Applied egg-rr21.4%
expm1-def98.0%
expm1-log1p98.1%
Simplified98.1%
Final simplification77.4%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (hypot (sin ky) (sin kx))))
(if (or (<= (sin ky) -2e-6) (not (<= (sin ky) 1e-12)))
(/ (/ (sin ky) t_1) (+ (/ 1.0 th) (* th 0.16666666666666666)))
(* (sin th) (/ ky t_1)))))
double code(double kx, double ky, double th) {
double t_1 = hypot(sin(ky), sin(kx));
double tmp;
if ((sin(ky) <= -2e-6) || !(sin(ky) <= 1e-12)) {
tmp = (sin(ky) / t_1) / ((1.0 / th) + (th * 0.16666666666666666));
} else {
tmp = sin(th) * (ky / t_1);
}
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(ky) <= -2e-6) || !(Math.sin(ky) <= 1e-12)) {
tmp = (Math.sin(ky) / t_1) / ((1.0 / th) + (th * 0.16666666666666666));
} else {
tmp = Math.sin(th) * (ky / t_1);
}
return tmp;
}
def code(kx, ky, th): t_1 = math.hypot(math.sin(ky), math.sin(kx)) tmp = 0 if (math.sin(ky) <= -2e-6) or not (math.sin(ky) <= 1e-12): tmp = (math.sin(ky) / t_1) / ((1.0 / th) + (th * 0.16666666666666666)) else: tmp = math.sin(th) * (ky / t_1) return tmp
function code(kx, ky, th) t_1 = hypot(sin(ky), sin(kx)) tmp = 0.0 if ((sin(ky) <= -2e-6) || !(sin(ky) <= 1e-12)) tmp = Float64(Float64(sin(ky) / t_1) / Float64(Float64(1.0 / th) + Float64(th * 0.16666666666666666))); else tmp = Float64(sin(th) * Float64(ky / t_1)); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = hypot(sin(ky), sin(kx)); tmp = 0.0; if ((sin(ky) <= -2e-6) || ~((sin(ky) <= 1e-12))) tmp = (sin(ky) / t_1) / ((1.0 / th) + (th * 0.16666666666666666)); else tmp = sin(th) * (ky / t_1); 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[Or[LessEqual[N[Sin[ky], $MachinePrecision], -2e-6], N[Not[LessEqual[N[Sin[ky], $MachinePrecision], 1e-12]], $MachinePrecision]], N[(N[(N[Sin[ky], $MachinePrecision] / t$95$1), $MachinePrecision] / N[(N[(1.0 / th), $MachinePrecision] + N[(th * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(ky / t$95$1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{hypot}\left(\sin ky, \sin kx\right)\\
\mathbf{if}\;\sin ky \leq -2 \cdot 10^{-6} \lor \neg \left(\sin ky \leq 10^{-12}\right):\\
\;\;\;\;\frac{\frac{\sin ky}{t_1}}{\frac{1}{th} + th \cdot 0.16666666666666666}\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{ky}{t_1}\\
\end{array}
\end{array}
if (sin.f64 ky) < -1.99999999999999991e-6 or 9.9999999999999998e-13 < (sin.f64 ky) Initial program 99.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-def99.7%
Simplified99.7%
associate-/r/99.4%
div-inv99.2%
associate-/r*99.4%
Applied egg-rr99.4%
Taylor expanded in th around 0 56.8%
if -1.99999999999999991e-6 < (sin.f64 ky) < 9.9999999999999998e-13Initial program 83.5%
associate-*l/81.2%
+-commutative81.2%
unpow281.2%
unpow281.2%
hypot-def92.0%
Simplified92.0%
Taylor expanded in ky around 0 92.0%
expm1-log1p-u92.0%
expm1-udef33.3%
div-inv33.2%
*-commutative33.2%
associate-*l*33.2%
div-inv33.3%
Applied egg-rr33.3%
expm1-def99.7%
expm1-log1p99.7%
*-commutative99.7%
associate-*l/92.0%
associate-*r/99.6%
Simplified99.6%
Final simplification77.5%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (hypot (sin ky) (sin kx))))
(if (<= (sin ky) -2e-6)
(/ th (/ t_1 (sin ky)))
(if (<= (sin ky) 1e-24)
(* (sin th) (/ ky t_1))
(* th (/ (sin ky) t_1))))))
double code(double kx, double ky, double th) {
double t_1 = hypot(sin(ky), sin(kx));
double tmp;
if (sin(ky) <= -2e-6) {
tmp = th / (t_1 / sin(ky));
} else if (sin(ky) <= 1e-24) {
tmp = sin(th) * (ky / t_1);
} else {
tmp = th * (sin(ky) / t_1);
}
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(ky) <= -2e-6) {
tmp = th / (t_1 / Math.sin(ky));
} else if (Math.sin(ky) <= 1e-24) {
tmp = Math.sin(th) * (ky / t_1);
} else {
tmp = th * (Math.sin(ky) / t_1);
}
return tmp;
}
def code(kx, ky, th): t_1 = math.hypot(math.sin(ky), math.sin(kx)) tmp = 0 if math.sin(ky) <= -2e-6: tmp = th / (t_1 / math.sin(ky)) elif math.sin(ky) <= 1e-24: tmp = math.sin(th) * (ky / t_1) else: tmp = th * (math.sin(ky) / t_1) return tmp
function code(kx, ky, th) t_1 = hypot(sin(ky), sin(kx)) tmp = 0.0 if (sin(ky) <= -2e-6) tmp = Float64(th / Float64(t_1 / sin(ky))); elseif (sin(ky) <= 1e-24) tmp = Float64(sin(th) * Float64(ky / t_1)); else tmp = Float64(th * Float64(sin(ky) / t_1)); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = hypot(sin(ky), sin(kx)); tmp = 0.0; if (sin(ky) <= -2e-6) tmp = th / (t_1 / sin(ky)); elseif (sin(ky) <= 1e-24) tmp = sin(th) * (ky / t_1); else tmp = th * (sin(ky) / t_1); 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[ky], $MachinePrecision], -2e-6], N[(th / N[(t$95$1 / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-24], N[(N[Sin[th], $MachinePrecision] * N[(ky / t$95$1), $MachinePrecision]), $MachinePrecision], N[(th * N[(N[Sin[ky], $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{hypot}\left(\sin ky, \sin kx\right)\\
\mathbf{if}\;\sin ky \leq -2 \cdot 10^{-6}:\\
\;\;\;\;\frac{th}{\frac{t_1}{\sin ky}}\\
\mathbf{elif}\;\sin ky \leq 10^{-24}:\\
\;\;\;\;\sin th \cdot \frac{ky}{t_1}\\
\mathbf{else}:\\
\;\;\;\;th \cdot \frac{\sin ky}{t_1}\\
\end{array}
\end{array}
if (sin.f64 ky) < -1.99999999999999991e-6Initial program 99.6%
associate-*l/99.4%
Simplified99.4%
Taylor expanded in th around 0 49.8%
associate-/l*49.8%
+-commutative49.8%
unpow249.8%
unpow249.8%
hypot-udef49.8%
associate-/r/49.9%
Applied egg-rr49.9%
expm1-log1p-u49.1%
expm1-udef3.4%
*-commutative3.4%
clear-num3.4%
un-div-inv3.4%
Applied egg-rr3.4%
expm1-def49.2%
expm1-log1p50.0%
Simplified50.0%
if -1.99999999999999991e-6 < (sin.f64 ky) < 9.99999999999999924e-25Initial program 83.3%
associate-*l/80.9%
+-commutative80.9%
unpow280.9%
unpow280.9%
hypot-def91.9%
Simplified91.9%
Taylor expanded in ky around 0 91.9%
expm1-log1p-u91.9%
expm1-udef33.8%
div-inv33.7%
*-commutative33.7%
associate-*l*33.7%
div-inv33.8%
Applied egg-rr33.8%
expm1-def99.7%
expm1-log1p99.7%
*-commutative99.7%
associate-*l/91.9%
associate-*r/99.6%
Simplified99.6%
if 9.99999999999999924e-25 < (sin.f64 ky) Initial program 99.7%
associate-*l/99.6%
Simplified99.6%
Taylor expanded in th around 0 62.4%
associate-/l*62.3%
+-commutative62.3%
unpow262.3%
unpow262.3%
hypot-udef62.3%
associate-/r/62.4%
Applied egg-rr62.4%
Final simplification77.3%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -5e-308) (/ (sin th) (/ (sin kx) ky)) (if (<= (sin ky) 5e-70) (* (sin th) (fabs (/ ky (sin kx)))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -5e-308) {
tmp = sin(th) / (sin(kx) / ky);
} else if (sin(ky) <= 5e-70) {
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) <= (-5d-308)) then
tmp = sin(th) / (sin(kx) / ky)
else if (sin(ky) <= 5d-70) 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) <= -5e-308) {
tmp = Math.sin(th) / (Math.sin(kx) / ky);
} else if (Math.sin(ky) <= 5e-70) {
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) <= -5e-308: tmp = math.sin(th) / (math.sin(kx) / ky) elif math.sin(ky) <= 5e-70: 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) <= -5e-308) tmp = Float64(sin(th) / Float64(sin(kx) / ky)); elseif (sin(ky) <= 5e-70) 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) <= -5e-308) tmp = sin(th) / (sin(kx) / ky); elseif (sin(ky) <= 5e-70) 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], -5e-308], N[(N[Sin[th], $MachinePrecision] / N[(N[Sin[kx], $MachinePrecision] / ky), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 5e-70], 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 -5 \cdot 10^{-308}:\\
\;\;\;\;\frac{\sin th}{\frac{\sin kx}{ky}}\\
\mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-70}:\\
\;\;\;\;\sin th \cdot \left|\frac{ky}{\sin kx}\right|\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -4.99999999999999955e-308Initial program 90.9%
+-commutative90.9%
unpow290.9%
unpow290.9%
hypot-def99.6%
Simplified99.6%
Taylor expanded in ky around 0 35.5%
associate-/l*35.7%
Simplified35.7%
if -4.99999999999999955e-308 < (sin.f64 ky) < 4.9999999999999998e-70Initial program 78.5%
+-commutative78.5%
unpow278.5%
unpow278.5%
hypot-def99.6%
Simplified99.6%
Taylor expanded in ky around 0 52.1%
add-sqr-sqrt43.5%
sqrt-unprod56.7%
pow256.7%
Applied egg-rr56.7%
unpow256.7%
rem-sqrt-square82.8%
Simplified82.8%
Taylor expanded in ky around 0 82.8%
if 4.9999999999999998e-70 < (sin.f64 ky) Initial program 99.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 56.2%
Final simplification50.9%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -5e-308) (* (sin ky) (/ (sin th) (sin kx))) (if (<= (sin ky) 5e-70) (* (sin th) (fabs (/ ky (sin kx)))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -5e-308) {
tmp = sin(ky) * (sin(th) / sin(kx));
} else if (sin(ky) <= 5e-70) {
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) <= (-5d-308)) then
tmp = sin(ky) * (sin(th) / sin(kx))
else if (sin(ky) <= 5d-70) 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) <= -5e-308) {
tmp = Math.sin(ky) * (Math.sin(th) / Math.sin(kx));
} else if (Math.sin(ky) <= 5e-70) {
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) <= -5e-308: tmp = math.sin(ky) * (math.sin(th) / math.sin(kx)) elif math.sin(ky) <= 5e-70: 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) <= -5e-308) tmp = Float64(sin(ky) * Float64(sin(th) / sin(kx))); elseif (sin(ky) <= 5e-70) 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) <= -5e-308) tmp = sin(ky) * (sin(th) / sin(kx)); elseif (sin(ky) <= 5e-70) 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], -5e-308], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 5e-70], 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 -5 \cdot 10^{-308}:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-70}:\\
\;\;\;\;\sin th \cdot \left|\frac{ky}{\sin kx}\right|\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -4.99999999999999955e-308Initial program 90.9%
associate-*l/90.1%
associate-*r/90.9%
+-commutative90.9%
unpow290.9%
unpow290.9%
hypot-def99.6%
Simplified99.6%
Taylor expanded in ky around 0 39.5%
if -4.99999999999999955e-308 < (sin.f64 ky) < 4.9999999999999998e-70Initial program 78.5%
+-commutative78.5%
unpow278.5%
unpow278.5%
hypot-def99.6%
Simplified99.6%
Taylor expanded in ky around 0 52.1%
add-sqr-sqrt43.5%
sqrt-unprod56.7%
pow256.7%
Applied egg-rr56.7%
unpow256.7%
rem-sqrt-square82.8%
Simplified82.8%
Taylor expanded in ky around 0 82.8%
if 4.9999999999999998e-70 < (sin.f64 ky) Initial program 99.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 56.2%
Final simplification52.7%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -5e-308)
(* (sin ky) (/ (sin th) (sin kx)))
(if (<= (sin ky) 5e-70)
(* (sin th) (fabs (/ ky (sin kx))))
(/ (* (sin th) (sin ky)) (sin ky)))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -5e-308) {
tmp = sin(ky) * (sin(th) / sin(kx));
} else if (sin(ky) <= 5e-70) {
tmp = sin(th) * fabs((ky / sin(kx)));
} else {
tmp = (sin(th) * sin(ky)) / 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) <= (-5d-308)) then
tmp = sin(ky) * (sin(th) / sin(kx))
else if (sin(ky) <= 5d-70) then
tmp = sin(th) * abs((ky / sin(kx)))
else
tmp = (sin(th) * sin(ky)) / sin(ky)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -5e-308) {
tmp = Math.sin(ky) * (Math.sin(th) / Math.sin(kx));
} else if (Math.sin(ky) <= 5e-70) {
tmp = Math.sin(th) * Math.abs((ky / Math.sin(kx)));
} else {
tmp = (Math.sin(th) * Math.sin(ky)) / Math.sin(ky);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -5e-308: tmp = math.sin(ky) * (math.sin(th) / math.sin(kx)) elif math.sin(ky) <= 5e-70: tmp = math.sin(th) * math.fabs((ky / math.sin(kx))) else: tmp = (math.sin(th) * math.sin(ky)) / math.sin(ky) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -5e-308) tmp = Float64(sin(ky) * Float64(sin(th) / sin(kx))); elseif (sin(ky) <= 5e-70) tmp = Float64(sin(th) * abs(Float64(ky / sin(kx)))); else tmp = Float64(Float64(sin(th) * sin(ky)) / sin(ky)); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -5e-308) tmp = sin(ky) * (sin(th) / sin(kx)); elseif (sin(ky) <= 5e-70) tmp = sin(th) * abs((ky / sin(kx))); else tmp = (sin(th) * sin(ky)) / sin(ky); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -5e-308], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 5e-70], N[(N[Sin[th], $MachinePrecision] * N[Abs[N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[th], $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -5 \cdot 10^{-308}:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-70}:\\
\;\;\;\;\sin th \cdot \left|\frac{ky}{\sin kx}\right|\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin th \cdot \sin ky}{\sin ky}\\
\end{array}
\end{array}
if (sin.f64 ky) < -4.99999999999999955e-308Initial program 90.9%
associate-*l/90.1%
associate-*r/90.9%
+-commutative90.9%
unpow290.9%
unpow290.9%
hypot-def99.6%
Simplified99.6%
Taylor expanded in ky around 0 39.5%
if -4.99999999999999955e-308 < (sin.f64 ky) < 4.9999999999999998e-70Initial program 78.5%
+-commutative78.5%
unpow278.5%
unpow278.5%
hypot-def99.6%
Simplified99.6%
Taylor expanded in ky around 0 52.1%
add-sqr-sqrt43.5%
sqrt-unprod56.7%
pow256.7%
Applied egg-rr56.7%
unpow256.7%
rem-sqrt-square82.8%
Simplified82.8%
Taylor expanded in ky around 0 82.8%
if 4.9999999999999998e-70 < (sin.f64 ky) Initial program 99.7%
associate-*l/99.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.6%
Simplified99.6%
Taylor expanded in kx around 0 57.0%
Final simplification53.0%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) 1e-23) (* (sin th) (/ ky (hypot (sin ky) (sin kx)))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= 1e-23) {
tmp = sin(th) * (ky / hypot(sin(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) <= 1e-23) {
tmp = Math.sin(th) * (ky / Math.hypot(Math.sin(ky), Math.sin(kx)));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= 1e-23: tmp = math.sin(th) * (ky / math.hypot(math.sin(ky), math.sin(kx))) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= 1e-23) tmp = Float64(sin(th) * Float64(ky / hypot(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) <= 1e-23) tmp = sin(th) * (ky / hypot(sin(ky), sin(kx))); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-23], N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq 10^{-23}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < 9.9999999999999996e-24Initial program 88.6%
associate-*l/86.9%
+-commutative86.9%
unpow286.9%
unpow286.9%
hypot-def94.4%
Simplified94.4%
Taylor expanded in ky around 0 64.2%
expm1-log1p-u63.7%
expm1-udef23.6%
div-inv23.5%
*-commutative23.5%
associate-*l*23.5%
div-inv23.6%
Applied egg-rr23.6%
expm1-def68.9%
expm1-log1p69.5%
*-commutative69.5%
associate-*l/64.2%
associate-*r/69.4%
Simplified69.4%
if 9.9999999999999996e-24 < (sin.f64 ky) Initial program 99.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 56.5%
Final simplification65.6%
(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.8%
associate-*l/90.6%
associate-*r/91.8%
+-commutative91.8%
unpow291.8%
unpow291.8%
hypot-def99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (kx ky th) :precision binary64 (* (sin th) (/ (sin ky) (hypot (sin ky) (sin kx)))))
double code(double kx, double ky, double th) {
return sin(th) * (sin(ky) / hypot(sin(ky), sin(kx)));
}
public static double code(double kx, double ky, double th) {
return Math.sin(th) * (Math.sin(ky) / Math.hypot(Math.sin(ky), Math.sin(kx)));
}
def code(kx, ky, th): return math.sin(th) * (math.sin(ky) / math.hypot(math.sin(ky), math.sin(kx)))
function code(kx, ky, th) return Float64(sin(th) * Float64(sin(ky) / hypot(sin(ky), sin(kx)))) end
function tmp = code(kx, ky, th) tmp = sin(th) * (sin(ky) / hypot(sin(ky), sin(kx))); end
code[kx_, ky_, th_] := N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}
\end{array}
Initial program 91.8%
+-commutative91.8%
unpow291.8%
unpow291.8%
hypot-def99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (hypot (sin ky) (sin kx))))
(if (or (<= ky -2.2e-6) (not (<= ky 5e-24)))
(* th (/ (sin ky) t_1))
(* (sin th) (/ ky t_1)))))
double code(double kx, double ky, double th) {
double t_1 = hypot(sin(ky), sin(kx));
double tmp;
if ((ky <= -2.2e-6) || !(ky <= 5e-24)) {
tmp = th * (sin(ky) / t_1);
} else {
tmp = sin(th) * (ky / t_1);
}
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 ((ky <= -2.2e-6) || !(ky <= 5e-24)) {
tmp = th * (Math.sin(ky) / t_1);
} else {
tmp = Math.sin(th) * (ky / t_1);
}
return tmp;
}
def code(kx, ky, th): t_1 = math.hypot(math.sin(ky), math.sin(kx)) tmp = 0 if (ky <= -2.2e-6) or not (ky <= 5e-24): tmp = th * (math.sin(ky) / t_1) else: tmp = math.sin(th) * (ky / t_1) return tmp
function code(kx, ky, th) t_1 = hypot(sin(ky), sin(kx)) tmp = 0.0 if ((ky <= -2.2e-6) || !(ky <= 5e-24)) tmp = Float64(th * Float64(sin(ky) / t_1)); else tmp = Float64(sin(th) * Float64(ky / t_1)); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = hypot(sin(ky), sin(kx)); tmp = 0.0; if ((ky <= -2.2e-6) || ~((ky <= 5e-24))) tmp = th * (sin(ky) / t_1); else tmp = sin(th) * (ky / t_1); 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[Or[LessEqual[ky, -2.2e-6], N[Not[LessEqual[ky, 5e-24]], $MachinePrecision]], N[(th * N[(N[Sin[ky], $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(ky / t$95$1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{hypot}\left(\sin ky, \sin kx\right)\\
\mathbf{if}\;ky \leq -2.2 \cdot 10^{-6} \lor \neg \left(ky \leq 5 \cdot 10^{-24}\right):\\
\;\;\;\;th \cdot \frac{\sin ky}{t_1}\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{ky}{t_1}\\
\end{array}
\end{array}
if ky < -2.2000000000000001e-6 or 4.9999999999999998e-24 < ky Initial program 99.7%
associate-*l/99.5%
Simplified99.5%
Taylor expanded in th around 0 56.9%
associate-/l*56.9%
+-commutative56.9%
unpow256.9%
unpow256.9%
hypot-udef56.9%
associate-/r/57.0%
Applied egg-rr57.0%
if -2.2000000000000001e-6 < ky < 4.9999999999999998e-24Initial program 83.3%
associate-*l/80.9%
+-commutative80.9%
unpow280.9%
unpow280.9%
hypot-def91.9%
Simplified91.9%
Taylor expanded in ky around 0 91.9%
expm1-log1p-u91.9%
expm1-udef33.8%
div-inv33.7%
*-commutative33.7%
associate-*l*33.7%
div-inv33.8%
Applied egg-rr33.8%
expm1-def99.7%
expm1-log1p99.7%
*-commutative99.7%
associate-*l/91.9%
associate-*r/99.6%
Simplified99.6%
Final simplification77.3%
(FPCore (kx ky th) :precision binary64 (if (<= (sin kx) -0.01) (fabs (/ ky (/ (sin kx) th))) (if (<= (sin kx) 2e-20) (sin th) (* ky (/ th (sin kx))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(kx) <= -0.01) {
tmp = fabs((ky / (sin(kx) / th)));
} else if (sin(kx) <= 2e-20) {
tmp = sin(th);
} else {
tmp = ky * (th / sin(kx));
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(kx) <= (-0.01d0)) then
tmp = abs((ky / (sin(kx) / th)))
else if (sin(kx) <= 2d-20) then
tmp = sin(th)
else
tmp = ky * (th / sin(kx))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(kx) <= -0.01) {
tmp = Math.abs((ky / (Math.sin(kx) / th)));
} else if (Math.sin(kx) <= 2e-20) {
tmp = Math.sin(th);
} else {
tmp = ky * (th / Math.sin(kx));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(kx) <= -0.01: tmp = math.fabs((ky / (math.sin(kx) / th))) elif math.sin(kx) <= 2e-20: tmp = math.sin(th) else: tmp = ky * (th / math.sin(kx)) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(kx) <= -0.01) tmp = abs(Float64(ky / Float64(sin(kx) / th))); elseif (sin(kx) <= 2e-20) tmp = sin(th); else tmp = Float64(ky * Float64(th / sin(kx))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(kx) <= -0.01) tmp = abs((ky / (sin(kx) / th))); elseif (sin(kx) <= 2e-20) tmp = sin(th); else tmp = ky * (th / sin(kx)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[kx], $MachinePrecision], -0.01], N[Abs[N[(ky / N[(N[Sin[kx], $MachinePrecision] / th), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 2e-20], N[Sin[th], $MachinePrecision], N[(ky * N[(th / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin kx \leq -0.01:\\
\;\;\;\;\left|\frac{ky}{\frac{\sin kx}{th}}\right|\\
\mathbf{elif}\;\sin kx \leq 2 \cdot 10^{-20}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;ky \cdot \frac{th}{\sin kx}\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.0100000000000000002Initial program 99.4%
associate-*l/99.5%
Simplified99.5%
Taylor expanded in th around 0 62.4%
Taylor expanded in ky around 0 14.6%
*-commutative14.6%
associate-/l*14.6%
Simplified14.6%
add-sqr-sqrt8.4%
sqrt-unprod24.1%
pow224.1%
Applied egg-rr24.1%
unpow224.1%
rem-sqrt-square24.1%
Simplified24.1%
add-sqr-sqrt17.3%
sqrt-unprod14.6%
pow214.6%
div-inv14.6%
add-sqr-sqrt8.3%
fabs-sqr8.3%
add-sqr-sqrt14.6%
clear-num14.6%
Applied egg-rr14.6%
unpow214.6%
rem-sqrt-square24.9%
*-commutative24.9%
associate-/r/25.0%
Simplified25.0%
if -0.0100000000000000002 < (sin.f64 kx) < 1.99999999999999989e-20Initial program 82.3%
+-commutative82.3%
unpow282.3%
unpow282.3%
hypot-def99.9%
Simplified99.9%
Taylor expanded in kx around 0 44.0%
if 1.99999999999999989e-20 < (sin.f64 kx) Initial program 99.4%
associate-*l/99.4%
Simplified99.4%
Taylor expanded in th around 0 59.6%
Taylor expanded in ky around 0 33.0%
*-commutative33.0%
associate-/l*33.0%
Simplified33.0%
associate-/r/33.1%
Applied egg-rr33.1%
Final simplification35.9%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) 1e-214) (* (sin ky) (/ th (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= 1e-214) {
tmp = sin(ky) * (th / sin(kx));
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(ky) <= 1d-214) then
tmp = sin(ky) * (th / sin(kx))
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= 1e-214) {
tmp = Math.sin(ky) * (th / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= 1e-214: tmp = math.sin(ky) * (th / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= 1e-214) tmp = Float64(sin(ky) * Float64(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-214) tmp = sin(ky) * (th / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-214], N[(N[Sin[ky], $MachinePrecision] * N[(th / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq 10^{-214}:\\
\;\;\;\;\sin ky \cdot \frac{th}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < 9.99999999999999913e-215Initial program 88.7%
associate-*l/87.3%
associate-*r/88.7%
+-commutative88.7%
unpow288.7%
unpow288.7%
hypot-def99.6%
Simplified99.6%
Taylor expanded in ky around 0 41.3%
Taylor expanded in th around 0 25.5%
if 9.99999999999999913e-215 < (sin.f64 ky) Initial program 95.8%
+-commutative95.8%
unpow295.8%
unpow295.8%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 50.4%
Final simplification36.5%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) 1e-94) (* (sin th) (/ ky (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= 1e-94) {
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) <= 1d-94) 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) <= 1e-94) {
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) <= 1e-94: 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) <= 1e-94) 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) <= 1e-94) 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], 1e-94], 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 10^{-94}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < 9.9999999999999996e-95Initial program 87.4%
+-commutative87.4%
unpow287.4%
unpow287.4%
hypot-def99.6%
Simplified99.6%
Taylor expanded in ky around 0 40.3%
if 9.9999999999999996e-95 < (sin.f64 ky) Initial program 99.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 55.0%
Final simplification45.7%
(FPCore (kx ky th) :precision binary64 (if (<= ky -2.25e-13) (sin th) (if (<= ky 4.6e-214) (/ th (* (sin kx) (/ 1.0 ky))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= -2.25e-13) {
tmp = sin(th);
} else if (ky <= 4.6e-214) {
tmp = th / (sin(kx) * (1.0 / 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 <= (-2.25d-13)) then
tmp = sin(th)
else if (ky <= 4.6d-214) then
tmp = th / (sin(kx) * (1.0d0 / 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 <= -2.25e-13) {
tmp = Math.sin(th);
} else if (ky <= 4.6e-214) {
tmp = th / (Math.sin(kx) * (1.0 / ky));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= -2.25e-13: tmp = math.sin(th) elif ky <= 4.6e-214: tmp = th / (math.sin(kx) * (1.0 / ky)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= -2.25e-13) tmp = sin(th); elseif (ky <= 4.6e-214) tmp = Float64(th / Float64(sin(kx) * Float64(1.0 / ky))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= -2.25e-13) tmp = sin(th); elseif (ky <= 4.6e-214) tmp = th / (sin(kx) * (1.0 / ky)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, -2.25e-13], N[Sin[th], $MachinePrecision], If[LessEqual[ky, 4.6e-214], N[(th / N[(N[Sin[kx], $MachinePrecision] * N[(1.0 / ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq -2.25 \cdot 10^{-13}:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;ky \leq 4.6 \cdot 10^{-214}:\\
\;\;\;\;\frac{th}{\sin kx \cdot \frac{1}{ky}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < -2.25e-13 or 4.60000000000000022e-214 < ky Initial program 97.1%
+-commutative97.1%
unpow297.1%
unpow297.1%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 34.0%
if -2.25e-13 < ky < 4.60000000000000022e-214Initial program 81.1%
associate-*l/78.8%
Simplified78.8%
Taylor expanded in th around 0 44.9%
Taylor expanded in ky around 0 37.2%
*-commutative37.2%
associate-/l*37.4%
Simplified37.4%
clear-num37.4%
associate-/r/37.4%
Applied egg-rr37.4%
Final simplification35.1%
(FPCore (kx ky th) :precision binary64 (if (<= ky -2.25e-13) (sin th) (if (<= ky 4.6e-214) (* th (/ ky (sin kx))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= -2.25e-13) {
tmp = sin(th);
} else if (ky <= 4.6e-214) {
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 <= (-2.25d-13)) then
tmp = sin(th)
else if (ky <= 4.6d-214) 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 <= -2.25e-13) {
tmp = Math.sin(th);
} else if (ky <= 4.6e-214) {
tmp = th * (ky / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= -2.25e-13: tmp = math.sin(th) elif ky <= 4.6e-214: tmp = th * (ky / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= -2.25e-13) tmp = sin(th); elseif (ky <= 4.6e-214) 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 <= -2.25e-13) tmp = sin(th); elseif (ky <= 4.6e-214) tmp = th * (ky / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, -2.25e-13], N[Sin[th], $MachinePrecision], If[LessEqual[ky, 4.6e-214], N[(th * N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq -2.25 \cdot 10^{-13}:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;ky \leq 4.6 \cdot 10^{-214}:\\
\;\;\;\;th \cdot \frac{ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < -2.25e-13 or 4.60000000000000022e-214 < ky Initial program 97.1%
+-commutative97.1%
unpow297.1%
unpow297.1%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 34.0%
if -2.25e-13 < ky < 4.60000000000000022e-214Initial program 81.1%
associate-*l/78.8%
Simplified78.8%
Taylor expanded in th around 0 44.9%
Taylor expanded in ky around 0 37.2%
*-commutative37.2%
associate-/l*37.4%
Simplified37.4%
clear-num36.7%
associate-/r/37.4%
clear-num37.4%
Applied egg-rr37.4%
Final simplification35.1%
(FPCore (kx ky th) :precision binary64 (if (<= ky -2.25e-13) (sin th) (if (<= ky 4.6e-214) (/ th (/ (sin kx) ky)) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= -2.25e-13) {
tmp = sin(th);
} else if (ky <= 4.6e-214) {
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 <= (-2.25d-13)) then
tmp = sin(th)
else if (ky <= 4.6d-214) 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 <= -2.25e-13) {
tmp = Math.sin(th);
} else if (ky <= 4.6e-214) {
tmp = th / (Math.sin(kx) / ky);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= -2.25e-13: tmp = math.sin(th) elif ky <= 4.6e-214: tmp = th / (math.sin(kx) / ky) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= -2.25e-13) tmp = sin(th); elseif (ky <= 4.6e-214) 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 <= -2.25e-13) tmp = sin(th); elseif (ky <= 4.6e-214) tmp = th / (sin(kx) / ky); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, -2.25e-13], N[Sin[th], $MachinePrecision], If[LessEqual[ky, 4.6e-214], N[(th / N[(N[Sin[kx], $MachinePrecision] / ky), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq -2.25 \cdot 10^{-13}:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;ky \leq 4.6 \cdot 10^{-214}:\\
\;\;\;\;\frac{th}{\frac{\sin kx}{ky}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < -2.25e-13 or 4.60000000000000022e-214 < ky Initial program 97.1%
+-commutative97.1%
unpow297.1%
unpow297.1%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 34.0%
if -2.25e-13 < ky < 4.60000000000000022e-214Initial program 81.1%
associate-*l/78.8%
Simplified78.8%
Taylor expanded in th around 0 44.9%
Taylor expanded in ky around 0 37.2%
*-commutative37.2%
associate-/l*37.4%
Simplified37.4%
Final simplification35.1%
(FPCore (kx ky th) :precision binary64 (if (<= ky -3.2) (sin th) (if (<= ky 4.6e-214) (/ th (/ kx ky)) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= -3.2) {
tmp = sin(th);
} else if (ky <= 4.6e-214) {
tmp = 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 (ky <= (-3.2d0)) then
tmp = sin(th)
else if (ky <= 4.6d-214) then
tmp = 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 (ky <= -3.2) {
tmp = Math.sin(th);
} else if (ky <= 4.6e-214) {
tmp = th / (kx / ky);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= -3.2: tmp = math.sin(th) elif ky <= 4.6e-214: tmp = th / (kx / ky) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= -3.2) tmp = sin(th); elseif (ky <= 4.6e-214) tmp = Float64(th / Float64(kx / ky)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= -3.2) tmp = sin(th); elseif (ky <= 4.6e-214) tmp = th / (kx / ky); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, -3.2], N[Sin[th], $MachinePrecision], If[LessEqual[ky, 4.6e-214], N[(th / N[(kx / ky), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq -3.2:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;ky \leq 4.6 \cdot 10^{-214}:\\
\;\;\;\;\frac{th}{\frac{kx}{ky}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < -3.2000000000000002 or 4.60000000000000022e-214 < ky Initial program 97.1%
+-commutative97.1%
unpow297.1%
unpow297.1%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 34.3%
if -3.2000000000000002 < ky < 4.60000000000000022e-214Initial program 81.5%
associate-*l/79.3%
Simplified79.3%
Taylor expanded in th around 0 45.0%
Taylor expanded in ky around 0 37.2%
*-commutative37.2%
associate-/l*37.5%
Simplified37.5%
Taylor expanded in kx around 0 30.0%
Final simplification32.9%
(FPCore (kx ky th) :precision binary64 (if (<= ky -80000000.0) th (if (<= ky 1.75e-119) (* th (/ ky kx)) th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= -80000000.0) {
tmp = th;
} else if (ky <= 1.75e-119) {
tmp = th * (ky / kx);
} 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 <= (-80000000.0d0)) then
tmp = th
else if (ky <= 1.75d-119) then
tmp = th * (ky / kx)
else
tmp = th
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= -80000000.0) {
tmp = th;
} else if (ky <= 1.75e-119) {
tmp = th * (ky / kx);
} else {
tmp = th;
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= -80000000.0: tmp = th elif ky <= 1.75e-119: tmp = th * (ky / kx) else: tmp = th return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= -80000000.0) tmp = th; elseif (ky <= 1.75e-119) tmp = Float64(th * Float64(ky / kx)); else tmp = th; end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= -80000000.0) tmp = th; elseif (ky <= 1.75e-119) tmp = th * (ky / kx); else tmp = th; end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, -80000000.0], th, If[LessEqual[ky, 1.75e-119], N[(th * N[(ky / kx), $MachinePrecision]), $MachinePrecision], th]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq -80000000:\\
\;\;\;\;th\\
\mathbf{elif}\;ky \leq 1.75 \cdot 10^{-119}:\\
\;\;\;\;th \cdot \frac{ky}{kx}\\
\mathbf{else}:\\
\;\;\;\;th\\
\end{array}
\end{array}
if ky < -8e7 or 1.75e-119 < ky Initial program 99.7%
associate-*l/99.5%
Simplified99.5%
Taylor expanded in th around 0 59.2%
Taylor expanded in kx around 0 24.2%
if -8e7 < ky < 1.75e-119Initial program 80.6%
associate-*l/77.8%
Simplified77.8%
Taylor expanded in th around 0 43.0%
Taylor expanded in ky around 0 35.0%
*-commutative35.0%
associate-/l*36.0%
Simplified36.0%
Taylor expanded in kx around 0 27.1%
associate-/l*28.0%
Simplified28.0%
associate-/r/28.3%
Applied egg-rr28.3%
Final simplification25.9%
(FPCore (kx ky th) :precision binary64 (if (<= ky -65000000.0) th (if (<= ky 2.1e-115) (/ th (/ kx ky)) th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= -65000000.0) {
tmp = th;
} else if (ky <= 2.1e-115) {
tmp = th / (kx / ky);
} 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 <= (-65000000.0d0)) then
tmp = th
else if (ky <= 2.1d-115) then
tmp = th / (kx / ky)
else
tmp = th
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= -65000000.0) {
tmp = th;
} else if (ky <= 2.1e-115) {
tmp = th / (kx / ky);
} else {
tmp = th;
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= -65000000.0: tmp = th elif ky <= 2.1e-115: tmp = th / (kx / ky) else: tmp = th return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= -65000000.0) tmp = th; elseif (ky <= 2.1e-115) tmp = Float64(th / Float64(kx / ky)); else tmp = th; end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= -65000000.0) tmp = th; elseif (ky <= 2.1e-115) tmp = th / (kx / ky); else tmp = th; end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, -65000000.0], th, If[LessEqual[ky, 2.1e-115], N[(th / N[(kx / ky), $MachinePrecision]), $MachinePrecision], th]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq -65000000:\\
\;\;\;\;th\\
\mathbf{elif}\;ky \leq 2.1 \cdot 10^{-115}:\\
\;\;\;\;\frac{th}{\frac{kx}{ky}}\\
\mathbf{else}:\\
\;\;\;\;th\\
\end{array}
\end{array}
if ky < -6.5e7 or 2.10000000000000002e-115 < ky Initial program 99.7%
associate-*l/99.5%
Simplified99.5%
Taylor expanded in th around 0 59.2%
Taylor expanded in kx around 0 24.2%
if -6.5e7 < ky < 2.10000000000000002e-115Initial program 80.6%
associate-*l/77.8%
Simplified77.8%
Taylor expanded in th around 0 43.0%
Taylor expanded in ky around 0 35.0%
*-commutative35.0%
associate-/l*36.0%
Simplified36.0%
Taylor expanded in kx around 0 28.3%
Final simplification25.9%
(FPCore (kx ky th) :precision binary64 th)
double code(double kx, double ky, double th) {
return th;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = th
end function
public static double code(double kx, double ky, double th) {
return th;
}
def code(kx, ky, th): return th
function code(kx, ky, th) return th end
function tmp = code(kx, ky, th) tmp = th; end
code[kx_, ky_, th_] := th
\begin{array}{l}
\\
th
\end{array}
Initial program 91.8%
associate-*l/90.6%
Simplified90.6%
Taylor expanded in th around 0 52.5%
Taylor expanded in kx around 0 17.1%
Final simplification17.1%
herbie shell --seed 2023207
(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)))