
(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}
(FPCore (l Om kx ky) :precision binary64 (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* (hypot (sin ky) (sin kx)) (* 2.0 (/ l Om))))))))
double code(double l, double Om, double kx, double ky) {
return sqrt((0.5 + (0.5 / hypot(1.0, (hypot(sin(ky), sin(kx)) * (2.0 * (l / Om)))))));
}
public static double code(double l, double Om, double kx, double ky) {
return Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, (Math.hypot(Math.sin(ky), Math.sin(kx)) * (2.0 * (l / Om)))))));
}
def code(l, Om, kx, ky): return math.sqrt((0.5 + (0.5 / math.hypot(1.0, (math.hypot(math.sin(ky), math.sin(kx)) * (2.0 * (l / Om)))))))
function code(l, Om, kx, ky) return sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(hypot(sin(ky), sin(kx)) * Float64(2.0 * Float64(l / Om))))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 / hypot(1.0, (hypot(sin(ky), sin(kx)) * (2.0 * (l / Om))))))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision] * N[(2.0 * N[(l / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)}}
\end{array}
Initial program 97.7%
Simplified97.7%
expm1-log1p-u97.7%
expm1-udef97.6%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
un-div-inv100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
hypot-def99.4%
unpow299.4%
unpow299.4%
+-commutative99.4%
unpow299.4%
unpow299.4%
hypot-def100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (l Om kx ky) :precision binary64 (if (<= ky 8.2e+94) (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 (ky <= 8.2e+94) {
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 (ky <= 8.2e+94) {
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 ky <= 8.2e+94: 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 (ky <= 8.2e+94) 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 (ky <= 8.2e+94) 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[ky, 8.2e+94], 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}\;ky \leq 8.2 \cdot 10^{+94}:\\
\;\;\;\;\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 ky < 8.20000000000000061e94Initial program 97.2%
Simplified97.2%
expm1-log1p-u97.2%
expm1-udef97.2%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
un-div-inv100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
hypot-def99.3%
unpow299.3%
unpow299.3%
+-commutative99.3%
unpow299.3%
unpow299.3%
hypot-def100.0%
Simplified100.0%
Taylor expanded in kx around 0 93.2%
Taylor expanded in ky around 0 86.3%
if 8.20000000000000061e94 < ky 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%
expm1-log1p-u100.0%
expm1-udef100.0%
un-div-inv100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
hypot-def100.0%
unpow2100.0%
unpow2100.0%
+-commutative100.0%
unpow2100.0%
unpow2100.0%
hypot-def100.0%
Simplified100.0%
Taylor expanded in ky around 0 92.1%
*-commutative92.1%
*-commutative92.1%
associate-*r/92.1%
associate-*l*92.1%
*-commutative92.1%
Simplified92.1%
Final simplification87.2%
(FPCore (l Om kx ky) :precision binary64 (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* (sin ky) (* 2.0 (/ l Om))))))))
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)))))));
}
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)))))));
}
def code(l, Om, kx, ky): return math.sqrt((0.5 + (0.5 / math.hypot(1.0, (math.sin(ky) * (2.0 * (l / Om)))))))
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
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 / hypot(1.0, (sin(ky) * (2.0 * (l / Om))))))); 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[(2.0 * N[(l / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\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 97.7%
Simplified97.7%
expm1-log1p-u97.7%
expm1-udef97.6%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
un-div-inv100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
hypot-def99.4%
unpow299.4%
unpow299.4%
+-commutative99.4%
unpow299.4%
unpow299.4%
hypot-def100.0%
Simplified100.0%
Taylor expanded in kx around 0 94.0%
Final simplification94.0%
(FPCore (l Om kx ky)
:precision binary64
(if (<= l 6.6e-62)
1.0
(if (<= l 1e+24)
(sqrt
(+
0.5
(* 0.5 (/ 1.0 (+ 1.0 (* 2.0 (/ (* ky l) (* (/ Om l) (/ Om ky)))))))))
(if (<= l 2.5e+34)
1.0
(sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* 2.0 (/ (* ky l) Om))))))))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= 6.6e-62) {
tmp = 1.0;
} else if (l <= 1e+24) {
tmp = sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((ky * l) / ((Om / l) * (Om / ky)))))))));
} else if (l <= 2.5e+34) {
tmp = 1.0;
} else {
tmp = sqrt((0.5 + (0.5 / hypot(1.0, (2.0 * ((ky * l) / Om))))));
}
return tmp;
}
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= 6.6e-62) {
tmp = 1.0;
} else if (l <= 1e+24) {
tmp = Math.sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((ky * l) / ((Om / l) * (Om / ky)))))))));
} else if (l <= 2.5e+34) {
tmp = 1.0;
} else {
tmp = Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, (2.0 * ((ky * l) / Om))))));
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if l <= 6.6e-62: tmp = 1.0 elif l <= 1e+24: tmp = math.sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((ky * l) / ((Om / l) * (Om / ky))))))))) elif l <= 2.5e+34: tmp = 1.0 else: tmp = math.sqrt((0.5 + (0.5 / math.hypot(1.0, (2.0 * ((ky * l) / Om)))))) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (l <= 6.6e-62) tmp = 1.0; elseif (l <= 1e+24) tmp = sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / Float64(1.0 + Float64(2.0 * Float64(Float64(ky * l) / Float64(Float64(Om / l) * Float64(Om / ky))))))))); elseif (l <= 2.5e+34) tmp = 1.0; else tmp = sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(2.0 * Float64(Float64(ky * l) / Om)))))); end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (l <= 6.6e-62) tmp = 1.0; elseif (l <= 1e+24) tmp = sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((ky * l) / ((Om / l) * (Om / ky))))))))); elseif (l <= 2.5e+34) tmp = 1.0; else tmp = sqrt((0.5 + (0.5 / hypot(1.0, (2.0 * ((ky * l) / Om)))))); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[l, 6.6e-62], 1.0, If[LessEqual[l, 1e+24], N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[(1.0 + N[(2.0 * N[(N[(ky * l), $MachinePrecision] / N[(N[(Om / l), $MachinePrecision] * N[(Om / ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[l, 2.5e+34], 1.0, 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]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 6.6 \cdot 10^{-62}:\\
\;\;\;\;1\\
\mathbf{elif}\;\ell \leq 10^{+24}:\\
\;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{1 + 2 \cdot \frac{ky \cdot \ell}{\frac{Om}{\ell} \cdot \frac{Om}{ky}}}}\\
\mathbf{elif}\;\ell \leq 2.5 \cdot 10^{+34}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, 2 \cdot \frac{ky \cdot \ell}{Om}\right)}}\\
\end{array}
\end{array}
if l < 6.60000000000000009e-62 or 9.9999999999999998e23 < l < 2.4999999999999999e34Initial program 99.0%
Simplified99.0%
expm1-log1p-u99.0%
expm1-udef99.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
un-div-inv100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
hypot-def99.7%
unpow299.7%
unpow299.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-def100.0%
Simplified100.0%
Taylor expanded in kx around 0 93.6%
Taylor expanded in ky around 0 72.3%
if 6.60000000000000009e-62 < l < 9.9999999999999998e23Initial program 100.0%
Simplified100.0%
Taylor expanded in kx around 0 98.1%
associate-*r/98.1%
associate-*r*98.1%
unpow298.1%
unpow298.1%
Simplified98.1%
Taylor expanded in ky around 0 100.0%
*-commutative100.0%
unpow2100.0%
times-frac100.0%
unpow2100.0%
associate-/l*100.0%
unpow2100.0%
Simplified100.0%
associate-/l*100.0%
frac-times100.0%
Applied egg-rr100.0%
if 2.4999999999999999e34 < l Initial program 92.3%
Simplified92.3%
expm1-log1p-u92.3%
expm1-udef92.3%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
un-div-inv100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
hypot-def98.1%
unpow298.1%
unpow298.1%
+-commutative98.1%
unpow298.1%
unpow298.1%
hypot-def100.0%
Simplified100.0%
Taylor expanded in kx around 0 94.5%
Taylor expanded in ky around 0 89.1%
Final simplification76.7%
(FPCore (l Om kx ky)
:precision binary64
(if (<= l 1.1e-61)
1.0
(if (or (<= l 1.3e+24) (not (<= l 4e+34)))
(sqrt
(+
0.5
(* 0.5 (/ 1.0 (+ 1.0 (* 2.0 (/ (* ky l) (* (/ Om l) (/ Om ky)))))))))
1.0)))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= 1.1e-61) {
tmp = 1.0;
} else if ((l <= 1.3e+24) || !(l <= 4e+34)) {
tmp = sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((ky * l) / ((Om / l) * (Om / ky)))))))));
} else {
tmp = 1.0;
}
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.1d-61) then
tmp = 1.0d0
else if ((l <= 1.3d+24) .or. (.not. (l <= 4d+34))) then
tmp = sqrt((0.5d0 + (0.5d0 * (1.0d0 / (1.0d0 + (2.0d0 * ((ky * l) / ((om / l) * (om / ky)))))))))
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= 1.1e-61) {
tmp = 1.0;
} else if ((l <= 1.3e+24) || !(l <= 4e+34)) {
tmp = Math.sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((ky * l) / ((Om / l) * (Om / ky)))))))));
} else {
tmp = 1.0;
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if l <= 1.1e-61: tmp = 1.0 elif (l <= 1.3e+24) or not (l <= 4e+34): tmp = math.sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((ky * l) / ((Om / l) * (Om / ky))))))))) else: tmp = 1.0 return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (l <= 1.1e-61) tmp = 1.0; elseif ((l <= 1.3e+24) || !(l <= 4e+34)) tmp = sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / Float64(1.0 + Float64(2.0 * Float64(Float64(ky * l) / Float64(Float64(Om / l) * Float64(Om / ky))))))))); else tmp = 1.0; end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (l <= 1.1e-61) tmp = 1.0; elseif ((l <= 1.3e+24) || ~((l <= 4e+34))) tmp = sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((ky * l) / ((Om / l) * (Om / ky))))))))); else tmp = 1.0; end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[l, 1.1e-61], 1.0, If[Or[LessEqual[l, 1.3e+24], N[Not[LessEqual[l, 4e+34]], $MachinePrecision]], N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[(1.0 + N[(2.0 * N[(N[(ky * l), $MachinePrecision] / N[(N[(Om / l), $MachinePrecision] * N[(Om / ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 1.1 \cdot 10^{-61}:\\
\;\;\;\;1\\
\mathbf{elif}\;\ell \leq 1.3 \cdot 10^{+24} \lor \neg \left(\ell \leq 4 \cdot 10^{+34}\right):\\
\;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{1 + 2 \cdot \frac{ky \cdot \ell}{\frac{Om}{\ell} \cdot \frac{Om}{ky}}}}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if l < 1.10000000000000004e-61 or 1.2999999999999999e24 < l < 3.99999999999999978e34Initial program 99.0%
Simplified99.0%
expm1-log1p-u99.0%
expm1-udef99.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
un-div-inv100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
hypot-def99.7%
unpow299.7%
unpow299.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-def100.0%
Simplified100.0%
Taylor expanded in kx around 0 93.6%
Taylor expanded in ky around 0 72.3%
if 1.10000000000000004e-61 < l < 1.2999999999999999e24 or 3.99999999999999978e34 < l Initial program 93.4%
Simplified93.4%
Taylor expanded in kx around 0 65.6%
associate-*r/65.6%
associate-*r*65.6%
unpow265.6%
unpow265.6%
Simplified65.6%
Taylor expanded in ky around 0 61.6%
*-commutative61.6%
unpow261.6%
times-frac70.7%
unpow270.7%
associate-/l*75.6%
unpow275.6%
Simplified75.6%
associate-/l*80.6%
frac-times90.7%
Applied egg-rr90.7%
Final simplification76.7%
(FPCore (l Om kx ky)
:precision binary64
(if (<= l 7.6e+34)
1.0
(sqrt
(+
0.5
(* 0.5 (/ 1.0 (+ 1.0 (* 2.0 (* (/ l (/ Om l)) (/ (* ky ky) Om))))))))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= 7.6e+34) {
tmp = 1.0;
} else {
tmp = sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((l / (Om / l)) * ((ky * ky) / Om))))))));
}
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 <= 7.6d+34) then
tmp = 1.0d0
else
tmp = sqrt((0.5d0 + (0.5d0 * (1.0d0 / (1.0d0 + (2.0d0 * ((l / (om / l)) * ((ky * ky) / om))))))))
end if
code = tmp
end function
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= 7.6e+34) {
tmp = 1.0;
} else {
tmp = Math.sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((l / (Om / l)) * ((ky * ky) / Om))))))));
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if l <= 7.6e+34: tmp = 1.0 else: tmp = math.sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((l / (Om / l)) * ((ky * ky) / Om)))))))) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (l <= 7.6e+34) tmp = 1.0; else tmp = sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / Float64(1.0 + Float64(2.0 * Float64(Float64(l / Float64(Om / l)) * Float64(Float64(ky * ky) / Om)))))))); end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (l <= 7.6e+34) tmp = 1.0; else tmp = sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((l / (Om / l)) * ((ky * ky) / Om)))))))); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[l, 7.6e+34], 1.0, N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[(1.0 + N[(2.0 * N[(N[(l / N[(Om / l), $MachinePrecision]), $MachinePrecision] * N[(N[(ky * ky), $MachinePrecision] / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 7.6 \cdot 10^{+34}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{1 + 2 \cdot \left(\frac{\ell}{\frac{Om}{\ell}} \cdot \frac{ky \cdot ky}{Om}\right)}}\\
\end{array}
\end{array}
if l < 7.6000000000000003e34Initial program 99.0%
Simplified99.0%
expm1-log1p-u99.0%
expm1-udef99.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
un-div-inv100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
hypot-def99.7%
unpow299.7%
unpow299.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-def100.0%
Simplified100.0%
Taylor expanded in kx around 0 93.8%
Taylor expanded in ky around 0 71.1%
if 7.6000000000000003e34 < l Initial program 92.3%
Simplified92.3%
Taylor expanded in kx around 0 60.0%
associate-*r/60.0%
associate-*r*60.0%
unpow260.0%
unpow260.0%
Simplified60.0%
Taylor expanded in ky around 0 55.0%
*-commutative55.0%
unpow255.0%
times-frac65.7%
unpow265.7%
associate-/l*71.4%
unpow271.4%
Simplified71.4%
Final simplification71.2%
(FPCore (l Om kx ky) :precision binary64 (if (<= l 5e+35) 1.0 (if (<= l 2e+47) (sqrt 0.5) (if (<= l 1e+70) 1.0 (sqrt 0.5)))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= 5e+35) {
tmp = 1.0;
} else if (l <= 2e+47) {
tmp = sqrt(0.5);
} else if (l <= 1e+70) {
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 <= 5d+35) then
tmp = 1.0d0
else if (l <= 2d+47) then
tmp = sqrt(0.5d0)
else if (l <= 1d+70) 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 <= 5e+35) {
tmp = 1.0;
} else if (l <= 2e+47) {
tmp = Math.sqrt(0.5);
} else if (l <= 1e+70) {
tmp = 1.0;
} else {
tmp = Math.sqrt(0.5);
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if l <= 5e+35: tmp = 1.0 elif l <= 2e+47: tmp = math.sqrt(0.5) elif l <= 1e+70: tmp = 1.0 else: tmp = math.sqrt(0.5) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (l <= 5e+35) tmp = 1.0; elseif (l <= 2e+47) tmp = sqrt(0.5); elseif (l <= 1e+70) 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 <= 5e+35) tmp = 1.0; elseif (l <= 2e+47) tmp = sqrt(0.5); elseif (l <= 1e+70) tmp = 1.0; else tmp = sqrt(0.5); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[l, 5e+35], 1.0, If[LessEqual[l, 2e+47], N[Sqrt[0.5], $MachinePrecision], If[LessEqual[l, 1e+70], 1.0, N[Sqrt[0.5], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 5 \cdot 10^{+35}:\\
\;\;\;\;1\\
\mathbf{elif}\;\ell \leq 2 \cdot 10^{+47}:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{elif}\;\ell \leq 10^{+70}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5}\\
\end{array}
\end{array}
if l < 5.00000000000000021e35 or 2.0000000000000001e47 < l < 1.00000000000000007e70Initial program 99.0%
Simplified99.0%
expm1-log1p-u99.0%
expm1-udef99.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
un-div-inv100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
hypot-def99.7%
unpow299.7%
unpow299.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-def100.0%
Simplified100.0%
Taylor expanded in kx around 0 93.9%
Taylor expanded in ky around 0 71.7%
if 5.00000000000000021e35 < l < 2.0000000000000001e47 or 1.00000000000000007e70 < l Initial program 91.7%
Simplified91.7%
Taylor expanded in Om around 0 72.5%
associate-*r*72.5%
unpow272.5%
unpow272.5%
hypot-def74.8%
*-commutative74.8%
Simplified74.8%
Taylor expanded in l around inf 77.2%
Final simplification72.7%
(FPCore (l Om kx ky) :precision binary64 1.0)
double code(double l, double Om, double kx, double ky) {
return 1.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 = 1.0d0
end function
public static double code(double l, double Om, double kx, double ky) {
return 1.0;
}
def code(l, Om, kx, ky): return 1.0
function code(l, Om, kx, ky) return 1.0 end
function tmp = code(l, Om, kx, ky) tmp = 1.0; end
code[l_, Om_, kx_, ky_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 97.7%
Simplified97.7%
expm1-log1p-u97.7%
expm1-udef97.6%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
un-div-inv100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
hypot-def99.4%
unpow299.4%
unpow299.4%
+-commutative99.4%
unpow299.4%
unpow299.4%
hypot-def100.0%
Simplified100.0%
Taylor expanded in kx around 0 94.0%
Taylor expanded in ky around 0 65.5%
Final simplification65.5%
herbie shell --seed 2023272
(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))))))))))