
(FPCore (kx ky th) :precision binary64 (* (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) (sin th)))
double code(double kx, double ky, double th) {
return (sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) * sin(th);
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = (sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))) * sin(th)
end function
public static double code(double kx, double ky, double th) {
return (Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))) * Math.sin(th);
}
def code(kx, ky, th): return (math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))) * math.sin(th)
function code(kx, ky, th) return Float64(Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th)) end
function tmp = code(kx, ky, th) tmp = (sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th); end
code[kx_, ky_, th_] := N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 16 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (kx ky th) :precision binary64 (* (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) (sin th)))
double code(double kx, double ky, double th) {
return (sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) * sin(th);
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = (sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))) * sin(th)
end function
public static double code(double kx, double ky, double th) {
return (Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))) * Math.sin(th);
}
def code(kx, ky, th): return (math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))) * math.sin(th)
function code(kx, ky, th) return Float64(Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th)) end
function tmp = code(kx, ky, th) tmp = (sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th); end
code[kx_, ky_, th_] := N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th
\end{array}
(FPCore (kx ky th) :precision binary64 (* (/ (sin ky) (hypot (sin ky) (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
return (sin(ky) / hypot(sin(ky), sin(kx))) * sin(th);
}
public static double code(double kx, double ky, double th) {
return (Math.sin(ky) / Math.hypot(Math.sin(ky), Math.sin(kx))) * Math.sin(th);
}
def code(kx, ky, th): return (math.sin(ky) / math.hypot(math.sin(ky), math.sin(kx))) * math.sin(th)
function code(kx, ky, th) return Float64(Float64(sin(ky) / hypot(sin(ky), sin(kx))) * sin(th)) end
function tmp = code(kx, ky, th) tmp = (sin(ky) / hypot(sin(ky), sin(kx))) * sin(th); end
code[kx_, ky_, th_] := N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \sin th
\end{array}
Initial program 92.1%
+-commutative92.1%
unpow292.1%
unpow292.1%
hypot-def99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (/ (sin th) (sin kx))))
(if (<= (sin th) -0.005)
(fabs (* (sin ky) t_1))
(if (<= (sin th) 5e-7)
(* (sin ky) (/ th (hypot (sin ky) (sin kx))))
(if (or (<= (sin th) 0.4) (not (<= (sin th) 0.72)))
(* (sin ky) (fabs t_1))
(sin th))))))
double code(double kx, double ky, double th) {
double t_1 = sin(th) / sin(kx);
double tmp;
if (sin(th) <= -0.005) {
tmp = fabs((sin(ky) * t_1));
} else if (sin(th) <= 5e-7) {
tmp = sin(ky) * (th / hypot(sin(ky), sin(kx)));
} else if ((sin(th) <= 0.4) || !(sin(th) <= 0.72)) {
tmp = sin(ky) * fabs(t_1);
} else {
tmp = sin(th);
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = Math.sin(th) / Math.sin(kx);
double tmp;
if (Math.sin(th) <= -0.005) {
tmp = Math.abs((Math.sin(ky) * t_1));
} else if (Math.sin(th) <= 5e-7) {
tmp = Math.sin(ky) * (th / Math.hypot(Math.sin(ky), Math.sin(kx)));
} else if ((Math.sin(th) <= 0.4) || !(Math.sin(th) <= 0.72)) {
tmp = Math.sin(ky) * Math.abs(t_1);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): t_1 = math.sin(th) / math.sin(kx) tmp = 0 if math.sin(th) <= -0.005: tmp = math.fabs((math.sin(ky) * t_1)) elif math.sin(th) <= 5e-7: tmp = math.sin(ky) * (th / math.hypot(math.sin(ky), math.sin(kx))) elif (math.sin(th) <= 0.4) or not (math.sin(th) <= 0.72): tmp = math.sin(ky) * math.fabs(t_1) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) t_1 = Float64(sin(th) / sin(kx)) tmp = 0.0 if (sin(th) <= -0.005) tmp = abs(Float64(sin(ky) * t_1)); elseif (sin(th) <= 5e-7) tmp = Float64(sin(ky) * Float64(th / hypot(sin(ky), sin(kx)))); elseif ((sin(th) <= 0.4) || !(sin(th) <= 0.72)) tmp = Float64(sin(ky) * abs(t_1)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = sin(th) / sin(kx); tmp = 0.0; if (sin(th) <= -0.005) tmp = abs((sin(ky) * t_1)); elseif (sin(th) <= 5e-7) tmp = sin(ky) * (th / hypot(sin(ky), sin(kx))); elseif ((sin(th) <= 0.4) || ~((sin(th) <= 0.72))) tmp = sin(ky) * abs(t_1); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Sin[th], $MachinePrecision], -0.005], N[Abs[N[(N[Sin[ky], $MachinePrecision] * t$95$1), $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[th], $MachinePrecision], 5e-7], N[(N[Sin[ky], $MachinePrecision] * N[(th / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[N[Sin[th], $MachinePrecision], 0.4], N[Not[LessEqual[N[Sin[th], $MachinePrecision], 0.72]], $MachinePrecision]], N[(N[Sin[ky], $MachinePrecision] * N[Abs[t$95$1], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\sin th}{\sin kx}\\
\mathbf{if}\;\sin th \leq -0.005:\\
\;\;\;\;\left|\sin ky \cdot t_1\right|\\
\mathbf{elif}\;\sin th \leq 5 \cdot 10^{-7}:\\
\;\;\;\;\sin ky \cdot \frac{th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\
\mathbf{elif}\;\sin th \leq 0.4 \lor \neg \left(\sin th \leq 0.72\right):\\
\;\;\;\;\sin ky \cdot \left|t_1\right|\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 th) < -0.0050000000000000001Initial program 94.5%
associate-*l/94.5%
associate-*r/94.4%
+-commutative94.4%
unpow294.4%
unpow294.4%
hypot-def99.5%
Simplified99.5%
Taylor expanded in ky around 0 23.7%
add-sqr-sqrt16.0%
sqrt-unprod19.9%
pow219.9%
Applied egg-rr19.9%
unpow219.9%
rem-sqrt-square29.6%
Simplified29.6%
if -0.0050000000000000001 < (sin.f64 th) < 4.99999999999999977e-7Initial program 92.5%
associate-*l/87.7%
+-commutative87.7%
unpow287.7%
unpow287.7%
hypot-def90.2%
Simplified90.2%
Taylor expanded in th around 0 90.1%
expm1-log1p-u90.1%
expm1-udef17.9%
div-inv17.9%
*-commutative17.9%
associate-*l*17.9%
div-inv17.9%
Applied egg-rr17.9%
expm1-def99.7%
expm1-log1p99.7%
*-commutative99.7%
associate-*l/90.1%
associate-*r/99.6%
Simplified99.6%
if 4.99999999999999977e-7 < (sin.f64 th) < 0.40000000000000002 or 0.71999999999999997 < (sin.f64 th) Initial program 91.7%
associate-*l/91.7%
associate-*r/91.6%
+-commutative91.6%
unpow291.6%
unpow291.6%
hypot-def99.4%
Simplified99.4%
Taylor expanded in ky around 0 35.6%
add-sqr-sqrt34.8%
sqrt-unprod45.9%
pow245.9%
Applied egg-rr45.9%
unpow245.9%
rem-sqrt-square48.3%
Simplified48.3%
if 0.40000000000000002 < (sin.f64 th) < 0.71999999999999997Initial program 80.6%
+-commutative80.6%
unpow280.6%
unpow280.6%
hypot-def100.0%
Simplified100.0%
Taylor expanded in kx around 0 50.9%
Final simplification71.3%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (/ (sin th) (sin kx))))
(if (<= (sin th) -0.005)
(fabs (* (sin ky) t_1))
(if (<= (sin th) 5e-7)
(* (/ (sin ky) (hypot (sin ky) (sin kx))) th)
(if (or (<= (sin th) 0.4) (not (<= (sin th) 0.72)))
(* (sin ky) (fabs t_1))
(sin th))))))
double code(double kx, double ky, double th) {
double t_1 = sin(th) / sin(kx);
double tmp;
if (sin(th) <= -0.005) {
tmp = fabs((sin(ky) * t_1));
} else if (sin(th) <= 5e-7) {
tmp = (sin(ky) / hypot(sin(ky), sin(kx))) * th;
} else if ((sin(th) <= 0.4) || !(sin(th) <= 0.72)) {
tmp = sin(ky) * fabs(t_1);
} else {
tmp = sin(th);
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = Math.sin(th) / Math.sin(kx);
double tmp;
if (Math.sin(th) <= -0.005) {
tmp = Math.abs((Math.sin(ky) * t_1));
} else if (Math.sin(th) <= 5e-7) {
tmp = (Math.sin(ky) / Math.hypot(Math.sin(ky), Math.sin(kx))) * th;
} else if ((Math.sin(th) <= 0.4) || !(Math.sin(th) <= 0.72)) {
tmp = Math.sin(ky) * Math.abs(t_1);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): t_1 = math.sin(th) / math.sin(kx) tmp = 0 if math.sin(th) <= -0.005: tmp = math.fabs((math.sin(ky) * t_1)) elif math.sin(th) <= 5e-7: tmp = (math.sin(ky) / math.hypot(math.sin(ky), math.sin(kx))) * th elif (math.sin(th) <= 0.4) or not (math.sin(th) <= 0.72): tmp = math.sin(ky) * math.fabs(t_1) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) t_1 = Float64(sin(th) / sin(kx)) tmp = 0.0 if (sin(th) <= -0.005) tmp = abs(Float64(sin(ky) * t_1)); elseif (sin(th) <= 5e-7) tmp = Float64(Float64(sin(ky) / hypot(sin(ky), sin(kx))) * th); elseif ((sin(th) <= 0.4) || !(sin(th) <= 0.72)) tmp = Float64(sin(ky) * abs(t_1)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = sin(th) / sin(kx); tmp = 0.0; if (sin(th) <= -0.005) tmp = abs((sin(ky) * t_1)); elseif (sin(th) <= 5e-7) tmp = (sin(ky) / hypot(sin(ky), sin(kx))) * th; elseif ((sin(th) <= 0.4) || ~((sin(th) <= 0.72))) tmp = sin(ky) * abs(t_1); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Sin[th], $MachinePrecision], -0.005], N[Abs[N[(N[Sin[ky], $MachinePrecision] * t$95$1), $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[th], $MachinePrecision], 5e-7], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * th), $MachinePrecision], If[Or[LessEqual[N[Sin[th], $MachinePrecision], 0.4], N[Not[LessEqual[N[Sin[th], $MachinePrecision], 0.72]], $MachinePrecision]], N[(N[Sin[ky], $MachinePrecision] * N[Abs[t$95$1], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\sin th}{\sin kx}\\
\mathbf{if}\;\sin th \leq -0.005:\\
\;\;\;\;\left|\sin ky \cdot t_1\right|\\
\mathbf{elif}\;\sin th \leq 5 \cdot 10^{-7}:\\
\;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot th\\
\mathbf{elif}\;\sin th \leq 0.4 \lor \neg \left(\sin th \leq 0.72\right):\\
\;\;\;\;\sin ky \cdot \left|t_1\right|\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 th) < -0.0050000000000000001Initial program 94.5%
associate-*l/94.5%
associate-*r/94.4%
+-commutative94.4%
unpow294.4%
unpow294.4%
hypot-def99.5%
Simplified99.5%
Taylor expanded in ky around 0 23.7%
add-sqr-sqrt16.0%
sqrt-unprod19.9%
pow219.9%
Applied egg-rr19.9%
unpow219.9%
rem-sqrt-square29.6%
Simplified29.6%
if -0.0050000000000000001 < (sin.f64 th) < 4.99999999999999977e-7Initial program 92.5%
associate-*l/87.7%
+-commutative87.7%
unpow287.7%
unpow287.7%
hypot-def90.2%
Simplified90.2%
Taylor expanded in th around 0 90.1%
associate-/l*99.5%
associate-/r/99.7%
Applied egg-rr99.7%
if 4.99999999999999977e-7 < (sin.f64 th) < 0.40000000000000002 or 0.71999999999999997 < (sin.f64 th) Initial program 91.7%
associate-*l/91.7%
associate-*r/91.6%
+-commutative91.6%
unpow291.6%
unpow291.6%
hypot-def99.4%
Simplified99.4%
Taylor expanded in ky around 0 35.6%
add-sqr-sqrt34.8%
sqrt-unprod45.9%
pow245.9%
Applied egg-rr45.9%
unpow245.9%
rem-sqrt-square48.3%
Simplified48.3%
if 0.40000000000000002 < (sin.f64 th) < 0.71999999999999997Initial program 80.6%
+-commutative80.6%
unpow280.6%
unpow280.6%
hypot-def100.0%
Simplified100.0%
Taylor expanded in kx around 0 50.9%
Final simplification71.4%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -0.045)
(* (/ (sin ky) (hypot (sin ky) (sin kx))) th)
(if (<= (sin ky) 1e-8)
(/ (sin ky) (/ (hypot ky (sin kx)) (sin th)))
(sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.045) {
tmp = (sin(ky) / hypot(sin(ky), sin(kx))) * th;
} else if (sin(ky) <= 1e-8) {
tmp = sin(ky) / (hypot(ky, sin(kx)) / sin(th));
} else {
tmp = sin(th);
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -0.045) {
tmp = (Math.sin(ky) / Math.hypot(Math.sin(ky), Math.sin(kx))) * th;
} else if (Math.sin(ky) <= 1e-8) {
tmp = Math.sin(ky) / (Math.hypot(ky, Math.sin(kx)) / Math.sin(th));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.045: tmp = (math.sin(ky) / math.hypot(math.sin(ky), math.sin(kx))) * th elif math.sin(ky) <= 1e-8: tmp = math.sin(ky) / (math.hypot(ky, math.sin(kx)) / math.sin(th)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.045) tmp = Float64(Float64(sin(ky) / hypot(sin(ky), sin(kx))) * th); elseif (sin(ky) <= 1e-8) tmp = Float64(sin(ky) / Float64(hypot(ky, sin(kx)) / sin(th))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.045) tmp = (sin(ky) / hypot(sin(ky), sin(kx))) * th; elseif (sin(ky) <= 1e-8) tmp = sin(ky) / (hypot(ky, sin(kx)) / sin(th)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.045], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * th), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-8], N[(N[Sin[ky], $MachinePrecision] / N[(N[Sqrt[ky ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision] / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.045:\\
\;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot th\\
\mathbf{elif}\;\sin ky \leq 10^{-8}:\\
\;\;\;\;\frac{\sin ky}{\frac{\mathsf{hypot}\left(ky, \sin kx\right)}{\sin th}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.044999999999999998Initial program 99.7%
associate-*l/99.5%
+-commutative99.5%
unpow299.5%
unpow299.5%
hypot-def99.6%
Simplified99.6%
Taylor expanded in th around 0 56.0%
associate-/l*56.0%
associate-/r/56.1%
Applied egg-rr56.1%
if -0.044999999999999998 < (sin.f64 ky) < 1e-8Initial program 84.6%
Taylor expanded in ky around 0 82.8%
unpow282.8%
Simplified82.8%
associate-*l/77.9%
associate-/l*82.8%
+-commutative82.8%
unpow282.8%
hypot-def97.8%
Applied egg-rr97.8%
if 1e-8 < (sin.f64 ky) Initial program 99.8%
+-commutative99.8%
unpow299.8%
unpow299.8%
hypot-def99.8%
Simplified99.8%
Taylor expanded in kx around 0 67.8%
Final simplification80.2%
(FPCore (kx ky th) :precision binary64 (if (<= (sin kx) -0.005) (fabs (* (sin ky) (/ (sin th) (sin kx)))) (if (<= (sin kx) 5e-107) (sin th) (* (sin th) (/ (sin ky) (sin kx))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(kx) <= -0.005) {
tmp = fabs((sin(ky) * (sin(th) / sin(kx))));
} else if (sin(kx) <= 5e-107) {
tmp = sin(th);
} else {
tmp = sin(th) * (sin(ky) / 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.005d0)) then
tmp = abs((sin(ky) * (sin(th) / sin(kx))))
else if (sin(kx) <= 5d-107) then
tmp = sin(th)
else
tmp = sin(th) * (sin(ky) / 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.005) {
tmp = Math.abs((Math.sin(ky) * (Math.sin(th) / Math.sin(kx))));
} else if (Math.sin(kx) <= 5e-107) {
tmp = Math.sin(th);
} else {
tmp = Math.sin(th) * (Math.sin(ky) / Math.sin(kx));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(kx) <= -0.005: tmp = math.fabs((math.sin(ky) * (math.sin(th) / math.sin(kx)))) elif math.sin(kx) <= 5e-107: tmp = math.sin(th) else: tmp = math.sin(th) * (math.sin(ky) / math.sin(kx)) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(kx) <= -0.005) tmp = abs(Float64(sin(ky) * Float64(sin(th) / sin(kx)))); elseif (sin(kx) <= 5e-107) tmp = sin(th); else tmp = Float64(sin(th) * Float64(sin(ky) / sin(kx))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(kx) <= -0.005) tmp = abs((sin(ky) * (sin(th) / sin(kx)))); elseif (sin(kx) <= 5e-107) tmp = sin(th); else tmp = sin(th) * (sin(ky) / sin(kx)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[kx], $MachinePrecision], -0.005], N[Abs[N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 5e-107], N[Sin[th], $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin kx \leq -0.005:\\
\;\;\;\;\left|\sin ky \cdot \frac{\sin th}{\sin kx}\right|\\
\mathbf{elif}\;\sin kx \leq 5 \cdot 10^{-107}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.0050000000000000001Initial program 99.5%
associate-*l/99.5%
associate-*r/99.5%
+-commutative99.5%
unpow299.5%
unpow299.5%
hypot-def99.4%
Simplified99.4%
Taylor expanded in ky around 0 18.5%
add-sqr-sqrt17.0%
sqrt-unprod38.4%
pow238.4%
Applied egg-rr38.4%
unpow238.4%
rem-sqrt-square47.2%
Simplified47.2%
if -0.0050000000000000001 < (sin.f64 kx) < 4.99999999999999971e-107Initial program 83.6%
+-commutative83.6%
unpow283.6%
unpow283.6%
hypot-def99.9%
Simplified99.9%
Taylor expanded in kx around 0 48.1%
if 4.99999999999999971e-107 < (sin.f64 kx) Initial program 99.5%
+-commutative99.5%
unpow299.5%
unpow299.5%
hypot-def99.6%
Simplified99.6%
Taylor expanded in ky around 0 56.1%
Final simplification50.8%
(FPCore (kx ky th) :precision binary64 (* (sin ky) (/ (sin th) (hypot (sin ky) (sin kx)))))
double code(double kx, double ky, double th) {
return sin(ky) * (sin(th) / hypot(sin(ky), sin(kx)));
}
public static double code(double kx, double ky, double th) {
return Math.sin(ky) * (Math.sin(th) / Math.hypot(Math.sin(ky), Math.sin(kx)));
}
def code(kx, ky, th): return math.sin(ky) * (math.sin(th) / math.hypot(math.sin(ky), math.sin(kx)))
function code(kx, ky, th) return Float64(sin(ky) * Float64(sin(th) / hypot(sin(ky), sin(kx)))) end
function tmp = code(kx, ky, th) tmp = sin(ky) * (sin(th) / hypot(sin(ky), sin(kx))); end
code[kx_, ky_, th_] := N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}
\end{array}
Initial program 92.1%
associate-*l/89.5%
associate-*r/92.0%
+-commutative92.0%
unpow292.0%
unpow292.0%
hypot-def99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -1e-100) (/ (* (sin ky) (- (sin th))) ky) (if (<= (sin ky) 1e-183) (* (sin th) (/ ky (sin kx))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -1e-100) {
tmp = (sin(ky) * -sin(th)) / ky;
} else if (sin(ky) <= 1e-183) {
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-100)) then
tmp = (sin(ky) * -sin(th)) / ky
else if (sin(ky) <= 1d-183) 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-100) {
tmp = (Math.sin(ky) * -Math.sin(th)) / ky;
} else if (Math.sin(ky) <= 1e-183) {
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-100: tmp = (math.sin(ky) * -math.sin(th)) / ky elif math.sin(ky) <= 1e-183: 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-100) tmp = Float64(Float64(sin(ky) * Float64(-sin(th))) / ky); elseif (sin(ky) <= 1e-183) 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-100) tmp = (sin(ky) * -sin(th)) / ky; elseif (sin(ky) <= 1e-183) 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-100], N[(N[(N[Sin[ky], $MachinePrecision] * (-N[Sin[th], $MachinePrecision])), $MachinePrecision] / ky), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-183], 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^{-100}:\\
\;\;\;\;\frac{\sin ky \cdot \left(-\sin th\right)}{ky}\\
\mathbf{elif}\;\sin ky \leq 10^{-183}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -1e-100Initial program 99.7%
Taylor expanded in ky around 0 29.0%
unpow229.0%
Simplified29.0%
Taylor expanded in ky around -inf 17.2%
mul-1-neg17.2%
*-commutative17.2%
Simplified17.2%
if -1e-100 < (sin.f64 ky) < 1.00000000000000001e-183Initial program 74.9%
+-commutative74.9%
unpow274.9%
unpow274.9%
hypot-def99.7%
Simplified99.7%
Taylor expanded in ky around 0 60.0%
if 1.00000000000000001e-183 < (sin.f64 ky) Initial program 97.0%
+-commutative97.0%
unpow297.0%
unpow297.0%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 60.4%
Final simplification46.3%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -1e-100) (* (sin th) (/ (sin ky) (- ky))) (if (<= (sin ky) 1e-183) (* (sin th) (/ ky (sin kx))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -1e-100) {
tmp = sin(th) * (sin(ky) / -ky);
} else if (sin(ky) <= 1e-183) {
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-100)) then
tmp = sin(th) * (sin(ky) / -ky)
else if (sin(ky) <= 1d-183) 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-100) {
tmp = Math.sin(th) * (Math.sin(ky) / -ky);
} else if (Math.sin(ky) <= 1e-183) {
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-100: tmp = math.sin(th) * (math.sin(ky) / -ky) elif math.sin(ky) <= 1e-183: 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-100) tmp = Float64(sin(th) * Float64(sin(ky) / Float64(-ky))); elseif (sin(ky) <= 1e-183) 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-100) tmp = sin(th) * (sin(ky) / -ky); elseif (sin(ky) <= 1e-183) 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-100], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / (-ky)), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-183], 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^{-100}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{-ky}\\
\mathbf{elif}\;\sin ky \leq 10^{-183}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -1e-100Initial program 99.7%
Taylor expanded in ky around 0 29.0%
unpow229.0%
Simplified29.0%
Taylor expanded in ky around -inf 18.3%
mul-1-neg18.3%
Simplified18.3%
if -1e-100 < (sin.f64 ky) < 1.00000000000000001e-183Initial program 74.9%
+-commutative74.9%
unpow274.9%
unpow274.9%
hypot-def99.7%
Simplified99.7%
Taylor expanded in ky around 0 60.0%
if 1.00000000000000001e-183 < (sin.f64 ky) Initial program 97.0%
+-commutative97.0%
unpow297.0%
unpow297.0%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 60.4%
Final simplification46.6%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) 2e-205) (* (sin ky) (/ (sin th) kx)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= 2e-205) {
tmp = sin(ky) * (sin(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) <= 2d-205) then
tmp = sin(ky) * (sin(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) <= 2e-205) {
tmp = Math.sin(ky) * (Math.sin(th) / kx);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= 2e-205: tmp = math.sin(ky) * (math.sin(th) / kx) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= 2e-205) tmp = Float64(sin(ky) * Float64(sin(th) / kx)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= 2e-205) tmp = sin(ky) * (sin(th) / kx); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-205], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / kx), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq 2 \cdot 10^{-205}:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < 2e-205Initial program 90.1%
associate-*l/87.5%
associate-*r/90.0%
+-commutative90.0%
unpow290.0%
unpow290.0%
hypot-def99.6%
Simplified99.6%
Taylor expanded in ky around 0 32.7%
Taylor expanded in kx around 0 19.0%
if 2e-205 < (sin.f64 ky) Initial program 94.6%
+-commutative94.6%
unpow294.6%
unpow294.6%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 59.5%
Final simplification36.9%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) 1e-183) (* (sin th) (/ ky (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= 1e-183) {
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-183) 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-183) {
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-183: 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-183) 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-183) 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-183], 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^{-183}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < 1.00000000000000001e-183Initial program 88.6%
+-commutative88.6%
unpow288.6%
unpow288.6%
hypot-def99.7%
Simplified99.7%
Taylor expanded in ky around 0 31.0%
if 1.00000000000000001e-183 < (sin.f64 ky) Initial program 97.0%
+-commutative97.0%
unpow297.0%
unpow297.0%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 60.4%
Final simplification43.2%
(FPCore (kx ky th)
:precision binary64
(if (<= ky -3100.0)
(sin th)
(if (<= ky 2.35e-238)
(* (+ (* kx 0.16666666666666666) (/ 1.0 kx)) (* ky (sin th)))
(sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= -3100.0) {
tmp = sin(th);
} else if (ky <= 2.35e-238) {
tmp = ((kx * 0.16666666666666666) + (1.0 / kx)) * (ky * sin(th));
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (ky <= (-3100.0d0)) then
tmp = sin(th)
else if (ky <= 2.35d-238) then
tmp = ((kx * 0.16666666666666666d0) + (1.0d0 / kx)) * (ky * sin(th))
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= -3100.0) {
tmp = Math.sin(th);
} else if (ky <= 2.35e-238) {
tmp = ((kx * 0.16666666666666666) + (1.0 / kx)) * (ky * Math.sin(th));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= -3100.0: tmp = math.sin(th) elif ky <= 2.35e-238: tmp = ((kx * 0.16666666666666666) + (1.0 / kx)) * (ky * math.sin(th)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= -3100.0) tmp = sin(th); elseif (ky <= 2.35e-238) tmp = Float64(Float64(Float64(kx * 0.16666666666666666) + Float64(1.0 / kx)) * Float64(ky * sin(th))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= -3100.0) tmp = sin(th); elseif (ky <= 2.35e-238) tmp = ((kx * 0.16666666666666666) + (1.0 / kx)) * (ky * sin(th)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, -3100.0], N[Sin[th], $MachinePrecision], If[LessEqual[ky, 2.35e-238], N[(N[(N[(kx * 0.16666666666666666), $MachinePrecision] + N[(1.0 / kx), $MachinePrecision]), $MachinePrecision] * N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq -3100:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;ky \leq 2.35 \cdot 10^{-238}:\\
\;\;\;\;\left(kx \cdot 0.16666666666666666 + \frac{1}{kx}\right) \cdot \left(ky \cdot \sin th\right)\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < -3100 or 2.35000000000000011e-238 < ky Initial program 94.9%
+-commutative94.9%
unpow294.9%
unpow294.9%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 38.7%
if -3100 < ky < 2.35000000000000011e-238Initial program 84.8%
+-commutative84.8%
unpow284.8%
unpow284.8%
hypot-def99.7%
Simplified99.7%
Taylor expanded in ky around 0 51.6%
Taylor expanded in kx around 0 18.9%
Taylor expanded in ky around 0 30.4%
Final simplification36.4%
(FPCore (kx ky th) :precision binary64 (if (<= ky -3100.0) (sin th) (if (<= ky 1.2e-202) (* ky (/ th (sin kx))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= -3100.0) {
tmp = sin(th);
} else if (ky <= 1.2e-202) {
tmp = 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 (ky <= (-3100.0d0)) then
tmp = sin(th)
else if (ky <= 1.2d-202) then
tmp = 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 (ky <= -3100.0) {
tmp = Math.sin(th);
} else if (ky <= 1.2e-202) {
tmp = ky * (th / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= -3100.0: tmp = math.sin(th) elif ky <= 1.2e-202: tmp = ky * (th / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= -3100.0) tmp = sin(th); elseif (ky <= 1.2e-202) tmp = Float64(ky * Float64(th / sin(kx))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= -3100.0) tmp = sin(th); elseif (ky <= 1.2e-202) tmp = ky * (th / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, -3100.0], N[Sin[th], $MachinePrecision], If[LessEqual[ky, 1.2e-202], N[(ky * N[(th / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq -3100:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;ky \leq 1.2 \cdot 10^{-202}:\\
\;\;\;\;ky \cdot \frac{th}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < -3100 or 1.2e-202 < ky Initial program 96.4%
+-commutative96.4%
unpow296.4%
unpow296.4%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 39.3%
if -3100 < ky < 1.2e-202Initial program 82.9%
associate-*l/78.4%
+-commutative78.4%
unpow278.4%
unpow278.4%
hypot-def89.5%
Simplified89.5%
Taylor expanded in th around 0 42.1%
Taylor expanded in ky around 0 26.7%
associate-/l*27.6%
Simplified27.6%
Taylor expanded in ky around 0 26.7%
associate-*r/27.6%
Simplified27.6%
Final simplification35.6%
(FPCore (kx ky th) :precision binary64 (if (<= ky -3100.0) (sin th) (if (<= ky 2.7e-203) (* th (/ ky (sin kx))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= -3100.0) {
tmp = sin(th);
} else if (ky <= 2.7e-203) {
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 <= (-3100.0d0)) then
tmp = sin(th)
else if (ky <= 2.7d-203) 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 <= -3100.0) {
tmp = Math.sin(th);
} else if (ky <= 2.7e-203) {
tmp = th * (ky / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= -3100.0: tmp = math.sin(th) elif ky <= 2.7e-203: tmp = th * (ky / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= -3100.0) tmp = sin(th); elseif (ky <= 2.7e-203) 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 <= -3100.0) tmp = sin(th); elseif (ky <= 2.7e-203) tmp = th * (ky / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, -3100.0], N[Sin[th], $MachinePrecision], If[LessEqual[ky, 2.7e-203], N[(th * N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq -3100:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;ky \leq 2.7 \cdot 10^{-203}:\\
\;\;\;\;th \cdot \frac{ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < -3100 or 2.69999999999999999e-203 < ky Initial program 96.4%
+-commutative96.4%
unpow296.4%
unpow296.4%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 39.3%
if -3100 < ky < 2.69999999999999999e-203Initial program 82.9%
associate-*l/78.4%
+-commutative78.4%
unpow278.4%
unpow278.4%
hypot-def89.5%
Simplified89.5%
Taylor expanded in th around 0 42.1%
Taylor expanded in ky around 0 26.7%
associate-/l*27.6%
Simplified27.6%
associate-/r/27.7%
Applied egg-rr27.7%
Final simplification35.6%
(FPCore (kx ky th) :precision binary64 (if (<= ky -3100.0) (sin th) (if (<= ky 1.25e-202) (* th (/ ky kx)) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= -3100.0) {
tmp = sin(th);
} else if (ky <= 1.25e-202) {
tmp = th * (ky / kx);
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (ky <= (-3100.0d0)) then
tmp = sin(th)
else if (ky <= 1.25d-202) then
tmp = th * (ky / kx)
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= -3100.0) {
tmp = Math.sin(th);
} else if (ky <= 1.25e-202) {
tmp = th * (ky / kx);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= -3100.0: tmp = math.sin(th) elif ky <= 1.25e-202: tmp = th * (ky / kx) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= -3100.0) tmp = sin(th); elseif (ky <= 1.25e-202) tmp = Float64(th * Float64(ky / kx)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= -3100.0) tmp = sin(th); elseif (ky <= 1.25e-202) tmp = th * (ky / kx); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, -3100.0], N[Sin[th], $MachinePrecision], If[LessEqual[ky, 1.25e-202], N[(th * N[(ky / kx), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq -3100:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;ky \leq 1.25 \cdot 10^{-202}:\\
\;\;\;\;th \cdot \frac{ky}{kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < -3100 or 1.24999999999999993e-202 < ky Initial program 96.4%
+-commutative96.4%
unpow296.4%
unpow296.4%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 39.3%
if -3100 < ky < 1.24999999999999993e-202Initial program 82.9%
associate-*l/78.4%
+-commutative78.4%
unpow278.4%
unpow278.4%
hypot-def89.5%
Simplified89.5%
Taylor expanded in th around 0 42.1%
Taylor expanded in ky around 0 26.7%
associate-/l*27.6%
Simplified27.6%
Taylor expanded in kx around 0 21.7%
*-commutative21.7%
associate-/l*22.6%
Simplified22.6%
associate-/r/22.6%
Applied egg-rr22.6%
Final simplification34.0%
(FPCore (kx ky th) :precision binary64 (if (<= kx 8.1e-116) th (* th (/ ky kx))))
double code(double kx, double ky, double th) {
double tmp;
if (kx <= 8.1e-116) {
tmp = th;
} else {
tmp = th * (ky / kx);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (kx <= 8.1d-116) then
tmp = th
else
tmp = th * (ky / kx)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (kx <= 8.1e-116) {
tmp = th;
} else {
tmp = th * (ky / kx);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if kx <= 8.1e-116: tmp = th else: tmp = th * (ky / kx) return tmp
function code(kx, ky, th) tmp = 0.0 if (kx <= 8.1e-116) tmp = th; else tmp = Float64(th * Float64(ky / kx)); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (kx <= 8.1e-116) tmp = th; else tmp = th * (ky / kx); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[kx, 8.1e-116], th, N[(th * N[(ky / kx), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;kx \leq 8.1 \cdot 10^{-116}:\\
\;\;\;\;th\\
\mathbf{else}:\\
\;\;\;\;th \cdot \frac{ky}{kx}\\
\end{array}
\end{array}
if kx < 8.1e-116Initial program 88.9%
associate-*l/86.6%
+-commutative86.6%
unpow286.6%
unpow286.6%
hypot-def94.0%
Simplified94.0%
Taylor expanded in th around 0 47.1%
Taylor expanded in kx around 0 20.3%
if 8.1e-116 < kx Initial program 99.6%
associate-*l/96.2%
+-commutative96.2%
unpow296.2%
unpow296.2%
hypot-def96.3%
Simplified96.3%
Taylor expanded in th around 0 54.3%
Taylor expanded in ky around 0 22.6%
associate-/l*26.0%
Simplified26.0%
Taylor expanded in kx around 0 17.2%
*-commutative17.2%
associate-/l*20.5%
Simplified20.5%
associate-/r/20.6%
Applied egg-rr20.6%
Final simplification20.4%
(FPCore (kx ky th) :precision binary64 th)
double code(double kx, double ky, double th) {
return th;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = th
end function
public static double code(double kx, double ky, double th) {
return th;
}
def code(kx, ky, th): return th
function code(kx, ky, th) return th end
function tmp = code(kx, ky, th) tmp = th; end
code[kx_, ky_, th_] := th
\begin{array}{l}
\\
th
\end{array}
Initial program 92.1%
associate-*l/89.5%
+-commutative89.5%
unpow289.5%
unpow289.5%
hypot-def94.7%
Simplified94.7%
Taylor expanded in th around 0 49.2%
Taylor expanded in kx around 0 16.8%
Final simplification16.8%
herbie shell --seed 2023240
(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)))