
(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 5 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 (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 / 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 / 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 / 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 / hypot(1.0, Float64(sin(ky) * Float64(2.0 * Float64(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 / 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[Sqrt[1.0 ^ 2 + N[(N[Sin[ky], $MachinePrecision] * N[(2.0 * N[(l / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
kx = |kx|\\
ky = |ky|\\
[kx, ky] = \mathsf{sort}([kx, ky])\\
\\
\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \sin ky \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)}}
\end{array}
Initial program 98.0%
distribute-rgt-in98.0%
metadata-eval98.0%
metadata-eval98.0%
associate-/l*98.0%
metadata-eval98.0%
Simplified98.0%
Taylor expanded in kx around 0 79.4%
associate-/l*79.8%
associate-/r/80.1%
unpow280.1%
unpow280.1%
times-frac90.1%
Simplified90.1%
add-sqr-sqrt90.1%
hypot-1-def90.1%
sqrt-prod90.1%
metadata-eval90.1%
sqrt-prod90.1%
sqrt-prod51.5%
add-sqr-sqrt90.7%
unpow290.7%
sqrt-prod49.0%
add-sqr-sqrt93.7%
Applied egg-rr93.7%
expm1-log1p-u93.2%
expm1-udef93.2%
associate-*l/93.2%
metadata-eval93.2%
associate-*r*93.2%
Applied egg-rr93.2%
expm1-def93.2%
expm1-log1p93.7%
*-commutative93.7%
Simplified93.7%
Final simplification93.7%
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 (or (<= Om 3.9e-69) (and (not (<= Om 8e-62)) (<= Om 1.7e-12)))
(sqrt
(+
0.5
(*
0.5
(/ 1.0 (sqrt (+ 1.0 (* 4.0 (* (* (/ l Om) (/ l 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 <= 3.9e-69) || (!(Om <= 8e-62) && (Om <= 1.7e-12))) {
tmp = sqrt((0.5 + (0.5 * (1.0 / sqrt((1.0 + (4.0 * (((l / Om) * (l / 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 <= 3.9d-69) .or. (.not. (om <= 8d-62)) .and. (om <= 1.7d-12)) then
tmp = sqrt((0.5d0 + (0.5d0 * (1.0d0 / sqrt((1.0d0 + (4.0d0 * (((l / om) * (l / 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 <= 3.9e-69) || (!(Om <= 8e-62) && (Om <= 1.7e-12))) {
tmp = Math.sqrt((0.5 + (0.5 * (1.0 / Math.sqrt((1.0 + (4.0 * (((l / Om) * (l / 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 <= 3.9e-69) or (not (Om <= 8e-62) and (Om <= 1.7e-12)): tmp = math.sqrt((0.5 + (0.5 * (1.0 / math.sqrt((1.0 + (4.0 * (((l / Om) * (l / 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 <= 3.9e-69) || (!(Om <= 8e-62) && (Om <= 1.7e-12))) tmp = sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / sqrt(Float64(1.0 + Float64(4.0 * Float64(Float64(Float64(l / Om) * Float64(l / 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 <= 3.9e-69) || (~((Om <= 8e-62)) && (Om <= 1.7e-12)))
tmp = sqrt((0.5 + (0.5 * (1.0 / sqrt((1.0 + (4.0 * (((l / Om) * (l / 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[Or[LessEqual[Om, 3.9e-69], And[N[Not[LessEqual[Om, 8e-62]], $MachinePrecision], LessEqual[Om, 1.7e-12]]], N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[Sqrt[N[(1.0 + N[(4.0 * N[(N[(N[(l / Om), $MachinePrecision] * N[(l / Om), $MachinePrecision]), $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 3.9 \cdot 10^{-69} \lor \neg \left(Om \leq 8 \cdot 10^{-62}\right) \land Om \leq 1.7 \cdot 10^{-12}:\\
\;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{\sqrt{1 + 4 \cdot \left(\left(\frac{\ell}{Om} \cdot \frac{\ell}{Om}\right) \cdot \left(ky \cdot ky\right)\right)}}}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if Om < 3.89999999999999981e-69 or 8.0000000000000003e-62 < Om < 1.7e-12Initial program 97.1%
distribute-rgt-in97.1%
metadata-eval97.1%
metadata-eval97.1%
associate-/l*97.1%
metadata-eval97.1%
Simplified97.1%
Taylor expanded in kx around 0 75.9%
associate-/l*77.0%
associate-/r/76.9%
unpow276.9%
unpow276.9%
times-frac87.9%
Simplified87.9%
Taylor expanded in ky around 0 77.2%
unpow277.2%
Simplified77.2%
if 3.89999999999999981e-69 < Om < 8.0000000000000003e-62 or 1.7e-12 < 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 86.8%
associate-/l*85.6%
associate-/r/86.8%
unpow286.8%
unpow286.8%
times-frac94.6%
Simplified94.6%
add-sqr-sqrt94.6%
hypot-1-def94.6%
sqrt-prod94.6%
metadata-eval94.6%
sqrt-prod94.6%
sqrt-prod60.0%
add-sqr-sqrt95.1%
unpow295.1%
sqrt-prod57.8%
add-sqr-sqrt95.1%
Applied egg-rr95.1%
expm1-log1p-u95.0%
expm1-udef95.0%
associate-*l/95.0%
metadata-eval95.0%
associate-*r*95.0%
Applied egg-rr95.0%
expm1-def95.0%
expm1-log1p95.1%
*-commutative95.1%
Simplified95.1%
Taylor expanded in ky around 0 87.3%
Final simplification80.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. (FPCore (l Om kx ky) :precision binary64 (if (<= Om 2.5e-69) (sqrt 0.5) (if (<= Om 5e-62) 1.0 (if (<= Om 7e-12) (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 <= 2.5e-69) {
tmp = sqrt(0.5);
} else if (Om <= 5e-62) {
tmp = 1.0;
} else if (Om <= 7e-12) {
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 <= 2.5d-69) then
tmp = sqrt(0.5d0)
else if (om <= 5d-62) then
tmp = 1.0d0
else if (om <= 7d-12) 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 <= 2.5e-69) {
tmp = Math.sqrt(0.5);
} else if (Om <= 5e-62) {
tmp = 1.0;
} else if (Om <= 7e-12) {
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 <= 2.5e-69: tmp = math.sqrt(0.5) elif Om <= 5e-62: tmp = 1.0 elif Om <= 7e-12: 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 <= 2.5e-69) tmp = sqrt(0.5); elseif (Om <= 5e-62) tmp = 1.0; elseif (Om <= 7e-12) 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 <= 2.5e-69)
tmp = sqrt(0.5);
elseif (Om <= 5e-62)
tmp = 1.0;
elseif (Om <= 7e-12)
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, 2.5e-69], N[Sqrt[0.5], $MachinePrecision], If[LessEqual[Om, 5e-62], 1.0, If[LessEqual[Om, 7e-12], 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 2.5 \cdot 10^{-69}:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{elif}\;Om \leq 5 \cdot 10^{-62}:\\
\;\;\;\;1\\
\mathbf{elif}\;Om \leq 7 \cdot 10^{-12}:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if Om < 2.50000000000000017e-69 or 5.0000000000000002e-62 < Om < 7.0000000000000001e-12Initial program 97.1%
distribute-rgt-in97.1%
metadata-eval97.1%
metadata-eval97.1%
associate-/l*97.1%
metadata-eval97.1%
Simplified97.1%
Taylor expanded in Om around 0 57.4%
associate-*r*57.4%
*-commutative57.4%
associate-*r*57.4%
unpow257.4%
unpow257.4%
hypot-def59.8%
Simplified59.8%
Taylor expanded in l around inf 66.0%
if 2.50000000000000017e-69 < Om < 5.0000000000000002e-62 or 7.0000000000000001e-12 < 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 86.8%
associate-/l*85.6%
associate-/r/86.8%
unpow286.8%
unpow286.8%
times-frac94.6%
Simplified94.6%
add-sqr-sqrt94.6%
hypot-1-def94.6%
sqrt-prod94.6%
metadata-eval94.6%
sqrt-prod94.6%
sqrt-prod60.0%
add-sqr-sqrt95.1%
unpow295.1%
sqrt-prod57.8%
add-sqr-sqrt95.1%
Applied egg-rr95.1%
expm1-log1p-u95.0%
expm1-udef95.0%
associate-*l/95.0%
metadata-eval95.0%
associate-*r*95.0%
Applied egg-rr95.0%
expm1-def95.0%
expm1-log1p95.1%
*-commutative95.1%
Simplified95.1%
Taylor expanded in ky around 0 87.3%
Final simplification72.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 (if (<= Om 1.7e+84) (sqrt 0.5) (+ 1.0 (* -0.5 (* (* ky (/ ky Om)) (* l (/ l Om)))))))
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+84) {
tmp = sqrt(0.5);
} else {
tmp = 1.0 + (-0.5 * ((ky * (ky / Om)) * (l * (l / Om))));
}
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.7d+84) then
tmp = sqrt(0.5d0)
else
tmp = 1.0d0 + ((-0.5d0) * ((ky * (ky / om)) * (l * (l / om))))
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.7e+84) {
tmp = Math.sqrt(0.5);
} else {
tmp = 1.0 + (-0.5 * ((ky * (ky / Om)) * (l * (l / Om))));
}
return tmp;
}
kx = abs(kx) ky = abs(ky) [kx, ky] = sort([kx, ky]) def code(l, Om, kx, ky): tmp = 0 if Om <= 1.7e+84: tmp = math.sqrt(0.5) else: tmp = 1.0 + (-0.5 * ((ky * (ky / Om)) * (l * (l / Om)))) 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+84) tmp = sqrt(0.5); else tmp = Float64(1.0 + Float64(-0.5 * Float64(Float64(ky * Float64(ky / Om)) * Float64(l * Float64(l / Om))))); 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.7e+84)
tmp = sqrt(0.5);
else
tmp = 1.0 + (-0.5 * ((ky * (ky / Om)) * (l * (l / Om))));
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.7e+84], N[Sqrt[0.5], $MachinePrecision], N[(1.0 + N[(-0.5 * N[(N[(ky * N[(ky / Om), $MachinePrecision]), $MachinePrecision] * N[(l * N[(l / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
kx = |kx|\\
ky = |ky|\\
[kx, ky] = \mathsf{sort}([kx, ky])\\
\\
\begin{array}{l}
\mathbf{if}\;Om \leq 1.7 \cdot 10^{+84}:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{else}:\\
\;\;\;\;1 + -0.5 \cdot \left(\left(ky \cdot \frac{ky}{Om}\right) \cdot \left(\ell \cdot \frac{\ell}{Om}\right)\right)\\
\end{array}
\end{array}
if Om < 1.6999999999999999e84Initial program 97.5%
distribute-rgt-in97.5%
metadata-eval97.5%
metadata-eval97.5%
associate-/l*97.5%
metadata-eval97.5%
Simplified97.5%
Taylor expanded in Om around 0 54.0%
associate-*r*54.0%
*-commutative54.0%
associate-*r*54.0%
unpow254.0%
unpow254.0%
hypot-def56.1%
Simplified56.1%
Taylor expanded in l around inf 62.7%
if 1.6999999999999999e84 < 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.5%
associate-/l*83.6%
associate-/r/85.5%
unpow285.5%
unpow285.5%
times-frac97.1%
Simplified97.1%
add-sqr-sqrt97.1%
hypot-1-def97.1%
sqrt-prod97.1%
metadata-eval97.1%
sqrt-prod97.1%
sqrt-prod63.6%
add-sqr-sqrt97.1%
unpow297.1%
sqrt-prod56.7%
add-sqr-sqrt97.1%
Applied egg-rr97.1%
Taylor expanded in ky around 0 63.7%
unpow263.7%
unpow263.7%
unpow263.7%
Simplified63.7%
expm1-log1p-u63.7%
expm1-udef63.7%
times-frac67.4%
associate-/l*75.0%
Applied egg-rr75.0%
expm1-def75.0%
expm1-log1p75.0%
associate-*r/82.7%
*-commutative82.7%
associate-/r/82.7%
Simplified82.7%
Final simplification67.0%
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 (+ 1.0 (* -0.5 (* (* ky (/ ky Om)) (* l (/ l Om))))))
kx = abs(kx);
ky = abs(ky);
assert(kx < ky);
double code(double l, double Om, double kx, double ky) {
return 1.0 + (-0.5 * ((ky * (ky / Om)) * (l * (l / Om))));
}
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 = 1.0d0 + ((-0.5d0) * ((ky * (ky / om)) * (l * (l / om))))
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 1.0 + (-0.5 * ((ky * (ky / Om)) * (l * (l / Om))));
}
kx = abs(kx) ky = abs(ky) [kx, ky] = sort([kx, ky]) def code(l, Om, kx, ky): return 1.0 + (-0.5 * ((ky * (ky / Om)) * (l * (l / Om))))
kx = abs(kx) ky = abs(ky) kx, ky = sort([kx, ky]) function code(l, Om, kx, ky) return Float64(1.0 + Float64(-0.5 * Float64(Float64(ky * Float64(ky / Om)) * Float64(l * Float64(l / Om))))) end
kx = abs(kx)
ky = abs(ky)
kx, ky = num2cell(sort([kx, ky])){:}
function tmp = code(l, Om, kx, ky)
tmp = 1.0 + (-0.5 * ((ky * (ky / Om)) * (l * (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[(1.0 + N[(-0.5 * N[(N[(ky * N[(ky / Om), $MachinePrecision]), $MachinePrecision] * N[(l * N[(l / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
kx = |kx|\\
ky = |ky|\\
[kx, ky] = \mathsf{sort}([kx, ky])\\
\\
1 + -0.5 \cdot \left(\left(ky \cdot \frac{ky}{Om}\right) \cdot \left(\ell \cdot \frac{\ell}{Om}\right)\right)
\end{array}
Initial program 98.0%
distribute-rgt-in98.0%
metadata-eval98.0%
metadata-eval98.0%
associate-/l*98.0%
metadata-eval98.0%
Simplified98.0%
Taylor expanded in kx around 0 79.4%
associate-/l*79.8%
associate-/r/80.1%
unpow280.1%
unpow280.1%
times-frac90.1%
Simplified90.1%
add-sqr-sqrt90.1%
hypot-1-def90.1%
sqrt-prod90.1%
metadata-eval90.1%
sqrt-prod90.1%
sqrt-prod51.5%
add-sqr-sqrt90.7%
unpow290.7%
sqrt-prod49.0%
add-sqr-sqrt93.7%
Applied egg-rr93.7%
Taylor expanded in ky around 0 33.7%
unpow233.7%
unpow233.7%
unpow233.7%
Simplified33.7%
expm1-log1p-u33.7%
expm1-udef33.7%
times-frac38.8%
associate-/l*40.4%
Applied egg-rr40.4%
expm1-def40.4%
expm1-log1p40.4%
associate-*r/43.3%
*-commutative43.3%
associate-/r/43.3%
Simplified43.3%
Final simplification43.3%
herbie shell --seed 2023258
(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))))))))))