
(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 17 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 93.9%
+-commutative93.9%
unpow293.9%
unpow293.9%
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
(if (<= (sin ky) -0.854)
(/ (sin ky) (fabs (/ (sin ky) (sin th))))
(if (<= (sin ky) -1e-30)
(fabs (sin th))
(if (<= (sin ky) 1e-114) (* (sin ky) (/ (sin th) (sin kx))) (sin th)))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.854) {
tmp = sin(ky) / fabs((sin(ky) / sin(th)));
} else if (sin(ky) <= -1e-30) {
tmp = fabs(sin(th));
} else if (sin(ky) <= 1e-114) {
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.854d0)) then
tmp = sin(ky) / abs((sin(ky) / sin(th)))
else if (sin(ky) <= (-1d-30)) then
tmp = abs(sin(th))
else if (sin(ky) <= 1d-114) 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.854) {
tmp = Math.sin(ky) / Math.abs((Math.sin(ky) / Math.sin(th)));
} else if (Math.sin(ky) <= -1e-30) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(ky) <= 1e-114) {
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.854: tmp = math.sin(ky) / math.fabs((math.sin(ky) / math.sin(th))) elif math.sin(ky) <= -1e-30: tmp = math.fabs(math.sin(th)) elif math.sin(ky) <= 1e-114: 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.854) tmp = Float64(sin(ky) / abs(Float64(sin(ky) / sin(th)))); elseif (sin(ky) <= -1e-30) tmp = abs(sin(th)); elseif (sin(ky) <= 1e-114) 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.854) tmp = sin(ky) / abs((sin(ky) / sin(th))); elseif (sin(ky) <= -1e-30) tmp = abs(sin(th)); elseif (sin(ky) <= 1e-114) 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.854], N[(N[Sin[ky], $MachinePrecision] / N[Abs[N[(N[Sin[ky], $MachinePrecision] / N[Sin[th], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], -1e-30], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-114], 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.854:\\
\;\;\;\;\frac{\sin ky}{\left|\frac{\sin ky}{\sin th}\right|}\\
\mathbf{elif}\;\sin ky \leq -1 \cdot 10^{-30}:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq 10^{-114}:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.853999999999999981Initial program 99.9%
associate-/r/99.7%
+-commutative99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
+-commutative99.7%
Simplified99.7%
Taylor expanded in kx around 0 2.0%
add-sqr-sqrt0.6%
sqrt-unprod63.0%
pow263.0%
Applied egg-rr63.0%
unpow263.0%
rem-sqrt-square67.7%
Simplified67.7%
if -0.853999999999999981 < (sin.f64 ky) < -1e-30Initial program 99.5%
associate-/r/99.5%
+-commutative99.5%
unpow299.5%
sqr-neg99.5%
sin-neg99.5%
sin-neg99.5%
unpow299.5%
+-commutative99.5%
Simplified99.6%
Taylor expanded in kx around 0 2.8%
associate-/r/2.8%
*-inverses2.8%
*-un-lft-identity2.8%
add-sqr-sqrt1.3%
sqrt-unprod29.3%
pow229.3%
Applied egg-rr29.3%
unpow229.3%
rem-sqrt-square34.4%
Simplified34.4%
if -1e-30 < (sin.f64 ky) < 1.0000000000000001e-114Initial program 84.5%
associate-/r/84.5%
+-commutative84.5%
unpow284.5%
sqr-neg84.5%
sin-neg84.5%
sin-neg84.5%
unpow284.5%
+-commutative84.5%
Simplified99.6%
clear-num98.3%
associate-/r/99.6%
clear-num99.7%
Applied egg-rr99.7%
Taylor expanded in ky around 0 47.4%
if 1.0000000000000001e-114 < (sin.f64 ky) Initial program 99.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.6%
Simplified99.6%
Taylor expanded in kx around 0 56.8%
Final simplification48.7%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin th) -0.001)
(* (sin ky) (/ (sin th) (sin kx)))
(if (<= (sin th) 5e-11)
(* (sin ky) (/ th (hypot (sin ky) (sin kx))))
(/ (sin ky) (fabs (/ (sin ky) (sin th)))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(th) <= -0.001) {
tmp = sin(ky) * (sin(th) / sin(kx));
} else if (sin(th) <= 5e-11) {
tmp = sin(ky) * (th / hypot(sin(ky), sin(kx)));
} else {
tmp = sin(ky) / fabs((sin(ky) / sin(th)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(th) <= -0.001) {
tmp = Math.sin(ky) * (Math.sin(th) / Math.sin(kx));
} else if (Math.sin(th) <= 5e-11) {
tmp = Math.sin(ky) * (th / Math.hypot(Math.sin(ky), Math.sin(kx)));
} else {
tmp = Math.sin(ky) / Math.abs((Math.sin(ky) / Math.sin(th)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(th) <= -0.001: tmp = math.sin(ky) * (math.sin(th) / math.sin(kx)) elif math.sin(th) <= 5e-11: tmp = math.sin(ky) * (th / math.hypot(math.sin(ky), math.sin(kx))) else: tmp = math.sin(ky) / math.fabs((math.sin(ky) / math.sin(th))) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(th) <= -0.001) tmp = Float64(sin(ky) * Float64(sin(th) / sin(kx))); elseif (sin(th) <= 5e-11) tmp = Float64(sin(ky) * Float64(th / hypot(sin(ky), sin(kx)))); else tmp = Float64(sin(ky) / abs(Float64(sin(ky) / sin(th)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(th) <= -0.001) tmp = sin(ky) * (sin(th) / sin(kx)); elseif (sin(th) <= 5e-11) tmp = sin(ky) * (th / hypot(sin(ky), sin(kx))); else tmp = sin(ky) / abs((sin(ky) / sin(th))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[th], $MachinePrecision], -0.001], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[th], $MachinePrecision], 5e-11], N[(N[Sin[ky], $MachinePrecision] * N[(th / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[ky], $MachinePrecision] / N[Abs[N[(N[Sin[ky], $MachinePrecision] / N[Sin[th], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin th \leq -0.001:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{elif}\;\sin th \leq 5 \cdot 10^{-11}:\\
\;\;\;\;\sin ky \cdot \frac{th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\left|\frac{\sin ky}{\sin th}\right|}\\
\end{array}
\end{array}
if (sin.f64 th) < -1e-3Initial program 94.4%
associate-/r/94.3%
+-commutative94.3%
unpow294.3%
sqr-neg94.3%
sin-neg94.3%
sin-neg94.3%
unpow294.3%
+-commutative94.3%
Simplified99.5%
clear-num99.4%
associate-/r/99.5%
clear-num99.6%
Applied egg-rr99.6%
Taylor expanded in ky around 0 18.2%
if -1e-3 < (sin.f64 th) < 5.00000000000000018e-11Initial program 91.7%
+-commutative91.7%
unpow291.7%
unpow291.7%
hypot-def99.7%
Simplified99.7%
Taylor expanded in th around 0 84.0%
*-commutative84.0%
associate-*l*89.1%
+-commutative89.1%
Simplified89.1%
expm1-log1p-u89.1%
expm1-udef16.1%
Applied egg-rr18.1%
expm1-def99.7%
expm1-log1p99.7%
associate-*r/89.1%
*-commutative89.1%
associate-*r/99.6%
Simplified99.6%
if 5.00000000000000018e-11 < (sin.f64 th) Initial program 97.1%
associate-/r/97.0%
+-commutative97.0%
unpow297.0%
sqr-neg97.0%
sin-neg97.0%
sin-neg97.0%
unpow297.0%
+-commutative97.0%
Simplified99.5%
Taylor expanded in kx around 0 24.1%
add-sqr-sqrt22.9%
sqrt-unprod51.0%
pow251.0%
Applied egg-rr51.0%
unpow251.0%
rem-sqrt-square52.5%
Simplified52.5%
Final simplification67.3%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin th) -0.001)
(* (sin ky) (/ (sin th) (sin kx)))
(if (<= (sin th) 5e-11)
(/ th (/ (hypot (sin ky) (sin kx)) (sin ky)))
(/ (sin ky) (fabs (/ (sin ky) (sin th)))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(th) <= -0.001) {
tmp = sin(ky) * (sin(th) / sin(kx));
} else if (sin(th) <= 5e-11) {
tmp = th / (hypot(sin(ky), sin(kx)) / sin(ky));
} else {
tmp = sin(ky) / fabs((sin(ky) / sin(th)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(th) <= -0.001) {
tmp = Math.sin(ky) * (Math.sin(th) / Math.sin(kx));
} else if (Math.sin(th) <= 5e-11) {
tmp = th / (Math.hypot(Math.sin(ky), Math.sin(kx)) / Math.sin(ky));
} else {
tmp = Math.sin(ky) / Math.abs((Math.sin(ky) / Math.sin(th)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(th) <= -0.001: tmp = math.sin(ky) * (math.sin(th) / math.sin(kx)) elif math.sin(th) <= 5e-11: tmp = th / (math.hypot(math.sin(ky), math.sin(kx)) / math.sin(ky)) else: tmp = math.sin(ky) / math.fabs((math.sin(ky) / math.sin(th))) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(th) <= -0.001) tmp = Float64(sin(ky) * Float64(sin(th) / sin(kx))); elseif (sin(th) <= 5e-11) tmp = Float64(th / Float64(hypot(sin(ky), sin(kx)) / sin(ky))); else tmp = Float64(sin(ky) / abs(Float64(sin(ky) / sin(th)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(th) <= -0.001) tmp = sin(ky) * (sin(th) / sin(kx)); elseif (sin(th) <= 5e-11) tmp = th / (hypot(sin(ky), sin(kx)) / sin(ky)); else tmp = sin(ky) / abs((sin(ky) / sin(th))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[th], $MachinePrecision], -0.001], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[th], $MachinePrecision], 5e-11], N[(th / N[(N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[ky], $MachinePrecision] / N[Abs[N[(N[Sin[ky], $MachinePrecision] / N[Sin[th], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin th \leq -0.001:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{elif}\;\sin th \leq 5 \cdot 10^{-11}:\\
\;\;\;\;\frac{th}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right)}{\sin ky}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\left|\frac{\sin ky}{\sin th}\right|}\\
\end{array}
\end{array}
if (sin.f64 th) < -1e-3Initial program 94.4%
associate-/r/94.3%
+-commutative94.3%
unpow294.3%
sqr-neg94.3%
sin-neg94.3%
sin-neg94.3%
unpow294.3%
+-commutative94.3%
Simplified99.5%
clear-num99.4%
associate-/r/99.5%
clear-num99.6%
Applied egg-rr99.6%
Taylor expanded in ky around 0 18.2%
if -1e-3 < (sin.f64 th) < 5.00000000000000018e-11Initial program 91.7%
+-commutative91.7%
unpow291.7%
unpow291.7%
hypot-def99.7%
Simplified99.7%
Taylor expanded in th around 0 84.0%
*-commutative84.0%
associate-*l*89.1%
+-commutative89.1%
Simplified89.1%
expm1-log1p-u89.1%
expm1-udef16.1%
Applied egg-rr18.1%
expm1-def99.7%
expm1-log1p99.7%
associate-*r/89.1%
associate-/l*99.7%
Simplified99.7%
if 5.00000000000000018e-11 < (sin.f64 th) Initial program 97.1%
associate-/r/97.0%
+-commutative97.0%
unpow297.0%
sqr-neg97.0%
sin-neg97.0%
sin-neg97.0%
unpow297.0%
+-commutative97.0%
Simplified99.5%
Taylor expanded in kx around 0 24.1%
add-sqr-sqrt22.9%
sqrt-unprod51.0%
pow251.0%
Applied egg-rr51.0%
unpow251.0%
rem-sqrt-square52.5%
Simplified52.5%
Final simplification67.3%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (hypot (sin ky) (sin kx))))
(if (<= (sin th) -0.001)
(/ (* (sin th) ky) t_1)
(if (<= (sin th) 5e-11)
(/ th (/ t_1 (sin ky)))
(/ (sin ky) (fabs (/ (sin ky) (sin th))))))))
double code(double kx, double ky, double th) {
double t_1 = hypot(sin(ky), sin(kx));
double tmp;
if (sin(th) <= -0.001) {
tmp = (sin(th) * ky) / t_1;
} else if (sin(th) <= 5e-11) {
tmp = th / (t_1 / sin(ky));
} else {
tmp = sin(ky) / fabs((sin(ky) / sin(th)));
}
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.001) {
tmp = (Math.sin(th) * ky) / t_1;
} else if (Math.sin(th) <= 5e-11) {
tmp = th / (t_1 / Math.sin(ky));
} else {
tmp = Math.sin(ky) / Math.abs((Math.sin(ky) / Math.sin(th)));
}
return tmp;
}
def code(kx, ky, th): t_1 = math.hypot(math.sin(ky), math.sin(kx)) tmp = 0 if math.sin(th) <= -0.001: tmp = (math.sin(th) * ky) / t_1 elif math.sin(th) <= 5e-11: tmp = th / (t_1 / math.sin(ky)) else: tmp = math.sin(ky) / math.fabs((math.sin(ky) / math.sin(th))) return tmp
function code(kx, ky, th) t_1 = hypot(sin(ky), sin(kx)) tmp = 0.0 if (sin(th) <= -0.001) tmp = Float64(Float64(sin(th) * ky) / t_1); elseif (sin(th) <= 5e-11) tmp = Float64(th / Float64(t_1 / sin(ky))); else tmp = Float64(sin(ky) / abs(Float64(sin(ky) / sin(th)))); 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.001) tmp = (sin(th) * ky) / t_1; elseif (sin(th) <= 5e-11) tmp = th / (t_1 / sin(ky)); else tmp = sin(ky) / abs((sin(ky) / sin(th))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]}, If[LessEqual[N[Sin[th], $MachinePrecision], -0.001], N[(N[(N[Sin[th], $MachinePrecision] * ky), $MachinePrecision] / t$95$1), $MachinePrecision], If[LessEqual[N[Sin[th], $MachinePrecision], 5e-11], N[(th / N[(t$95$1 / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[ky], $MachinePrecision] / N[Abs[N[(N[Sin[ky], $MachinePrecision] / N[Sin[th], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{hypot}\left(\sin ky, \sin kx\right)\\
\mathbf{if}\;\sin th \leq -0.001:\\
\;\;\;\;\frac{\sin th \cdot ky}{t_1}\\
\mathbf{elif}\;\sin th \leq 5 \cdot 10^{-11}:\\
\;\;\;\;\frac{th}{\frac{t_1}{\sin ky}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\left|\frac{\sin ky}{\sin th}\right|}\\
\end{array}
\end{array}
if (sin.f64 th) < -1e-3Initial program 94.4%
associate-*l/94.3%
+-commutative94.3%
unpow294.3%
unpow294.3%
hypot-def99.5%
Simplified99.5%
Taylor expanded in ky around 0 48.6%
if -1e-3 < (sin.f64 th) < 5.00000000000000018e-11Initial program 91.7%
+-commutative91.7%
unpow291.7%
unpow291.7%
hypot-def99.7%
Simplified99.7%
Taylor expanded in th around 0 84.0%
*-commutative84.0%
associate-*l*89.1%
+-commutative89.1%
Simplified89.1%
expm1-log1p-u89.1%
expm1-udef16.1%
Applied egg-rr18.1%
expm1-def99.7%
expm1-log1p99.7%
associate-*r/89.1%
associate-/l*99.7%
Simplified99.7%
if 5.00000000000000018e-11 < (sin.f64 th) Initial program 97.1%
associate-/r/97.0%
+-commutative97.0%
unpow297.0%
sqr-neg97.0%
sin-neg97.0%
sin-neg97.0%
unpow297.0%
+-commutative97.0%
Simplified99.5%
Taylor expanded in kx around 0 24.1%
add-sqr-sqrt22.9%
sqrt-unprod51.0%
pow251.0%
Applied egg-rr51.0%
unpow251.0%
rem-sqrt-square52.5%
Simplified52.5%
Final simplification74.0%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -1e-30) (fabs (sin th)) (if (<= (sin ky) 1e-114) (* (sin ky) (/ (sin th) (sin kx))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -1e-30) {
tmp = fabs(sin(th));
} else if (sin(ky) <= 1e-114) {
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) <= (-1d-30)) then
tmp = abs(sin(th))
else if (sin(ky) <= 1d-114) 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) <= -1e-30) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(ky) <= 1e-114) {
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) <= -1e-30: tmp = math.fabs(math.sin(th)) elif math.sin(ky) <= 1e-114: 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) <= -1e-30) tmp = abs(sin(th)); elseif (sin(ky) <= 1e-114) 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) <= -1e-30) tmp = abs(sin(th)); elseif (sin(ky) <= 1e-114) 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], -1e-30], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-114], 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 -1 \cdot 10^{-30}:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq 10^{-114}:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -1e-30Initial program 99.6%
associate-/r/99.6%
+-commutative99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
+-commutative99.6%
Simplified99.6%
Taylor expanded in kx around 0 2.6%
associate-/r/2.6%
*-inverses2.6%
*-un-lft-identity2.6%
add-sqr-sqrt1.4%
sqrt-unprod25.6%
pow225.6%
Applied egg-rr25.6%
unpow225.6%
rem-sqrt-square30.6%
Simplified30.6%
if -1e-30 < (sin.f64 ky) < 1.0000000000000001e-114Initial program 84.5%
associate-/r/84.5%
+-commutative84.5%
unpow284.5%
sqr-neg84.5%
sin-neg84.5%
sin-neg84.5%
unpow284.5%
+-commutative84.5%
Simplified99.6%
clear-num98.3%
associate-/r/99.6%
clear-num99.7%
Applied egg-rr99.7%
Taylor expanded in ky around 0 47.4%
if 1.0000000000000001e-114 < (sin.f64 ky) Initial program 99.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.6%
Simplified99.6%
Taylor expanded in kx around 0 56.8%
Final simplification44.9%
(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 93.9%
+-commutative93.9%
unpow293.9%
unpow293.9%
hypot-def99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -1e-30) (fabs (sin th)) (if (<= (sin ky) 1e-114) (* (sin th) (/ ky (sin kx))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -1e-30) {
tmp = fabs(sin(th));
} else if (sin(ky) <= 1e-114) {
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-30)) then
tmp = abs(sin(th))
else if (sin(ky) <= 1d-114) 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-30) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(ky) <= 1e-114) {
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-30: tmp = math.fabs(math.sin(th)) elif math.sin(ky) <= 1e-114: 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-30) tmp = abs(sin(th)); elseif (sin(ky) <= 1e-114) 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-30) tmp = abs(sin(th)); elseif (sin(ky) <= 1e-114) 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-30], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-114], 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 -1 \cdot 10^{-30}:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq 10^{-114}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -1e-30Initial program 99.6%
associate-/r/99.6%
+-commutative99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
+-commutative99.6%
Simplified99.6%
Taylor expanded in kx around 0 2.6%
associate-/r/2.6%
*-inverses2.6%
*-un-lft-identity2.6%
add-sqr-sqrt1.4%
sqrt-unprod25.6%
pow225.6%
Applied egg-rr25.6%
unpow225.6%
rem-sqrt-square30.6%
Simplified30.6%
if -1e-30 < (sin.f64 ky) < 1.0000000000000001e-114Initial program 84.5%
+-commutative84.5%
unpow284.5%
unpow284.5%
hypot-def99.6%
Simplified99.6%
Taylor expanded in ky around 0 47.4%
if 1.0000000000000001e-114 < (sin.f64 ky) Initial program 99.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.6%
Simplified99.6%
Taylor expanded in kx around 0 56.8%
Final simplification44.9%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -1e-30) (fabs (sin th)) (if (<= (sin ky) 1e-114) (* th (/ ky (sin kx))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -1e-30) {
tmp = fabs(sin(th));
} else if (sin(ky) <= 1e-114) {
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 (sin(ky) <= (-1d-30)) then
tmp = abs(sin(th))
else if (sin(ky) <= 1d-114) 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 (Math.sin(ky) <= -1e-30) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(ky) <= 1e-114) {
tmp = th * (ky / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -1e-30: tmp = math.fabs(math.sin(th)) elif math.sin(ky) <= 1e-114: tmp = th * (ky / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -1e-30) tmp = abs(sin(th)); elseif (sin(ky) <= 1e-114) 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 (sin(ky) <= -1e-30) tmp = abs(sin(th)); elseif (sin(ky) <= 1e-114) tmp = th * (ky / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -1e-30], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-114], N[(th * N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -1 \cdot 10^{-30}:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq 10^{-114}:\\
\;\;\;\;th \cdot \frac{ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -1e-30Initial program 99.6%
associate-/r/99.6%
+-commutative99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
+-commutative99.6%
Simplified99.6%
Taylor expanded in kx around 0 2.6%
associate-/r/2.6%
*-inverses2.6%
*-un-lft-identity2.6%
add-sqr-sqrt1.4%
sqrt-unprod25.6%
pow225.6%
Applied egg-rr25.6%
unpow225.6%
rem-sqrt-square30.6%
Simplified30.6%
if -1e-30 < (sin.f64 ky) < 1.0000000000000001e-114Initial program 84.5%
+-commutative84.5%
unpow284.5%
unpow284.5%
hypot-def99.6%
Simplified99.6%
Taylor expanded in th around 0 36.1%
*-commutative36.1%
associate-*l*40.9%
+-commutative40.9%
Simplified40.9%
Taylor expanded in ky around 0 25.4%
associate-/l*30.2%
Simplified30.2%
associate-/r/30.3%
Applied egg-rr30.3%
if 1.0000000000000001e-114 < (sin.f64 ky) Initial program 99.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.6%
Simplified99.6%
Taylor expanded in kx around 0 56.8%
Final simplification38.5%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) 1e-147) (* (sin ky) (/ th kx)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= 1e-147) {
tmp = sin(ky) * (th / 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-147) then
tmp = sin(ky) * (th / 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-147) {
tmp = Math.sin(ky) * (th / kx);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= 1e-147: tmp = math.sin(ky) * (th / kx) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= 1e-147) tmp = Float64(sin(ky) * Float64(th / kx)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= 1e-147) tmp = sin(ky) * (th / kx); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-147], N[(N[Sin[ky], $MachinePrecision] * N[(th / kx), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq 10^{-147}:\\
\;\;\;\;\sin ky \cdot \frac{th}{kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < 9.9999999999999997e-148Initial program 91.2%
+-commutative91.2%
unpow291.2%
unpow291.2%
hypot-def99.7%
Simplified99.7%
Taylor expanded in th around 0 42.8%
*-commutative42.8%
associate-*l*45.5%
+-commutative45.5%
Simplified45.5%
Taylor expanded in ky around 0 19.9%
Taylor expanded in kx around 0 15.6%
if 9.9999999999999997e-148 < (sin.f64 ky) Initial program 99.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.6%
Simplified99.6%
Taylor expanded in kx around 0 54.9%
Final simplification28.4%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) 1e-114) (* th (/ ky (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= 1e-114) {
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 (sin(ky) <= 1d-114) 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 (Math.sin(ky) <= 1e-114) {
tmp = th * (ky / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= 1e-114: tmp = th * (ky / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= 1e-114) 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 (sin(ky) <= 1e-114) tmp = th * (ky / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-114], N[(th * N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq 10^{-114}:\\
\;\;\;\;th \cdot \frac{ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < 1.0000000000000001e-114Initial program 91.5%
+-commutative91.5%
unpow291.5%
unpow291.5%
hypot-def99.7%
Simplified99.7%
Taylor expanded in th around 0 42.7%
*-commutative42.7%
associate-*l*45.4%
+-commutative45.4%
Simplified45.4%
Taylor expanded in ky around 0 16.4%
associate-/l*19.0%
Simplified19.0%
associate-/r/19.0%
Applied egg-rr19.0%
if 1.0000000000000001e-114 < (sin.f64 ky) Initial program 99.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.6%
Simplified99.6%
Taylor expanded in kx around 0 56.8%
Final simplification30.5%
(FPCore (kx ky th) :precision binary64 (if (<= ky -1800000.0) (sin th) (if (<= ky 1e-147) (/ th (/ kx ky)) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= -1800000.0) {
tmp = sin(th);
} else if (ky <= 1e-147) {
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 <= (-1800000.0d0)) then
tmp = sin(th)
else if (ky <= 1d-147) 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 <= -1800000.0) {
tmp = Math.sin(th);
} else if (ky <= 1e-147) {
tmp = th / (kx / ky);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= -1800000.0: tmp = math.sin(th) elif ky <= 1e-147: tmp = th / (kx / ky) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= -1800000.0) tmp = sin(th); elseif (ky <= 1e-147) 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 <= -1800000.0) tmp = sin(th); elseif (ky <= 1e-147) tmp = th / (kx / ky); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, -1800000.0], N[Sin[th], $MachinePrecision], If[LessEqual[ky, 1e-147], N[(th / N[(kx / ky), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq -1800000:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;ky \leq 10^{-147}:\\
\;\;\;\;\frac{th}{\frac{kx}{ky}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < -1.8e6 or 9.9999999999999997e-148 < ky Initial program 99.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 29.8%
if -1.8e6 < ky < 9.9999999999999997e-148Initial program 84.7%
+-commutative84.7%
unpow284.7%
unpow284.7%
hypot-def99.6%
Simplified99.6%
Taylor expanded in th around 0 38.7%
*-commutative38.7%
associate-*l*43.5%
+-commutative43.5%
Simplified43.5%
Taylor expanded in ky around 0 26.8%
associate-/l*31.6%
Simplified31.6%
Taylor expanded in kx around 0 20.0%
associate-/l*25.0%
Simplified25.0%
Final simplification28.0%
(FPCore (kx ky th) :precision binary64 (if (<= ky -4.2e+80) th (if (<= ky 5.7e-114) (* th (/ ky kx)) th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= -4.2e+80) {
tmp = th;
} else if (ky <= 5.7e-114) {
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 <= (-4.2d+80)) then
tmp = th
else if (ky <= 5.7d-114) 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 <= -4.2e+80) {
tmp = th;
} else if (ky <= 5.7e-114) {
tmp = th * (ky / kx);
} else {
tmp = th;
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= -4.2e+80: tmp = th elif ky <= 5.7e-114: tmp = th * (ky / kx) else: tmp = th return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= -4.2e+80) tmp = th; elseif (ky <= 5.7e-114) 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 <= -4.2e+80) tmp = th; elseif (ky <= 5.7e-114) tmp = th * (ky / kx); else tmp = th; end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, -4.2e+80], th, If[LessEqual[ky, 5.7e-114], N[(th * N[(ky / kx), $MachinePrecision]), $MachinePrecision], th]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq -4.2 \cdot 10^{+80}:\\
\;\;\;\;th\\
\mathbf{elif}\;ky \leq 5.7 \cdot 10^{-114}:\\
\;\;\;\;th \cdot \frac{ky}{kx}\\
\mathbf{else}:\\
\;\;\;\;th\\
\end{array}
\end{array}
if ky < -4.20000000000000003e80 or 5.6999999999999997e-114 < ky Initial program 99.6%
associate-/r/99.5%
+-commutative99.5%
unpow299.5%
sqr-neg99.5%
sin-neg99.5%
sin-neg99.5%
unpow299.5%
+-commutative99.5%
Simplified99.6%
Taylor expanded in kx around 0 29.7%
Taylor expanded in th around 0 16.3%
if -4.20000000000000003e80 < ky < 5.6999999999999997e-114Initial program 86.4%
+-commutative86.4%
unpow286.4%
unpow286.4%
hypot-def99.6%
Simplified99.6%
Taylor expanded in th around 0 37.9%
*-commutative37.9%
associate-*l*42.2%
+-commutative42.2%
Simplified42.2%
Taylor expanded in ky around 0 25.0%
associate-/l*29.2%
Simplified29.2%
Taylor expanded in kx around 0 23.2%
associate-/r/23.3%
Applied egg-rr23.3%
Final simplification19.3%
(FPCore (kx ky th) :precision binary64 (if (<= ky -1.8e+83) th (if (<= ky 8.2e-115) (* ky (/ th kx)) th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= -1.8e+83) {
tmp = th;
} else if (ky <= 8.2e-115) {
tmp = ky * (th / 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 <= (-1.8d+83)) then
tmp = th
else if (ky <= 8.2d-115) then
tmp = ky * (th / kx)
else
tmp = th
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= -1.8e+83) {
tmp = th;
} else if (ky <= 8.2e-115) {
tmp = ky * (th / kx);
} else {
tmp = th;
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= -1.8e+83: tmp = th elif ky <= 8.2e-115: tmp = ky * (th / kx) else: tmp = th return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= -1.8e+83) tmp = th; elseif (ky <= 8.2e-115) tmp = Float64(ky * Float64(th / kx)); else tmp = th; end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= -1.8e+83) tmp = th; elseif (ky <= 8.2e-115) tmp = ky * (th / kx); else tmp = th; end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, -1.8e+83], th, If[LessEqual[ky, 8.2e-115], N[(ky * N[(th / kx), $MachinePrecision]), $MachinePrecision], th]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq -1.8 \cdot 10^{+83}:\\
\;\;\;\;th\\
\mathbf{elif}\;ky \leq 8.2 \cdot 10^{-115}:\\
\;\;\;\;ky \cdot \frac{th}{kx}\\
\mathbf{else}:\\
\;\;\;\;th\\
\end{array}
\end{array}
if ky < -1.7999999999999999e83 or 8.1999999999999993e-115 < ky Initial program 99.6%
associate-/r/99.5%
+-commutative99.5%
unpow299.5%
sqr-neg99.5%
sin-neg99.5%
sin-neg99.5%
unpow299.5%
+-commutative99.5%
Simplified99.6%
Taylor expanded in kx around 0 29.7%
Taylor expanded in th around 0 16.3%
if -1.7999999999999999e83 < ky < 8.1999999999999993e-115Initial program 86.4%
+-commutative86.4%
unpow286.4%
unpow286.4%
hypot-def99.6%
Simplified99.6%
Taylor expanded in th around 0 37.9%
*-commutative37.9%
associate-*l*42.2%
+-commutative42.2%
Simplified42.2%
Taylor expanded in ky around 0 25.0%
associate-/l*29.2%
Simplified29.2%
Taylor expanded in kx around 0 23.2%
clear-num23.2%
associate-/r/23.2%
clear-num23.2%
Applied egg-rr23.2%
Final simplification19.2%
(FPCore (kx ky th) :precision binary64 (if (<= ky -8e+83) th (if (<= ky 1.95e-113) (/ ky (/ kx th)) th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= -8e+83) {
tmp = th;
} else if (ky <= 1.95e-113) {
tmp = ky / (kx / th);
} else {
tmp = th;
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (ky <= (-8d+83)) then
tmp = th
else if (ky <= 1.95d-113) then
tmp = ky / (kx / th)
else
tmp = th
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= -8e+83) {
tmp = th;
} else if (ky <= 1.95e-113) {
tmp = ky / (kx / th);
} else {
tmp = th;
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= -8e+83: tmp = th elif ky <= 1.95e-113: tmp = ky / (kx / th) else: tmp = th return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= -8e+83) tmp = th; elseif (ky <= 1.95e-113) tmp = Float64(ky / Float64(kx / th)); else tmp = th; end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= -8e+83) tmp = th; elseif (ky <= 1.95e-113) tmp = ky / (kx / th); else tmp = th; end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, -8e+83], th, If[LessEqual[ky, 1.95e-113], N[(ky / N[(kx / th), $MachinePrecision]), $MachinePrecision], th]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq -8 \cdot 10^{+83}:\\
\;\;\;\;th\\
\mathbf{elif}\;ky \leq 1.95 \cdot 10^{-113}:\\
\;\;\;\;\frac{ky}{\frac{kx}{th}}\\
\mathbf{else}:\\
\;\;\;\;th\\
\end{array}
\end{array}
if ky < -8.00000000000000025e83 or 1.9499999999999999e-113 < ky Initial program 99.6%
associate-/r/99.5%
+-commutative99.5%
unpow299.5%
sqr-neg99.5%
sin-neg99.5%
sin-neg99.5%
unpow299.5%
+-commutative99.5%
Simplified99.6%
Taylor expanded in kx around 0 29.7%
Taylor expanded in th around 0 16.3%
if -8.00000000000000025e83 < ky < 1.9499999999999999e-113Initial program 86.4%
+-commutative86.4%
unpow286.4%
unpow286.4%
hypot-def99.6%
Simplified99.6%
Taylor expanded in th around 0 37.9%
*-commutative37.9%
associate-*l*42.2%
+-commutative42.2%
Simplified42.2%
Taylor expanded in ky around 0 25.0%
associate-/l*29.2%
Simplified29.2%
Taylor expanded in kx around 0 23.2%
Final simplification19.3%
(FPCore (kx ky th) :precision binary64 (if (<= ky -8.6e+82) th (if (<= ky 1.75e-114) (/ th (/ kx ky)) th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= -8.6e+82) {
tmp = th;
} else if (ky <= 1.75e-114) {
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 <= (-8.6d+82)) then
tmp = th
else if (ky <= 1.75d-114) 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 <= -8.6e+82) {
tmp = th;
} else if (ky <= 1.75e-114) {
tmp = th / (kx / ky);
} else {
tmp = th;
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= -8.6e+82: tmp = th elif ky <= 1.75e-114: tmp = th / (kx / ky) else: tmp = th return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= -8.6e+82) tmp = th; elseif (ky <= 1.75e-114) 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 <= -8.6e+82) tmp = th; elseif (ky <= 1.75e-114) tmp = th / (kx / ky); else tmp = th; end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, -8.6e+82], th, If[LessEqual[ky, 1.75e-114], N[(th / N[(kx / ky), $MachinePrecision]), $MachinePrecision], th]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq -8.6 \cdot 10^{+82}:\\
\;\;\;\;th\\
\mathbf{elif}\;ky \leq 1.75 \cdot 10^{-114}:\\
\;\;\;\;\frac{th}{\frac{kx}{ky}}\\
\mathbf{else}:\\
\;\;\;\;th\\
\end{array}
\end{array}
if ky < -8.60000000000000029e82 or 1.75e-114 < ky Initial program 99.6%
associate-/r/99.5%
+-commutative99.5%
unpow299.5%
sqr-neg99.5%
sin-neg99.5%
sin-neg99.5%
unpow299.5%
+-commutative99.5%
Simplified99.6%
Taylor expanded in kx around 0 29.7%
Taylor expanded in th around 0 16.3%
if -8.60000000000000029e82 < ky < 1.75e-114Initial program 86.4%
+-commutative86.4%
unpow286.4%
unpow286.4%
hypot-def99.6%
Simplified99.6%
Taylor expanded in th around 0 37.9%
*-commutative37.9%
associate-*l*42.2%
+-commutative42.2%
Simplified42.2%
Taylor expanded in ky around 0 25.0%
associate-/l*29.2%
Simplified29.2%
Taylor expanded in kx around 0 19.0%
associate-/l*23.4%
Simplified23.4%
Final simplification19.3%
(FPCore (kx ky th) :precision binary64 th)
double code(double kx, double ky, double th) {
return th;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = th
end function
public static double code(double kx, double ky, double th) {
return th;
}
def code(kx, ky, th): return th
function code(kx, ky, th) return th end
function tmp = code(kx, ky, th) tmp = th; end
code[kx_, ky_, th_] := th
\begin{array}{l}
\\
th
\end{array}
Initial program 93.9%
associate-/r/93.9%
+-commutative93.9%
unpow293.9%
sqr-neg93.9%
sin-neg93.9%
sin-neg93.9%
unpow293.9%
+-commutative93.9%
Simplified99.6%
Taylor expanded in kx around 0 21.1%
Taylor expanded in th around 0 11.0%
Final simplification11.0%
herbie shell --seed 2023309
(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)))