
(FPCore (l Om kx ky)
:precision binary64
(sqrt
(*
(/ 1.0 2.0)
(+
1.0
(/
1.0
(sqrt
(+
1.0
(*
(pow (/ (* 2.0 l) Om) 2.0)
(+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))))))))))
double code(double l, double Om, double kx, double ky) {
return sqrt(((1.0 / 2.0) * (1.0 + (1.0 / sqrt((1.0 + (pow(((2.0 * l) / Om), 2.0) * (pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))))))));
}
real(8) function code(l, om, kx, ky)
real(8), intent (in) :: l
real(8), intent (in) :: om
real(8), intent (in) :: kx
real(8), intent (in) :: ky
code = sqrt(((1.0d0 / 2.0d0) * (1.0d0 + (1.0d0 / sqrt((1.0d0 + ((((2.0d0 * l) / om) ** 2.0d0) * ((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))))))))
end function
public static double code(double l, double Om, double kx, double ky) {
return Math.sqrt(((1.0 / 2.0) * (1.0 + (1.0 / Math.sqrt((1.0 + (Math.pow(((2.0 * l) / Om), 2.0) * (Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))))))));
}
def code(l, Om, kx, ky): return math.sqrt(((1.0 / 2.0) * (1.0 + (1.0 / math.sqrt((1.0 + (math.pow(((2.0 * l) / Om), 2.0) * (math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))))))))
function code(l, Om, kx, ky) return sqrt(Float64(Float64(1.0 / 2.0) * Float64(1.0 + Float64(1.0 / sqrt(Float64(1.0 + Float64((Float64(Float64(2.0 * l) / Om) ^ 2.0) * Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))))))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt(((1.0 / 2.0) * (1.0 + (1.0 / sqrt((1.0 + ((((2.0 * l) / Om) ^ 2.0) * ((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))))))))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(N[(1.0 / 2.0), $MachinePrecision] * N[(1.0 + N[(1.0 / N[Sqrt[N[(1.0 + N[(N[Power[N[(N[(2.0 * l), $MachinePrecision] / Om), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\frac{1}{2} \cdot \left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (l Om kx ky)
:precision binary64
(sqrt
(*
(/ 1.0 2.0)
(+
1.0
(/
1.0
(sqrt
(+
1.0
(*
(pow (/ (* 2.0 l) Om) 2.0)
(+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))))))))))
double code(double l, double Om, double kx, double ky) {
return sqrt(((1.0 / 2.0) * (1.0 + (1.0 / sqrt((1.0 + (pow(((2.0 * l) / Om), 2.0) * (pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))))))));
}
real(8) function code(l, om, kx, ky)
real(8), intent (in) :: l
real(8), intent (in) :: om
real(8), intent (in) :: kx
real(8), intent (in) :: ky
code = sqrt(((1.0d0 / 2.0d0) * (1.0d0 + (1.0d0 / sqrt((1.0d0 + ((((2.0d0 * l) / om) ** 2.0d0) * ((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))))))))
end function
public static double code(double l, double Om, double kx, double ky) {
return Math.sqrt(((1.0 / 2.0) * (1.0 + (1.0 / Math.sqrt((1.0 + (Math.pow(((2.0 * l) / Om), 2.0) * (Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))))))));
}
def code(l, Om, kx, ky): return math.sqrt(((1.0 / 2.0) * (1.0 + (1.0 / math.sqrt((1.0 + (math.pow(((2.0 * l) / Om), 2.0) * (math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))))))))
function code(l, Om, kx, ky) return sqrt(Float64(Float64(1.0 / 2.0) * Float64(1.0 + Float64(1.0 / sqrt(Float64(1.0 + Float64((Float64(Float64(2.0 * l) / Om) ^ 2.0) * Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))))))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt(((1.0 / 2.0) * (1.0 + (1.0 / sqrt((1.0 + ((((2.0 * l) / Om) ^ 2.0) * ((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))))))))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(N[(1.0 / 2.0), $MachinePrecision] * N[(1.0 + N[(1.0 / N[Sqrt[N[(1.0 + N[(N[Power[N[(N[(2.0 * l), $MachinePrecision] / Om), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\frac{1}{2} \cdot \left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)}
\end{array}
NOTE: kx should be positive before calling this function NOTE: ky should be positive before calling this function NOTE: kx and ky should be sorted in increasing order before calling this function. (FPCore (l Om kx ky) :precision binary64 (sqrt (+ 0.5 (* 0.5 (/ 1.0 (hypot 1.0 (* (sin ky) (/ (* 2.0 l) Om))))))))
kx = abs(kx);
ky = abs(ky);
assert(kx < ky);
double code(double l, double Om, double kx, double ky) {
return sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, (sin(ky) * ((2.0 * l) / Om)))))));
}
kx = Math.abs(kx);
ky = Math.abs(ky);
assert kx < ky;
public static double code(double l, double Om, double kx, double ky) {
return Math.sqrt((0.5 + (0.5 * (1.0 / Math.hypot(1.0, (Math.sin(ky) * ((2.0 * l) / Om)))))));
}
kx = abs(kx) ky = abs(ky) [kx, ky] = sort([kx, ky]) def code(l, Om, kx, ky): return math.sqrt((0.5 + (0.5 * (1.0 / math.hypot(1.0, (math.sin(ky) * ((2.0 * l) / Om)))))))
kx = abs(kx) ky = abs(ky) kx, ky = sort([kx, ky]) function code(l, Om, kx, ky) return sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / hypot(1.0, Float64(sin(ky) * Float64(Float64(2.0 * l) / Om))))))) end
kx = abs(kx)
ky = abs(ky)
kx, ky = num2cell(sort([kx, ky])){:}
function tmp = code(l, Om, kx, ky)
tmp = sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, (sin(ky) * ((2.0 * l) / Om)))))));
end
NOTE: kx should be positive before calling this function NOTE: ky should be positive before calling this function NOTE: kx and ky should be sorted in increasing order before calling this function. code[l_, Om_, kx_, ky_] := N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[Sqrt[1.0 ^ 2 + N[(N[Sin[ky], $MachinePrecision] * N[(N[(2.0 * l), $MachinePrecision] / Om), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
kx = |kx|\\
ky = |ky|\\
[kx, ky] = \mathsf{sort}([kx, ky])\\
\\
\sqrt{0.5 + 0.5 \cdot \frac{1}{\mathsf{hypot}\left(1, \sin ky \cdot \frac{2 \cdot \ell}{Om}\right)}}
\end{array}
Initial program 99.2%
distribute-rgt-in99.2%
metadata-eval99.2%
metadata-eval99.2%
associate-/l*99.2%
metadata-eval99.2%
Simplified99.2%
Taylor expanded in kx around 0 81.2%
associate-/l*81.3%
associate-/r/82.2%
unpow282.2%
unpow282.2%
times-frac90.8%
Simplified90.8%
expm1-log1p-u90.8%
expm1-udef90.8%
Applied egg-rr95.6%
expm1-def95.6%
expm1-log1p95.6%
*-commutative95.6%
*-commutative95.6%
associate-*l*95.6%
associate-*l/95.6%
*-commutative95.6%
Simplified95.6%
Final simplification95.6%
NOTE: kx should be positive before calling this function
NOTE: ky should be positive before calling this function
NOTE: kx and ky should be sorted in increasing order before calling this function.
(FPCore (l Om kx ky)
:precision binary64
(if (<= Om 5e-166)
(sqrt
(+
0.5
(* 0.5 (/ 1.0 (+ (* 2.0 (/ (* ky l) Om)) (* 0.25 (/ Om (* ky l))))))))
(if (<= Om 1e+122)
(sqrt
(+
0.5
(*
0.5
(/ 1.0 (sqrt (+ 1.0 (* 4.0 (/ (* (* ky l) (* ky l)) (* Om Om)))))))))
1.0)))kx = abs(kx);
ky = abs(ky);
assert(kx < ky);
double code(double l, double Om, double kx, double ky) {
double tmp;
if (Om <= 5e-166) {
tmp = sqrt((0.5 + (0.5 * (1.0 / ((2.0 * ((ky * l) / Om)) + (0.25 * (Om / (ky * l))))))));
} else if (Om <= 1e+122) {
tmp = sqrt((0.5 + (0.5 * (1.0 / sqrt((1.0 + (4.0 * (((ky * l) * (ky * l)) / (Om * Om)))))))));
} else {
tmp = 1.0;
}
return tmp;
}
NOTE: kx should be positive before calling this function
NOTE: ky should be positive before calling this function
NOTE: kx and ky should be sorted in increasing order before calling this function.
real(8) function code(l, om, kx, ky)
real(8), intent (in) :: l
real(8), intent (in) :: om
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8) :: tmp
if (om <= 5d-166) then
tmp = sqrt((0.5d0 + (0.5d0 * (1.0d0 / ((2.0d0 * ((ky * l) / om)) + (0.25d0 * (om / (ky * l))))))))
else if (om <= 1d+122) then
tmp = sqrt((0.5d0 + (0.5d0 * (1.0d0 / sqrt((1.0d0 + (4.0d0 * (((ky * l) * (ky * l)) / (om * om)))))))))
else
tmp = 1.0d0
end if
code = tmp
end function
kx = Math.abs(kx);
ky = Math.abs(ky);
assert kx < ky;
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if (Om <= 5e-166) {
tmp = Math.sqrt((0.5 + (0.5 * (1.0 / ((2.0 * ((ky * l) / Om)) + (0.25 * (Om / (ky * l))))))));
} else if (Om <= 1e+122) {
tmp = Math.sqrt((0.5 + (0.5 * (1.0 / Math.sqrt((1.0 + (4.0 * (((ky * l) * (ky * l)) / (Om * Om)))))))));
} else {
tmp = 1.0;
}
return tmp;
}
kx = abs(kx) ky = abs(ky) [kx, ky] = sort([kx, ky]) def code(l, Om, kx, ky): tmp = 0 if Om <= 5e-166: tmp = math.sqrt((0.5 + (0.5 * (1.0 / ((2.0 * ((ky * l) / Om)) + (0.25 * (Om / (ky * l)))))))) elif Om <= 1e+122: tmp = math.sqrt((0.5 + (0.5 * (1.0 / math.sqrt((1.0 + (4.0 * (((ky * l) * (ky * l)) / (Om * Om))))))))) else: tmp = 1.0 return tmp
kx = abs(kx) ky = abs(ky) kx, ky = sort([kx, ky]) function code(l, Om, kx, ky) tmp = 0.0 if (Om <= 5e-166) tmp = sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / Float64(Float64(2.0 * Float64(Float64(ky * l) / Om)) + Float64(0.25 * Float64(Om / Float64(ky * l)))))))); elseif (Om <= 1e+122) tmp = sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / sqrt(Float64(1.0 + Float64(4.0 * Float64(Float64(Float64(ky * l) * Float64(ky * l)) / Float64(Om * Om))))))))); else tmp = 1.0; end return tmp end
kx = abs(kx)
ky = abs(ky)
kx, ky = num2cell(sort([kx, ky])){:}
function tmp_2 = code(l, Om, kx, ky)
tmp = 0.0;
if (Om <= 5e-166)
tmp = sqrt((0.5 + (0.5 * (1.0 / ((2.0 * ((ky * l) / Om)) + (0.25 * (Om / (ky * l))))))));
elseif (Om <= 1e+122)
tmp = sqrt((0.5 + (0.5 * (1.0 / sqrt((1.0 + (4.0 * (((ky * l) * (ky * l)) / (Om * Om)))))))));
else
tmp = 1.0;
end
tmp_2 = tmp;
end
NOTE: kx should be positive before calling this function NOTE: ky should be positive before calling this function NOTE: kx and ky should be sorted in increasing order before calling this function. code[l_, Om_, kx_, ky_] := If[LessEqual[Om, 5e-166], N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[(N[(2.0 * N[(N[(ky * l), $MachinePrecision] / Om), $MachinePrecision]), $MachinePrecision] + N[(0.25 * N[(Om / N[(ky * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[Om, 1e+122], N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[Sqrt[N[(1.0 + N[(4.0 * N[(N[(N[(ky * l), $MachinePrecision] * N[(ky * l), $MachinePrecision]), $MachinePrecision] / N[(Om * Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 1.0]]
\begin{array}{l}
kx = |kx|\\
ky = |ky|\\
[kx, ky] = \mathsf{sort}([kx, ky])\\
\\
\begin{array}{l}
\mathbf{if}\;Om \leq 5 \cdot 10^{-166}:\\
\;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{2 \cdot \frac{ky \cdot \ell}{Om} + 0.25 \cdot \frac{Om}{ky \cdot \ell}}}\\
\mathbf{elif}\;Om \leq 10^{+122}:\\
\;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{\sqrt{1 + 4 \cdot \frac{\left(ky \cdot \ell\right) \cdot \left(ky \cdot \ell\right)}{Om \cdot Om}}}}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if Om < 5e-166Initial program 98.7%
distribute-rgt-in98.7%
metadata-eval98.7%
metadata-eval98.7%
associate-/l*98.7%
metadata-eval98.7%
Simplified98.7%
Taylor expanded in kx around 0 76.5%
associate-/l*77.5%
associate-/r/78.2%
unpow278.2%
unpow278.2%
times-frac88.3%
Simplified88.3%
Taylor expanded in ky around 0 59.5%
unpow259.5%
unpow259.5%
unswap-sqr70.6%
unpow270.6%
Simplified70.6%
Taylor expanded in l around inf 57.8%
if 5e-166 < Om < 1.00000000000000001e122Initial program 100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-/l*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in kx around 0 91.7%
associate-/l*89.8%
associate-/r/91.7%
unpow291.7%
unpow291.7%
times-frac90.6%
Simplified90.6%
Taylor expanded in ky around 0 76.2%
unpow276.2%
unpow276.2%
unswap-sqr80.4%
unpow280.4%
Simplified80.4%
if 1.00000000000000001e122 < Om Initial program 100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-/l*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in kx around 0 85.3%
associate-/l*84.4%
associate-/r/85.3%
unpow285.3%
unpow285.3%
times-frac100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
*-commutative100.0%
associate-*l*100.0%
associate-*l/100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in ky around 0 94.1%
Final simplification68.9%
NOTE: kx should be positive before calling this function
NOTE: ky should be positive before calling this function
NOTE: kx and ky should be sorted in increasing order before calling this function.
(FPCore (l Om kx ky)
:precision binary64
(if (<= Om 1.7e-202)
(sqrt
(+
0.5
(* 0.5 (/ 1.0 (+ (* 2.0 (/ (* ky l) Om)) (* 0.25 (/ Om (* ky l))))))))
(if (<= Om 1.15e-56)
(sqrt
(+
0.5
(* 0.5 (/ 1.0 (fma 2.0 (/ (* (* ky l) (* ky l)) (* Om Om)) 1.0)))))
1.0)))kx = abs(kx);
ky = abs(ky);
assert(kx < ky);
double code(double l, double Om, double kx, double ky) {
double tmp;
if (Om <= 1.7e-202) {
tmp = sqrt((0.5 + (0.5 * (1.0 / ((2.0 * ((ky * l) / Om)) + (0.25 * (Om / (ky * l))))))));
} else if (Om <= 1.15e-56) {
tmp = sqrt((0.5 + (0.5 * (1.0 / fma(2.0, (((ky * l) * (ky * l)) / (Om * Om)), 1.0)))));
} else {
tmp = 1.0;
}
return tmp;
}
kx = abs(kx) ky = abs(ky) kx, ky = sort([kx, ky]) function code(l, Om, kx, ky) tmp = 0.0 if (Om <= 1.7e-202) tmp = sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / Float64(Float64(2.0 * Float64(Float64(ky * l) / Om)) + Float64(0.25 * Float64(Om / Float64(ky * l)))))))); elseif (Om <= 1.15e-56) tmp = sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / fma(2.0, Float64(Float64(Float64(ky * l) * Float64(ky * l)) / Float64(Om * Om)), 1.0))))); else tmp = 1.0; end return tmp end
NOTE: kx should be positive before calling this function NOTE: ky should be positive before calling this function NOTE: kx and ky should be sorted in increasing order before calling this function. code[l_, Om_, kx_, ky_] := If[LessEqual[Om, 1.7e-202], N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[(N[(2.0 * N[(N[(ky * l), $MachinePrecision] / Om), $MachinePrecision]), $MachinePrecision] + N[(0.25 * N[(Om / N[(ky * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[Om, 1.15e-56], N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[(2.0 * N[(N[(N[(ky * l), $MachinePrecision] * N[(ky * l), $MachinePrecision]), $MachinePrecision] / N[(Om * Om), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 1.0]]
\begin{array}{l}
kx = |kx|\\
ky = |ky|\\
[kx, ky] = \mathsf{sort}([kx, ky])\\
\\
\begin{array}{l}
\mathbf{if}\;Om \leq 1.7 \cdot 10^{-202}:\\
\;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{2 \cdot \frac{ky \cdot \ell}{Om} + 0.25 \cdot \frac{Om}{ky \cdot \ell}}}\\
\mathbf{elif}\;Om \leq 1.15 \cdot 10^{-56}:\\
\;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{\mathsf{fma}\left(2, \frac{\left(ky \cdot \ell\right) \cdot \left(ky \cdot \ell\right)}{Om \cdot Om}, 1\right)}}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if Om < 1.70000000000000006e-202Initial program 98.7%
distribute-rgt-in98.7%
metadata-eval98.7%
metadata-eval98.7%
associate-/l*98.7%
metadata-eval98.7%
Simplified98.7%
Taylor expanded in kx around 0 76.6%
associate-/l*77.6%
associate-/r/78.2%
unpow278.2%
unpow278.2%
times-frac88.0%
Simplified88.0%
Taylor expanded in ky around 0 59.1%
unpow259.1%
unpow259.1%
unswap-sqr70.4%
unpow270.4%
Simplified70.4%
Taylor expanded in l around inf 57.3%
if 1.70000000000000006e-202 < Om < 1.15000000000000001e-56Initial program 100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-/l*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in kx around 0 82.4%
associate-/l*82.4%
associate-/r/82.4%
unpow282.4%
unpow282.4%
times-frac86.4%
Simplified86.4%
Taylor expanded in ky around 0 78.4%
+-commutative78.4%
fma-def78.4%
unpow278.4%
unpow278.4%
unswap-sqr80.0%
unpow280.0%
Simplified80.0%
if 1.15000000000000001e-56 < Om Initial program 100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-/l*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in kx around 0 90.1%
associate-/l*88.3%
associate-/r/90.1%
unpow290.1%
unpow290.1%
times-frac97.9%
Simplified97.9%
expm1-log1p-u97.9%
expm1-udef97.9%
Applied egg-rr97.9%
expm1-def97.9%
expm1-log1p97.9%
*-commutative97.9%
*-commutative97.9%
associate-*l*97.9%
associate-*l/97.9%
*-commutative97.9%
Simplified97.9%
Taylor expanded in ky around 0 89.3%
Final simplification69.1%
NOTE: kx should be positive before calling this function
NOTE: ky should be positive before calling this function
NOTE: kx and ky should be sorted in increasing order before calling this function.
(FPCore (l Om kx ky)
:precision binary64
(if (<= Om 8.2e-139)
(sqrt 0.5)
(if (<= Om 1.1e-56)
(sqrt
(+
0.5
(* 0.5 (/ 1.0 (+ 1.0 (* 2.0 (/ (* l l) (/ (* Om Om) (* ky ky)))))))))
1.0)))kx = abs(kx);
ky = abs(ky);
assert(kx < ky);
double code(double l, double Om, double kx, double ky) {
double tmp;
if (Om <= 8.2e-139) {
tmp = sqrt(0.5);
} else if (Om <= 1.1e-56) {
tmp = sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((l * l) / ((Om * Om) / (ky * ky)))))))));
} else {
tmp = 1.0;
}
return tmp;
}
NOTE: kx should be positive before calling this function
NOTE: ky should be positive before calling this function
NOTE: kx and ky should be sorted in increasing order before calling this function.
real(8) function code(l, om, kx, ky)
real(8), intent (in) :: l
real(8), intent (in) :: om
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8) :: tmp
if (om <= 8.2d-139) then
tmp = sqrt(0.5d0)
else if (om <= 1.1d-56) then
tmp = sqrt((0.5d0 + (0.5d0 * (1.0d0 / (1.0d0 + (2.0d0 * ((l * l) / ((om * om) / (ky * ky)))))))))
else
tmp = 1.0d0
end if
code = tmp
end function
kx = Math.abs(kx);
ky = Math.abs(ky);
assert kx < ky;
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if (Om <= 8.2e-139) {
tmp = Math.sqrt(0.5);
} else if (Om <= 1.1e-56) {
tmp = Math.sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((l * l) / ((Om * Om) / (ky * ky)))))))));
} else {
tmp = 1.0;
}
return tmp;
}
kx = abs(kx) ky = abs(ky) [kx, ky] = sort([kx, ky]) def code(l, Om, kx, ky): tmp = 0 if Om <= 8.2e-139: tmp = math.sqrt(0.5) elif Om <= 1.1e-56: tmp = math.sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((l * l) / ((Om * Om) / (ky * ky))))))))) else: tmp = 1.0 return tmp
kx = abs(kx) ky = abs(ky) kx, ky = sort([kx, ky]) function code(l, Om, kx, ky) tmp = 0.0 if (Om <= 8.2e-139) tmp = sqrt(0.5); elseif (Om <= 1.1e-56) tmp = sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / Float64(1.0 + Float64(2.0 * Float64(Float64(l * l) / Float64(Float64(Om * Om) / Float64(ky * ky))))))))); else tmp = 1.0; end return tmp end
kx = abs(kx)
ky = abs(ky)
kx, ky = num2cell(sort([kx, ky])){:}
function tmp_2 = code(l, Om, kx, ky)
tmp = 0.0;
if (Om <= 8.2e-139)
tmp = sqrt(0.5);
elseif (Om <= 1.1e-56)
tmp = sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((l * l) / ((Om * Om) / (ky * ky)))))))));
else
tmp = 1.0;
end
tmp_2 = tmp;
end
NOTE: kx should be positive before calling this function NOTE: ky should be positive before calling this function NOTE: kx and ky should be sorted in increasing order before calling this function. code[l_, Om_, kx_, ky_] := If[LessEqual[Om, 8.2e-139], N[Sqrt[0.5], $MachinePrecision], If[LessEqual[Om, 1.1e-56], N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[(1.0 + N[(2.0 * N[(N[(l * l), $MachinePrecision] / N[(N[(Om * Om), $MachinePrecision] / N[(ky * ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 1.0]]
\begin{array}{l}
kx = |kx|\\
ky = |ky|\\
[kx, ky] = \mathsf{sort}([kx, ky])\\
\\
\begin{array}{l}
\mathbf{if}\;Om \leq 8.2 \cdot 10^{-139}:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{elif}\;Om \leq 1.1 \cdot 10^{-56}:\\
\;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{1 + 2 \cdot \frac{\ell \cdot \ell}{\frac{Om \cdot Om}{ky \cdot ky}}}}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if Om < 8.20000000000000028e-139Initial program 98.8%
distribute-rgt-in98.8%
metadata-eval98.8%
metadata-eval98.8%
associate-/l*98.8%
metadata-eval98.8%
Simplified98.8%
Taylor expanded in Om around 0 50.0%
associate-*r*50.0%
*-commutative50.0%
associate-*r*50.0%
unpow250.0%
unpow250.0%
hypot-def51.2%
Simplified51.2%
Taylor expanded in l around inf 59.4%
if 8.20000000000000028e-139 < Om < 1.10000000000000002e-56Initial program 100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-/l*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in kx around 0 77.3%
associate-/l*77.3%
associate-/r/77.3%
unpow277.3%
unpow277.3%
times-frac77.3%
Simplified77.3%
Taylor expanded in ky around 0 70.7%
associate-/l*64.0%
unpow264.0%
unpow264.0%
unpow264.0%
Simplified64.0%
if 1.10000000000000002e-56 < Om Initial program 100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-/l*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in kx around 0 90.1%
associate-/l*88.3%
associate-/r/90.1%
unpow290.1%
unpow290.1%
times-frac97.9%
Simplified97.9%
expm1-log1p-u97.9%
expm1-udef97.9%
Applied egg-rr97.9%
expm1-def97.9%
expm1-log1p97.9%
*-commutative97.9%
*-commutative97.9%
associate-*l*97.9%
associate-*l/97.9%
*-commutative97.9%
Simplified97.9%
Taylor expanded in ky around 0 89.3%
Final simplification68.6%
NOTE: kx should be positive before calling this function
NOTE: ky should be positive before calling this function
NOTE: kx and ky should be sorted in increasing order before calling this function.
(FPCore (l Om kx ky)
:precision binary64
(if (<= Om 1.26e-138)
(sqrt
(+
0.5
(* 0.5 (/ 1.0 (+ (* 2.0 (/ (* ky l) Om)) (* 0.25 (/ Om (* ky l))))))))
(if (<= Om 1.15e-56)
(sqrt
(+
0.5
(* 0.5 (/ 1.0 (+ 1.0 (* 2.0 (/ (* l l) (/ (* Om Om) (* ky ky)))))))))
1.0)))kx = abs(kx);
ky = abs(ky);
assert(kx < ky);
double code(double l, double Om, double kx, double ky) {
double tmp;
if (Om <= 1.26e-138) {
tmp = sqrt((0.5 + (0.5 * (1.0 / ((2.0 * ((ky * l) / Om)) + (0.25 * (Om / (ky * l))))))));
} else if (Om <= 1.15e-56) {
tmp = sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((l * l) / ((Om * Om) / (ky * ky)))))))));
} else {
tmp = 1.0;
}
return tmp;
}
NOTE: kx should be positive before calling this function
NOTE: ky should be positive before calling this function
NOTE: kx and ky should be sorted in increasing order before calling this function.
real(8) function code(l, om, kx, ky)
real(8), intent (in) :: l
real(8), intent (in) :: om
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8) :: tmp
if (om <= 1.26d-138) then
tmp = sqrt((0.5d0 + (0.5d0 * (1.0d0 / ((2.0d0 * ((ky * l) / om)) + (0.25d0 * (om / (ky * l))))))))
else if (om <= 1.15d-56) then
tmp = sqrt((0.5d0 + (0.5d0 * (1.0d0 / (1.0d0 + (2.0d0 * ((l * l) / ((om * om) / (ky * ky)))))))))
else
tmp = 1.0d0
end if
code = tmp
end function
kx = Math.abs(kx);
ky = Math.abs(ky);
assert kx < ky;
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if (Om <= 1.26e-138) {
tmp = Math.sqrt((0.5 + (0.5 * (1.0 / ((2.0 * ((ky * l) / Om)) + (0.25 * (Om / (ky * l))))))));
} else if (Om <= 1.15e-56) {
tmp = Math.sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((l * l) / ((Om * Om) / (ky * ky)))))))));
} else {
tmp = 1.0;
}
return tmp;
}
kx = abs(kx) ky = abs(ky) [kx, ky] = sort([kx, ky]) def code(l, Om, kx, ky): tmp = 0 if Om <= 1.26e-138: tmp = math.sqrt((0.5 + (0.5 * (1.0 / ((2.0 * ((ky * l) / Om)) + (0.25 * (Om / (ky * l)))))))) elif Om <= 1.15e-56: tmp = math.sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((l * l) / ((Om * Om) / (ky * ky))))))))) else: tmp = 1.0 return tmp
kx = abs(kx) ky = abs(ky) kx, ky = sort([kx, ky]) function code(l, Om, kx, ky) tmp = 0.0 if (Om <= 1.26e-138) tmp = sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / Float64(Float64(2.0 * Float64(Float64(ky * l) / Om)) + Float64(0.25 * Float64(Om / Float64(ky * l)))))))); elseif (Om <= 1.15e-56) tmp = sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / Float64(1.0 + Float64(2.0 * Float64(Float64(l * l) / Float64(Float64(Om * Om) / Float64(ky * ky))))))))); else tmp = 1.0; end return tmp end
kx = abs(kx)
ky = abs(ky)
kx, ky = num2cell(sort([kx, ky])){:}
function tmp_2 = code(l, Om, kx, ky)
tmp = 0.0;
if (Om <= 1.26e-138)
tmp = sqrt((0.5 + (0.5 * (1.0 / ((2.0 * ((ky * l) / Om)) + (0.25 * (Om / (ky * l))))))));
elseif (Om <= 1.15e-56)
tmp = sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((l * l) / ((Om * Om) / (ky * ky)))))))));
else
tmp = 1.0;
end
tmp_2 = tmp;
end
NOTE: kx should be positive before calling this function NOTE: ky should be positive before calling this function NOTE: kx and ky should be sorted in increasing order before calling this function. code[l_, Om_, kx_, ky_] := If[LessEqual[Om, 1.26e-138], N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[(N[(2.0 * N[(N[(ky * l), $MachinePrecision] / Om), $MachinePrecision]), $MachinePrecision] + N[(0.25 * N[(Om / N[(ky * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[Om, 1.15e-56], N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[(1.0 + N[(2.0 * N[(N[(l * l), $MachinePrecision] / N[(N[(Om * Om), $MachinePrecision] / N[(ky * ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 1.0]]
\begin{array}{l}
kx = |kx|\\
ky = |ky|\\
[kx, ky] = \mathsf{sort}([kx, ky])\\
\\
\begin{array}{l}
\mathbf{if}\;Om \leq 1.26 \cdot 10^{-138}:\\
\;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{2 \cdot \frac{ky \cdot \ell}{Om} + 0.25 \cdot \frac{Om}{ky \cdot \ell}}}\\
\mathbf{elif}\;Om \leq 1.15 \cdot 10^{-56}:\\
\;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{1 + 2 \cdot \frac{\ell \cdot \ell}{\frac{Om \cdot Om}{ky \cdot ky}}}}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if Om < 1.26e-138Initial program 98.8%
distribute-rgt-in98.8%
metadata-eval98.8%
metadata-eval98.8%
associate-/l*98.8%
metadata-eval98.8%
Simplified98.8%
Taylor expanded in kx around 0 77.4%
associate-/l*78.3%
associate-/r/78.9%
unpow278.9%
unpow278.9%
times-frac88.8%
Simplified88.8%
Taylor expanded in ky around 0 61.0%
unpow261.0%
unpow261.0%
unswap-sqr71.6%
unpow271.6%
Simplified71.6%
Taylor expanded in l around inf 59.4%
if 1.26e-138 < Om < 1.15000000000000001e-56Initial program 100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-/l*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in kx around 0 77.3%
associate-/l*77.3%
associate-/r/77.3%
unpow277.3%
unpow277.3%
times-frac77.3%
Simplified77.3%
Taylor expanded in ky around 0 70.7%
associate-/l*64.0%
unpow264.0%
unpow264.0%
unpow264.0%
Simplified64.0%
if 1.15000000000000001e-56 < Om Initial program 100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-/l*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in kx around 0 90.1%
associate-/l*88.3%
associate-/r/90.1%
unpow290.1%
unpow290.1%
times-frac97.9%
Simplified97.9%
expm1-log1p-u97.9%
expm1-udef97.9%
Applied egg-rr97.9%
expm1-def97.9%
expm1-log1p97.9%
*-commutative97.9%
*-commutative97.9%
associate-*l*97.9%
associate-*l/97.9%
*-commutative97.9%
Simplified97.9%
Taylor expanded in ky around 0 89.3%
Final simplification68.6%
NOTE: kx should be positive before calling this function NOTE: ky should be positive before calling this function NOTE: kx and ky should be sorted in increasing order before calling this function. (FPCore (l Om kx ky) :precision binary64 (if (<= Om 5e-108) (sqrt 0.5) (if (<= Om 1.6e-82) 1.0 (if (<= Om 1.05e-56) (sqrt 0.5) 1.0))))
kx = abs(kx);
ky = abs(ky);
assert(kx < ky);
double code(double l, double Om, double kx, double ky) {
double tmp;
if (Om <= 5e-108) {
tmp = sqrt(0.5);
} else if (Om <= 1.6e-82) {
tmp = 1.0;
} else if (Om <= 1.05e-56) {
tmp = sqrt(0.5);
} else {
tmp = 1.0;
}
return tmp;
}
NOTE: kx should be positive before calling this function
NOTE: ky should be positive before calling this function
NOTE: kx and ky should be sorted in increasing order before calling this function.
real(8) function code(l, om, kx, ky)
real(8), intent (in) :: l
real(8), intent (in) :: om
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8) :: tmp
if (om <= 5d-108) then
tmp = sqrt(0.5d0)
else if (om <= 1.6d-82) then
tmp = 1.0d0
else if (om <= 1.05d-56) then
tmp = sqrt(0.5d0)
else
tmp = 1.0d0
end if
code = tmp
end function
kx = Math.abs(kx);
ky = Math.abs(ky);
assert kx < ky;
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if (Om <= 5e-108) {
tmp = Math.sqrt(0.5);
} else if (Om <= 1.6e-82) {
tmp = 1.0;
} else if (Om <= 1.05e-56) {
tmp = Math.sqrt(0.5);
} else {
tmp = 1.0;
}
return tmp;
}
kx = abs(kx) ky = abs(ky) [kx, ky] = sort([kx, ky]) def code(l, Om, kx, ky): tmp = 0 if Om <= 5e-108: tmp = math.sqrt(0.5) elif Om <= 1.6e-82: tmp = 1.0 elif Om <= 1.05e-56: tmp = math.sqrt(0.5) else: tmp = 1.0 return tmp
kx = abs(kx) ky = abs(ky) kx, ky = sort([kx, ky]) function code(l, Om, kx, ky) tmp = 0.0 if (Om <= 5e-108) tmp = sqrt(0.5); elseif (Om <= 1.6e-82) tmp = 1.0; elseif (Om <= 1.05e-56) tmp = sqrt(0.5); else tmp = 1.0; end return tmp end
kx = abs(kx)
ky = abs(ky)
kx, ky = num2cell(sort([kx, ky])){:}
function tmp_2 = code(l, Om, kx, ky)
tmp = 0.0;
if (Om <= 5e-108)
tmp = sqrt(0.5);
elseif (Om <= 1.6e-82)
tmp = 1.0;
elseif (Om <= 1.05e-56)
tmp = sqrt(0.5);
else
tmp = 1.0;
end
tmp_2 = tmp;
end
NOTE: kx should be positive before calling this function NOTE: ky should be positive before calling this function NOTE: kx and ky should be sorted in increasing order before calling this function. code[l_, Om_, kx_, ky_] := If[LessEqual[Om, 5e-108], N[Sqrt[0.5], $MachinePrecision], If[LessEqual[Om, 1.6e-82], 1.0, If[LessEqual[Om, 1.05e-56], N[Sqrt[0.5], $MachinePrecision], 1.0]]]
\begin{array}{l}
kx = |kx|\\
ky = |ky|\\
[kx, ky] = \mathsf{sort}([kx, ky])\\
\\
\begin{array}{l}
\mathbf{if}\;Om \leq 5 \cdot 10^{-108}:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{elif}\;Om \leq 1.6 \cdot 10^{-82}:\\
\;\;\;\;1\\
\mathbf{elif}\;Om \leq 1.05 \cdot 10^{-56}:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if Om < 5e-108 or 1.6000000000000001e-82 < Om < 1.05000000000000003e-56Initial program 98.9%
distribute-rgt-in98.9%
metadata-eval98.9%
metadata-eval98.9%
associate-/l*98.9%
metadata-eval98.9%
Simplified98.9%
Taylor expanded in Om around 0 51.7%
associate-*r*51.7%
*-commutative51.7%
associate-*r*51.7%
unpow251.7%
unpow251.7%
hypot-def52.9%
Simplified52.9%
Taylor expanded in l around inf 60.8%
if 5e-108 < Om < 1.6000000000000001e-82 or 1.05000000000000003e-56 < Om Initial program 100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-/l*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in kx around 0 90.5%
associate-/l*88.8%
associate-/r/90.5%
unpow290.5%
unpow290.5%
times-frac98.0%
Simplified98.0%
expm1-log1p-u98.0%
expm1-udef98.0%
Applied egg-rr98.0%
expm1-def98.0%
expm1-log1p98.0%
*-commutative98.0%
*-commutative98.0%
associate-*l*98.0%
associate-*l/98.0%
*-commutative98.0%
Simplified98.0%
Taylor expanded in ky around 0 89.7%
Final simplification69.8%
NOTE: kx should be positive before calling this function NOTE: ky should be positive before calling this function NOTE: kx and ky should be sorted in increasing order before calling this function. (FPCore (l Om kx ky) :precision binary64 (sqrt 0.5))
kx = abs(kx);
ky = abs(ky);
assert(kx < ky);
double code(double l, double Om, double kx, double ky) {
return sqrt(0.5);
}
NOTE: kx should be positive before calling this function
NOTE: ky should be positive before calling this function
NOTE: kx and ky should be sorted in increasing order before calling this function.
real(8) function code(l, om, kx, ky)
real(8), intent (in) :: l
real(8), intent (in) :: om
real(8), intent (in) :: kx
real(8), intent (in) :: ky
code = sqrt(0.5d0)
end function
kx = Math.abs(kx);
ky = Math.abs(ky);
assert kx < ky;
public static double code(double l, double Om, double kx, double ky) {
return Math.sqrt(0.5);
}
kx = abs(kx) ky = abs(ky) [kx, ky] = sort([kx, ky]) def code(l, Om, kx, ky): return math.sqrt(0.5)
kx = abs(kx) ky = abs(ky) kx, ky = sort([kx, ky]) function code(l, Om, kx, ky) return sqrt(0.5) end
kx = abs(kx)
ky = abs(ky)
kx, ky = num2cell(sort([kx, ky])){:}
function tmp = code(l, Om, kx, ky)
tmp = sqrt(0.5);
end
NOTE: kx should be positive before calling this function NOTE: ky should be positive before calling this function NOTE: kx and ky should be sorted in increasing order before calling this function. code[l_, Om_, kx_, ky_] := N[Sqrt[0.5], $MachinePrecision]
\begin{array}{l}
kx = |kx|\\
ky = |ky|\\
[kx, ky] = \mathsf{sort}([kx, ky])\\
\\
\sqrt{0.5}
\end{array}
Initial program 99.2%
distribute-rgt-in99.2%
metadata-eval99.2%
metadata-eval99.2%
associate-/l*99.2%
metadata-eval99.2%
Simplified99.2%
Taylor expanded in Om around 0 40.4%
associate-*r*40.4%
*-commutative40.4%
associate-*r*40.4%
unpow240.4%
unpow240.4%
hypot-def41.2%
Simplified41.2%
Taylor expanded in l around inf 51.1%
Final simplification51.1%
herbie shell --seed 2023217
(FPCore (l Om kx ky)
:name "Toniolo and Linder, Equation (3a)"
:precision binary64
(sqrt (* (/ 1.0 2.0) (+ 1.0 (/ 1.0 (sqrt (+ 1.0 (* (pow (/ (* 2.0 l) Om) 2.0) (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))))))))))