
(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
(/ 1.0 (hypot 1.0 (* (* l (/ 2.0 Om)) (hypot (sin kx) (sin ky)))))))))
double code(double l, double Om, double kx, double ky) {
return sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, ((l * (2.0 / Om)) * hypot(sin(kx), sin(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, ((l * (2.0 / Om)) * Math.hypot(Math.sin(kx), Math.sin(ky))))))));
}
def code(l, Om, kx, ky): return math.sqrt((0.5 + (0.5 * (1.0 / math.hypot(1.0, ((l * (2.0 / Om)) * math.hypot(math.sin(kx), math.sin(ky))))))))
function code(l, Om, kx, ky) return sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / hypot(1.0, Float64(Float64(l * Float64(2.0 / Om)) * hypot(sin(kx), sin(ky)))))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, ((l * (2.0 / Om)) * hypot(sin(kx), sin(ky)))))))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[Sqrt[1.0 ^ 2 + N[(N[(l * N[(2.0 / Om), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + 0.5 \cdot \frac{1}{\mathsf{hypot}\left(1, \left(\ell \cdot \frac{2}{Om}\right) \cdot \mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}}
\end{array}
Initial program 96.9%
Simplified96.9%
add-sqr-sqrt96.9%
hypot-1-def96.9%
sqrt-prod96.9%
unpow296.9%
sqrt-prod55.8%
add-sqr-sqrt97.9%
associate-/r/97.9%
*-commutative97.9%
unpow297.9%
unpow297.9%
hypot-def100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (l Om kx ky) :precision binary64 (if (<= ky 7.2e+92) (sqrt (+ 0.5 (* 0.5 (/ 1.0 (hypot 1.0 (/ (* 2.0 (* l ky)) Om)))))) (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* (sin kx) (/ (/ l Om) 0.5))))))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (ky <= 7.2e+92) {
tmp = sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, ((2.0 * (l * ky)) / Om))))));
} else {
tmp = sqrt((0.5 + (0.5 / hypot(1.0, (sin(kx) * ((l / Om) / 0.5))))));
}
return tmp;
}
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if (ky <= 7.2e+92) {
tmp = Math.sqrt((0.5 + (0.5 * (1.0 / Math.hypot(1.0, ((2.0 * (l * ky)) / Om))))));
} else {
tmp = Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, (Math.sin(kx) * ((l / Om) / 0.5))))));
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if ky <= 7.2e+92: tmp = math.sqrt((0.5 + (0.5 * (1.0 / math.hypot(1.0, ((2.0 * (l * ky)) / Om)))))) else: tmp = math.sqrt((0.5 + (0.5 / math.hypot(1.0, (math.sin(kx) * ((l / Om) / 0.5)))))) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (ky <= 7.2e+92) tmp = sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / hypot(1.0, Float64(Float64(2.0 * Float64(l * ky)) / Om)))))); else tmp = sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(sin(kx) * Float64(Float64(l / Om) / 0.5)))))); end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (ky <= 7.2e+92) tmp = sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, ((2.0 * (l * ky)) / Om)))))); else tmp = sqrt((0.5 + (0.5 / hypot(1.0, (sin(kx) * ((l / Om) / 0.5)))))); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[ky, 7.2e+92], N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[Sqrt[1.0 ^ 2 + N[(N[(2.0 * N[(l * ky), $MachinePrecision]), $MachinePrecision] / Om), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(N[Sin[kx], $MachinePrecision] * N[(N[(l / Om), $MachinePrecision] / 0.5), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 7.2 \cdot 10^{+92}:\\
\;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{\mathsf{hypot}\left(1, \frac{2 \cdot \left(\ell \cdot ky\right)}{Om}\right)}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \sin kx \cdot \frac{\frac{\ell}{Om}}{0.5}\right)}}\\
\end{array}
\end{array}
if ky < 7.2e92Initial program 96.3%
Simplified96.3%
add-sqr-sqrt96.3%
hypot-1-def96.3%
sqrt-prod96.3%
unpow296.3%
sqrt-prod53.9%
add-sqr-sqrt97.5%
associate-/r/97.5%
*-commutative97.5%
unpow297.5%
unpow297.5%
hypot-def100.0%
Applied egg-rr100.0%
Taylor expanded in kx around 0 90.5%
associate-*r/90.5%
Simplified90.5%
Taylor expanded in ky around 0 82.6%
associate-*r/82.6%
*-commutative82.6%
Simplified82.6%
if 7.2e92 < ky Initial program 100.0%
Simplified100.0%
Taylor expanded in ky around 0 75.3%
associate-/l*77.8%
associate-/r/77.3%
associate-*l*77.3%
*-commutative77.3%
unpow277.3%
unpow277.3%
times-frac87.5%
metadata-eval87.5%
swap-sqr87.5%
associate-*l/87.5%
associate-*r/87.5%
associate-*l/87.5%
associate-*r/87.5%
unpow287.5%
swap-sqr90.9%
Simplified90.9%
expm1-log1p-u90.4%
expm1-udef90.4%
Applied egg-rr90.4%
expm1-def90.4%
expm1-log1p90.9%
associate-/r*90.9%
Simplified90.9%
Final simplification84.0%
(FPCore (l Om kx ky) :precision binary64 (sqrt (+ 0.5 (* 0.5 (/ 1.0 (hypot 1.0 (/ (* 2.0 (* l (sin ky))) Om)))))))
double code(double l, double Om, double kx, double ky) {
return sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, ((2.0 * (l * sin(ky))) / 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, ((2.0 * (l * Math.sin(ky))) / Om))))));
}
def code(l, Om, kx, ky): return math.sqrt((0.5 + (0.5 * (1.0 / math.hypot(1.0, ((2.0 * (l * math.sin(ky))) / Om))))))
function code(l, Om, kx, ky) return sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / hypot(1.0, Float64(Float64(2.0 * Float64(l * sin(ky))) / Om)))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, ((2.0 * (l * sin(ky))) / 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[(2.0 * N[(l * N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / Om), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + 0.5 \cdot \frac{1}{\mathsf{hypot}\left(1, \frac{2 \cdot \left(\ell \cdot \sin ky\right)}{Om}\right)}}
\end{array}
Initial program 96.9%
Simplified96.9%
add-sqr-sqrt96.9%
hypot-1-def96.9%
sqrt-prod96.9%
unpow296.9%
sqrt-prod55.8%
add-sqr-sqrt97.9%
associate-/r/97.9%
*-commutative97.9%
unpow297.9%
unpow297.9%
hypot-def100.0%
Applied egg-rr100.0%
Taylor expanded in kx around 0 91.8%
associate-*r/91.8%
Simplified91.8%
Final simplification91.8%
(FPCore (l Om kx ky) :precision binary64 (if (<= ky 4.4e+138) (sqrt (+ 0.5 (* 0.5 (/ 1.0 (hypot 1.0 (/ (* 2.0 (* l ky)) Om)))))) (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (/ (* 2.0 (* l kx)) Om)))))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (ky <= 4.4e+138) {
tmp = sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, ((2.0 * (l * ky)) / Om))))));
} else {
tmp = sqrt((0.5 + (0.5 / hypot(1.0, ((2.0 * (l * kx)) / Om)))));
}
return tmp;
}
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if (ky <= 4.4e+138) {
tmp = Math.sqrt((0.5 + (0.5 * (1.0 / Math.hypot(1.0, ((2.0 * (l * ky)) / Om))))));
} else {
tmp = Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, ((2.0 * (l * kx)) / Om)))));
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if ky <= 4.4e+138: tmp = math.sqrt((0.5 + (0.5 * (1.0 / math.hypot(1.0, ((2.0 * (l * ky)) / Om)))))) else: tmp = math.sqrt((0.5 + (0.5 / math.hypot(1.0, ((2.0 * (l * kx)) / Om))))) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (ky <= 4.4e+138) tmp = sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / hypot(1.0, Float64(Float64(2.0 * Float64(l * ky)) / Om)))))); else tmp = sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(Float64(2.0 * Float64(l * kx)) / Om))))); end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (ky <= 4.4e+138) tmp = sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, ((2.0 * (l * ky)) / Om)))))); else tmp = sqrt((0.5 + (0.5 / hypot(1.0, ((2.0 * (l * kx)) / Om))))); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[ky, 4.4e+138], N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[Sqrt[1.0 ^ 2 + N[(N[(2.0 * N[(l * ky), $MachinePrecision]), $MachinePrecision] / Om), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(N[(2.0 * N[(l * kx), $MachinePrecision]), $MachinePrecision] / Om), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 4.4 \cdot 10^{+138}:\\
\;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{\mathsf{hypot}\left(1, \frac{2 \cdot \left(\ell \cdot ky\right)}{Om}\right)}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \frac{2 \cdot \left(\ell \cdot kx\right)}{Om}\right)}}\\
\end{array}
\end{array}
if ky < 4.4000000000000001e138Initial program 96.3%
Simplified96.3%
add-sqr-sqrt96.3%
hypot-1-def96.3%
sqrt-prod96.3%
unpow296.3%
sqrt-prod54.5%
add-sqr-sqrt97.6%
associate-/r/97.6%
*-commutative97.6%
unpow297.6%
unpow297.6%
hypot-def100.0%
Applied egg-rr100.0%
Taylor expanded in kx around 0 90.7%
associate-*r/90.7%
Simplified90.7%
Taylor expanded in ky around 0 82.7%
associate-*r/82.7%
*-commutative82.7%
Simplified82.7%
if 4.4000000000000001e138 < ky Initial program 100.0%
Simplified100.0%
Taylor expanded in ky around 0 74.7%
associate-/l*77.5%
associate-/r/76.9%
associate-*l*76.9%
*-commutative76.9%
unpow276.9%
unpow276.9%
times-frac88.0%
metadata-eval88.0%
swap-sqr88.0%
associate-*l/88.0%
associate-*r/88.0%
associate-*l/88.0%
associate-*r/88.0%
unpow288.0%
swap-sqr91.9%
Simplified91.9%
expm1-log1p-u91.3%
expm1-udef91.3%
Applied egg-rr91.3%
expm1-def91.3%
expm1-log1p91.9%
associate-/r*91.9%
Simplified91.9%
Taylor expanded in kx around 0 84.4%
associate-*r/84.4%
*-commutative84.4%
Simplified84.4%
Final simplification82.9%
(FPCore (l Om kx ky) :precision binary64 (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (/ (* 2.0 (* l kx)) Om))))))
double code(double l, double Om, double kx, double ky) {
return sqrt((0.5 + (0.5 / hypot(1.0, ((2.0 * (l * kx)) / Om)))));
}
public static double code(double l, double Om, double kx, double ky) {
return Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, ((2.0 * (l * kx)) / Om)))));
}
def code(l, Om, kx, ky): return math.sqrt((0.5 + (0.5 / math.hypot(1.0, ((2.0 * (l * kx)) / Om)))))
function code(l, Om, kx, ky) return sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(Float64(2.0 * Float64(l * kx)) / Om))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 / hypot(1.0, ((2.0 * (l * kx)) / Om))))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(N[(2.0 * N[(l * kx), $MachinePrecision]), $MachinePrecision] / Om), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \frac{2 \cdot \left(\ell \cdot kx\right)}{Om}\right)}}
\end{array}
Initial program 96.9%
Simplified96.9%
Taylor expanded in ky around 0 75.3%
associate-/l*76.8%
associate-/r/76.1%
associate-*l*76.1%
*-commutative76.1%
unpow276.1%
unpow276.1%
times-frac88.3%
metadata-eval88.3%
swap-sqr88.3%
associate-*l/88.3%
associate-*r/88.3%
associate-*l/88.3%
associate-*r/88.3%
unpow288.3%
swap-sqr94.6%
Simplified94.6%
expm1-log1p-u94.1%
expm1-udef94.1%
Applied egg-rr94.1%
expm1-def94.1%
expm1-log1p94.6%
associate-/r*94.6%
Simplified94.6%
Taylor expanded in kx around 0 84.8%
associate-*r/84.8%
*-commutative84.8%
Simplified84.8%
Final simplification84.8%
(FPCore (l Om kx ky)
:precision binary64
(if (<= l 4100000000.0)
1.0
(if (<= l 2e+30)
(sqrt 0.5)
(if (<= l 1.28e+95)
1.0
(sqrt
(+
0.5
(*
0.5
(/ 1.0 (+ (* 0.25 (/ Om (* l ky))) (* 2.0 (/ (* l ky) Om)))))))))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= 4100000000.0) {
tmp = 1.0;
} else if (l <= 2e+30) {
tmp = sqrt(0.5);
} else if (l <= 1.28e+95) {
tmp = 1.0;
} else {
tmp = sqrt((0.5 + (0.5 * (1.0 / ((0.25 * (Om / (l * ky))) + (2.0 * ((l * 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 <= 4100000000.0d0) then
tmp = 1.0d0
else if (l <= 2d+30) then
tmp = sqrt(0.5d0)
else if (l <= 1.28d+95) then
tmp = 1.0d0
else
tmp = sqrt((0.5d0 + (0.5d0 * (1.0d0 / ((0.25d0 * (om / (l * ky))) + (2.0d0 * ((l * ky) / om)))))))
end if
code = tmp
end function
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= 4100000000.0) {
tmp = 1.0;
} else if (l <= 2e+30) {
tmp = Math.sqrt(0.5);
} else if (l <= 1.28e+95) {
tmp = 1.0;
} else {
tmp = Math.sqrt((0.5 + (0.5 * (1.0 / ((0.25 * (Om / (l * ky))) + (2.0 * ((l * ky) / Om)))))));
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if l <= 4100000000.0: tmp = 1.0 elif l <= 2e+30: tmp = math.sqrt(0.5) elif l <= 1.28e+95: tmp = 1.0 else: tmp = math.sqrt((0.5 + (0.5 * (1.0 / ((0.25 * (Om / (l * ky))) + (2.0 * ((l * ky) / Om))))))) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (l <= 4100000000.0) tmp = 1.0; elseif (l <= 2e+30) tmp = sqrt(0.5); elseif (l <= 1.28e+95) tmp = 1.0; else tmp = sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / Float64(Float64(0.25 * Float64(Om / Float64(l * ky))) + Float64(2.0 * Float64(Float64(l * ky) / Om))))))); end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (l <= 4100000000.0) tmp = 1.0; elseif (l <= 2e+30) tmp = sqrt(0.5); elseif (l <= 1.28e+95) tmp = 1.0; else tmp = sqrt((0.5 + (0.5 * (1.0 / ((0.25 * (Om / (l * ky))) + (2.0 * ((l * ky) / Om))))))); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[l, 4100000000.0], 1.0, If[LessEqual[l, 2e+30], N[Sqrt[0.5], $MachinePrecision], If[LessEqual[l, 1.28e+95], 1.0, N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[(N[(0.25 * N[(Om / N[(l * ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[(N[(l * ky), $MachinePrecision] / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 4100000000:\\
\;\;\;\;1\\
\mathbf{elif}\;\ell \leq 2 \cdot 10^{+30}:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{elif}\;\ell \leq 1.28 \cdot 10^{+95}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{0.25 \cdot \frac{Om}{\ell \cdot ky} + 2 \cdot \frac{\ell \cdot ky}{Om}}}\\
\end{array}
\end{array}
if l < 4.1e9 or 2e30 < l < 1.28000000000000006e95Initial program 98.1%
Simplified98.1%
Taylor expanded in ky around 0 79.9%
associate-/l*81.9%
associate-/r/81.4%
associate-*l*81.4%
*-commutative81.4%
unpow281.4%
unpow281.4%
times-frac91.7%
metadata-eval91.7%
swap-sqr91.7%
associate-*l/91.7%
associate-*r/91.7%
associate-*l/91.7%
associate-*r/91.7%
unpow291.7%
swap-sqr95.3%
Simplified95.3%
add-cube-cbrt94.8%
pow394.8%
Applied egg-rr94.8%
Taylor expanded in kx around 0 69.8%
if 4.1e9 < l < 2e30Initial program 75.0%
Simplified75.0%
Taylor expanded in Om around 0 52.1%
unpow252.1%
unpow252.1%
hypot-def77.1%
Simplified77.1%
Taylor expanded in l around inf 80.0%
if 1.28000000000000006e95 < l Initial program 93.3%
Simplified93.3%
add-sqr-sqrt93.3%
hypot-1-def93.3%
sqrt-prod93.3%
unpow293.3%
sqrt-prod57.8%
add-sqr-sqrt95.6%
associate-/r/95.6%
*-commutative95.6%
unpow295.6%
unpow295.6%
hypot-def100.0%
Applied egg-rr100.0%
Taylor expanded in kx around 0 86.2%
associate-*r/86.2%
Simplified86.2%
Taylor expanded in ky around 0 79.3%
associate-*r/79.3%
*-commutative79.3%
Simplified79.3%
Taylor expanded in l around inf 73.7%
Final simplification70.7%
(FPCore (l Om kx ky) :precision binary64 (if (<= l 4400000000.0) 1.0 (if (<= l 2e+30) (sqrt 0.5) (if (<= l 2e+95) 1.0 (sqrt 0.5)))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= 4400000000.0) {
tmp = 1.0;
} else if (l <= 2e+30) {
tmp = sqrt(0.5);
} else if (l <= 2e+95) {
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 <= 4400000000.0d0) then
tmp = 1.0d0
else if (l <= 2d+30) then
tmp = sqrt(0.5d0)
else if (l <= 2d+95) 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 <= 4400000000.0) {
tmp = 1.0;
} else if (l <= 2e+30) {
tmp = Math.sqrt(0.5);
} else if (l <= 2e+95) {
tmp = 1.0;
} else {
tmp = Math.sqrt(0.5);
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if l <= 4400000000.0: tmp = 1.0 elif l <= 2e+30: tmp = math.sqrt(0.5) elif l <= 2e+95: tmp = 1.0 else: tmp = math.sqrt(0.5) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (l <= 4400000000.0) tmp = 1.0; elseif (l <= 2e+30) tmp = sqrt(0.5); elseif (l <= 2e+95) 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 <= 4400000000.0) tmp = 1.0; elseif (l <= 2e+30) tmp = sqrt(0.5); elseif (l <= 2e+95) tmp = 1.0; else tmp = sqrt(0.5); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[l, 4400000000.0], 1.0, If[LessEqual[l, 2e+30], N[Sqrt[0.5], $MachinePrecision], If[LessEqual[l, 2e+95], 1.0, N[Sqrt[0.5], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 4400000000:\\
\;\;\;\;1\\
\mathbf{elif}\;\ell \leq 2 \cdot 10^{+30}:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{elif}\;\ell \leq 2 \cdot 10^{+95}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5}\\
\end{array}
\end{array}
if l < 4.4e9 or 2e30 < l < 2.00000000000000004e95Initial program 98.1%
Simplified98.1%
Taylor expanded in ky around 0 79.9%
associate-/l*81.9%
associate-/r/81.4%
associate-*l*81.4%
*-commutative81.4%
unpow281.4%
unpow281.4%
times-frac91.7%
metadata-eval91.7%
swap-sqr91.7%
associate-*l/91.7%
associate-*r/91.7%
associate-*l/91.7%
associate-*r/91.7%
unpow291.7%
swap-sqr95.3%
Simplified95.3%
add-cube-cbrt94.8%
pow394.8%
Applied egg-rr94.8%
Taylor expanded in kx around 0 69.8%
if 4.4e9 < l < 2e30 or 2.00000000000000004e95 < l Initial program 91.8%
Simplified91.8%
Taylor expanded in Om around 0 65.7%
unpow265.7%
unpow265.7%
hypot-def71.9%
Simplified71.9%
Taylor expanded in l around inf 74.8%
Final simplification70.8%
(FPCore (l Om kx ky) :precision binary64 (sqrt 0.5))
double code(double l, double Om, double kx, double ky) {
return sqrt(0.5);
}
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
public static double code(double l, double Om, double kx, double ky) {
return Math.sqrt(0.5);
}
def code(l, Om, kx, ky): return math.sqrt(0.5)
function code(l, Om, kx, ky) return sqrt(0.5) end
function tmp = code(l, Om, kx, ky) tmp = sqrt(0.5); end
code[l_, Om_, kx_, ky_] := N[Sqrt[0.5], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5}
\end{array}
Initial program 96.9%
Simplified96.9%
Taylor expanded in Om around 0 42.4%
unpow242.4%
unpow242.4%
hypot-def44.4%
Simplified44.4%
Taylor expanded in l around inf 53.7%
Final simplification53.7%
herbie shell --seed 2024019
(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))))))))))