
(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
(pow
(sqrt (hypot 1.0 (* (hypot (sin ky) (sin kx)) (* 2.0 (/ l Om)))))
-2.0)))))
double code(double l, double Om, double kx, double ky) {
return sqrt((0.5 + (0.5 * pow(sqrt(hypot(1.0, (hypot(sin(ky), sin(kx)) * (2.0 * (l / Om))))), -2.0))));
}
public static double code(double l, double Om, double kx, double ky) {
return Math.sqrt((0.5 + (0.5 * Math.pow(Math.sqrt(Math.hypot(1.0, (Math.hypot(Math.sin(ky), Math.sin(kx)) * (2.0 * (l / Om))))), -2.0))));
}
def code(l, Om, kx, ky): return math.sqrt((0.5 + (0.5 * math.pow(math.sqrt(math.hypot(1.0, (math.hypot(math.sin(ky), math.sin(kx)) * (2.0 * (l / Om))))), -2.0))))
function code(l, Om, kx, ky) return sqrt(Float64(0.5 + Float64(0.5 * (sqrt(hypot(1.0, Float64(hypot(sin(ky), sin(kx)) * Float64(2.0 * Float64(l / Om))))) ^ -2.0)))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 * (sqrt(hypot(1.0, (hypot(sin(ky), sin(kx)) * (2.0 * (l / Om))))) ^ -2.0)))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(0.5 + N[(0.5 * N[Power[N[Sqrt[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], -2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + 0.5 \cdot {\left(\sqrt{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)}\right)}^{-2}}
\end{array}
Initial program 97.3%
Simplified97.3%
inv-pow97.3%
add-sqr-sqrt97.3%
unpow-prod-down97.3%
Applied egg-rr100.0%
pow-sqr100.0%
*-commutative100.0%
hypot-def98.1%
unpow298.1%
unpow298.1%
+-commutative98.1%
unpow298.1%
unpow298.1%
hypot-def100.0%
metadata-eval100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (l Om kx ky)
:precision binary64
(sqrt
(+
0.5
(*
0.5
(/ 1.0 (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 * (1.0 / 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 * (1.0 / 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 * (1.0 / 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 * Float64(1.0 / 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 * (1.0 / 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[(1.0 / 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]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + 0.5 \cdot \frac{1}{\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.3%
Simplified97.3%
expm1-log1p-u97.3%
expm1-udef97.3%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
hypot-def98.1%
unpow298.1%
unpow298.1%
+-commutative98.1%
unpow298.1%
unpow298.1%
hypot-def100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (l Om kx ky) :precision binary64 (sqrt (+ 0.5 (* 0.5 (/ 1.0 (sqrt (+ 1.0 (* 4.0 (pow (* (sin ky) (/ l Om)) 2.0)))))))))
double code(double l, double Om, double kx, double ky) {
return sqrt((0.5 + (0.5 * (1.0 / sqrt((1.0 + (4.0 * pow((sin(ky) * (l / Om)), 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((0.5d0 + (0.5d0 * (1.0d0 / sqrt((1.0d0 + (4.0d0 * ((sin(ky) * (l / om)) ** 2.0d0))))))))
end function
public static double code(double l, double Om, double kx, double ky) {
return Math.sqrt((0.5 + (0.5 * (1.0 / Math.sqrt((1.0 + (4.0 * Math.pow((Math.sin(ky) * (l / Om)), 2.0))))))));
}
def code(l, Om, kx, ky): return math.sqrt((0.5 + (0.5 * (1.0 / math.sqrt((1.0 + (4.0 * math.pow((math.sin(ky) * (l / Om)), 2.0))))))))
function code(l, Om, kx, ky) return sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / sqrt(Float64(1.0 + Float64(4.0 * (Float64(sin(ky) * Float64(l / Om)) ^ 2.0)))))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 * (1.0 / sqrt((1.0 + (4.0 * ((sin(ky) * (l / Om)) ^ 2.0)))))))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[Sqrt[N[(1.0 + N[(4.0 * N[Power[N[(N[Sin[ky], $MachinePrecision] * N[(l / Om), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + 0.5 \cdot \frac{1}{\sqrt{1 + 4 \cdot {\left(\sin ky \cdot \frac{\ell}{Om}\right)}^{2}}}}
\end{array}
Initial program 97.3%
Simplified97.3%
Taylor expanded in kx around 0 75.1%
associate-/l*75.5%
unpow275.5%
unpow275.5%
Simplified75.5%
add-sqr-sqrt75.5%
pow275.5%
associate-/r/75.7%
sqrt-prod75.7%
frac-times88.7%
sqrt-unprod49.0%
add-sqr-sqrt90.1%
unpow290.1%
sqrt-prod42.2%
add-sqr-sqrt94.1%
Applied egg-rr94.1%
Final simplification94.1%
(FPCore (l Om kx ky)
:precision binary64
(if (or (<= Om 1.85e-225) (not (<= Om 1e+96)))
(sqrt (+ 0.5 (* 0.5 (/ 1.0 (hypot 1.0 (* (sin kx) (* 2.0 (/ l Om))))))))
(sqrt
(+ 0.5 (* 0.5 (/ 1.0 (sqrt (+ 1.0 (* (/ (* l l) (* Om Om)) 12.0)))))))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if ((Om <= 1.85e-225) || !(Om <= 1e+96)) {
tmp = sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, (sin(kx) * (2.0 * (l / Om))))))));
} else {
tmp = sqrt((0.5 + (0.5 * (1.0 / sqrt((1.0 + (((l * l) / (Om * Om)) * 12.0)))))));
}
return tmp;
}
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if ((Om <= 1.85e-225) || !(Om <= 1e+96)) {
tmp = Math.sqrt((0.5 + (0.5 * (1.0 / Math.hypot(1.0, (Math.sin(kx) * (2.0 * (l / Om))))))));
} else {
tmp = Math.sqrt((0.5 + (0.5 * (1.0 / Math.sqrt((1.0 + (((l * l) / (Om * Om)) * 12.0)))))));
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if (Om <= 1.85e-225) or not (Om <= 1e+96): tmp = math.sqrt((0.5 + (0.5 * (1.0 / math.hypot(1.0, (math.sin(kx) * (2.0 * (l / Om)))))))) else: tmp = math.sqrt((0.5 + (0.5 * (1.0 / math.sqrt((1.0 + (((l * l) / (Om * Om)) * 12.0))))))) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if ((Om <= 1.85e-225) || !(Om <= 1e+96)) tmp = sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / hypot(1.0, Float64(sin(kx) * Float64(2.0 * Float64(l / Om)))))))); else tmp = sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / sqrt(Float64(1.0 + Float64(Float64(Float64(l * l) / Float64(Om * Om)) * 12.0))))))); end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if ((Om <= 1.85e-225) || ~((Om <= 1e+96))) tmp = sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, (sin(kx) * (2.0 * (l / Om)))))))); else tmp = sqrt((0.5 + (0.5 * (1.0 / sqrt((1.0 + (((l * l) / (Om * Om)) * 12.0))))))); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[Or[LessEqual[Om, 1.85e-225], N[Not[LessEqual[Om, 1e+96]], $MachinePrecision]], N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[Sqrt[1.0 ^ 2 + N[(N[Sin[kx], $MachinePrecision] * N[(2.0 * N[(l / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[Sqrt[N[(1.0 + N[(N[(N[(l * l), $MachinePrecision] / N[(Om * Om), $MachinePrecision]), $MachinePrecision] * 12.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;Om \leq 1.85 \cdot 10^{-225} \lor \neg \left(Om \leq 10^{+96}\right):\\
\;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{\mathsf{hypot}\left(1, \sin kx \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{\sqrt{1 + \frac{\ell \cdot \ell}{Om \cdot Om} \cdot 12}}}\\
\end{array}
\end{array}
if Om < 1.84999999999999994e-225 or 1.00000000000000005e96 < Om Initial program 97.9%
Simplified97.9%
expm1-log1p-u97.9%
expm1-udef97.9%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
hypot-def98.2%
unpow298.2%
unpow298.2%
+-commutative98.2%
unpow298.2%
unpow298.2%
hypot-def100.0%
Simplified100.0%
Taylor expanded in ky around 0 96.9%
if 1.84999999999999994e-225 < Om < 1.00000000000000005e96Initial program 95.4%
Simplified95.4%
Taylor expanded in kx around 0 84.9%
associate-/l*83.3%
unpow283.3%
unpow283.3%
Simplified83.3%
Taylor expanded in ky around 0 83.4%
fma-def83.4%
unpow283.4%
unpow283.4%
unpow283.4%
Simplified83.4%
Taylor expanded in ky around inf 91.3%
*-commutative91.3%
unpow291.3%
unpow291.3%
Simplified91.3%
Final simplification95.4%
(FPCore (l Om kx ky) :precision binary64 (sqrt (+ 0.5 (* 0.5 (/ 1.0 (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 * (1.0 / 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 * (1.0 / Math.hypot(1.0, (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.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(sin(ky) * Float64(Float64(2.0 * l) / Om))))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, (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[Sin[ky], $MachinePrecision] * N[(N[(2.0 * l), $MachinePrecision] / Om), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + 0.5 \cdot \frac{1}{\mathsf{hypot}\left(1, \sin ky \cdot \frac{2 \cdot \ell}{Om}\right)}}
\end{array}
Initial program 97.3%
Simplified97.3%
expm1-log1p-u97.3%
expm1-udef97.3%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.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.1%
associate-*l/94.1%
associate-*r*94.1%
associate-*r/94.1%
Simplified94.1%
Final simplification94.1%
(FPCore (l Om kx ky)
:precision binary64
(if (<= Om 1.6e-162)
(sqrt 0.5)
(if (<= Om 1.35e+154)
(sqrt
(+ 0.5 (* 0.5 (/ 1.0 (sqrt (+ 1.0 (* (/ (* l l) (* Om Om)) 12.0)))))))
1.0)))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (Om <= 1.6e-162) {
tmp = sqrt(0.5);
} else if (Om <= 1.35e+154) {
tmp = sqrt((0.5 + (0.5 * (1.0 / sqrt((1.0 + (((l * l) / (Om * Om)) * 12.0)))))));
} 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 (om <= 1.6d-162) then
tmp = sqrt(0.5d0)
else if (om <= 1.35d+154) then
tmp = sqrt((0.5d0 + (0.5d0 * (1.0d0 / sqrt((1.0d0 + (((l * l) / (om * om)) * 12.0d0)))))))
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 (Om <= 1.6e-162) {
tmp = Math.sqrt(0.5);
} else if (Om <= 1.35e+154) {
tmp = Math.sqrt((0.5 + (0.5 * (1.0 / Math.sqrt((1.0 + (((l * l) / (Om * Om)) * 12.0)))))));
} else {
tmp = 1.0;
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if Om <= 1.6e-162: tmp = math.sqrt(0.5) elif Om <= 1.35e+154: tmp = math.sqrt((0.5 + (0.5 * (1.0 / math.sqrt((1.0 + (((l * l) / (Om * Om)) * 12.0))))))) else: tmp = 1.0 return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (Om <= 1.6e-162) tmp = sqrt(0.5); elseif (Om <= 1.35e+154) tmp = sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / sqrt(Float64(1.0 + Float64(Float64(Float64(l * l) / Float64(Om * Om)) * 12.0))))))); else tmp = 1.0; end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (Om <= 1.6e-162) tmp = sqrt(0.5); elseif (Om <= 1.35e+154) tmp = sqrt((0.5 + (0.5 * (1.0 / sqrt((1.0 + (((l * l) / (Om * Om)) * 12.0))))))); else tmp = 1.0; end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[Om, 1.6e-162], N[Sqrt[0.5], $MachinePrecision], If[LessEqual[Om, 1.35e+154], N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[Sqrt[N[(1.0 + N[(N[(N[(l * l), $MachinePrecision] / N[(Om * Om), $MachinePrecision]), $MachinePrecision] * 12.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;Om \leq 1.6 \cdot 10^{-162}:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{elif}\;Om \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{\sqrt{1 + \frac{\ell \cdot \ell}{Om \cdot Om} \cdot 12}}}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if Om < 1.59999999999999988e-162Initial program 96.3%
Simplified96.3%
Taylor expanded in Om around 0 51.9%
*-commutative51.9%
associate-*r*51.9%
associate-*l/51.9%
unpow251.9%
unpow251.9%
hypot-def54.4%
associate-*l/54.4%
*-commutative54.4%
Simplified54.4%
Taylor expanded in l around inf 61.5%
if 1.59999999999999988e-162 < Om < 1.35000000000000003e154Initial program 98.2%
Simplified98.2%
Taylor expanded in kx around 0 91.2%
associate-/l*89.5%
unpow289.5%
unpow289.5%
Simplified89.5%
Taylor expanded in ky around 0 88.0%
fma-def88.0%
unpow288.0%
unpow288.0%
unpow288.0%
Simplified88.0%
Taylor expanded in ky around inf 93.4%
*-commutative93.4%
unpow293.4%
unpow293.4%
Simplified93.4%
if 1.35000000000000003e154 < Om Initial program 100.0%
Simplified100.0%
Taylor expanded in Om around inf 93.5%
Final simplification73.2%
(FPCore (l Om kx ky) :precision binary64 (if (<= Om 1e-75) (sqrt 0.5) (if (<= Om 2e-18) 1.0 (if (<= Om 1.5e+32) (sqrt 0.5) 1.0))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (Om <= 1e-75) {
tmp = sqrt(0.5);
} else if (Om <= 2e-18) {
tmp = 1.0;
} else if (Om <= 1.5e+32) {
tmp = sqrt(0.5);
} 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 (om <= 1d-75) then
tmp = sqrt(0.5d0)
else if (om <= 2d-18) then
tmp = 1.0d0
else if (om <= 1.5d+32) then
tmp = sqrt(0.5d0)
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 (Om <= 1e-75) {
tmp = Math.sqrt(0.5);
} else if (Om <= 2e-18) {
tmp = 1.0;
} else if (Om <= 1.5e+32) {
tmp = Math.sqrt(0.5);
} else {
tmp = 1.0;
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if Om <= 1e-75: tmp = math.sqrt(0.5) elif Om <= 2e-18: tmp = 1.0 elif Om <= 1.5e+32: tmp = math.sqrt(0.5) else: tmp = 1.0 return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (Om <= 1e-75) tmp = sqrt(0.5); elseif (Om <= 2e-18) tmp = 1.0; elseif (Om <= 1.5e+32) tmp = sqrt(0.5); else tmp = 1.0; end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (Om <= 1e-75) tmp = sqrt(0.5); elseif (Om <= 2e-18) tmp = 1.0; elseif (Om <= 1.5e+32) tmp = sqrt(0.5); else tmp = 1.0; end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[Om, 1e-75], N[Sqrt[0.5], $MachinePrecision], If[LessEqual[Om, 2e-18], 1.0, If[LessEqual[Om, 1.5e+32], N[Sqrt[0.5], $MachinePrecision], 1.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;Om \leq 10^{-75}:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{elif}\;Om \leq 2 \cdot 10^{-18}:\\
\;\;\;\;1\\
\mathbf{elif}\;Om \leq 1.5 \cdot 10^{+32}:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if Om < 9.9999999999999996e-76 or 2.0000000000000001e-18 < Om < 1.5e32Initial program 96.3%
Simplified96.3%
Taylor expanded in Om around 0 54.8%
*-commutative54.8%
associate-*r*54.8%
associate-*l/54.8%
unpow254.8%
unpow254.8%
hypot-def57.5%
associate-*l/57.5%
*-commutative57.5%
Simplified57.5%
Taylor expanded in l around inf 64.0%
if 9.9999999999999996e-76 < Om < 2.0000000000000001e-18 or 1.5e32 < Om Initial program 100.0%
Simplified100.0%
Taylor expanded in Om around inf 84.2%
Final simplification69.2%
(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 97.3%
Simplified97.3%
Taylor expanded in Om around 0 45.7%
*-commutative45.7%
associate-*r*45.7%
associate-*l/45.7%
unpow245.7%
unpow245.7%
hypot-def47.7%
associate-*l/47.7%
*-commutative47.7%
Simplified47.7%
Taylor expanded in l around inf 56.2%
Final simplification56.2%
herbie shell --seed 2023274
(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))))))))))