
(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 7 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 (* (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 98.4%
distribute-rgt-in98.4%
metadata-eval98.4%
metadata-eval98.4%
associate-/l*98.4%
metadata-eval98.4%
Simplified98.4%
expm1-log1p-u98.4%
expm1-udef98.4%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
hypot-def98.6%
unpow298.6%
unpow298.6%
+-commutative98.6%
unpow298.6%
unpow298.6%
hypot-def100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (l Om kx ky) :precision binary64 (if (<= ky 2e-79) (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* (/ l Om) (* (sin kx) 2.0)))))) (cbrt (pow (+ 0.5 (/ 0.5 (hypot 1.0 (* (sin ky) (/ (* 2.0 l) Om))))) 1.5))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (ky <= 2e-79) {
tmp = sqrt((0.5 + (0.5 / hypot(1.0, ((l / Om) * (sin(kx) * 2.0))))));
} else {
tmp = cbrt(pow((0.5 + (0.5 / hypot(1.0, (sin(ky) * ((2.0 * l) / Om))))), 1.5));
}
return tmp;
}
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if (ky <= 2e-79) {
tmp = Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, ((l / Om) * (Math.sin(kx) * 2.0))))));
} else {
tmp = Math.cbrt(Math.pow((0.5 + (0.5 / Math.hypot(1.0, (Math.sin(ky) * ((2.0 * l) / Om))))), 1.5));
}
return tmp;
}
function code(l, Om, kx, ky) tmp = 0.0 if (ky <= 2e-79) tmp = sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(Float64(l / Om) * Float64(sin(kx) * 2.0)))))); else tmp = cbrt((Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(sin(ky) * Float64(Float64(2.0 * l) / Om))))) ^ 1.5)); end return tmp end
code[l_, Om_, kx_, ky_] := If[LessEqual[ky, 2e-79], N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(N[(l / Om), $MachinePrecision] * N[(N[Sin[kx], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Power[N[Power[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(N[Sin[ky], $MachinePrecision] * N[(N[(2.0 * l), $MachinePrecision] / Om), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.5], $MachinePrecision], 1/3], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 2 \cdot 10^{-79}:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \frac{\ell}{Om} \cdot \left(\sin kx \cdot 2\right)\right)}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{{\left(0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \sin ky \cdot \frac{2 \cdot \ell}{Om}\right)}\right)}^{1.5}}\\
\end{array}
\end{array}
if ky < 2e-79Initial program 97.5%
distribute-rgt-in97.5%
metadata-eval97.5%
metadata-eval97.5%
associate-/l*97.5%
metadata-eval97.5%
Simplified97.5%
expm1-log1p-u97.5%
expm1-udef97.5%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
hypot-def97.8%
unpow297.8%
unpow297.8%
+-commutative97.8%
unpow297.8%
unpow297.8%
hypot-def100.0%
Simplified100.0%
Taylor expanded in ky around 0 94.9%
expm1-log1p-u94.3%
expm1-udef94.3%
associate-*l/94.3%
metadata-eval94.3%
Applied egg-rr94.3%
expm1-def94.3%
expm1-log1p94.9%
associate-*r*94.9%
Simplified94.9%
if 2e-79 < ky Initial program 100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-/l*100.0%
metadata-eval100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
hypot-def100.0%
unpow2100.0%
unpow2100.0%
+-commutative100.0%
unpow2100.0%
unpow2100.0%
hypot-def100.0%
Simplified100.0%
add-cbrt-cube99.9%
add-sqr-sqrt99.9%
pow199.9%
pow1/299.9%
pow-prod-up99.9%
Applied egg-rr99.9%
associate-*r/99.9%
Simplified99.9%
Taylor expanded in kx around 0 99.2%
Final simplification96.5%
(FPCore (l Om kx ky) :precision binary64 (if (<= ky 9e-79) (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* (/ l Om) (* (sin kx) 2.0)))))) (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) {
double tmp;
if (ky <= 9e-79) {
tmp = sqrt((0.5 + (0.5 / hypot(1.0, ((l / Om) * (sin(kx) * 2.0))))));
} else {
tmp = sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, (sin(ky) * (2.0 * (l / Om))))))));
}
return tmp;
}
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if (ky <= 9e-79) {
tmp = Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, ((l / Om) * (Math.sin(kx) * 2.0))))));
} else {
tmp = Math.sqrt((0.5 + (0.5 * (1.0 / Math.hypot(1.0, (Math.sin(ky) * (2.0 * (l / Om))))))));
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if ky <= 9e-79: tmp = math.sqrt((0.5 + (0.5 / math.hypot(1.0, ((l / Om) * (math.sin(kx) * 2.0)))))) else: tmp = math.sqrt((0.5 + (0.5 * (1.0 / math.hypot(1.0, (math.sin(ky) * (2.0 * (l / Om)))))))) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (ky <= 9e-79) tmp = sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(Float64(l / Om) * Float64(sin(kx) * 2.0)))))); else tmp = sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / hypot(1.0, Float64(sin(ky) * Float64(2.0 * Float64(l / Om)))))))); end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (ky <= 9e-79) tmp = sqrt((0.5 + (0.5 / hypot(1.0, ((l / Om) * (sin(kx) * 2.0)))))); else tmp = sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, (sin(ky) * (2.0 * (l / Om)))))))); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[ky, 9e-79], N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(N[(l / Om), $MachinePrecision] * N[(N[Sin[kx], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[Sqrt[1.0 ^ 2 + N[(N[Sin[ky], $MachinePrecision] * N[(2.0 * N[(l / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 9 \cdot 10^{-79}:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \frac{\ell}{Om} \cdot \left(\sin kx \cdot 2\right)\right)}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{\mathsf{hypot}\left(1, \sin ky \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)}}\\
\end{array}
\end{array}
if ky < 9.0000000000000006e-79Initial program 97.5%
distribute-rgt-in97.5%
metadata-eval97.5%
metadata-eval97.5%
associate-/l*97.5%
metadata-eval97.5%
Simplified97.5%
expm1-log1p-u97.5%
expm1-udef97.5%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
hypot-def97.8%
unpow297.8%
unpow297.8%
+-commutative97.8%
unpow297.8%
unpow297.8%
hypot-def100.0%
Simplified100.0%
Taylor expanded in ky around 0 94.9%
expm1-log1p-u94.3%
expm1-udef94.3%
associate-*l/94.3%
metadata-eval94.3%
Applied egg-rr94.3%
expm1-def94.3%
expm1-log1p94.9%
associate-*r*94.9%
Simplified94.9%
if 9.0000000000000006e-79 < ky Initial program 100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-/l*100.0%
metadata-eval100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
hypot-def100.0%
unpow2100.0%
unpow2100.0%
+-commutative100.0%
unpow2100.0%
unpow2100.0%
hypot-def100.0%
Simplified100.0%
Taylor expanded in kx around 0 99.3%
Final simplification96.5%
(FPCore (l Om kx ky) :precision binary64 (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* (/ l Om) (* (sin kx) 2.0)))))))
double code(double l, double Om, double kx, double ky) {
return sqrt((0.5 + (0.5 / hypot(1.0, ((l / Om) * (sin(kx) * 2.0))))));
}
public static double code(double l, double Om, double kx, double ky) {
return Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, ((l / Om) * (Math.sin(kx) * 2.0))))));
}
def code(l, Om, kx, ky): return math.sqrt((0.5 + (0.5 / math.hypot(1.0, ((l / Om) * (math.sin(kx) * 2.0))))))
function code(l, Om, kx, ky) return sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(Float64(l / Om) * Float64(sin(kx) * 2.0)))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 / hypot(1.0, ((l / Om) * (sin(kx) * 2.0)))))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(N[(l / Om), $MachinePrecision] * N[(N[Sin[kx], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \frac{\ell}{Om} \cdot \left(\sin kx \cdot 2\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%
expm1-log1p-u98.4%
expm1-udef98.4%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
hypot-def98.6%
unpow298.6%
unpow298.6%
+-commutative98.6%
unpow298.6%
unpow298.6%
hypot-def100.0%
Simplified100.0%
Taylor expanded in ky around 0 93.3%
expm1-log1p-u92.6%
expm1-udef92.6%
associate-*l/92.6%
metadata-eval92.6%
Applied egg-rr92.6%
expm1-def92.6%
expm1-log1p93.3%
associate-*r*93.3%
Simplified93.3%
Final simplification93.3%
(FPCore (l Om kx ky) :precision binary64 (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (/ (* 2.0 (* kx l)) Om))))))
double code(double l, double Om, double kx, double ky) {
return sqrt((0.5 + (0.5 / hypot(1.0, ((2.0 * (kx * 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, ((2.0 * (kx * l)) / Om)))));
}
def code(l, Om, kx, ky): return math.sqrt((0.5 + (0.5 / math.hypot(1.0, ((2.0 * (kx * l)) / Om)))))
function code(l, Om, kx, ky) return sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(Float64(2.0 * Float64(kx * l)) / Om))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 / hypot(1.0, ((2.0 * (kx * l)) / 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[(kx * l), $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(kx \cdot \ell\right)}{Om}\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%
expm1-log1p-u98.4%
expm1-udef98.4%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
hypot-def98.6%
unpow298.6%
unpow298.6%
+-commutative98.6%
unpow298.6%
unpow298.6%
hypot-def100.0%
Simplified100.0%
Taylor expanded in ky around 0 93.3%
expm1-log1p-u92.6%
expm1-udef92.6%
associate-*l/92.6%
metadata-eval92.6%
Applied egg-rr92.6%
expm1-def92.6%
expm1-log1p93.3%
associate-*r*93.3%
Simplified93.3%
Taylor expanded in kx around 0 85.4%
associate-*r/85.4%
Simplified85.4%
Final simplification85.4%
(FPCore (l Om kx ky)
:precision binary64
(if (<= l -68000.0)
(sqrt 0.5)
(if (<= l 3.2e-93)
1.0
(if (<= l 1.4e-50) (sqrt 0.5) (if (<= l 5.4e-11) 1.0 (sqrt 0.5))))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= -68000.0) {
tmp = sqrt(0.5);
} else if (l <= 3.2e-93) {
tmp = 1.0;
} else if (l <= 1.4e-50) {
tmp = sqrt(0.5);
} else if (l <= 5.4e-11) {
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 <= (-68000.0d0)) then
tmp = sqrt(0.5d0)
else if (l <= 3.2d-93) then
tmp = 1.0d0
else if (l <= 1.4d-50) then
tmp = sqrt(0.5d0)
else if (l <= 5.4d-11) 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 <= -68000.0) {
tmp = Math.sqrt(0.5);
} else if (l <= 3.2e-93) {
tmp = 1.0;
} else if (l <= 1.4e-50) {
tmp = Math.sqrt(0.5);
} else if (l <= 5.4e-11) {
tmp = 1.0;
} else {
tmp = Math.sqrt(0.5);
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if l <= -68000.0: tmp = math.sqrt(0.5) elif l <= 3.2e-93: tmp = 1.0 elif l <= 1.4e-50: tmp = math.sqrt(0.5) elif l <= 5.4e-11: tmp = 1.0 else: tmp = math.sqrt(0.5) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (l <= -68000.0) tmp = sqrt(0.5); elseif (l <= 3.2e-93) tmp = 1.0; elseif (l <= 1.4e-50) tmp = sqrt(0.5); elseif (l <= 5.4e-11) 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 <= -68000.0) tmp = sqrt(0.5); elseif (l <= 3.2e-93) tmp = 1.0; elseif (l <= 1.4e-50) tmp = sqrt(0.5); elseif (l <= 5.4e-11) tmp = 1.0; else tmp = sqrt(0.5); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[l, -68000.0], N[Sqrt[0.5], $MachinePrecision], If[LessEqual[l, 3.2e-93], 1.0, If[LessEqual[l, 1.4e-50], N[Sqrt[0.5], $MachinePrecision], If[LessEqual[l, 5.4e-11], 1.0, N[Sqrt[0.5], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -68000:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{elif}\;\ell \leq 3.2 \cdot 10^{-93}:\\
\;\;\;\;1\\
\mathbf{elif}\;\ell \leq 1.4 \cdot 10^{-50}:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{elif}\;\ell \leq 5.4 \cdot 10^{-11}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5}\\
\end{array}
\end{array}
if l < -68000 or 3.1999999999999999e-93 < l < 1.3999999999999999e-50 or 5.40000000000000009e-11 < l Initial program 98.0%
distribute-rgt-in98.0%
metadata-eval98.0%
metadata-eval98.0%
associate-/l*98.0%
metadata-eval98.0%
Simplified98.0%
expm1-log1p-u98.0%
expm1-udef98.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
hypot-def98.0%
unpow298.0%
unpow298.0%
+-commutative98.0%
unpow298.0%
unpow298.0%
hypot-def100.0%
Simplified100.0%
Taylor expanded in l around inf 82.9%
if -68000 < l < 3.1999999999999999e-93 or 1.3999999999999999e-50 < l < 5.40000000000000009e-11Initial program 99.1%
distribute-rgt-in99.1%
metadata-eval99.1%
metadata-eval99.1%
associate-/l*99.1%
metadata-eval99.1%
Simplified99.1%
expm1-log1p-u99.1%
expm1-udef99.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
hypot-def99.4%
unpow299.4%
unpow299.4%
+-commutative99.4%
unpow299.4%
unpow299.4%
hypot-def100.0%
Simplified100.0%
add-cbrt-cube99.9%
add-sqr-sqrt100.0%
pow1100.0%
pow1/2100.0%
pow-prod-up100.0%
Applied egg-rr100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in l around 0 86.7%
Final simplification84.5%
(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.4%
distribute-rgt-in98.4%
metadata-eval98.4%
metadata-eval98.4%
associate-/l*98.4%
metadata-eval98.4%
Simplified98.4%
expm1-log1p-u98.4%
expm1-udef98.4%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
hypot-def98.6%
unpow298.6%
unpow298.6%
+-commutative98.6%
unpow298.6%
unpow298.6%
hypot-def100.0%
Simplified100.0%
add-cbrt-cube100.0%
add-sqr-sqrt100.0%
pow1100.0%
pow1/2100.0%
pow-prod-up100.0%
Applied egg-rr100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in l around 0 57.2%
Final simplification57.2%
herbie shell --seed 2023207
(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))))))))))