
(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 15 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 94.2%
+-commutative94.2%
unpow294.2%
unpow294.2%
hypot-def99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (hypot (sin ky) (sin kx))) (t_2 (* (sin ky) (/ th t_1))))
(if (<= (sin ky) -0.018)
t_2
(if (<= (sin ky) 1e-9)
(* (sin th) (/ ky t_1))
(if (<= (sin ky) 0.8425) (sin th) t_2)))))
double code(double kx, double ky, double th) {
double t_1 = hypot(sin(ky), sin(kx));
double t_2 = sin(ky) * (th / t_1);
double tmp;
if (sin(ky) <= -0.018) {
tmp = t_2;
} else if (sin(ky) <= 1e-9) {
tmp = sin(th) * (ky / t_1);
} else if (sin(ky) <= 0.8425) {
tmp = sin(th);
} else {
tmp = t_2;
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = Math.hypot(Math.sin(ky), Math.sin(kx));
double t_2 = Math.sin(ky) * (th / t_1);
double tmp;
if (Math.sin(ky) <= -0.018) {
tmp = t_2;
} else if (Math.sin(ky) <= 1e-9) {
tmp = Math.sin(th) * (ky / t_1);
} else if (Math.sin(ky) <= 0.8425) {
tmp = Math.sin(th);
} else {
tmp = t_2;
}
return tmp;
}
def code(kx, ky, th): t_1 = math.hypot(math.sin(ky), math.sin(kx)) t_2 = math.sin(ky) * (th / t_1) tmp = 0 if math.sin(ky) <= -0.018: tmp = t_2 elif math.sin(ky) <= 1e-9: tmp = math.sin(th) * (ky / t_1) elif math.sin(ky) <= 0.8425: tmp = math.sin(th) else: tmp = t_2 return tmp
function code(kx, ky, th) t_1 = hypot(sin(ky), sin(kx)) t_2 = Float64(sin(ky) * Float64(th / t_1)) tmp = 0.0 if (sin(ky) <= -0.018) tmp = t_2; elseif (sin(ky) <= 1e-9) tmp = Float64(sin(th) * Float64(ky / t_1)); elseif (sin(ky) <= 0.8425) tmp = sin(th); else tmp = t_2; end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = hypot(sin(ky), sin(kx)); t_2 = sin(ky) * (th / t_1); tmp = 0.0; if (sin(ky) <= -0.018) tmp = t_2; elseif (sin(ky) <= 1e-9) tmp = sin(th) * (ky / t_1); elseif (sin(ky) <= 0.8425) tmp = sin(th); else tmp = t_2; 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]}, Block[{t$95$2 = N[(N[Sin[ky], $MachinePrecision] * N[(th / t$95$1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Sin[ky], $MachinePrecision], -0.018], t$95$2, If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-9], N[(N[Sin[th], $MachinePrecision] * N[(ky / t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 0.8425], N[Sin[th], $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{hypot}\left(\sin ky, \sin kx\right)\\
t_2 := \sin ky \cdot \frac{th}{t_1}\\
\mathbf{if}\;\sin ky \leq -0.018:\\
\;\;\;\;t_2\\
\mathbf{elif}\;\sin ky \leq 10^{-9}:\\
\;\;\;\;\sin th \cdot \frac{ky}{t_1}\\
\mathbf{elif}\;\sin ky \leq 0.8425:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.0179999999999999986 or 0.84250000000000003 < (sin.f64 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 th around 0 62.3%
associate-*r/62.4%
+-commutative62.4%
unpow262.4%
unpow262.4%
hypot-def62.4%
*-rgt-identity62.4%
hypot-def62.4%
unpow262.4%
unpow262.4%
+-commutative62.4%
unpow262.4%
unpow262.4%
hypot-def62.4%
Simplified62.4%
clear-num62.4%
associate-/r/62.2%
clear-num62.3%
Applied egg-rr62.3%
if -0.0179999999999999986 < (sin.f64 ky) < 1.00000000000000006e-9Initial program 89.4%
associate-*l/85.7%
+-commutative85.7%
unpow285.7%
unpow285.7%
hypot-def93.3%
Simplified93.3%
Taylor expanded in ky around 0 92.4%
expm1-log1p-u92.4%
expm1-udef38.8%
associate-/l*38.8%
hypot-udef32.4%
+-commutative32.4%
hypot-udef38.8%
Applied egg-rr38.8%
expm1-def98.7%
expm1-log1p98.7%
associate-/r/98.7%
associate-*l/92.4%
associate-*r/98.8%
hypot-def88.5%
unpow288.5%
unpow288.5%
+-commutative88.5%
unpow288.5%
unpow288.5%
hypot-def98.8%
Simplified98.8%
if 1.00000000000000006e-9 < (sin.f64 ky) < 0.84250000000000003Initial program 99.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.8%
Simplified99.8%
Taylor expanded in kx around 0 66.5%
Final simplification82.4%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (hypot (sin ky) (sin kx))) (t_2 (* (/ (sin ky) t_1) th)))
(if (<= (sin ky) -0.018)
t_2
(if (<= (sin ky) 1e-9)
(* (sin th) (/ ky t_1))
(if (<= (sin ky) 0.8425) (sin th) t_2)))))
double code(double kx, double ky, double th) {
double t_1 = hypot(sin(ky), sin(kx));
double t_2 = (sin(ky) / t_1) * th;
double tmp;
if (sin(ky) <= -0.018) {
tmp = t_2;
} else if (sin(ky) <= 1e-9) {
tmp = sin(th) * (ky / t_1);
} else if (sin(ky) <= 0.8425) {
tmp = sin(th);
} else {
tmp = t_2;
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = Math.hypot(Math.sin(ky), Math.sin(kx));
double t_2 = (Math.sin(ky) / t_1) * th;
double tmp;
if (Math.sin(ky) <= -0.018) {
tmp = t_2;
} else if (Math.sin(ky) <= 1e-9) {
tmp = Math.sin(th) * (ky / t_1);
} else if (Math.sin(ky) <= 0.8425) {
tmp = Math.sin(th);
} else {
tmp = t_2;
}
return tmp;
}
def code(kx, ky, th): t_1 = math.hypot(math.sin(ky), math.sin(kx)) t_2 = (math.sin(ky) / t_1) * th tmp = 0 if math.sin(ky) <= -0.018: tmp = t_2 elif math.sin(ky) <= 1e-9: tmp = math.sin(th) * (ky / t_1) elif math.sin(ky) <= 0.8425: tmp = math.sin(th) else: tmp = t_2 return tmp
function code(kx, ky, th) t_1 = hypot(sin(ky), sin(kx)) t_2 = Float64(Float64(sin(ky) / t_1) * th) tmp = 0.0 if (sin(ky) <= -0.018) tmp = t_2; elseif (sin(ky) <= 1e-9) tmp = Float64(sin(th) * Float64(ky / t_1)); elseif (sin(ky) <= 0.8425) tmp = sin(th); else tmp = t_2; end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = hypot(sin(ky), sin(kx)); t_2 = (sin(ky) / t_1) * th; tmp = 0.0; if (sin(ky) <= -0.018) tmp = t_2; elseif (sin(ky) <= 1e-9) tmp = sin(th) * (ky / t_1); elseif (sin(ky) <= 0.8425) tmp = sin(th); else tmp = t_2; 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]}, Block[{t$95$2 = N[(N[(N[Sin[ky], $MachinePrecision] / t$95$1), $MachinePrecision] * th), $MachinePrecision]}, If[LessEqual[N[Sin[ky], $MachinePrecision], -0.018], t$95$2, If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-9], N[(N[Sin[th], $MachinePrecision] * N[(ky / t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 0.8425], N[Sin[th], $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{hypot}\left(\sin ky, \sin kx\right)\\
t_2 := \frac{\sin ky}{t_1} \cdot th\\
\mathbf{if}\;\sin ky \leq -0.018:\\
\;\;\;\;t_2\\
\mathbf{elif}\;\sin ky \leq 10^{-9}:\\
\;\;\;\;\sin th \cdot \frac{ky}{t_1}\\
\mathbf{elif}\;\sin ky \leq 0.8425:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.0179999999999999986 or 0.84250000000000003 < (sin.f64 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 th around 0 62.3%
associate-*r/62.4%
+-commutative62.4%
unpow262.4%
unpow262.4%
hypot-def62.4%
*-rgt-identity62.4%
hypot-def62.4%
unpow262.4%
unpow262.4%
+-commutative62.4%
unpow262.4%
unpow262.4%
hypot-def62.4%
Simplified62.4%
associate-/r/62.5%
Applied egg-rr62.5%
if -0.0179999999999999986 < (sin.f64 ky) < 1.00000000000000006e-9Initial program 89.4%
associate-*l/85.7%
+-commutative85.7%
unpow285.7%
unpow285.7%
hypot-def93.3%
Simplified93.3%
Taylor expanded in ky around 0 92.4%
expm1-log1p-u92.4%
expm1-udef38.8%
associate-/l*38.8%
hypot-udef32.4%
+-commutative32.4%
hypot-udef38.8%
Applied egg-rr38.8%
expm1-def98.7%
expm1-log1p98.7%
associate-/r/98.7%
associate-*l/92.4%
associate-*r/98.8%
hypot-def88.5%
unpow288.5%
unpow288.5%
+-commutative88.5%
unpow288.5%
unpow288.5%
hypot-def98.8%
Simplified98.8%
if 1.00000000000000006e-9 < (sin.f64 ky) < 0.84250000000000003Initial program 99.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.8%
Simplified99.8%
Taylor expanded in kx around 0 66.5%
Final simplification82.4%
(FPCore (kx ky th)
:precision binary64
(if (or (<= (sin th) -5e-5) (not (<= (sin th) 0.005)))
(/
(sin th)
(* (hypot (sin kx) (sin ky)) (+ (* ky 0.16666666666666666) (/ 1.0 ky))))
(* (/ (sin ky) (hypot (sin ky) (sin kx))) th)))
double code(double kx, double ky, double th) {
double tmp;
if ((sin(th) <= -5e-5) || !(sin(th) <= 0.005)) {
tmp = sin(th) / (hypot(sin(kx), sin(ky)) * ((ky * 0.16666666666666666) + (1.0 / ky)));
} else {
tmp = (sin(ky) / hypot(sin(ky), sin(kx))) * th;
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if ((Math.sin(th) <= -5e-5) || !(Math.sin(th) <= 0.005)) {
tmp = Math.sin(th) / (Math.hypot(Math.sin(kx), Math.sin(ky)) * ((ky * 0.16666666666666666) + (1.0 / ky)));
} else {
tmp = (Math.sin(ky) / Math.hypot(Math.sin(ky), Math.sin(kx))) * th;
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if (math.sin(th) <= -5e-5) or not (math.sin(th) <= 0.005): tmp = math.sin(th) / (math.hypot(math.sin(kx), math.sin(ky)) * ((ky * 0.16666666666666666) + (1.0 / ky))) else: tmp = (math.sin(ky) / math.hypot(math.sin(ky), math.sin(kx))) * th return tmp
function code(kx, ky, th) tmp = 0.0 if ((sin(th) <= -5e-5) || !(sin(th) <= 0.005)) tmp = Float64(sin(th) / Float64(hypot(sin(kx), sin(ky)) * Float64(Float64(ky * 0.16666666666666666) + Float64(1.0 / ky)))); else tmp = Float64(Float64(sin(ky) / hypot(sin(ky), sin(kx))) * th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if ((sin(th) <= -5e-5) || ~((sin(th) <= 0.005))) tmp = sin(th) / (hypot(sin(kx), sin(ky)) * ((ky * 0.16666666666666666) + (1.0 / ky))); else tmp = (sin(ky) / hypot(sin(ky), sin(kx))) * th; end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[Or[LessEqual[N[Sin[th], $MachinePrecision], -5e-5], N[Not[LessEqual[N[Sin[th], $MachinePrecision], 0.005]], $MachinePrecision]], N[(N[Sin[th], $MachinePrecision] / N[(N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision] * N[(N[(ky * 0.16666666666666666), $MachinePrecision] + N[(1.0 / ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * th), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin th \leq -5 \cdot 10^{-5} \lor \neg \left(\sin th \leq 0.005\right):\\
\;\;\;\;\frac{\sin th}{\mathsf{hypot}\left(\sin kx, \sin ky\right) \cdot \left(ky \cdot 0.16666666666666666 + \frac{1}{ky}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot th\\
\end{array}
\end{array}
if (sin.f64 th) < -5.00000000000000024e-5 or 0.0050000000000000001 < (sin.f64 th) Initial program 92.3%
+-commutative92.3%
unpow292.3%
unpow292.3%
hypot-def99.7%
Simplified99.7%
*-commutative99.7%
clear-num99.6%
un-div-inv99.5%
hypot-udef92.2%
unpow292.2%
unpow292.2%
+-commutative92.2%
unpow292.2%
unpow292.2%
hypot-def99.5%
Applied egg-rr99.5%
div-inv99.5%
Applied egg-rr99.5%
Taylor expanded in ky around 0 60.7%
if -5.00000000000000024e-5 < (sin.f64 th) < 0.0050000000000000001Initial program 95.8%
associate-/r/95.7%
+-commutative95.7%
unpow295.7%
sqr-neg95.7%
sin-neg95.7%
sin-neg95.7%
unpow295.7%
+-commutative95.7%
Simplified99.7%
Taylor expanded in th around 0 94.7%
associate-*r/94.8%
+-commutative94.8%
unpow294.8%
unpow294.8%
hypot-def98.7%
*-rgt-identity98.7%
hypot-def94.8%
unpow294.8%
unpow294.8%
+-commutative94.8%
unpow294.8%
unpow294.8%
hypot-def98.7%
Simplified98.7%
associate-/r/98.9%
Applied egg-rr98.9%
Final simplification81.0%
(FPCore (kx ky th) :precision binary64 (if (<= (sin kx) -0.04) (fabs (* ky (/ (sin th) (sin kx)))) (if (<= (sin kx) 4e-58) (sin th) (* (sin th) (/ (sin ky) (sin kx))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(kx) <= -0.04) {
tmp = fabs((ky * (sin(th) / sin(kx))));
} else if (sin(kx) <= 4e-58) {
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.04d0)) then
tmp = abs((ky * (sin(th) / sin(kx))))
else if (sin(kx) <= 4d-58) 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.04) {
tmp = Math.abs((ky * (Math.sin(th) / Math.sin(kx))));
} else if (Math.sin(kx) <= 4e-58) {
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.04: tmp = math.fabs((ky * (math.sin(th) / math.sin(kx)))) elif math.sin(kx) <= 4e-58: 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.04) tmp = abs(Float64(ky * Float64(sin(th) / sin(kx)))); elseif (sin(kx) <= 4e-58) 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.04) tmp = abs((ky * (sin(th) / sin(kx)))); elseif (sin(kx) <= 4e-58) 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.04], N[Abs[N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 4e-58], 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.04:\\
\;\;\;\;\left|ky \cdot \frac{\sin th}{\sin kx}\right|\\
\mathbf{elif}\;\sin kx \leq 4 \cdot 10^{-58}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.0400000000000000008Initial program 99.4%
Taylor expanded in ky around 0 15.0%
add-sqr-sqrt12.3%
sqrt-unprod22.9%
pow222.9%
div-inv22.8%
associate-*l*22.8%
associate-/r/22.8%
*-un-lft-identity22.8%
associate-*l/22.8%
associate-/r*22.9%
clear-num22.9%
/-rgt-identity22.9%
Applied egg-rr22.9%
associate-*r/22.9%
*-commutative22.9%
unpow222.9%
rem-sqrt-square38.8%
*-commutative38.8%
associate-*r/38.9%
Simplified38.9%
if -0.0400000000000000008 < (sin.f64 kx) < 4.0000000000000001e-58Initial program 87.9%
+-commutative87.9%
unpow287.9%
unpow287.9%
hypot-def99.9%
Simplified99.9%
Taylor expanded in kx around 0 46.9%
if 4.0000000000000001e-58 < (sin.f64 kx) Initial program 99.5%
Taylor expanded in ky around 0 60.0%
Final simplification47.8%
(FPCore (kx ky th) :precision binary64 (if (<= (sin kx) -0.02) (* (sin ky) (/ (- (sin th)) (sin kx))) (if (<= (sin kx) 4e-58) (sin th) (* (sin th) (/ (sin ky) (sin kx))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(kx) <= -0.02) {
tmp = sin(ky) * (-sin(th) / sin(kx));
} else if (sin(kx) <= 4e-58) {
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.02d0)) then
tmp = sin(ky) * (-sin(th) / sin(kx))
else if (sin(kx) <= 4d-58) 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.02) {
tmp = Math.sin(ky) * (-Math.sin(th) / Math.sin(kx));
} else if (Math.sin(kx) <= 4e-58) {
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.02: tmp = math.sin(ky) * (-math.sin(th) / math.sin(kx)) elif math.sin(kx) <= 4e-58: 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.02) tmp = Float64(sin(ky) * Float64(Float64(-sin(th)) / sin(kx))); elseif (sin(kx) <= 4e-58) 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.02) tmp = sin(ky) * (-sin(th) / sin(kx)); elseif (sin(kx) <= 4e-58) 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.02], N[(N[Sin[ky], $MachinePrecision] * N[((-N[Sin[th], $MachinePrecision]) / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 4e-58], 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.02:\\
\;\;\;\;\sin ky \cdot \frac{-\sin th}{\sin kx}\\
\mathbf{elif}\;\sin kx \leq 4 \cdot 10^{-58}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.0200000000000000004Initial program 99.4%
associate-/r/99.4%
+-commutative99.4%
unpow299.4%
sqr-neg99.4%
sin-neg99.4%
sin-neg99.4%
unpow299.4%
+-commutative99.4%
Simplified99.5%
Taylor expanded in ky around 0 14.9%
frac-2neg14.9%
neg-sub014.9%
metadata-eval14.9%
div-sub14.9%
metadata-eval14.9%
distribute-neg-frac14.9%
add-sqr-sqrt5.7%
sqrt-unprod27.3%
sqr-neg27.3%
sqrt-unprod29.6%
add-sqr-sqrt62.0%
frac-2neg62.0%
associate-/r/62.0%
*-commutative62.0%
Applied egg-rr62.0%
div062.0%
neg-sub062.0%
associate-*r/62.1%
associate-*l/62.1%
*-commutative62.1%
distribute-rgt-neg-in62.1%
distribute-frac-neg62.1%
Simplified62.1%
if -0.0200000000000000004 < (sin.f64 kx) < 4.0000000000000001e-58Initial program 87.9%
+-commutative87.9%
unpow287.9%
unpow287.9%
hypot-def99.9%
Simplified99.9%
Taylor expanded in kx around 0 46.9%
if 4.0000000000000001e-58 < (sin.f64 kx) Initial program 99.5%
Taylor expanded in ky around 0 60.0%
Final simplification54.7%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) 1e-9) (* (sin th) (/ ky (hypot (sin ky) (sin kx)))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= 1e-9) {
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-9) {
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-9: 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-9) 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-9) 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-9], 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^{-9}:\\
\;\;\;\;\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) < 1.00000000000000006e-9Initial program 92.4%
associate-*l/89.8%
+-commutative89.8%
unpow289.8%
unpow289.8%
hypot-def95.2%
Simplified95.2%
Taylor expanded in ky around 0 66.0%
expm1-log1p-u65.6%
expm1-udef28.2%
associate-/l*28.2%
hypot-udef23.7%
+-commutative23.7%
hypot-udef28.2%
Applied egg-rr28.2%
expm1-def70.0%
expm1-log1p70.4%
associate-/r/70.4%
associate-*l/66.0%
associate-*r/70.5%
hypot-def63.2%
unpow263.2%
unpow263.2%
+-commutative63.2%
unpow263.2%
unpow263.2%
hypot-def70.5%
Simplified70.5%
if 1.00000000000000006e-9 < (sin.f64 ky) Initial program 99.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.8%
Simplified99.8%
Taylor expanded in kx around 0 59.3%
Final simplification67.7%
(FPCore (kx ky th) :precision binary64 (if (<= (sin kx) -0.04) (fabs (* ky (/ (sin th) (sin kx)))) (if (<= (sin kx) 1e-43) (sin th) (/ (sin th) (/ (sin kx) ky)))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(kx) <= -0.04) {
tmp = fabs((ky * (sin(th) / sin(kx))));
} else if (sin(kx) <= 1e-43) {
tmp = sin(th);
} else {
tmp = sin(th) / (sin(kx) / 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(kx) <= (-0.04d0)) then
tmp = abs((ky * (sin(th) / sin(kx))))
else if (sin(kx) <= 1d-43) then
tmp = sin(th)
else
tmp = sin(th) / (sin(kx) / ky)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(kx) <= -0.04) {
tmp = Math.abs((ky * (Math.sin(th) / Math.sin(kx))));
} else if (Math.sin(kx) <= 1e-43) {
tmp = Math.sin(th);
} else {
tmp = Math.sin(th) / (Math.sin(kx) / ky);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(kx) <= -0.04: tmp = math.fabs((ky * (math.sin(th) / math.sin(kx)))) elif math.sin(kx) <= 1e-43: tmp = math.sin(th) else: tmp = math.sin(th) / (math.sin(kx) / ky) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(kx) <= -0.04) tmp = abs(Float64(ky * Float64(sin(th) / sin(kx)))); elseif (sin(kx) <= 1e-43) tmp = sin(th); else tmp = Float64(sin(th) / Float64(sin(kx) / ky)); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(kx) <= -0.04) tmp = abs((ky * (sin(th) / sin(kx)))); elseif (sin(kx) <= 1e-43) tmp = sin(th); else tmp = sin(th) / (sin(kx) / ky); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[kx], $MachinePrecision], -0.04], N[Abs[N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 1e-43], N[Sin[th], $MachinePrecision], N[(N[Sin[th], $MachinePrecision] / N[(N[Sin[kx], $MachinePrecision] / ky), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin kx \leq -0.04:\\
\;\;\;\;\left|ky \cdot \frac{\sin th}{\sin kx}\right|\\
\mathbf{elif}\;\sin kx \leq 10^{-43}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin th}{\frac{\sin kx}{ky}}\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.0400000000000000008Initial program 99.4%
Taylor expanded in ky around 0 15.0%
add-sqr-sqrt12.3%
sqrt-unprod22.9%
pow222.9%
div-inv22.8%
associate-*l*22.8%
associate-/r/22.8%
*-un-lft-identity22.8%
associate-*l/22.8%
associate-/r*22.9%
clear-num22.9%
/-rgt-identity22.9%
Applied egg-rr22.9%
associate-*r/22.9%
*-commutative22.9%
unpow222.9%
rem-sqrt-square38.8%
*-commutative38.8%
associate-*r/38.9%
Simplified38.9%
if -0.0400000000000000008 < (sin.f64 kx) < 1.00000000000000008e-43Initial program 88.2%
+-commutative88.2%
unpow288.2%
unpow288.2%
hypot-def99.9%
Simplified99.9%
Taylor expanded in kx around 0 46.7%
if 1.00000000000000008e-43 < (sin.f64 kx) Initial program 99.4%
+-commutative99.4%
unpow299.4%
unpow299.4%
hypot-def99.6%
Simplified99.6%
*-commutative99.6%
clear-num99.4%
un-div-inv99.4%
hypot-udef99.3%
unpow299.3%
unpow299.3%
+-commutative99.3%
unpow299.3%
unpow299.3%
hypot-def99.4%
Applied egg-rr99.4%
Taylor expanded in ky around 0 50.1%
associate-/l*51.5%
Simplified51.5%
Final simplification45.5%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) 4e-94) (* (sin th) (/ ky (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= 4e-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) <= 4d-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) <= 4e-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) <= 4e-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) <= 4e-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) <= 4e-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], 4e-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 4 \cdot 10^{-94}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < 3.9999999999999998e-94Initial program 91.4%
Taylor expanded in ky around 0 29.3%
if 3.9999999999999998e-94 < (sin.f64 ky) Initial program 99.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-def99.8%
Simplified99.8%
Taylor expanded in kx around 0 60.0%
Final simplification39.6%
(FPCore (kx ky th) :precision binary64 (if (<= ky -3.2) (sin th) (if (<= ky 1.36e-84) (* ky (/ (sin th) (sin kx))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= -3.2) {
tmp = sin(th);
} else if (ky <= 1.36e-84) {
tmp = 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 (ky <= (-3.2d0)) then
tmp = sin(th)
else if (ky <= 1.36d-84) then
tmp = 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 (ky <= -3.2) {
tmp = Math.sin(th);
} else if (ky <= 1.36e-84) {
tmp = ky * (Math.sin(th) / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= -3.2: tmp = math.sin(th) elif ky <= 1.36e-84: tmp = ky * (math.sin(th) / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= -3.2) tmp = sin(th); elseif (ky <= 1.36e-84) tmp = Float64(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 (ky <= -3.2) tmp = sin(th); elseif (ky <= 1.36e-84) tmp = ky * (sin(th) / sin(kx)); 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, 1.36e-84], N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq -3.2:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;ky \leq 1.36 \cdot 10^{-84}:\\
\;\;\;\;ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < -3.2000000000000002 or 1.36e-84 < ky Initial program 99.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.8%
Simplified99.8%
Taylor expanded in kx around 0 37.0%
if -3.2000000000000002 < ky < 1.36e-84Initial program 87.1%
+-commutative87.1%
unpow287.1%
unpow287.1%
hypot-def99.7%
Simplified99.7%
*-commutative99.7%
clear-num99.6%
un-div-inv99.6%
hypot-udef87.0%
unpow287.0%
unpow287.0%
+-commutative87.0%
unpow287.0%
unpow287.0%
hypot-def99.6%
Applied egg-rr99.6%
div-inv99.6%
Applied egg-rr99.6%
Taylor expanded in ky around 0 39.4%
*-commutative39.4%
associate-*r/43.0%
Simplified43.0%
Final simplification39.6%
(FPCore (kx ky th) :precision binary64 (if (<= ky -6200000000.0) (sin th) (if (<= ky 7e-107) (* (sin th) (/ ky kx)) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= -6200000000.0) {
tmp = sin(th);
} else if (ky <= 7e-107) {
tmp = sin(th) * (ky / kx);
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (ky <= (-6200000000.0d0)) then
tmp = sin(th)
else if (ky <= 7d-107) then
tmp = sin(th) * (ky / kx)
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= -6200000000.0) {
tmp = Math.sin(th);
} else if (ky <= 7e-107) {
tmp = Math.sin(th) * (ky / kx);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= -6200000000.0: tmp = math.sin(th) elif ky <= 7e-107: tmp = math.sin(th) * (ky / kx) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= -6200000000.0) tmp = sin(th); elseif (ky <= 7e-107) tmp = Float64(sin(th) * Float64(ky / kx)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= -6200000000.0) tmp = sin(th); elseif (ky <= 7e-107) tmp = sin(th) * (ky / kx); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, -6200000000.0], N[Sin[th], $MachinePrecision], If[LessEqual[ky, 7e-107], N[(N[Sin[th], $MachinePrecision] * N[(ky / kx), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq -6200000000:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;ky \leq 7 \cdot 10^{-107}:\\
\;\;\;\;\sin th \cdot \frac{ky}{kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < -6.2e9 or 6.99999999999999971e-107 < ky Initial program 99.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.8%
Simplified99.8%
Taylor expanded in kx around 0 37.5%
if -6.2e9 < ky < 6.99999999999999971e-107Initial program 86.7%
Taylor expanded in ky around 0 42.6%
Taylor expanded in kx around 0 30.6%
Final simplification34.6%
(FPCore (kx ky th) :precision binary64 (if (<= kx 1.15e-43) (sin th) (/ ky (/ (sin kx) th))))
double code(double kx, double ky, double th) {
double tmp;
if (kx <= 1.15e-43) {
tmp = sin(th);
} else {
tmp = ky / (sin(kx) / 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 (kx <= 1.15d-43) then
tmp = sin(th)
else
tmp = ky / (sin(kx) / th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (kx <= 1.15e-43) {
tmp = Math.sin(th);
} else {
tmp = ky / (Math.sin(kx) / th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if kx <= 1.15e-43: tmp = math.sin(th) else: tmp = ky / (math.sin(kx) / th) return tmp
function code(kx, ky, th) tmp = 0.0 if (kx <= 1.15e-43) tmp = sin(th); else tmp = Float64(ky / Float64(sin(kx) / th)); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (kx <= 1.15e-43) tmp = sin(th); else tmp = ky / (sin(kx) / th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[kx, 1.15e-43], N[Sin[th], $MachinePrecision], N[(ky / N[(N[Sin[kx], $MachinePrecision] / th), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;kx \leq 1.15 \cdot 10^{-43}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\frac{ky}{\frac{\sin kx}{th}}\\
\end{array}
\end{array}
if kx < 1.1499999999999999e-43Initial program 91.9%
+-commutative91.9%
unpow291.9%
unpow291.9%
hypot-def99.8%
Simplified99.8%
Taylor expanded in kx around 0 34.0%
if 1.1499999999999999e-43 < kx Initial program 99.4%
associate-*l/98.3%
+-commutative98.3%
unpow298.3%
unpow298.3%
hypot-def98.4%
Simplified98.4%
Taylor expanded in ky around 0 48.2%
Taylor expanded in th around 0 28.6%
Taylor expanded in ky around 0 23.5%
associate-/l*24.7%
Simplified24.7%
Final simplification31.1%
(FPCore (kx ky th) :precision binary64 (if (<= ky -6200000000.0) (sin th) (if (<= ky 3.5e-214) (/ ky (/ kx th)) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= -6200000000.0) {
tmp = sin(th);
} else if (ky <= 3.5e-214) {
tmp = ky / (kx / th);
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (ky <= (-6200000000.0d0)) then
tmp = sin(th)
else if (ky <= 3.5d-214) then
tmp = ky / (kx / th)
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= -6200000000.0) {
tmp = Math.sin(th);
} else if (ky <= 3.5e-214) {
tmp = ky / (kx / th);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= -6200000000.0: tmp = math.sin(th) elif ky <= 3.5e-214: tmp = ky / (kx / th) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= -6200000000.0) tmp = sin(th); elseif (ky <= 3.5e-214) tmp = Float64(ky / Float64(kx / th)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= -6200000000.0) tmp = sin(th); elseif (ky <= 3.5e-214) tmp = ky / (kx / th); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, -6200000000.0], N[Sin[th], $MachinePrecision], If[LessEqual[ky, 3.5e-214], N[(ky / N[(kx / th), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq -6200000000:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;ky \leq 3.5 \cdot 10^{-214}:\\
\;\;\;\;\frac{ky}{\frac{kx}{th}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < -6.2e9 or 3.5e-214 < ky Initial program 97.7%
+-commutative97.7%
unpow297.7%
unpow297.7%
hypot-def99.8%
Simplified99.8%
Taylor expanded in kx around 0 36.0%
if -6.2e9 < ky < 3.5e-214Initial program 87.0%
Taylor expanded in ky around 0 43.9%
Taylor expanded in kx around 0 32.4%
Taylor expanded in th around 0 22.7%
*-commutative22.7%
associate-/l*27.4%
Simplified27.4%
Final simplification33.1%
(FPCore (kx ky th) :precision binary64 (if (<= ky -5.2e-69) th (if (<= ky 8.5e-101) (/ ky (/ kx th)) th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= -5.2e-69) {
tmp = th;
} else if (ky <= 8.5e-101) {
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 <= (-5.2d-69)) then
tmp = th
else if (ky <= 8.5d-101) 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 <= -5.2e-69) {
tmp = th;
} else if (ky <= 8.5e-101) {
tmp = ky / (kx / th);
} else {
tmp = th;
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= -5.2e-69: tmp = th elif ky <= 8.5e-101: tmp = ky / (kx / th) else: tmp = th return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= -5.2e-69) tmp = th; elseif (ky <= 8.5e-101) 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 <= -5.2e-69) tmp = th; elseif (ky <= 8.5e-101) tmp = ky / (kx / th); else tmp = th; end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, -5.2e-69], th, If[LessEqual[ky, 8.5e-101], N[(ky / N[(kx / th), $MachinePrecision]), $MachinePrecision], th]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq -5.2 \cdot 10^{-69}:\\
\;\;\;\;th\\
\mathbf{elif}\;ky \leq 8.5 \cdot 10^{-101}:\\
\;\;\;\;\frac{ky}{\frac{kx}{th}}\\
\mathbf{else}:\\
\;\;\;\;th\\
\end{array}
\end{array}
if ky < -5.2000000000000004e-69 or 8.49999999999999941e-101 < ky Initial program 99.7%
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 th around 0 57.6%
associate-*r/57.8%
+-commutative57.8%
unpow257.8%
unpow257.8%
hypot-def57.8%
*-rgt-identity57.8%
hypot-def57.8%
unpow257.8%
unpow257.8%
+-commutative57.8%
unpow257.8%
unpow257.8%
hypot-def57.8%
Simplified57.8%
Taylor expanded in kx around 0 18.2%
if -5.2000000000000004e-69 < ky < 8.49999999999999941e-101Initial program 85.2%
Taylor expanded in ky around 0 47.2%
Taylor expanded in kx around 0 33.7%
Taylor expanded in th around 0 25.5%
*-commutative25.5%
associate-/l*29.7%
Simplified29.7%
Final simplification22.6%
(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 94.2%
associate-/r/94.1%
+-commutative94.1%
unpow294.1%
sqr-neg94.1%
sin-neg94.1%
sin-neg94.1%
unpow294.1%
+-commutative94.1%
Simplified99.6%
Taylor expanded in th around 0 52.1%
associate-*r/52.1%
+-commutative52.1%
unpow252.1%
unpow252.1%
hypot-def54.5%
*-rgt-identity54.5%
hypot-def52.1%
unpow252.1%
unpow252.1%
+-commutative52.1%
unpow252.1%
unpow252.1%
hypot-def54.5%
Simplified54.5%
Taylor expanded in kx around 0 13.8%
Final simplification13.8%
herbie shell --seed 2023275
(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)))