
(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
(sqrt
(+ 1.0 (pow (* (hypot (sin ky) (sin kx)) (* l (/ 2.0 Om))) 2.0))))))))
double code(double l, double Om, double kx, double ky) {
return sqrt((0.5 + (0.5 * (1.0 / sqrt((1.0 + pow((hypot(sin(ky), sin(kx)) * (l * (2.0 / Om))), 2.0)))))));
}
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 + Math.pow((Math.hypot(Math.sin(ky), Math.sin(kx)) * (l * (2.0 / Om))), 2.0)))))));
}
def code(l, Om, kx, ky): return math.sqrt((0.5 + (0.5 * (1.0 / math.sqrt((1.0 + math.pow((math.hypot(math.sin(ky), math.sin(kx)) * (l * (2.0 / 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(hypot(sin(ky), sin(kx)) * Float64(l * Float64(2.0 / Om))) ^ 2.0))))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 * (1.0 / sqrt((1.0 + ((hypot(sin(ky), sin(kx)) * (l * (2.0 / 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[Power[N[(N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision] * N[(l * N[(2.0 / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + 0.5 \cdot \frac{1}{\sqrt{1 + {\left(\mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}^{2}}}}
\end{array}
Initial program 98.8%
distribute-rgt-in98.8%
metadata-eval98.8%
metadata-eval98.8%
associate-/l*98.8%
metadata-eval98.8%
Simplified98.8%
pow198.8%
add-sqr-sqrt98.8%
pow298.8%
sqrt-prod98.8%
unpow298.8%
sqrt-prod51.6%
add-sqr-sqrt98.8%
div-inv98.8%
clear-num98.8%
unpow298.8%
unpow298.8%
hypot-def100.0%
Applied egg-rr100.0%
unpow1100.0%
*-commutative100.0%
hypot-def98.8%
unpow298.8%
unpow298.8%
+-commutative98.8%
unpow298.8%
unpow298.8%
hypot-def100.0%
*-commutative100.0%
associate-*l/100.0%
associate-*r/100.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)) (* l (/ 2.0 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)) * (l * (2.0 / 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)) * (l * (2.0 / 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)) * (l * (2.0 / 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(l * Float64(2.0 / 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)) * (l * (2.0 / 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[(l * N[(2.0 / 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(\ell \cdot \frac{2}{Om}\right)\right)}}
\end{array}
Initial program 98.8%
distribute-rgt-in98.8%
metadata-eval98.8%
metadata-eval98.8%
associate-/l*98.8%
metadata-eval98.8%
Simplified98.8%
expm1-log1p-u98.8%
expm1-udef98.8%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
hypot-def98.8%
unpow298.8%
unpow298.8%
+-commutative98.8%
unpow298.8%
unpow298.8%
hypot-def100.0%
*-commutative100.0%
associate-*l/100.0%
associate-*r/100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (l Om kx ky) :precision binary64 (sqrt (+ 0.5 (* 0.5 (pow (+ 1.0 (pow (/ (* l (* (sin ky) 2.0)) Om) 2.0)) -0.5)))))
double code(double l, double Om, double kx, double ky) {
return sqrt((0.5 + (0.5 * pow((1.0 + pow(((l * (sin(ky) * 2.0)) / Om), 2.0)), -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 + (0.5d0 * ((1.0d0 + (((l * (sin(ky) * 2.0d0)) / om) ** 2.0d0)) ** (-0.5d0)))))
end function
public static double code(double l, double Om, double kx, double ky) {
return Math.sqrt((0.5 + (0.5 * Math.pow((1.0 + Math.pow(((l * (Math.sin(ky) * 2.0)) / Om), 2.0)), -0.5))));
}
def code(l, Om, kx, ky): return math.sqrt((0.5 + (0.5 * math.pow((1.0 + math.pow(((l * (math.sin(ky) * 2.0)) / Om), 2.0)), -0.5))))
function code(l, Om, kx, ky) return sqrt(Float64(0.5 + Float64(0.5 * (Float64(1.0 + (Float64(Float64(l * Float64(sin(ky) * 2.0)) / Om) ^ 2.0)) ^ -0.5)))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 * ((1.0 + (((l * (sin(ky) * 2.0)) / Om) ^ 2.0)) ^ -0.5)))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(0.5 + N[(0.5 * N[Power[N[(1.0 + N[Power[N[(N[(l * N[(N[Sin[ky], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] / Om), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + 0.5 \cdot {\left(1 + {\left(\frac{\ell \cdot \left(\sin ky \cdot 2\right)}{Om}\right)}^{2}\right)}^{-0.5}}
\end{array}
Initial program 98.8%
distribute-rgt-in98.8%
metadata-eval98.8%
metadata-eval98.8%
associate-/l*98.8%
metadata-eval98.8%
Simplified98.8%
Taylor expanded in kx around 0 76.4%
associate-*r/76.4%
*-commutative76.4%
associate-*r*76.4%
unpow276.4%
unpow276.4%
Simplified76.4%
inv-pow76.4%
sqrt-pow276.4%
Applied egg-rr94.1%
Final simplification94.1%
(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(Float64(sin(ky) * 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[(N[Sin[ky], $MachinePrecision] * 2.0), $MachinePrecision] * N[(l / Om), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \left(\sin ky \cdot 2\right) \cdot \frac{\ell}{Om}\right)}}
\end{array}
Initial program 98.8%
distribute-rgt-in98.8%
metadata-eval98.8%
metadata-eval98.8%
associate-/l*98.8%
metadata-eval98.8%
Simplified98.8%
Taylor expanded in kx around 0 76.4%
associate-*r/76.4%
*-commutative76.4%
associate-*r*76.4%
unpow276.4%
unpow276.4%
Simplified76.4%
add-sqr-sqrt76.4%
hypot-1-def76.4%
sqrt-div76.4%
*-commutative76.4%
sqrt-prod77.6%
sqrt-prod38.5%
add-sqr-sqrt86.0%
*-commutative86.0%
sqrt-prod86.0%
unpow286.0%
sqrt-prod43.8%
add-sqr-sqrt91.9%
metadata-eval91.9%
sqrt-prod42.7%
add-sqr-sqrt94.1%
Applied egg-rr94.1%
expm1-log1p-u93.4%
expm1-udef93.4%
associate-*l/93.4%
metadata-eval93.4%
associate-/l*93.4%
Applied egg-rr93.4%
expm1-def93.4%
expm1-log1p94.1%
associate-/r/94.1%
*-commutative94.1%
Simplified94.1%
Final simplification94.1%
(FPCore (l Om kx ky) :precision binary64 (if (<= Om 1.4e+145) (sqrt (+ 0.5 (* 0.5 (/ 1.0 (hypot 1.0 (/ (* 2.0 (* ky l)) Om)))))) 1.0))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (Om <= 1.4e+145) {
tmp = sqrt((0.5 + (0.5 * (1.0 / 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 (Om <= 1.4e+145) {
tmp = Math.sqrt((0.5 + (0.5 * (1.0 / Math.hypot(1.0, ((2.0 * (ky * l)) / Om))))));
} else {
tmp = 1.0;
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if Om <= 1.4e+145: tmp = math.sqrt((0.5 + (0.5 * (1.0 / 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 (Om <= 1.4e+145) tmp = sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / hypot(1.0, Float64(Float64(2.0 * Float64(ky * l)) / Om)))))); else tmp = 1.0; end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (Om <= 1.4e+145) tmp = sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, ((2.0 * (ky * l)) / Om)))))); else tmp = 1.0; end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[Om, 1.4e+145], N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[Sqrt[1.0 ^ 2 + N[(N[(2.0 * N[(ky * l), $MachinePrecision]), $MachinePrecision] / Om), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;Om \leq 1.4 \cdot 10^{+145}:\\
\;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{\mathsf{hypot}\left(1, \frac{2 \cdot \left(ky \cdot \ell\right)}{Om}\right)}}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if Om < 1.3999999999999999e145Initial program 98.7%
distribute-rgt-in98.7%
metadata-eval98.7%
metadata-eval98.7%
associate-/l*98.7%
metadata-eval98.7%
Simplified98.7%
Taylor expanded in kx around 0 77.1%
associate-*r/77.1%
*-commutative77.1%
associate-*r*77.1%
unpow277.1%
unpow277.1%
Simplified77.1%
add-sqr-sqrt77.1%
hypot-1-def77.1%
sqrt-div77.1%
*-commutative77.1%
sqrt-prod78.4%
sqrt-prod38.8%
add-sqr-sqrt85.3%
*-commutative85.3%
sqrt-prod85.3%
unpow285.3%
sqrt-prod42.0%
add-sqr-sqrt91.8%
metadata-eval91.8%
sqrt-prod37.0%
add-sqr-sqrt93.5%
Applied egg-rr93.5%
Taylor expanded in ky around 0 85.4%
if 1.3999999999999999e145 < Om Initial program 100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-/l*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in kx around 0 69.6%
associate-*r/69.6%
*-commutative69.6%
associate-*r*69.6%
unpow269.6%
unpow269.6%
Simplified69.6%
inv-pow69.6%
sqrt-pow269.6%
Applied egg-rr100.0%
Taylor expanded in l around 0 93.0%
Final simplification86.1%
(FPCore (l Om kx ky)
:precision binary64
(if (<= Om 6e-157)
(sqrt 0.5)
(if (<= Om 1.4e+101)
(sqrt (+ 0.5 (/ 0.5 (+ 1.0 (* 2.0 (* (/ (* l l) (* Om Om)) (* ky ky)))))))
1.0)))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (Om <= 6e-157) {
tmp = sqrt(0.5);
} else if (Om <= 1.4e+101) {
tmp = sqrt((0.5 + (0.5 / (1.0 + (2.0 * (((l * l) / (Om * Om)) * (ky * 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 (om <= 6d-157) then
tmp = sqrt(0.5d0)
else if (om <= 1.4d+101) then
tmp = sqrt((0.5d0 + (0.5d0 / (1.0d0 + (2.0d0 * (((l * l) / (om * om)) * (ky * 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 (Om <= 6e-157) {
tmp = Math.sqrt(0.5);
} else if (Om <= 1.4e+101) {
tmp = Math.sqrt((0.5 + (0.5 / (1.0 + (2.0 * (((l * l) / (Om * Om)) * (ky * ky)))))));
} else {
tmp = 1.0;
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if Om <= 6e-157: tmp = math.sqrt(0.5) elif Om <= 1.4e+101: tmp = math.sqrt((0.5 + (0.5 / (1.0 + (2.0 * (((l * l) / (Om * Om)) * (ky * ky))))))) else: tmp = 1.0 return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (Om <= 6e-157) tmp = sqrt(0.5); elseif (Om <= 1.4e+101) tmp = sqrt(Float64(0.5 + Float64(0.5 / Float64(1.0 + Float64(2.0 * Float64(Float64(Float64(l * l) / Float64(Om * Om)) * Float64(ky * ky))))))); else tmp = 1.0; end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (Om <= 6e-157) tmp = sqrt(0.5); elseif (Om <= 1.4e+101) tmp = sqrt((0.5 + (0.5 / (1.0 + (2.0 * (((l * l) / (Om * Om)) * (ky * ky))))))); else tmp = 1.0; end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[Om, 6e-157], N[Sqrt[0.5], $MachinePrecision], If[LessEqual[Om, 1.4e+101], N[Sqrt[N[(0.5 + N[(0.5 / N[(1.0 + N[(2.0 * N[(N[(N[(l * l), $MachinePrecision] / N[(Om * Om), $MachinePrecision]), $MachinePrecision] * N[(ky * ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;Om \leq 6 \cdot 10^{-157}:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{elif}\;Om \leq 1.4 \cdot 10^{+101}:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{1 + 2 \cdot \left(\frac{\ell \cdot \ell}{Om \cdot Om} \cdot \left(ky \cdot ky\right)\right)}}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if Om < 6e-157Initial program 98.3%
distribute-rgt-in98.3%
metadata-eval98.3%
metadata-eval98.3%
associate-/l*98.3%
metadata-eval98.3%
Simplified98.3%
Taylor expanded in Om around 0 54.3%
*-commutative54.3%
associate-*r*54.3%
unpow254.3%
unpow254.3%
hypot-def56.0%
associate-*l/56.0%
associate-*r/56.0%
Simplified56.0%
Taylor expanded in l around inf 63.7%
if 6e-157 < Om < 1.39999999999999991e101Initial program 100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-/l*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in kx around 0 83.9%
associate-*r/83.9%
*-commutative83.9%
associate-*r*83.9%
unpow283.9%
unpow283.9%
Simplified83.9%
Taylor expanded in ky around 0 73.5%
associate-/l*71.6%
unpow271.6%
unpow271.6%
unpow271.6%
Simplified71.6%
associate-*l/71.6%
metadata-eval71.6%
associate-/r/73.1%
Applied egg-rr73.1%
if 1.39999999999999991e101 < Om Initial program 100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-/l*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in kx around 0 71.6%
associate-*r/71.6%
*-commutative71.6%
associate-*r*71.6%
unpow271.6%
unpow271.6%
Simplified71.6%
inv-pow71.6%
sqrt-pow271.6%
Applied egg-rr100.0%
Taylor expanded in l around 0 89.7%
Final simplification68.7%
(FPCore (l Om kx ky) :precision binary64 (if (<= Om 6.5e-11) (sqrt 0.5) 1.0))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (Om <= 6.5e-11) {
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 <= 6.5d-11) 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 <= 6.5e-11) {
tmp = Math.sqrt(0.5);
} else {
tmp = 1.0;
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if Om <= 6.5e-11: tmp = math.sqrt(0.5) else: tmp = 1.0 return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (Om <= 6.5e-11) 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 <= 6.5e-11) tmp = sqrt(0.5); else tmp = 1.0; end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[Om, 6.5e-11], N[Sqrt[0.5], $MachinePrecision], 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;Om \leq 6.5 \cdot 10^{-11}:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if Om < 6.49999999999999953e-11Initial program 98.5%
distribute-rgt-in98.5%
metadata-eval98.5%
metadata-eval98.5%
associate-/l*98.5%
metadata-eval98.5%
Simplified98.5%
Taylor expanded in Om around 0 55.4%
*-commutative55.4%
associate-*r*55.4%
unpow255.4%
unpow255.4%
hypot-def56.9%
associate-*l/56.9%
associate-*r/56.9%
Simplified56.9%
Taylor expanded in l around inf 64.1%
if 6.49999999999999953e-11 < Om Initial program 100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-/l*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in kx around 0 80.0%
associate-*r/80.0%
*-commutative80.0%
associate-*r*80.0%
unpow280.0%
unpow280.0%
Simplified80.0%
inv-pow80.0%
sqrt-pow280.0%
Applied egg-rr98.4%
Taylor expanded in l around 0 83.1%
Final simplification67.8%
(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 98.8%
distribute-rgt-in98.8%
metadata-eval98.8%
metadata-eval98.8%
associate-/l*98.8%
metadata-eval98.8%
Simplified98.8%
Taylor expanded in kx around 0 76.4%
associate-*r/76.4%
*-commutative76.4%
associate-*r*76.4%
unpow276.4%
unpow276.4%
Simplified76.4%
inv-pow76.4%
sqrt-pow276.4%
Applied egg-rr94.1%
Taylor expanded in l around 0 60.1%
Final simplification60.1%
herbie shell --seed 2023215
(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))))))))))