
(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 (/ 1.0 (hypot 1.0 (* 2.0 (* (/ l Om) (sin ky)))))))))
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, (2.0 * ((l / Om) * sin(ky))))))));
}
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, (2.0 * ((l / Om) * Math.sin(ky))))))));
}
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, (2.0 * ((l / Om) * math.sin(ky))))))))
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(2.0 * Float64(Float64(l / Om) * sin(ky)))))))) 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, (2.0 * ((l / Om) * sin(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[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[Sqrt[1.0 ^ 2 + N[(2.0 * N[(N[(l / Om), $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $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, 2 \cdot \left(\frac{\ell}{Om} \cdot \sin ky\right)\right)}}
\end{array}
Initial program 98.4%
distribute-rgt-in98.4%
metadata-eval98.4%
metadata-eval98.4%
associate-/l*98.4%
metadata-eval98.4%
Simplified98.4%
Taylor expanded in kx around 0 76.3%
associate-/l*75.6%
associate-/r/76.6%
unpow276.6%
unpow276.6%
times-frac89.0%
Simplified89.0%
add-sqr-sqrt89.0%
hypot-1-def89.0%
sqrt-prod89.0%
metadata-eval89.0%
sqrt-prod89.0%
sqrt-prod48.1%
add-sqr-sqrt89.7%
unpow289.7%
sqrt-prod47.3%
add-sqr-sqrt94.6%
Applied egg-rr94.6%
Final simplification94.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 4.8e-154)
(sqrt 0.5)
(if (<= Om 3.6e+149)
(sqrt
(+
0.5
(*
0.5
(/
1.0
(+
1.0
(*
2.0
(/ (+ 0.5 (* (cos (* 2.0 ky)) -0.5)) (/ (* Om Om) (* l l)))))))))
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 <= 4.8e-154) {
tmp = sqrt(0.5);
} else if (Om <= 3.6e+149) {
tmp = sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((0.5 + (cos((2.0 * ky)) * -0.5)) / ((Om * Om) / (l * l)))))))));
} 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 <= 4.8d-154) then
tmp = sqrt(0.5d0)
else if (om <= 3.6d+149) then
tmp = sqrt((0.5d0 + (0.5d0 * (1.0d0 / (1.0d0 + (2.0d0 * ((0.5d0 + (cos((2.0d0 * ky)) * (-0.5d0))) / ((om * om) / (l * l)))))))))
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 <= 4.8e-154) {
tmp = Math.sqrt(0.5);
} else if (Om <= 3.6e+149) {
tmp = Math.sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((0.5 + (Math.cos((2.0 * ky)) * -0.5)) / ((Om * Om) / (l * l)))))))));
} 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 <= 4.8e-154: tmp = math.sqrt(0.5) elif Om <= 3.6e+149: tmp = math.sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((0.5 + (math.cos((2.0 * ky)) * -0.5)) / ((Om * Om) / (l * l))))))))) 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 <= 4.8e-154) tmp = sqrt(0.5); elseif (Om <= 3.6e+149) tmp = sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / Float64(1.0 + Float64(2.0 * Float64(Float64(0.5 + Float64(cos(Float64(2.0 * ky)) * -0.5)) / Float64(Float64(Om * Om) / Float64(l * l))))))))); 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 <= 4.8e-154)
tmp = sqrt(0.5);
elseif (Om <= 3.6e+149)
tmp = sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((0.5 + (cos((2.0 * ky)) * -0.5)) / ((Om * Om) / (l * l)))))))));
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, 4.8e-154], N[Sqrt[0.5], $MachinePrecision], If[LessEqual[Om, 3.6e+149], N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[(1.0 + N[(2.0 * N[(N[(0.5 + N[(N[Cos[N[(2.0 * ky), $MachinePrecision]], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] / N[(N[(Om * Om), $MachinePrecision] / N[(l * l), $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 4.8 \cdot 10^{-154}:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{elif}\;Om \leq 3.6 \cdot 10^{+149}:\\
\;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{1 + 2 \cdot \frac{0.5 + \cos \left(2 \cdot ky\right) \cdot -0.5}{\frac{Om \cdot Om}{\ell \cdot \ell}}}}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if Om < 4.79999999999999974e-154Initial program 98.1%
distribute-rgt-in98.1%
metadata-eval98.1%
metadata-eval98.1%
associate-/l*98.1%
metadata-eval98.1%
Simplified98.1%
Taylor expanded in Om around 0 51.3%
associate-*r*51.3%
*-commutative51.3%
associate-*r*51.3%
unpow251.3%
unpow251.3%
hypot-def53.3%
Simplified53.3%
Taylor expanded in l around inf 60.8%
if 4.79999999999999974e-154 < Om < 3.59999999999999995e149Initial program 98.6%
distribute-rgt-in98.6%
metadata-eval98.6%
metadata-eval98.6%
associate-/l*98.6%
metadata-eval98.6%
Simplified98.6%
Taylor expanded in kx around 0 92.9%
associate-/l*90.0%
associate-/r/92.9%
unpow292.9%
unpow292.9%
times-frac92.0%
Simplified92.0%
unpow292.0%
sin-mult82.2%
cos-sum82.2%
cos-282.2%
Applied egg-rr82.2%
div-sub82.2%
+-inverses82.2%
cos-082.2%
metadata-eval82.2%
Simplified82.2%
Taylor expanded in l around 0 81.8%
associate-/l*81.8%
sub-neg81.8%
*-commutative81.8%
distribute-rgt-neg-in81.8%
metadata-eval81.8%
unpow281.8%
unpow281.8%
Simplified81.8%
if 3.59999999999999995e149 < 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 69.7%
associate-/l*69.7%
associate-/r/69.7%
unpow269.7%
unpow269.7%
times-frac97.6%
Simplified97.6%
add-sqr-sqrt97.6%
hypot-1-def97.6%
sqrt-prod97.6%
metadata-eval97.6%
sqrt-prod97.6%
sqrt-prod58.2%
add-sqr-sqrt97.6%
unpow297.6%
sqrt-prod57.6%
add-sqr-sqrt97.6%
Applied egg-rr97.6%
Taylor expanded in l around 0 90.3%
Final simplification70.3%
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 (<= l 9.5e-31)
1.0
(if (<= l 28000000.0)
(sqrt (+ 0.5 (* 0.25 (/ Om (* l ky)))))
(if (<= l 9.8e+119) 1.0 (sqrt 0.5)))))kx = abs(kx);
ky = abs(ky);
assert(kx < ky);
double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= 9.5e-31) {
tmp = 1.0;
} else if (l <= 28000000.0) {
tmp = sqrt((0.5 + (0.25 * (Om / (l * ky)))));
} else if (l <= 9.8e+119) {
tmp = 1.0;
} else {
tmp = sqrt(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 (l <= 9.5d-31) then
tmp = 1.0d0
else if (l <= 28000000.0d0) then
tmp = sqrt((0.5d0 + (0.25d0 * (om / (l * ky)))))
else if (l <= 9.8d+119) then
tmp = 1.0d0
else
tmp = sqrt(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 (l <= 9.5e-31) {
tmp = 1.0;
} else if (l <= 28000000.0) {
tmp = Math.sqrt((0.5 + (0.25 * (Om / (l * ky)))));
} else if (l <= 9.8e+119) {
tmp = 1.0;
} else {
tmp = Math.sqrt(0.5);
}
return tmp;
}
kx = abs(kx) ky = abs(ky) [kx, ky] = sort([kx, ky]) def code(l, Om, kx, ky): tmp = 0 if l <= 9.5e-31: tmp = 1.0 elif l <= 28000000.0: tmp = math.sqrt((0.5 + (0.25 * (Om / (l * ky))))) elif l <= 9.8e+119: tmp = 1.0 else: tmp = math.sqrt(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 (l <= 9.5e-31) tmp = 1.0; elseif (l <= 28000000.0) tmp = sqrt(Float64(0.5 + Float64(0.25 * Float64(Om / Float64(l * ky))))); elseif (l <= 9.8e+119) tmp = 1.0; else tmp = sqrt(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 (l <= 9.5e-31)
tmp = 1.0;
elseif (l <= 28000000.0)
tmp = sqrt((0.5 + (0.25 * (Om / (l * ky)))));
elseif (l <= 9.8e+119)
tmp = 1.0;
else
tmp = sqrt(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[l, 9.5e-31], 1.0, If[LessEqual[l, 28000000.0], N[Sqrt[N[(0.5 + N[(0.25 * N[(Om / N[(l * ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[l, 9.8e+119], 1.0, N[Sqrt[0.5], $MachinePrecision]]]]
\begin{array}{l}
kx = |kx|\\
ky = |ky|\\
[kx, ky] = \mathsf{sort}([kx, ky])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 9.5 \cdot 10^{-31}:\\
\;\;\;\;1\\
\mathbf{elif}\;\ell \leq 28000000:\\
\;\;\;\;\sqrt{0.5 + 0.25 \cdot \frac{Om}{\ell \cdot ky}}\\
\mathbf{elif}\;\ell \leq 9.8 \cdot 10^{+119}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5}\\
\end{array}
\end{array}
if l < 9.5000000000000008e-31 or 2.8e7 < l < 9.79999999999999992e119Initial program 98.1%
distribute-rgt-in98.1%
metadata-eval98.1%
metadata-eval98.1%
associate-/l*98.1%
metadata-eval98.1%
Simplified98.1%
Taylor expanded in kx around 0 77.9%
associate-/l*78.4%
associate-/r/78.3%
unpow278.3%
unpow278.3%
times-frac90.1%
Simplified90.1%
add-sqr-sqrt90.1%
hypot-1-def90.1%
sqrt-prod90.1%
metadata-eval90.1%
sqrt-prod90.1%
sqrt-prod50.6%
add-sqr-sqrt90.7%
unpow290.7%
sqrt-prod46.1%
add-sqr-sqrt95.1%
Applied egg-rr95.1%
Taylor expanded in l around 0 70.8%
if 9.5000000000000008e-31 < l < 2.8e7Initial 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 Om around 0 100.0%
associate-*r*100.0%
*-commutative100.0%
associate-*r*100.0%
unpow2100.0%
unpow2100.0%
hypot-def100.0%
Simplified100.0%
Taylor expanded in kx around 0 98.4%
+-commutative98.4%
Simplified98.4%
Taylor expanded in ky around 0 98.4%
if 9.79999999999999992e119 < l 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 Om around 0 81.9%
associate-*r*81.9%
*-commutative81.9%
associate-*r*81.9%
unpow281.9%
unpow281.9%
hypot-def81.9%
Simplified81.9%
Taylor expanded in l around inf 84.2%
Final simplification73.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 (<= l 9e-31) 1.0 (if (<= l 50000000.0) (sqrt 0.5) (if (<= l 9.8e+119) 1.0 (sqrt 0.5)))))
kx = abs(kx);
ky = abs(ky);
assert(kx < ky);
double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= 9e-31) {
tmp = 1.0;
} else if (l <= 50000000.0) {
tmp = sqrt(0.5);
} else if (l <= 9.8e+119) {
tmp = 1.0;
} else {
tmp = sqrt(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 (l <= 9d-31) then
tmp = 1.0d0
else if (l <= 50000000.0d0) then
tmp = sqrt(0.5d0)
else if (l <= 9.8d+119) then
tmp = 1.0d0
else
tmp = sqrt(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 (l <= 9e-31) {
tmp = 1.0;
} else if (l <= 50000000.0) {
tmp = Math.sqrt(0.5);
} else if (l <= 9.8e+119) {
tmp = 1.0;
} else {
tmp = Math.sqrt(0.5);
}
return tmp;
}
kx = abs(kx) ky = abs(ky) [kx, ky] = sort([kx, ky]) def code(l, Om, kx, ky): tmp = 0 if l <= 9e-31: tmp = 1.0 elif l <= 50000000.0: tmp = math.sqrt(0.5) elif l <= 9.8e+119: tmp = 1.0 else: tmp = math.sqrt(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 (l <= 9e-31) tmp = 1.0; elseif (l <= 50000000.0) tmp = sqrt(0.5); elseif (l <= 9.8e+119) tmp = 1.0; else tmp = sqrt(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 (l <= 9e-31)
tmp = 1.0;
elseif (l <= 50000000.0)
tmp = sqrt(0.5);
elseif (l <= 9.8e+119)
tmp = 1.0;
else
tmp = sqrt(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[l, 9e-31], 1.0, If[LessEqual[l, 50000000.0], N[Sqrt[0.5], $MachinePrecision], If[LessEqual[l, 9.8e+119], 1.0, N[Sqrt[0.5], $MachinePrecision]]]]
\begin{array}{l}
kx = |kx|\\
ky = |ky|\\
[kx, ky] = \mathsf{sort}([kx, ky])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 9 \cdot 10^{-31}:\\
\;\;\;\;1\\
\mathbf{elif}\;\ell \leq 50000000:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{elif}\;\ell \leq 9.8 \cdot 10^{+119}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5}\\
\end{array}
\end{array}
if l < 9.0000000000000008e-31 or 5e7 < l < 9.79999999999999992e119Initial program 98.1%
distribute-rgt-in98.1%
metadata-eval98.1%
metadata-eval98.1%
associate-/l*98.1%
metadata-eval98.1%
Simplified98.1%
Taylor expanded in kx around 0 77.9%
associate-/l*78.4%
associate-/r/78.3%
unpow278.3%
unpow278.3%
times-frac90.1%
Simplified90.1%
add-sqr-sqrt90.1%
hypot-1-def90.1%
sqrt-prod90.1%
metadata-eval90.1%
sqrt-prod90.1%
sqrt-prod50.6%
add-sqr-sqrt90.7%
unpow290.7%
sqrt-prod46.1%
add-sqr-sqrt95.1%
Applied egg-rr95.1%
Taylor expanded in l around 0 70.8%
if 9.0000000000000008e-31 < l < 5e7 or 9.79999999999999992e119 < l 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 Om around 0 84.1%
associate-*r*84.1%
*-commutative84.1%
associate-*r*84.1%
unpow284.1%
unpow284.1%
hypot-def84.1%
Simplified84.1%
Taylor expanded in l around inf 86.2%
Final simplification73.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 (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 98.4%
distribute-rgt-in98.4%
metadata-eval98.4%
metadata-eval98.4%
associate-/l*98.4%
metadata-eval98.4%
Simplified98.4%
Taylor expanded in Om around 0 44.1%
associate-*r*44.1%
*-commutative44.1%
associate-*r*44.1%
unpow244.1%
unpow244.1%
hypot-def45.7%
Simplified45.7%
Taylor expanded in l around inf 54.6%
Final simplification54.6%
herbie shell --seed 2023240
(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))))))))))