
(FPCore (l Om kx ky)
:precision binary64
(sqrt
(*
(/ 1.0 2.0)
(+
1.0
(/
1.0
(sqrt
(+
1.0
(*
(pow (/ (* 2.0 l) Om) 2.0)
(+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))))))))))
double code(double l, double Om, double kx, double ky) {
return sqrt(((1.0 / 2.0) * (1.0 + (1.0 / sqrt((1.0 + (pow(((2.0 * l) / Om), 2.0) * (pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))))))));
}
real(8) function code(l, om, kx, ky)
real(8), intent (in) :: l
real(8), intent (in) :: om
real(8), intent (in) :: kx
real(8), intent (in) :: ky
code = sqrt(((1.0d0 / 2.0d0) * (1.0d0 + (1.0d0 / sqrt((1.0d0 + ((((2.0d0 * l) / om) ** 2.0d0) * ((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))))))))
end function
public static double code(double l, double Om, double kx, double ky) {
return Math.sqrt(((1.0 / 2.0) * (1.0 + (1.0 / Math.sqrt((1.0 + (Math.pow(((2.0 * l) / Om), 2.0) * (Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))))))));
}
def code(l, Om, kx, ky): return math.sqrt(((1.0 / 2.0) * (1.0 + (1.0 / math.sqrt((1.0 + (math.pow(((2.0 * l) / Om), 2.0) * (math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))))))))
function code(l, Om, kx, ky) return sqrt(Float64(Float64(1.0 / 2.0) * Float64(1.0 + Float64(1.0 / sqrt(Float64(1.0 + Float64((Float64(Float64(2.0 * l) / Om) ^ 2.0) * Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))))))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt(((1.0 / 2.0) * (1.0 + (1.0 / sqrt((1.0 + ((((2.0 * l) / Om) ^ 2.0) * ((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))))))))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(N[(1.0 / 2.0), $MachinePrecision] * N[(1.0 + N[(1.0 / N[Sqrt[N[(1.0 + N[(N[Power[N[(N[(2.0 * l), $MachinePrecision] / Om), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\frac{1}{2} \cdot \left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (l Om kx ky)
:precision binary64
(sqrt
(*
(/ 1.0 2.0)
(+
1.0
(/
1.0
(sqrt
(+
1.0
(*
(pow (/ (* 2.0 l) Om) 2.0)
(+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))))))))))
double code(double l, double Om, double kx, double ky) {
return sqrt(((1.0 / 2.0) * (1.0 + (1.0 / sqrt((1.0 + (pow(((2.0 * l) / Om), 2.0) * (pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))))))));
}
real(8) function code(l, om, kx, ky)
real(8), intent (in) :: l
real(8), intent (in) :: om
real(8), intent (in) :: kx
real(8), intent (in) :: ky
code = sqrt(((1.0d0 / 2.0d0) * (1.0d0 + (1.0d0 / sqrt((1.0d0 + ((((2.0d0 * l) / om) ** 2.0d0) * ((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))))))))
end function
public static double code(double l, double Om, double kx, double ky) {
return Math.sqrt(((1.0 / 2.0) * (1.0 + (1.0 / Math.sqrt((1.0 + (Math.pow(((2.0 * l) / Om), 2.0) * (Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))))))));
}
def code(l, Om, kx, ky): return math.sqrt(((1.0 / 2.0) * (1.0 + (1.0 / math.sqrt((1.0 + (math.pow(((2.0 * l) / Om), 2.0) * (math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))))))))
function code(l, Om, kx, ky) return sqrt(Float64(Float64(1.0 / 2.0) * Float64(1.0 + Float64(1.0 / sqrt(Float64(1.0 + Float64((Float64(Float64(2.0 * l) / Om) ^ 2.0) * Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))))))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt(((1.0 / 2.0) * (1.0 + (1.0 / sqrt((1.0 + ((((2.0 * l) / Om) ^ 2.0) * ((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))))))))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(N[(1.0 / 2.0), $MachinePrecision] * N[(1.0 + N[(1.0 / N[Sqrt[N[(1.0 + N[(N[Power[N[(N[(2.0 * l), $MachinePrecision] / Om), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\frac{1}{2} \cdot \left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)}
\end{array}
(FPCore (l Om kx ky)
:precision binary64
(sqrt
(+
0.5
(*
0.5
(pow
(sqrt (hypot 1.0 (* (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 * pow(sqrt(hypot(1.0, (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 * Math.pow(Math.sqrt(Math.hypot(1.0, (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 * math.pow(math.sqrt(math.hypot(1.0, (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 * (sqrt(hypot(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 * (sqrt(hypot(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[Power[N[Sqrt[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], -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(\ell \cdot \frac{2}{Om}\right)\right)}\right)}^{-2}}
\end{array}
Initial program 98.4%
distribute-rgt-in98.4%
metadata-eval98.4%
metadata-eval98.4%
associate-/l*98.4%
metadata-eval98.4%
Simplified98.4%
inv-pow98.4%
add-sqr-sqrt98.4%
unpow-prod-down98.4%
Applied egg-rr100.0%
pow-sqr100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (l Om kx ky) :precision binary64 (sqrt (+ 0.5 (* 0.5 (pow (sqrt (hypot 1.0 (/ (* 2.0 (* (sin ky) 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, ((2.0 * (sin(ky) * 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, ((2.0 * (Math.sin(ky) * 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, ((2.0 * (math.sin(ky) * l)) / Om))), -2.0))))
function code(l, Om, kx, ky) return sqrt(Float64(0.5 + Float64(0.5 * (sqrt(hypot(1.0, Float64(Float64(2.0 * Float64(sin(ky) * l)) / Om))) ^ -2.0)))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 * (sqrt(hypot(1.0, ((2.0 * (sin(ky) * 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[(2.0 * N[(N[Sin[ky], $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] / Om), $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, \frac{2 \cdot \left(\sin ky \cdot \ell\right)}{Om}\right)}\right)}^{-2}}
\end{array}
Initial program 98.4%
distribute-rgt-in98.4%
metadata-eval98.4%
metadata-eval98.4%
associate-/l*98.4%
metadata-eval98.4%
Simplified98.4%
inv-pow98.4%
add-sqr-sqrt98.4%
unpow-prod-down98.4%
Applied egg-rr100.0%
pow-sqr100.0%
Simplified100.0%
Taylor expanded in kx around 0 93.9%
associate-*r/93.9%
Simplified93.9%
Final simplification93.9%
(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 98.4%
distribute-rgt-in98.4%
metadata-eval98.4%
metadata-eval98.4%
associate-/l*98.4%
metadata-eval98.4%
Simplified98.4%
inv-pow98.4%
add-sqr-sqrt98.4%
unpow-prod-down98.4%
Applied egg-rr100.0%
pow-sqr100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
sqrt-pow2100.0%
metadata-eval100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
unpow-1100.0%
associate-*r/100.0%
associate-/l*100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
associate-*l/100.0%
metadata-eval100.0%
associate-/r/100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (l Om kx ky) :precision binary64 (if (<= kx 2.5e-141) (sqrt (+ 0.5 (* 0.5 (/ 1.0 (hypot 1.0 (* (/ 2.0 Om) (* ky l))))))) (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (/ (sin kx) (/ (* 0.5 Om) l))))))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (kx <= 2.5e-141) {
tmp = sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, ((2.0 / Om) * (ky * l)))))));
} else {
tmp = sqrt((0.5 + (0.5 / hypot(1.0, (sin(kx) / ((0.5 * Om) / l))))));
}
return tmp;
}
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if (kx <= 2.5e-141) {
tmp = Math.sqrt((0.5 + (0.5 * (1.0 / Math.hypot(1.0, ((2.0 / Om) * (ky * l)))))));
} else {
tmp = Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, (Math.sin(kx) / ((0.5 * Om) / l))))));
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if kx <= 2.5e-141: tmp = math.sqrt((0.5 + (0.5 * (1.0 / math.hypot(1.0, ((2.0 / Om) * (ky * l))))))) else: tmp = math.sqrt((0.5 + (0.5 / math.hypot(1.0, (math.sin(kx) / ((0.5 * Om) / l)))))) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (kx <= 2.5e-141) tmp = sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / hypot(1.0, Float64(Float64(2.0 / Om) * Float64(ky * l))))))); else tmp = sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(sin(kx) / Float64(Float64(0.5 * Om) / l)))))); end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (kx <= 2.5e-141) tmp = sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, ((2.0 / Om) * (ky * l))))))); else tmp = sqrt((0.5 + (0.5 / hypot(1.0, (sin(kx) / ((0.5 * Om) / l)))))); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[kx, 2.5e-141], N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[Sqrt[1.0 ^ 2 + N[(N[(2.0 / Om), $MachinePrecision] * N[(ky * l), $MachinePrecision]), $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[(0.5 * Om), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;kx \leq 2.5 \cdot 10^{-141}:\\
\;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{\mathsf{hypot}\left(1, \frac{2}{Om} \cdot \left(ky \cdot \ell\right)\right)}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \frac{\sin kx}{\frac{0.5 \cdot Om}{\ell}}\right)}}\\
\end{array}
\end{array}
if kx < 2.5e-141Initial program 97.4%
distribute-rgt-in97.4%
metadata-eval97.4%
metadata-eval97.4%
associate-/l*97.4%
metadata-eval97.4%
Simplified97.4%
inv-pow97.4%
add-sqr-sqrt97.4%
unpow-prod-down97.4%
Applied egg-rr100.0%
pow-sqr100.0%
Simplified100.0%
Taylor expanded in kx around 0 96.1%
associate-*r/96.1%
Simplified96.1%
Taylor expanded in ky around 0 88.0%
*-un-lft-identity88.0%
sqrt-pow288.0%
associate-/l*88.0%
*-commutative88.0%
metadata-eval88.0%
Applied egg-rr88.0%
*-lft-identity88.0%
unpow-188.0%
associate-/r/88.0%
*-commutative88.0%
Simplified88.0%
if 2.5e-141 < kx Initial program 100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-/l*100.0%
metadata-eval100.0%
Simplified100.0%
inv-pow100.0%
add-sqr-sqrt100.0%
unpow-prod-down100.0%
Applied egg-rr100.0%
pow-sqr100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
sqrt-pow2100.0%
metadata-eval100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
unpow-1100.0%
associate-*r/100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in ky around 0 96.5%
*-un-lft-identity96.5%
associate-*l/96.5%
metadata-eval96.5%
associate-*r/96.5%
div-inv96.5%
metadata-eval96.5%
Applied egg-rr96.5%
*-lft-identity96.5%
associate-/l*96.5%
Simplified96.5%
Final simplification91.4%
(FPCore (l Om kx ky) :precision binary64 (sqrt (+ 0.5 (* 0.5 (/ 1.0 (hypot 1.0 (/ (* l 2.0) (/ Om (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 / 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.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.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 * 2.0) / Float64(Om / 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 / 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 * 2.0), $MachinePrecision] / N[(Om / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + 0.5 \cdot \frac{1}{\mathsf{hypot}\left(1, \frac{\ell \cdot 2}{\frac{Om}{\sin ky}}\right)}}
\end{array}
Initial program 98.4%
distribute-rgt-in98.4%
metadata-eval98.4%
metadata-eval98.4%
associate-/l*98.4%
metadata-eval98.4%
Simplified98.4%
inv-pow98.4%
add-sqr-sqrt98.4%
unpow-prod-down98.4%
Applied egg-rr100.0%
pow-sqr100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
sqrt-pow2100.0%
metadata-eval100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
unpow-1100.0%
associate-*r/100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in kx around 0 93.9%
associate-*r/93.9%
associate-*l*93.9%
associate-/l*93.9%
Simplified93.9%
Final simplification93.9%
(FPCore (l Om kx ky) :precision binary64 (if (<= l 1.75e-50) 1.0 (sqrt (+ 0.5 (* 0.5 (/ 1.0 (hypot 1.0 (* (/ 2.0 Om) (* ky l)))))))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= 1.75e-50) {
tmp = 1.0;
} else {
tmp = sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, ((2.0 / Om) * (ky * l)))))));
}
return tmp;
}
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= 1.75e-50) {
tmp = 1.0;
} else {
tmp = Math.sqrt((0.5 + (0.5 * (1.0 / Math.hypot(1.0, ((2.0 / Om) * (ky * l)))))));
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if l <= 1.75e-50: tmp = 1.0 else: tmp = math.sqrt((0.5 + (0.5 * (1.0 / math.hypot(1.0, ((2.0 / Om) * (ky * l))))))) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (l <= 1.75e-50) tmp = 1.0; else tmp = sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / hypot(1.0, Float64(Float64(2.0 / Om) * Float64(ky * l))))))); end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (l <= 1.75e-50) tmp = 1.0; else tmp = sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, ((2.0 / Om) * (ky * l))))))); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[l, 1.75e-50], 1.0, N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[Sqrt[1.0 ^ 2 + N[(N[(2.0 / Om), $MachinePrecision] * N[(ky * l), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 1.75 \cdot 10^{-50}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{\mathsf{hypot}\left(1, \frac{2}{Om} \cdot \left(ky \cdot \ell\right)\right)}}\\
\end{array}
\end{array}
if l < 1.74999999999999998e-50Initial program 97.7%
distribute-rgt-in97.7%
metadata-eval97.7%
metadata-eval97.7%
associate-/l*97.7%
metadata-eval97.7%
Simplified97.7%
inv-pow97.7%
add-sqr-sqrt97.7%
unpow-prod-down97.7%
Applied egg-rr100.0%
pow-sqr100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
sqrt-pow2100.0%
metadata-eval100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
unpow-1100.0%
associate-*r/100.0%
associate-/l*100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
associate-*l/100.0%
metadata-eval100.0%
associate-/r/100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in l around 0 73.1%
if 1.74999999999999998e-50 < l Initial program 100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-/l*100.0%
metadata-eval100.0%
Simplified100.0%
inv-pow100.0%
add-sqr-sqrt100.0%
unpow-prod-down100.0%
Applied egg-rr100.0%
pow-sqr100.0%
Simplified100.0%
Taylor expanded in kx around 0 92.8%
associate-*r/92.8%
Simplified92.8%
Taylor expanded in ky around 0 85.6%
*-un-lft-identity85.6%
sqrt-pow285.6%
associate-/l*85.6%
*-commutative85.6%
metadata-eval85.6%
Applied egg-rr85.6%
*-lft-identity85.6%
unpow-185.6%
associate-/r/85.6%
*-commutative85.6%
Simplified85.6%
Final simplification76.9%
(FPCore (l Om kx ky) :precision binary64 (if (<= Om 1e-59) (sqrt 0.5) (if (<= Om 2e-50) 1.0 (if (<= Om 5000000000000.0) (sqrt 0.5) 1.0))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (Om <= 1e-59) {
tmp = sqrt(0.5);
} else if (Om <= 2e-50) {
tmp = 1.0;
} else if (Om <= 5000000000000.0) {
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-59) then
tmp = sqrt(0.5d0)
else if (om <= 2d-50) then
tmp = 1.0d0
else if (om <= 5000000000000.0d0) 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-59) {
tmp = Math.sqrt(0.5);
} else if (Om <= 2e-50) {
tmp = 1.0;
} else if (Om <= 5000000000000.0) {
tmp = Math.sqrt(0.5);
} else {
tmp = 1.0;
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if Om <= 1e-59: tmp = math.sqrt(0.5) elif Om <= 2e-50: tmp = 1.0 elif Om <= 5000000000000.0: tmp = math.sqrt(0.5) else: tmp = 1.0 return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (Om <= 1e-59) tmp = sqrt(0.5); elseif (Om <= 2e-50) tmp = 1.0; elseif (Om <= 5000000000000.0) 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-59) tmp = sqrt(0.5); elseif (Om <= 2e-50) tmp = 1.0; elseif (Om <= 5000000000000.0) tmp = sqrt(0.5); else tmp = 1.0; end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[Om, 1e-59], N[Sqrt[0.5], $MachinePrecision], If[LessEqual[Om, 2e-50], 1.0, If[LessEqual[Om, 5000000000000.0], N[Sqrt[0.5], $MachinePrecision], 1.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;Om \leq 10^{-59}:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{elif}\;Om \leq 2 \cdot 10^{-50}:\\
\;\;\;\;1\\
\mathbf{elif}\;Om \leq 5000000000000:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if Om < 1e-59 or 2.00000000000000002e-50 < Om < 5e12Initial program 98.0%
distribute-rgt-in98.0%
metadata-eval98.0%
metadata-eval98.0%
associate-/l*98.0%
metadata-eval98.0%
Simplified98.0%
Taylor expanded in Om around 0 51.6%
*-commutative51.6%
associate-*r*51.6%
unpow251.6%
unpow251.6%
hypot-def53.3%
associate-*l/53.3%
associate-*r/53.3%
Simplified53.3%
Taylor expanded in l around inf 61.1%
if 1e-59 < Om < 2.00000000000000002e-50 or 5e12 < Om Initial program 100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-/l*100.0%
metadata-eval100.0%
Simplified100.0%
inv-pow100.0%
add-sqr-sqrt100.0%
unpow-prod-down100.0%
Applied egg-rr100.0%
pow-sqr100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
sqrt-pow2100.0%
metadata-eval100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
unpow-1100.0%
associate-*r/100.0%
associate-/l*100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
associate-*l/100.0%
metadata-eval100.0%
associate-/r/100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in l around 0 87.4%
Final simplification67.3%
(FPCore (l Om kx ky) :precision binary64 (if (<= Om 8e+76) (sqrt 0.5) (+ 1.0 (* -0.5 (/ (* l l) (/ (* Om Om) (* ky ky)))))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (Om <= 8e+76) {
tmp = sqrt(0.5);
} else {
tmp = 1.0 + (-0.5 * ((l * l) / ((Om * Om) / (ky * ky))));
}
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 <= 8d+76) then
tmp = sqrt(0.5d0)
else
tmp = 1.0d0 + ((-0.5d0) * ((l * l) / ((om * om) / (ky * ky))))
end if
code = tmp
end function
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if (Om <= 8e+76) {
tmp = Math.sqrt(0.5);
} else {
tmp = 1.0 + (-0.5 * ((l * l) / ((Om * Om) / (ky * ky))));
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if Om <= 8e+76: tmp = math.sqrt(0.5) else: tmp = 1.0 + (-0.5 * ((l * l) / ((Om * Om) / (ky * ky)))) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (Om <= 8e+76) tmp = sqrt(0.5); else tmp = Float64(1.0 + Float64(-0.5 * Float64(Float64(l * l) / Float64(Float64(Om * Om) / Float64(ky * ky))))); end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (Om <= 8e+76) tmp = sqrt(0.5); else tmp = 1.0 + (-0.5 * ((l * l) / ((Om * Om) / (ky * ky)))); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[Om, 8e+76], N[Sqrt[0.5], $MachinePrecision], N[(1.0 + N[(-0.5 * N[(N[(l * l), $MachinePrecision] / N[(N[(Om * Om), $MachinePrecision] / N[(ky * ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;Om \leq 8 \cdot 10^{+76}:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{else}:\\
\;\;\;\;1 + -0.5 \cdot \frac{\ell \cdot \ell}{\frac{Om \cdot Om}{ky \cdot ky}}\\
\end{array}
\end{array}
if Om < 8.0000000000000004e76Initial program 98.1%
distribute-rgt-in98.1%
metadata-eval98.1%
metadata-eval98.1%
associate-/l*98.1%
metadata-eval98.1%
Simplified98.1%
Taylor expanded in Om around 0 51.4%
*-commutative51.4%
associate-*r*51.4%
unpow251.4%
unpow251.4%
hypot-def53.0%
associate-*l/53.0%
associate-*r/53.0%
Simplified53.0%
Taylor expanded in l around inf 60.8%
if 8.0000000000000004e76 < 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 82.9%
associate-*r/82.9%
*-commutative82.9%
associate-*r*82.9%
unpow282.9%
unpow282.9%
Simplified82.9%
Taylor expanded in l around 0 78.9%
associate-*r/78.9%
associate-*r*78.9%
unpow278.9%
unpow278.9%
Simplified78.9%
Taylor expanded in ky around 0 60.6%
associate-/l*60.6%
unpow260.6%
unpow260.6%
unpow260.6%
Simplified60.6%
Final simplification60.8%
(FPCore (l Om kx ky) :precision binary64 (+ 1.0 (* -0.5 (/ (* l l) (/ (* Om Om) (* ky ky))))))
double code(double l, double Om, double kx, double ky) {
return 1.0 + (-0.5 * ((l * l) / ((Om * Om) / (ky * ky))));
}
real(8) function code(l, om, kx, ky)
real(8), intent (in) :: l
real(8), intent (in) :: om
real(8), intent (in) :: kx
real(8), intent (in) :: ky
code = 1.0d0 + ((-0.5d0) * ((l * l) / ((om * om) / (ky * ky))))
end function
public static double code(double l, double Om, double kx, double ky) {
return 1.0 + (-0.5 * ((l * l) / ((Om * Om) / (ky * ky))));
}
def code(l, Om, kx, ky): return 1.0 + (-0.5 * ((l * l) / ((Om * Om) / (ky * ky))))
function code(l, Om, kx, ky) return Float64(1.0 + Float64(-0.5 * Float64(Float64(l * l) / Float64(Float64(Om * Om) / Float64(ky * ky))))) end
function tmp = code(l, Om, kx, ky) tmp = 1.0 + (-0.5 * ((l * l) / ((Om * Om) / (ky * ky)))); end
code[l_, Om_, kx_, ky_] := N[(1.0 + N[(-0.5 * N[(N[(l * l), $MachinePrecision] / N[(N[(Om * Om), $MachinePrecision] / N[(ky * ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + -0.5 \cdot \frac{\ell \cdot \ell}{\frac{Om \cdot Om}{ky \cdot ky}}
\end{array}
Initial program 98.4%
distribute-rgt-in98.4%
metadata-eval98.4%
metadata-eval98.4%
associate-/l*98.4%
metadata-eval98.4%
Simplified98.4%
Taylor expanded in kx around 0 79.7%
associate-*r/79.7%
*-commutative79.7%
associate-*r*79.7%
unpow279.7%
unpow279.7%
Simplified79.7%
Taylor expanded in l around 0 50.0%
associate-*r/50.0%
associate-*r*50.0%
unpow250.0%
unpow250.0%
Simplified50.0%
Taylor expanded in ky around 0 37.6%
associate-/l*36.8%
unpow236.8%
unpow236.8%
unpow236.8%
Simplified36.8%
Final simplification36.8%
herbie shell --seed 2023192
(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))))))))))