
(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 9 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}
(FPCore (l Om kx ky)
:precision binary64
(sqrt
(+
0.5
(*
0.5
(/ 1.0 (hypot 1.0 (* (hypot (sin kx) (sin ky)) (* 2.0 (/ l Om)))))))))
double code(double l, double Om, double kx, double ky) {
return sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, (hypot(sin(kx), sin(ky)) * (2.0 * (l / Om))))))));
}
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.hypot(Math.sin(kx), Math.sin(ky)) * (2.0 * (l / Om))))))));
}
def code(l, Om, kx, ky): return math.sqrt((0.5 + (0.5 * (1.0 / math.hypot(1.0, (math.hypot(math.sin(kx), math.sin(ky)) * (2.0 * (l / Om))))))))
function code(l, Om, kx, ky) return sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / hypot(1.0, Float64(hypot(sin(kx), sin(ky)) * Float64(2.0 * Float64(l / Om)))))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, (hypot(sin(kx), sin(ky)) * (2.0 * (l / Om)))))))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[Sqrt[1.0 ^ 2 + N[(N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision] * N[(2.0 * N[(l / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + 0.5 \cdot \frac{1}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin kx, \sin ky\right) \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)}}
\end{array}
Initial program 100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (l Om kx ky) :precision binary64 (if (<= kx 4.2e-199) (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* 2.0 (/ (* ky l) Om)))))) (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* (sin kx) (* 2.0 (/ l Om)))))))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (kx <= 4.2e-199) {
tmp = sqrt((0.5 + (0.5 / hypot(1.0, (2.0 * ((ky * l) / Om))))));
} else {
tmp = sqrt((0.5 + (0.5 / hypot(1.0, (sin(kx) * (2.0 * (l / Om)))))));
}
return tmp;
}
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if (kx <= 4.2e-199) {
tmp = Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, (2.0 * ((ky * l) / Om))))));
} else {
tmp = Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, (Math.sin(kx) * (2.0 * (l / Om)))))));
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if kx <= 4.2e-199: tmp = math.sqrt((0.5 + (0.5 / math.hypot(1.0, (2.0 * ((ky * l) / Om)))))) else: tmp = math.sqrt((0.5 + (0.5 / math.hypot(1.0, (math.sin(kx) * (2.0 * (l / Om))))))) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (kx <= 4.2e-199) tmp = sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(2.0 * Float64(Float64(ky * l) / Om)))))); else tmp = sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(sin(kx) * Float64(2.0 * Float64(l / Om))))))); end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (kx <= 4.2e-199) tmp = sqrt((0.5 + (0.5 / hypot(1.0, (2.0 * ((ky * l) / Om)))))); else tmp = sqrt((0.5 + (0.5 / hypot(1.0, (sin(kx) * (2.0 * (l / Om))))))); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[kx, 4.2e-199], N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(2.0 * N[(N[(ky * l), $MachinePrecision] / Om), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(N[Sin[kx], $MachinePrecision] * N[(2.0 * N[(l / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;kx \leq 4.2 \cdot 10^{-199}:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, 2 \cdot \frac{ky \cdot \ell}{Om}\right)}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \sin kx \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)}}\\
\end{array}
\end{array}
if kx < 4.20000000000000004e-199Initial program 100.0%
Simplified100.0%
Taylor expanded in kx around 0 76.5%
associate-*r/76.5%
associate-*r*76.5%
unpow276.5%
unpow276.5%
Simplified76.5%
add-sqr-sqrt76.5%
hypot-1-def76.5%
sqrt-div76.5%
*-commutative76.5%
sqrt-prod76.5%
unpow276.5%
sqrt-prod38.0%
add-sqr-sqrt85.6%
*-commutative85.6%
sqrt-prod85.6%
sqrt-prod40.4%
add-sqr-sqrt91.6%
metadata-eval91.6%
sqrt-prod40.2%
add-sqr-sqrt94.2%
Applied egg-rr94.2%
un-div-inv94.2%
associate-/l*94.2%
Applied egg-rr94.2%
Taylor expanded in ky around 0 82.8%
if 4.20000000000000004e-199 < kx Initial program 100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in ky around 0 98.3%
expm1-log1p-u97.6%
expm1-udef97.6%
un-div-inv97.6%
Applied egg-rr97.6%
expm1-def97.6%
expm1-log1p98.3%
Simplified98.3%
Final simplification89.7%
(FPCore (l Om kx ky) :precision binary64 (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (/ (sin ky) (/ Om (* 2.0 l))))))))
double code(double l, double Om, double kx, double ky) {
return sqrt((0.5 + (0.5 / hypot(1.0, (sin(ky) / (Om / (2.0 * l)))))));
}
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) / (Om / (2.0 * l)))))));
}
def code(l, Om, kx, ky): return math.sqrt((0.5 + (0.5 / math.hypot(1.0, (math.sin(ky) / (Om / (2.0 * l)))))))
function code(l, Om, kx, ky) return sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(sin(ky) / Float64(Om / Float64(2.0 * l))))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 / hypot(1.0, (sin(ky) / (Om / (2.0 * l))))))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(N[Sin[ky], $MachinePrecision] / N[(Om / N[(2.0 * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \frac{\sin ky}{\frac{Om}{2 \cdot \ell}}\right)}}
\end{array}
Initial program 100.0%
Simplified100.0%
Taylor expanded in kx around 0 74.2%
associate-*r/74.2%
associate-*r*74.2%
unpow274.2%
unpow274.2%
Simplified74.2%
add-sqr-sqrt74.2%
hypot-1-def74.2%
sqrt-div74.2%
*-commutative74.2%
sqrt-prod74.3%
unpow274.3%
sqrt-prod37.9%
add-sqr-sqrt81.8%
*-commutative81.8%
sqrt-prod81.8%
sqrt-prod39.8%
add-sqr-sqrt88.9%
metadata-eval88.9%
sqrt-prod43.7%
add-sqr-sqrt94.4%
Applied egg-rr94.4%
un-div-inv94.4%
associate-/l*94.4%
Applied egg-rr94.4%
Final simplification94.4%
(FPCore (l Om kx ky)
:precision binary64
(if (<= l 3.8e-159)
1.0
(if (or (<= l 7.9e-56) (not (<= l 2.9e-26)))
(sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* 2.0 (/ (* ky l) Om))))))
1.0)))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= 3.8e-159) {
tmp = 1.0;
} else if ((l <= 7.9e-56) || !(l <= 2.9e-26)) {
tmp = sqrt((0.5 + (0.5 / hypot(1.0, (2.0 * ((ky * l) / Om))))));
} else {
tmp = 1.0;
}
return tmp;
}
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= 3.8e-159) {
tmp = 1.0;
} else if ((l <= 7.9e-56) || !(l <= 2.9e-26)) {
tmp = Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, (2.0 * ((ky * l) / Om))))));
} else {
tmp = 1.0;
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if l <= 3.8e-159: tmp = 1.0 elif (l <= 7.9e-56) or not (l <= 2.9e-26): tmp = math.sqrt((0.5 + (0.5 / math.hypot(1.0, (2.0 * ((ky * l) / Om)))))) else: tmp = 1.0 return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (l <= 3.8e-159) tmp = 1.0; elseif ((l <= 7.9e-56) || !(l <= 2.9e-26)) tmp = sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(2.0 * Float64(Float64(ky * l) / Om)))))); else tmp = 1.0; end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (l <= 3.8e-159) tmp = 1.0; elseif ((l <= 7.9e-56) || ~((l <= 2.9e-26))) tmp = sqrt((0.5 + (0.5 / hypot(1.0, (2.0 * ((ky * l) / Om)))))); else tmp = 1.0; end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[l, 3.8e-159], 1.0, If[Or[LessEqual[l, 7.9e-56], N[Not[LessEqual[l, 2.9e-26]], $MachinePrecision]], N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(2.0 * N[(N[(ky * l), $MachinePrecision] / Om), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 3.8 \cdot 10^{-159}:\\
\;\;\;\;1\\
\mathbf{elif}\;\ell \leq 7.9 \cdot 10^{-56} \lor \neg \left(\ell \leq 2.9 \cdot 10^{-26}\right):\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, 2 \cdot \frac{ky \cdot \ell}{Om}\right)}}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if l < 3.8000000000000001e-159 or 7.90000000000000034e-56 < l < 2.8999999999999998e-26Initial program 100.0%
Simplified100.0%
Taylor expanded in kx around 0 75.5%
associate-*r/75.5%
associate-*r*75.5%
unpow275.5%
unpow275.5%
Simplified75.5%
add-sqr-sqrt75.5%
hypot-1-def75.5%
sqrt-div75.5%
*-commutative75.5%
sqrt-prod75.6%
unpow275.6%
sqrt-prod40.7%
add-sqr-sqrt80.7%
*-commutative80.7%
sqrt-prod80.7%
sqrt-prod16.9%
add-sqr-sqrt88.7%
metadata-eval88.7%
sqrt-prod47.8%
add-sqr-sqrt94.8%
Applied egg-rr94.8%
Taylor expanded in ky around 0 67.6%
if 3.8000000000000001e-159 < l < 7.90000000000000034e-56 or 2.8999999999999998e-26 < l Initial program 100.0%
Simplified100.0%
Taylor expanded in kx around 0 71.4%
associate-*r/71.4%
associate-*r*71.4%
unpow271.4%
unpow271.4%
Simplified71.4%
add-sqr-sqrt71.4%
hypot-1-def71.4%
sqrt-div71.4%
*-commutative71.4%
sqrt-prod71.4%
unpow271.4%
sqrt-prod31.7%
add-sqr-sqrt84.0%
*-commutative84.0%
sqrt-prod84.0%
sqrt-prod89.4%
add-sqr-sqrt89.4%
metadata-eval89.4%
sqrt-prod34.8%
add-sqr-sqrt93.6%
Applied egg-rr93.6%
un-div-inv93.6%
associate-/l*93.6%
Applied egg-rr93.6%
Taylor expanded in ky around 0 83.3%
Final simplification72.6%
(FPCore (l Om kx ky)
:precision binary64
(if (<= l 1.2e-26)
1.0
(if (<= l 1.8e+140)
(sqrt
(+
0.5
(* 0.5 (/ 1.0 (+ 1.0 (* 2.0 (/ (* ky ky) (/ (* Om Om) (* l l)))))))))
(sqrt 0.5))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= 1.2e-26) {
tmp = 1.0;
} else if (l <= 1.8e+140) {
tmp = sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((ky * ky) / ((Om * Om) / (l * l)))))))));
} else {
tmp = sqrt(0.5);
}
return tmp;
}
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 <= 1.2d-26) then
tmp = 1.0d0
else if (l <= 1.8d+140) then
tmp = sqrt((0.5d0 + (0.5d0 * (1.0d0 / (1.0d0 + (2.0d0 * ((ky * ky) / ((om * om) / (l * l)))))))))
else
tmp = sqrt(0.5d0)
end if
code = tmp
end function
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= 1.2e-26) {
tmp = 1.0;
} else if (l <= 1.8e+140) {
tmp = Math.sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((ky * ky) / ((Om * Om) / (l * l)))))))));
} else {
tmp = Math.sqrt(0.5);
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if l <= 1.2e-26: tmp = 1.0 elif l <= 1.8e+140: tmp = math.sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((ky * ky) / ((Om * Om) / (l * l))))))))) else: tmp = math.sqrt(0.5) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (l <= 1.2e-26) tmp = 1.0; elseif (l <= 1.8e+140) tmp = sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / Float64(1.0 + Float64(2.0 * Float64(Float64(ky * ky) / Float64(Float64(Om * Om) / Float64(l * l))))))))); else tmp = sqrt(0.5); end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (l <= 1.2e-26) tmp = 1.0; elseif (l <= 1.8e+140) tmp = sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((ky * ky) / ((Om * Om) / (l * l))))))))); else tmp = sqrt(0.5); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[l, 1.2e-26], 1.0, If[LessEqual[l, 1.8e+140], N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[(1.0 + N[(2.0 * N[(N[(ky * ky), $MachinePrecision] / N[(N[(Om * Om), $MachinePrecision] / N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[0.5], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 1.2 \cdot 10^{-26}:\\
\;\;\;\;1\\
\mathbf{elif}\;\ell \leq 1.8 \cdot 10^{+140}:\\
\;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{1 + 2 \cdot \frac{ky \cdot ky}{\frac{Om \cdot Om}{\ell \cdot \ell}}}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5}\\
\end{array}
\end{array}
if l < 1.2e-26Initial program 100.0%
Simplified100.0%
Taylor expanded in kx around 0 76.8%
associate-*r/76.8%
associate-*r*76.8%
unpow276.8%
unpow276.8%
Simplified76.8%
add-sqr-sqrt76.8%
hypot-1-def76.8%
sqrt-div76.8%
*-commutative76.8%
sqrt-prod76.9%
unpow276.9%
sqrt-prod38.8%
add-sqr-sqrt81.7%
*-commutative81.7%
sqrt-prod81.7%
sqrt-prod22.6%
add-sqr-sqrt89.1%
metadata-eval89.1%
sqrt-prod46.9%
add-sqr-sqrt95.2%
Applied egg-rr95.2%
Taylor expanded in ky around 0 68.7%
if 1.2e-26 < l < 1.8e140Initial program 100.0%
Simplified100.0%
Taylor expanded in kx around 0 89.8%
associate-*r/89.8%
associate-*r*89.8%
unpow289.8%
unpow289.8%
Simplified89.8%
Taylor expanded in ky around 0 79.5%
associate-/l*79.5%
unpow279.5%
unpow279.5%
unpow279.5%
Simplified79.5%
if 1.8e140 < l Initial program 100.0%
Simplified100.0%
Taylor expanded in Om around 0 82.3%
associate-*r*82.3%
unpow282.3%
unpow282.3%
hypot-def82.3%
*-commutative82.3%
Simplified82.3%
Taylor expanded in l around inf 84.9%
Final simplification72.3%
(FPCore (l Om kx ky) :precision binary64 (if (<= l 1.9e-24) (+ 1.0 (/ (* -0.5 (* kx kx)) (* (/ Om l) (/ Om l)))) (sqrt 0.5)))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= 1.9e-24) {
tmp = 1.0 + ((-0.5 * (kx * kx)) / ((Om / l) * (Om / l)));
} else {
tmp = sqrt(0.5);
}
return tmp;
}
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 <= 1.9d-24) then
tmp = 1.0d0 + (((-0.5d0) * (kx * kx)) / ((om / l) * (om / l)))
else
tmp = sqrt(0.5d0)
end if
code = tmp
end function
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= 1.9e-24) {
tmp = 1.0 + ((-0.5 * (kx * kx)) / ((Om / l) * (Om / l)));
} else {
tmp = Math.sqrt(0.5);
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if l <= 1.9e-24: tmp = 1.0 + ((-0.5 * (kx * kx)) / ((Om / l) * (Om / l))) else: tmp = math.sqrt(0.5) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (l <= 1.9e-24) tmp = Float64(1.0 + Float64(Float64(-0.5 * Float64(kx * kx)) / Float64(Float64(Om / l) * Float64(Om / l)))); else tmp = sqrt(0.5); end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (l <= 1.9e-24) tmp = 1.0 + ((-0.5 * (kx * kx)) / ((Om / l) * (Om / l))); else tmp = sqrt(0.5); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[l, 1.9e-24], N[(1.0 + N[(N[(-0.5 * N[(kx * kx), $MachinePrecision]), $MachinePrecision] / N[(N[(Om / l), $MachinePrecision] * N[(Om / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sqrt[0.5], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 1.9 \cdot 10^{-24}:\\
\;\;\;\;1 + \frac{-0.5 \cdot \left(kx \cdot kx\right)}{\frac{Om}{\ell} \cdot \frac{Om}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5}\\
\end{array}
\end{array}
if l < 1.90000000000000013e-24Initial program 100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in ky around 0 94.6%
Taylor expanded in kx around 0 37.1%
associate-/l*38.2%
unpow238.2%
unpow238.2%
unpow238.2%
Simplified38.2%
Taylor expanded in kx around 0 37.1%
metadata-eval37.1%
unpow237.1%
associate-/l*38.2%
unpow238.2%
unpow238.2%
times-frac45.4%
times-frac45.4%
*-lft-identity45.4%
Simplified45.4%
if 1.90000000000000013e-24 < l Initial program 100.0%
Simplified100.0%
Taylor expanded in Om around 0 68.8%
associate-*r*68.8%
unpow268.8%
unpow268.8%
hypot-def68.8%
*-commutative68.8%
Simplified68.8%
Taylor expanded in l around inf 74.4%
Final simplification53.0%
(FPCore (l Om kx ky) :precision binary64 (if (<= l 1.6e+32) 1.0 (sqrt 0.5)))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= 1.6e+32) {
tmp = 1.0;
} else {
tmp = sqrt(0.5);
}
return tmp;
}
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 <= 1.6d+32) then
tmp = 1.0d0
else
tmp = sqrt(0.5d0)
end if
code = tmp
end function
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= 1.6e+32) {
tmp = 1.0;
} else {
tmp = Math.sqrt(0.5);
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if l <= 1.6e+32: tmp = 1.0 else: tmp = math.sqrt(0.5) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (l <= 1.6e+32) tmp = 1.0; else tmp = sqrt(0.5); end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (l <= 1.6e+32) tmp = 1.0; else tmp = sqrt(0.5); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[l, 1.6e+32], 1.0, N[Sqrt[0.5], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 1.6 \cdot 10^{+32}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5}\\
\end{array}
\end{array}
if l < 1.5999999999999999e32Initial program 100.0%
Simplified100.0%
Taylor expanded in kx around 0 77.5%
associate-*r/77.5%
associate-*r*77.5%
unpow277.5%
unpow277.5%
Simplified77.5%
add-sqr-sqrt77.5%
hypot-1-def77.5%
sqrt-div77.5%
*-commutative77.5%
sqrt-prod77.6%
unpow277.6%
sqrt-prod39.6%
add-sqr-sqrt82.7%
*-commutative82.7%
sqrt-prod82.7%
sqrt-prod26.9%
add-sqr-sqrt89.7%
metadata-eval89.7%
sqrt-prod45.4%
add-sqr-sqrt95.1%
Applied egg-rr95.1%
Taylor expanded in ky around 0 68.5%
if 1.5999999999999999e32 < l Initial program 100.0%
Simplified100.0%
Taylor expanded in Om around 0 73.3%
associate-*r*73.3%
unpow273.3%
unpow273.3%
hypot-def73.3%
*-commutative73.3%
Simplified73.3%
Taylor expanded in l around inf 77.9%
Final simplification70.5%
(FPCore (l Om kx ky) :precision binary64 (+ 1.0 (* -0.5 (* (* l l) (* (/ kx Om) (/ kx Om))))))
double code(double l, double Om, double kx, double ky) {
return 1.0 + (-0.5 * ((l * l) * ((kx / Om) * (kx / Om))));
}
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) * ((kx / om) * (kx / om))))
end function
public static double code(double l, double Om, double kx, double ky) {
return 1.0 + (-0.5 * ((l * l) * ((kx / Om) * (kx / Om))));
}
def code(l, Om, kx, ky): return 1.0 + (-0.5 * ((l * l) * ((kx / Om) * (kx / Om))))
function code(l, Om, kx, ky) return Float64(1.0 + Float64(-0.5 * Float64(Float64(l * l) * Float64(Float64(kx / Om) * Float64(kx / Om))))) end
function tmp = code(l, Om, kx, ky) tmp = 1.0 + (-0.5 * ((l * l) * ((kx / Om) * (kx / Om)))); end
code[l_, Om_, kx_, ky_] := N[(1.0 + N[(-0.5 * N[(N[(l * l), $MachinePrecision] * N[(N[(kx / Om), $MachinePrecision] * N[(kx / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + -0.5 \cdot \left(\left(\ell \cdot \ell\right) \cdot \left(\frac{kx}{Om} \cdot \frac{kx}{Om}\right)\right)
\end{array}
Initial program 100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in ky around 0 94.6%
Taylor expanded in kx around 0 31.6%
associate-/l*32.7%
unpow232.7%
unpow232.7%
unpow232.7%
Simplified32.7%
Taylor expanded in kx around 0 31.6%
unpow231.6%
associate-*l/30.5%
unpow230.5%
*-commutative30.5%
unpow230.5%
times-frac35.2%
Simplified35.2%
Final simplification35.2%
(FPCore (l Om kx ky) :precision binary64 (+ 1.0 (/ (* -0.5 (* kx kx)) (* (/ Om l) (/ Om l)))))
double code(double l, double Om, double kx, double ky) {
return 1.0 + ((-0.5 * (kx * kx)) / ((Om / l) * (Om / l)));
}
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) * (kx * kx)) / ((om / l) * (om / l)))
end function
public static double code(double l, double Om, double kx, double ky) {
return 1.0 + ((-0.5 * (kx * kx)) / ((Om / l) * (Om / l)));
}
def code(l, Om, kx, ky): return 1.0 + ((-0.5 * (kx * kx)) / ((Om / l) * (Om / l)))
function code(l, Om, kx, ky) return Float64(1.0 + Float64(Float64(-0.5 * Float64(kx * kx)) / Float64(Float64(Om / l) * Float64(Om / l)))) end
function tmp = code(l, Om, kx, ky) tmp = 1.0 + ((-0.5 * (kx * kx)) / ((Om / l) * (Om / l))); end
code[l_, Om_, kx_, ky_] := N[(1.0 + N[(N[(-0.5 * N[(kx * kx), $MachinePrecision]), $MachinePrecision] / N[(N[(Om / l), $MachinePrecision] * N[(Om / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{-0.5 \cdot \left(kx \cdot kx\right)}{\frac{Om}{\ell} \cdot \frac{Om}{\ell}}
\end{array}
Initial program 100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in ky around 0 94.6%
Taylor expanded in kx around 0 31.6%
associate-/l*32.7%
unpow232.7%
unpow232.7%
unpow232.7%
Simplified32.7%
Taylor expanded in kx around 0 31.6%
metadata-eval31.6%
unpow231.6%
associate-/l*32.7%
unpow232.7%
unpow232.7%
times-frac39.2%
times-frac39.2%
*-lft-identity39.2%
Simplified39.2%
Final simplification39.2%
herbie shell --seed 2023275
(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))))))))))