
(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 8 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 (sqrt (+ 1.0 (* 4.0 (pow (* (/ l Om) (sin ky)) 2.0)))))))))
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 / sqrt((1.0 + (4.0 * pow(((l / Om) * sin(ky)), 2.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.
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 + (0.5d0 * (1.0d0 / sqrt((1.0d0 + (4.0d0 * (((l / om) * sin(ky)) ** 2.0d0))))))))
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 + (0.5 * (1.0 / Math.sqrt((1.0 + (4.0 * Math.pow(((l / Om) * Math.sin(ky)), 2.0))))))));
}
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.sqrt((1.0 + (4.0 * math.pow(((l / Om) * math.sin(ky)), 2.0))))))))
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 / sqrt(Float64(1.0 + Float64(4.0 * (Float64(Float64(l / Om) * sin(ky)) ^ 2.0)))))))) 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 / sqrt((1.0 + (4.0 * (((l / Om) * sin(ky)) ^ 2.0))))))));
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[N[(1.0 + N[(4.0 * N[Power[N[(N[(l / Om), $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $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}{\sqrt{1 + 4 \cdot {\left(\frac{\ell}{Om} \cdot \sin ky\right)}^{2}}}}
\end{array}
Initial program 99.2%
Simplified99.2%
Taylor expanded in kx around 0 79.2%
associate-/l*79.2%
unpow279.2%
unpow279.2%
Simplified79.2%
add-sqr-sqrt79.2%
pow279.2%
associate-/r/79.5%
sqrt-prod79.5%
frac-times86.5%
sqrt-unprod53.9%
add-sqr-sqrt87.2%
unpow287.2%
sqrt-prod43.0%
add-sqr-sqrt92.4%
Applied egg-rr92.4%
Final simplification92.4%
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 (* (/ l Om) (* (sin ky) 2.0)))))))
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, ((l / Om) * (sin(ky) * 2.0))))));
}
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, ((l / Om) * (Math.sin(ky) * 2.0))))));
}
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, ((l / Om) * (math.sin(ky) * 2.0))))))
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(Float64(l / Om) * Float64(sin(ky) * 2.0)))))) 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, ((l / Om) * (sin(ky) * 2.0))))));
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[(l / Om), $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] * 2.0), $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, \frac{\ell}{Om} \cdot \left(\sin ky \cdot 2\right)\right)}}
\end{array}
Initial program 99.2%
Simplified99.2%
Taylor expanded in kx around 0 79.2%
associate-/l*79.2%
unpow279.2%
unpow279.2%
Simplified79.2%
expm1-log1p-u79.2%
expm1-udef79.2%
Applied egg-rr92.4%
expm1-def92.4%
expm1-log1p92.4%
*-commutative92.4%
*-commutative92.4%
associate-*l*92.4%
Simplified92.4%
clear-num92.4%
un-div-inv92.4%
/-rgt-identity92.4%
associate-*r*92.4%
*-commutative92.4%
associate-*l*92.4%
Applied egg-rr92.4%
Final simplification92.4%
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 4e-92) (sqrt 0.5) (if (<= Om 5.8e-73) 1.0 (if (<= Om 4.4e+32) (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 <= 4e-92) {
tmp = sqrt(0.5);
} else if (Om <= 5.8e-73) {
tmp = 1.0;
} else if (Om <= 4.4e+32) {
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 <= 4d-92) then
tmp = sqrt(0.5d0)
else if (om <= 5.8d-73) then
tmp = 1.0d0
else if (om <= 4.4d+32) 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 <= 4e-92) {
tmp = Math.sqrt(0.5);
} else if (Om <= 5.8e-73) {
tmp = 1.0;
} else if (Om <= 4.4e+32) {
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 <= 4e-92: tmp = math.sqrt(0.5) elif Om <= 5.8e-73: tmp = 1.0 elif Om <= 4.4e+32: 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 <= 4e-92) tmp = sqrt(0.5); elseif (Om <= 5.8e-73) tmp = 1.0; elseif (Om <= 4.4e+32) 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 <= 4e-92)
tmp = sqrt(0.5);
elseif (Om <= 5.8e-73)
tmp = 1.0;
elseif (Om <= 4.4e+32)
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, 4e-92], N[Sqrt[0.5], $MachinePrecision], If[LessEqual[Om, 5.8e-73], 1.0, If[LessEqual[Om, 4.4e+32], 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 4 \cdot 10^{-92}:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{elif}\;Om \leq 5.8 \cdot 10^{-73}:\\
\;\;\;\;1\\
\mathbf{elif}\;Om \leq 4.4 \cdot 10^{+32}:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if Om < 3.99999999999999995e-92 or 5.8e-73 < Om < 4.40000000000000002e32Initial program 99.0%
Simplified99.0%
Taylor expanded in Om around 0 63.5%
unpow263.5%
unpow263.5%
hypot-def64.5%
Simplified64.5%
Taylor expanded in l around inf 70.6%
if 3.99999999999999995e-92 < Om < 5.8e-73 or 4.40000000000000002e32 < Om Initial program 100.0%
Simplified100.0%
Taylor expanded in kx around 0 89.6%
associate-/l*87.9%
unpow287.9%
unpow287.9%
Simplified87.9%
expm1-log1p-u87.9%
expm1-udef87.9%
Applied egg-rr95.7%
expm1-def95.7%
expm1-log1p95.7%
*-commutative95.7%
*-commutative95.7%
associate-*l*95.7%
Simplified95.7%
clear-num95.7%
un-div-inv95.7%
/-rgt-identity95.7%
associate-*r*95.7%
*-commutative95.7%
associate-*l*95.7%
Applied egg-rr95.7%
Taylor expanded in l around 0 84.3%
Final simplification73.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 2.6e+131) (sqrt 0.5) (+ 1.0 (* (/ (* l l) (* (/ (* Om Om) ky) (/ 1.0 ky))) -0.5))))
kx = abs(kx);
ky = abs(ky);
assert(kx < ky);
double code(double l, double Om, double kx, double ky) {
double tmp;
if (Om <= 2.6e+131) {
tmp = sqrt(0.5);
} else {
tmp = 1.0 + (((l * l) / (((Om * Om) / ky) * (1.0 / ky))) * -0.5);
}
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.6d+131) then
tmp = sqrt(0.5d0)
else
tmp = 1.0d0 + (((l * l) / (((om * om) / ky) * (1.0d0 / ky))) * (-0.5d0))
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.6e+131) {
tmp = Math.sqrt(0.5);
} else {
tmp = 1.0 + (((l * l) / (((Om * Om) / ky) * (1.0 / ky))) * -0.5);
}
return tmp;
}
kx = abs(kx) ky = abs(ky) [kx, ky] = sort([kx, ky]) def code(l, Om, kx, ky): tmp = 0 if Om <= 2.6e+131: tmp = math.sqrt(0.5) else: tmp = 1.0 + (((l * l) / (((Om * Om) / ky) * (1.0 / ky))) * -0.5) 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.6e+131) tmp = sqrt(0.5); else tmp = Float64(1.0 + Float64(Float64(Float64(l * l) / Float64(Float64(Float64(Om * Om) / ky) * Float64(1.0 / ky))) * -0.5)); 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.6e+131)
tmp = sqrt(0.5);
else
tmp = 1.0 + (((l * l) / (((Om * Om) / ky) * (1.0 / ky))) * -0.5);
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.6e+131], N[Sqrt[0.5], $MachinePrecision], N[(1.0 + N[(N[(N[(l * l), $MachinePrecision] / N[(N[(N[(Om * Om), $MachinePrecision] / ky), $MachinePrecision] * N[(1.0 / ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
kx = |kx|\\
ky = |ky|\\
[kx, ky] = \mathsf{sort}([kx, ky])\\
\\
\begin{array}{l}
\mathbf{if}\;Om \leq 2.6 \cdot 10^{+131}:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{\ell \cdot \ell}{\frac{Om \cdot Om}{ky} \cdot \frac{1}{ky}} \cdot -0.5\\
\end{array}
\end{array}
if Om < 2.6e131Initial program 99.1%
Simplified99.1%
Taylor expanded in Om around 0 60.6%
unpow260.6%
unpow260.6%
hypot-def61.5%
Simplified61.5%
Taylor expanded in l around inf 68.1%
if 2.6e131 < Om Initial program 99.9%
Simplified99.9%
Taylor expanded in kx around 0 89.7%
associate-/l*89.7%
unpow289.7%
unpow289.7%
Simplified89.7%
expm1-log1p-u89.7%
expm1-udef89.7%
Applied egg-rr100.0%
expm1-def99.9%
expm1-log1p99.9%
*-commutative99.9%
*-commutative99.9%
associate-*l*99.9%
Simplified99.9%
Taylor expanded in ky around 0 58.6%
*-commutative58.6%
associate-/l*62.1%
unpow262.1%
unpow262.1%
unpow262.1%
Simplified62.1%
associate-/r*89.7%
div-inv89.7%
Applied egg-rr89.7%
Final simplification70.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 2e+121) (+ 1.0 (* -0.5 (* (/ 1.0 (/ Om ky)) (/ (* l l) (/ Om ky))))) (+ 1.0 (* (/ (* l l) (* (/ (* Om Om) ky) (/ 1.0 ky))) -0.5))))
kx = abs(kx);
ky = abs(ky);
assert(kx < ky);
double code(double l, double Om, double kx, double ky) {
double tmp;
if (Om <= 2e+121) {
tmp = 1.0 + (-0.5 * ((1.0 / (Om / ky)) * ((l * l) / (Om / ky))));
} else {
tmp = 1.0 + (((l * l) / (((Om * Om) / ky) * (1.0 / ky))) * -0.5);
}
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 <= 2d+121) then
tmp = 1.0d0 + ((-0.5d0) * ((1.0d0 / (om / ky)) * ((l * l) / (om / ky))))
else
tmp = 1.0d0 + (((l * l) / (((om * om) / ky) * (1.0d0 / ky))) * (-0.5d0))
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 <= 2e+121) {
tmp = 1.0 + (-0.5 * ((1.0 / (Om / ky)) * ((l * l) / (Om / ky))));
} else {
tmp = 1.0 + (((l * l) / (((Om * Om) / ky) * (1.0 / ky))) * -0.5);
}
return tmp;
}
kx = abs(kx) ky = abs(ky) [kx, ky] = sort([kx, ky]) def code(l, Om, kx, ky): tmp = 0 if Om <= 2e+121: tmp = 1.0 + (-0.5 * ((1.0 / (Om / ky)) * ((l * l) / (Om / ky)))) else: tmp = 1.0 + (((l * l) / (((Om * Om) / ky) * (1.0 / ky))) * -0.5) return tmp
kx = abs(kx) ky = abs(ky) kx, ky = sort([kx, ky]) function code(l, Om, kx, ky) tmp = 0.0 if (Om <= 2e+121) tmp = Float64(1.0 + Float64(-0.5 * Float64(Float64(1.0 / Float64(Om / ky)) * Float64(Float64(l * l) / Float64(Om / ky))))); else tmp = Float64(1.0 + Float64(Float64(Float64(l * l) / Float64(Float64(Float64(Om * Om) / ky) * Float64(1.0 / ky))) * -0.5)); 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 <= 2e+121)
tmp = 1.0 + (-0.5 * ((1.0 / (Om / ky)) * ((l * l) / (Om / ky))));
else
tmp = 1.0 + (((l * l) / (((Om * Om) / ky) * (1.0 / ky))) * -0.5);
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, 2e+121], N[(1.0 + N[(-0.5 * N[(N[(1.0 / N[(Om / ky), $MachinePrecision]), $MachinePrecision] * N[(N[(l * l), $MachinePrecision] / N[(Om / ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(N[(l * l), $MachinePrecision] / N[(N[(N[(Om * Om), $MachinePrecision] / ky), $MachinePrecision] * N[(1.0 / ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
kx = |kx|\\
ky = |ky|\\
[kx, ky] = \mathsf{sort}([kx, ky])\\
\\
\begin{array}{l}
\mathbf{if}\;Om \leq 2 \cdot 10^{+121}:\\
\;\;\;\;1 + -0.5 \cdot \left(\frac{1}{\frac{Om}{ky}} \cdot \frac{\ell \cdot \ell}{\frac{Om}{ky}}\right)\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{\ell \cdot \ell}{\frac{Om \cdot Om}{ky} \cdot \frac{1}{ky}} \cdot -0.5\\
\end{array}
\end{array}
if Om < 2.00000000000000007e121Initial program 99.1%
Simplified99.1%
Taylor expanded in kx around 0 77.7%
associate-/l*77.7%
unpow277.7%
unpow277.7%
Simplified77.7%
expm1-log1p-u77.7%
expm1-udef77.7%
Applied egg-rr91.4%
expm1-def91.4%
expm1-log1p91.4%
*-commutative91.4%
*-commutative91.4%
associate-*l*91.4%
Simplified91.4%
Taylor expanded in ky around 0 24.1%
*-commutative24.1%
associate-/l*24.1%
unpow224.1%
unpow224.1%
unpow224.1%
Simplified24.1%
*-un-lft-identity24.1%
add-sqr-sqrt24.1%
times-frac24.1%
times-frac24.1%
sqrt-prod12.6%
add-sqr-sqrt24.8%
times-frac30.7%
sqrt-prod16.1%
add-sqr-sqrt33.2%
Applied egg-rr33.2%
if 2.00000000000000007e121 < Om Initial program 99.9%
Simplified99.9%
Taylor expanded in kx around 0 90.0%
associate-/l*90.0%
unpow290.0%
unpow290.0%
Simplified90.0%
expm1-log1p-u90.0%
expm1-udef90.0%
Applied egg-rr100.0%
expm1-def99.9%
expm1-log1p99.9%
*-commutative99.9%
*-commutative99.9%
associate-*l*99.9%
Simplified99.9%
Taylor expanded in ky around 0 60.0%
*-commutative60.0%
associate-/l*63.3%
unpow263.3%
unpow263.3%
unpow263.3%
Simplified63.3%
associate-/r*90.0%
div-inv90.0%
Applied egg-rr90.0%
Final simplification39.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 (+ 1.0 (* -0.5 (* l (* l (* (/ ky Om) (/ ky 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 * (l * (l * ((ky / Om) * (ky / 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) * (l * (l * ((ky / om) * (ky / 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 * (l * (l * ((ky / Om) * (ky / Om)))));
}
kx = abs(kx) ky = abs(ky) [kx, ky] = sort([kx, ky]) def code(l, Om, kx, ky): return 1.0 + (-0.5 * (l * (l * ((ky / Om) * (ky / 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(l * Float64(l * Float64(Float64(ky / Om) * Float64(ky / 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 * (l * (l * ((ky / Om) * (ky / 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[(l * N[(l * N[(N[(ky / Om), $MachinePrecision] * N[(ky / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
kx = |kx|\\
ky = |ky|\\
[kx, ky] = \mathsf{sort}([kx, ky])\\
\\
1 + -0.5 \cdot \left(\ell \cdot \left(\ell \cdot \left(\frac{ky}{Om} \cdot \frac{ky}{Om}\right)\right)\right)
\end{array}
Initial program 99.2%
Simplified99.2%
Taylor expanded in kx around 0 79.2%
associate-/l*79.2%
unpow279.2%
unpow279.2%
Simplified79.2%
expm1-log1p-u79.2%
expm1-udef79.2%
Applied egg-rr92.4%
expm1-def92.4%
expm1-log1p92.4%
*-commutative92.4%
*-commutative92.4%
associate-*l*92.4%
Simplified92.4%
Taylor expanded in ky around 0 28.3%
*-commutative28.3%
associate-/l*28.7%
unpow228.7%
unpow228.7%
unpow228.7%
Simplified28.7%
div-inv28.3%
clear-num28.3%
associate-*l*31.1%
times-frac37.6%
Applied egg-rr37.6%
Final simplification37.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 (let* ((t_0 (* (/ l Om) ky))) (+ 1.0 (* -0.5 (* t_0 t_0)))))
kx = abs(kx);
ky = abs(ky);
assert(kx < ky);
double code(double l, double Om, double kx, double ky) {
double t_0 = (l / Om) * ky;
return 1.0 + (-0.5 * (t_0 * t_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.
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) :: t_0
t_0 = (l / om) * ky
code = 1.0d0 + ((-0.5d0) * (t_0 * t_0))
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 t_0 = (l / Om) * ky;
return 1.0 + (-0.5 * (t_0 * t_0));
}
kx = abs(kx) ky = abs(ky) [kx, ky] = sort([kx, ky]) def code(l, Om, kx, ky): t_0 = (l / Om) * ky return 1.0 + (-0.5 * (t_0 * t_0))
kx = abs(kx) ky = abs(ky) kx, ky = sort([kx, ky]) function code(l, Om, kx, ky) t_0 = Float64(Float64(l / Om) * ky) return Float64(1.0 + Float64(-0.5 * Float64(t_0 * t_0))) end
kx = abs(kx)
ky = abs(ky)
kx, ky = num2cell(sort([kx, ky])){:}
function tmp = code(l, Om, kx, ky)
t_0 = (l / Om) * ky;
tmp = 1.0 + (-0.5 * (t_0 * t_0));
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_] := Block[{t$95$0 = N[(N[(l / Om), $MachinePrecision] * ky), $MachinePrecision]}, N[(1.0 + N[(-0.5 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
kx = |kx|\\
ky = |ky|\\
[kx, ky] = \mathsf{sort}([kx, ky])\\
\\
\begin{array}{l}
t_0 := \frac{\ell}{Om} \cdot ky\\
1 + -0.5 \cdot \left(t_0 \cdot t_0\right)
\end{array}
\end{array}
Initial program 99.2%
Simplified99.2%
Taylor expanded in kx around 0 79.2%
associate-/l*79.2%
unpow279.2%
unpow279.2%
Simplified79.2%
expm1-log1p-u79.2%
expm1-udef79.2%
Applied egg-rr92.4%
expm1-def92.4%
expm1-log1p92.4%
*-commutative92.4%
*-commutative92.4%
associate-*l*92.4%
Simplified92.4%
Taylor expanded in ky around 0 28.3%
*-commutative28.3%
associate-/l*28.7%
unpow228.7%
unpow228.7%
unpow228.7%
Simplified28.7%
add-sqr-sqrt28.7%
associate-/r/28.6%
sqrt-prod28.6%
frac-times28.6%
sqrt-unprod20.5%
add-sqr-sqrt29.1%
sqrt-prod12.8%
add-sqr-sqrt29.3%
associate-/r/30.0%
sqrt-prod30.0%
frac-times33.0%
sqrt-unprod22.7%
add-sqr-sqrt33.8%
sqrt-prod16.4%
add-sqr-sqrt39.1%
Applied egg-rr39.1%
Final simplification39.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 (+ 1.0 (* -0.5 (/ (* ky (/ (* l l) Om)) (/ Om ky)))))
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 * ((l * l) / Om)) / (Om / ky)));
}
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 * ((l * l) / om)) / (om / ky)))
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 * ((l * l) / Om)) / (Om / ky)));
}
kx = abs(kx) ky = abs(ky) [kx, ky] = sort([kx, ky]) def code(l, Om, kx, ky): return 1.0 + (-0.5 * ((ky * ((l * l) / Om)) / (Om / ky)))
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(Float64(l * l) / Om)) / Float64(Om / ky)))) 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 * ((l * l) / Om)) / (Om / ky)));
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[(N[(l * l), $MachinePrecision] / Om), $MachinePrecision]), $MachinePrecision] / N[(Om / ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
kx = |kx|\\
ky = |ky|\\
[kx, ky] = \mathsf{sort}([kx, ky])\\
\\
1 + -0.5 \cdot \frac{ky \cdot \frac{\ell \cdot \ell}{Om}}{\frac{Om}{ky}}
\end{array}
Initial program 99.2%
Simplified99.2%
Taylor expanded in kx around 0 79.2%
associate-/l*79.2%
unpow279.2%
unpow279.2%
Simplified79.2%
expm1-log1p-u79.2%
expm1-udef79.2%
Applied egg-rr92.4%
expm1-def92.4%
expm1-log1p92.4%
*-commutative92.4%
*-commutative92.4%
associate-*l*92.4%
Simplified92.4%
Taylor expanded in ky around 0 28.3%
*-commutative28.3%
associate-/l*28.7%
unpow228.7%
unpow228.7%
unpow228.7%
Simplified28.7%
*-un-lft-identity28.7%
add-sqr-sqrt28.7%
times-frac28.7%
times-frac28.7%
sqrt-prod14.2%
add-sqr-sqrt29.3%
times-frac36.5%
sqrt-prod17.8%
add-sqr-sqrt38.7%
Applied egg-rr38.7%
associate-*l/38.7%
*-lft-identity38.7%
unpow238.7%
associate-/r/38.6%
unpow238.6%
Simplified38.6%
Final simplification38.6%
herbie shell --seed 2023264
(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))))))))))