
(FPCore (l Om kx ky)
:precision binary64
(sqrt
(*
(/ 1.0 2.0)
(+
1.0
(/
1.0
(sqrt
(+
1.0
(*
(pow (/ (* 2.0 l) Om) 2.0)
(+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))))))))))
double code(double l, double Om, double kx, double ky) {
return sqrt(((1.0 / 2.0) * (1.0 + (1.0 / sqrt((1.0 + (pow(((2.0 * l) / Om), 2.0) * (pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))))))));
}
real(8) function code(l, om, kx, ky)
real(8), intent (in) :: l
real(8), intent (in) :: om
real(8), intent (in) :: kx
real(8), intent (in) :: ky
code = sqrt(((1.0d0 / 2.0d0) * (1.0d0 + (1.0d0 / sqrt((1.0d0 + ((((2.0d0 * l) / om) ** 2.0d0) * ((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))))))))
end function
public static double code(double l, double Om, double kx, double ky) {
return Math.sqrt(((1.0 / 2.0) * (1.0 + (1.0 / Math.sqrt((1.0 + (Math.pow(((2.0 * l) / Om), 2.0) * (Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))))))));
}
def code(l, Om, kx, ky): return math.sqrt(((1.0 / 2.0) * (1.0 + (1.0 / math.sqrt((1.0 + (math.pow(((2.0 * l) / Om), 2.0) * (math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))))))))
function code(l, Om, kx, ky) return sqrt(Float64(Float64(1.0 / 2.0) * Float64(1.0 + Float64(1.0 / sqrt(Float64(1.0 + Float64((Float64(Float64(2.0 * l) / Om) ^ 2.0) * Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))))))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt(((1.0 / 2.0) * (1.0 + (1.0 / sqrt((1.0 + ((((2.0 * l) / Om) ^ 2.0) * ((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))))))))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(N[(1.0 / 2.0), $MachinePrecision] * N[(1.0 + N[(1.0 / N[Sqrt[N[(1.0 + N[(N[Power[N[(N[(2.0 * l), $MachinePrecision] / Om), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\frac{1}{2} \cdot \left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (l Om kx ky)
:precision binary64
(sqrt
(*
(/ 1.0 2.0)
(+
1.0
(/
1.0
(sqrt
(+
1.0
(*
(pow (/ (* 2.0 l) Om) 2.0)
(+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))))))))))
double code(double l, double Om, double kx, double ky) {
return sqrt(((1.0 / 2.0) * (1.0 + (1.0 / sqrt((1.0 + (pow(((2.0 * l) / Om), 2.0) * (pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))))))));
}
real(8) function code(l, om, kx, ky)
real(8), intent (in) :: l
real(8), intent (in) :: om
real(8), intent (in) :: kx
real(8), intent (in) :: ky
code = sqrt(((1.0d0 / 2.0d0) * (1.0d0 + (1.0d0 / sqrt((1.0d0 + ((((2.0d0 * l) / om) ** 2.0d0) * ((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))))))))
end function
public static double code(double l, double Om, double kx, double ky) {
return Math.sqrt(((1.0 / 2.0) * (1.0 + (1.0 / Math.sqrt((1.0 + (Math.pow(((2.0 * l) / Om), 2.0) * (Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))))))));
}
def code(l, Om, kx, ky): return math.sqrt(((1.0 / 2.0) * (1.0 + (1.0 / math.sqrt((1.0 + (math.pow(((2.0 * l) / Om), 2.0) * (math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))))))))
function code(l, Om, kx, ky) return sqrt(Float64(Float64(1.0 / 2.0) * Float64(1.0 + Float64(1.0 / sqrt(Float64(1.0 + Float64((Float64(Float64(2.0 * l) / Om) ^ 2.0) * Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))))))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt(((1.0 / 2.0) * (1.0 + (1.0 / sqrt((1.0 + ((((2.0 * l) / Om) ^ 2.0) * ((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))))))))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(N[(1.0 / 2.0), $MachinePrecision] * N[(1.0 + N[(1.0 / N[Sqrt[N[(1.0 + N[(N[Power[N[(N[(2.0 * l), $MachinePrecision] / Om), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\frac{1}{2} \cdot \left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)}
\end{array}
(FPCore (l Om kx ky)
:precision binary64
(sqrt
(+
0.5
(*
0.5
(/ 1.0 (hypot 1.0 (* (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.9%
unpow298.9%
unpow298.9%
+-commutative98.9%
unpow298.9%
unpow298.9%
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
(if (<= (pow (sin ky) 2.0) 0.022)
(sqrt
(+ 0.5 (* 0.5 (pow (+ 1.0 (pow (* (sin kx) (* l (/ 2.0 Om))) 2.0)) -0.5))))
(sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* (/ 2.0 Om) (* (sin ky) l))))))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (pow(sin(ky), 2.0) <= 0.022) {
tmp = sqrt((0.5 + (0.5 * pow((1.0 + pow((sin(kx) * (l * (2.0 / Om))), 2.0)), -0.5))));
} else {
tmp = sqrt((0.5 + (0.5 / hypot(1.0, ((2.0 / Om) * (sin(ky) * l))))));
}
return tmp;
}
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if (Math.pow(Math.sin(ky), 2.0) <= 0.022) {
tmp = Math.sqrt((0.5 + (0.5 * Math.pow((1.0 + Math.pow((Math.sin(kx) * (l * (2.0 / Om))), 2.0)), -0.5))));
} else {
tmp = Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, ((2.0 / Om) * (Math.sin(ky) * l))))));
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if math.pow(math.sin(ky), 2.0) <= 0.022: tmp = math.sqrt((0.5 + (0.5 * math.pow((1.0 + math.pow((math.sin(kx) * (l * (2.0 / Om))), 2.0)), -0.5)))) else: tmp = math.sqrt((0.5 + (0.5 / math.hypot(1.0, ((2.0 / Om) * (math.sin(ky) * l)))))) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if ((sin(ky) ^ 2.0) <= 0.022) tmp = sqrt(Float64(0.5 + Float64(0.5 * (Float64(1.0 + (Float64(sin(kx) * Float64(l * Float64(2.0 / Om))) ^ 2.0)) ^ -0.5)))); else tmp = sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(Float64(2.0 / Om) * Float64(sin(ky) * l)))))); end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if ((sin(ky) ^ 2.0) <= 0.022) tmp = sqrt((0.5 + (0.5 * ((1.0 + ((sin(kx) * (l * (2.0 / Om))) ^ 2.0)) ^ -0.5)))); else tmp = sqrt((0.5 + (0.5 / hypot(1.0, ((2.0 / Om) * (sin(ky) * l)))))); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision], 0.022], N[Sqrt[N[(0.5 + N[(0.5 * N[Power[N[(1.0 + N[Power[N[(N[Sin[kx], $MachinePrecision] * N[(l * N[(2.0 / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(N[(2.0 / Om), $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{\sin ky}^{2} \leq 0.022:\\
\;\;\;\;\sqrt{0.5 + 0.5 \cdot {\left(1 + {\left(\sin kx \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}^{2}\right)}^{-0.5}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \frac{2}{Om} \cdot \left(\sin ky \cdot \ell\right)\right)}}\\
\end{array}
\end{array}
if (pow.f64 (sin.f64 ky) 2) < 0.021999999999999999Initial program 97.7%
distribute-rgt-in97.7%
metadata-eval97.7%
metadata-eval97.7%
associate-/l*97.7%
metadata-eval97.7%
Simplified97.7%
expm1-log1p-u97.7%
expm1-udef97.7%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
hypot-def97.9%
unpow297.9%
unpow297.9%
+-commutative97.9%
unpow297.9%
unpow297.9%
hypot-def100.0%
*-commutative100.0%
associate-*l/100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in ky around 0 97.0%
inv-pow97.0%
add-sqr-sqrt97.0%
sqrt-unprod97.0%
sqrt-pow297.0%
hypot-udef97.0%
hypot-udef97.0%
add-sqr-sqrt97.0%
metadata-eval97.0%
pow297.0%
metadata-eval97.0%
Applied egg-rr97.0%
if 0.021999999999999999 < (pow.f64 (sin.f64 ky) 2) 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%
*-commutative100.0%
associate-*l/100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in kx around 0 98.5%
expm1-log1p-u97.9%
expm1-udef97.9%
associate-*l/97.9%
metadata-eval97.9%
*-commutative97.9%
associate-*l*97.9%
Applied egg-rr97.9%
expm1-def97.9%
expm1-log1p98.5%
*-commutative98.5%
associate-*r*98.5%
Simplified98.5%
Final simplification97.7%
(FPCore (l Om kx ky) :precision binary64 (if (<= (pow (sin ky) 2.0) 0.022) (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* (sin kx) (* l (/ 2.0 Om))))))) (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* (/ 2.0 Om) (* (sin ky) l))))))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (pow(sin(ky), 2.0) <= 0.022) {
tmp = sqrt((0.5 + (0.5 / hypot(1.0, (sin(kx) * (l * (2.0 / Om)))))));
} else {
tmp = sqrt((0.5 + (0.5 / hypot(1.0, ((2.0 / Om) * (sin(ky) * l))))));
}
return tmp;
}
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if (Math.pow(Math.sin(ky), 2.0) <= 0.022) {
tmp = Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, (Math.sin(kx) * (l * (2.0 / Om)))))));
} else {
tmp = Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, ((2.0 / Om) * (Math.sin(ky) * l))))));
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if math.pow(math.sin(ky), 2.0) <= 0.022: tmp = math.sqrt((0.5 + (0.5 / math.hypot(1.0, (math.sin(kx) * (l * (2.0 / Om))))))) else: tmp = math.sqrt((0.5 + (0.5 / math.hypot(1.0, ((2.0 / Om) * (math.sin(ky) * l)))))) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if ((sin(ky) ^ 2.0) <= 0.022) tmp = sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(sin(kx) * Float64(l * Float64(2.0 / Om))))))); else tmp = sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(Float64(2.0 / Om) * Float64(sin(ky) * l)))))); end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if ((sin(ky) ^ 2.0) <= 0.022) tmp = sqrt((0.5 + (0.5 / hypot(1.0, (sin(kx) * (l * (2.0 / Om))))))); else tmp = sqrt((0.5 + (0.5 / hypot(1.0, ((2.0 / Om) * (sin(ky) * l)))))); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision], 0.022], N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(N[Sin[kx], $MachinePrecision] * N[(l * N[(2.0 / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(N[(2.0 / Om), $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{\sin ky}^{2} \leq 0.022:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \sin kx \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \frac{2}{Om} \cdot \left(\sin ky \cdot \ell\right)\right)}}\\
\end{array}
\end{array}
if (pow.f64 (sin.f64 ky) 2) < 0.021999999999999999Initial program 97.7%
distribute-rgt-in97.7%
metadata-eval97.7%
metadata-eval97.7%
associate-/l*97.7%
metadata-eval97.7%
Simplified97.7%
expm1-log1p-u97.7%
expm1-udef97.7%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
hypot-def97.9%
unpow297.9%
unpow297.9%
+-commutative97.9%
unpow297.9%
unpow297.9%
hypot-def100.0%
*-commutative100.0%
associate-*l/100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in ky around 0 97.0%
expm1-log1p-u97.0%
expm1-udef97.0%
associate-*l/97.0%
metadata-eval97.0%
Applied egg-rr97.0%
expm1-def97.0%
expm1-log1p97.0%
Simplified97.0%
if 0.021999999999999999 < (pow.f64 (sin.f64 ky) 2) 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%
*-commutative100.0%
associate-*l/100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in kx around 0 98.5%
expm1-log1p-u97.9%
expm1-udef97.9%
associate-*l/97.9%
metadata-eval97.9%
*-commutative97.9%
associate-*l*97.9%
Applied egg-rr97.9%
expm1-def97.9%
expm1-log1p98.5%
*-commutative98.5%
associate-*r*98.5%
Simplified98.5%
Final simplification97.7%
(FPCore (l Om kx ky) :precision binary64 (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* (sin kx) (* l (/ 2.0 Om))))))))
double code(double l, double Om, double kx, double ky) {
return sqrt((0.5 + (0.5 / hypot(1.0, (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 / Math.hypot(1.0, (Math.sin(kx) * (l * (2.0 / Om)))))));
}
def code(l, Om, kx, ky): return math.sqrt((0.5 + (0.5 / math.hypot(1.0, (math.sin(kx) * (l * (2.0 / Om)))))))
function code(l, Om, kx, ky) return sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(sin(kx) * Float64(l * Float64(2.0 / Om))))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 / hypot(1.0, (sin(kx) * (l * (2.0 / Om))))))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(N[Sin[kx], $MachinePrecision] * N[(l * N[(2.0 / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \sin kx \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.9%
unpow298.9%
unpow298.9%
+-commutative98.9%
unpow298.9%
unpow298.9%
hypot-def100.0%
*-commutative100.0%
associate-*l/100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in ky around 0 94.2%
expm1-log1p-u94.2%
expm1-udef94.2%
associate-*l/94.2%
metadata-eval94.2%
Applied egg-rr94.2%
expm1-def94.2%
expm1-log1p94.2%
Simplified94.2%
Final simplification94.2%
(FPCore (l Om kx ky)
:precision binary64
(if (<= l -4.8e+57)
(sqrt 0.5)
(if (or (<= l -3.8e-19) (and (not (<= l -1.02e-76)) (<= l 1.22e-26)))
(+ 1.0 (/ (* -0.5 (* l l)) (* (/ Om ky) (/ Om ky))))
(sqrt 0.5))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= -4.8e+57) {
tmp = sqrt(0.5);
} else if ((l <= -3.8e-19) || (!(l <= -1.02e-76) && (l <= 1.22e-26))) {
tmp = 1.0 + ((-0.5 * (l * l)) / ((Om / ky) * (Om / ky)));
} 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 <= (-4.8d+57)) then
tmp = sqrt(0.5d0)
else if ((l <= (-3.8d-19)) .or. (.not. (l <= (-1.02d-76))) .and. (l <= 1.22d-26)) then
tmp = 1.0d0 + (((-0.5d0) * (l * l)) / ((om / ky) * (om / ky)))
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 <= -4.8e+57) {
tmp = Math.sqrt(0.5);
} else if ((l <= -3.8e-19) || (!(l <= -1.02e-76) && (l <= 1.22e-26))) {
tmp = 1.0 + ((-0.5 * (l * l)) / ((Om / ky) * (Om / ky)));
} else {
tmp = Math.sqrt(0.5);
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if l <= -4.8e+57: tmp = math.sqrt(0.5) elif (l <= -3.8e-19) or (not (l <= -1.02e-76) and (l <= 1.22e-26)): tmp = 1.0 + ((-0.5 * (l * l)) / ((Om / ky) * (Om / ky))) else: tmp = math.sqrt(0.5) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (l <= -4.8e+57) tmp = sqrt(0.5); elseif ((l <= -3.8e-19) || (!(l <= -1.02e-76) && (l <= 1.22e-26))) tmp = Float64(1.0 + Float64(Float64(-0.5 * Float64(l * l)) / Float64(Float64(Om / ky) * Float64(Om / ky)))); else tmp = sqrt(0.5); end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (l <= -4.8e+57) tmp = sqrt(0.5); elseif ((l <= -3.8e-19) || (~((l <= -1.02e-76)) && (l <= 1.22e-26))) tmp = 1.0 + ((-0.5 * (l * l)) / ((Om / ky) * (Om / ky))); else tmp = sqrt(0.5); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[l, -4.8e+57], N[Sqrt[0.5], $MachinePrecision], If[Or[LessEqual[l, -3.8e-19], And[N[Not[LessEqual[l, -1.02e-76]], $MachinePrecision], LessEqual[l, 1.22e-26]]], N[(1.0 + N[(N[(-0.5 * N[(l * l), $MachinePrecision]), $MachinePrecision] / N[(N[(Om / ky), $MachinePrecision] * N[(Om / ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sqrt[0.5], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -4.8 \cdot 10^{+57}:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{elif}\;\ell \leq -3.8 \cdot 10^{-19} \lor \neg \left(\ell \leq -1.02 \cdot 10^{-76}\right) \land \ell \leq 1.22 \cdot 10^{-26}:\\
\;\;\;\;1 + \frac{-0.5 \cdot \left(\ell \cdot \ell\right)}{\frac{Om}{ky} \cdot \frac{Om}{ky}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5}\\
\end{array}
\end{array}
if l < -4.80000000000000009e57 or -3.8e-19 < l < -1.02000000000000006e-76 or 1.22e-26 < l Initial program 97.4%
distribute-rgt-in97.4%
metadata-eval97.4%
metadata-eval97.4%
associate-/l*97.4%
metadata-eval97.4%
Simplified97.4%
Taylor expanded in l around -inf 69.1%
*-commutative69.1%
associate-*l*69.1%
unpow269.1%
unpow269.1%
hypot-def71.6%
Simplified71.6%
Taylor expanded in l around inf 76.3%
if -4.80000000000000009e57 < l < -3.8e-19 or -1.02000000000000006e-76 < l < 1.22e-26Initial 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%
*-commutative100.0%
associate-*l/100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in kx around 0 97.3%
Taylor expanded in ky around 0 61.7%
associate-/l*59.5%
unpow259.5%
unpow259.5%
unpow259.5%
Simplified59.5%
associate-*r/59.5%
times-frac75.8%
Applied egg-rr75.8%
Final simplification76.0%
(FPCore (l Om kx ky) :precision binary64 (if (<= l -4e+68) (sqrt 0.5) (if (<= l 1.14e-26) 1.0 (sqrt 0.5))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= -4e+68) {
tmp = sqrt(0.5);
} else if (l <= 1.14e-26) {
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 <= (-4d+68)) then
tmp = sqrt(0.5d0)
else if (l <= 1.14d-26) 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 <= -4e+68) {
tmp = Math.sqrt(0.5);
} else if (l <= 1.14e-26) {
tmp = 1.0;
} else {
tmp = Math.sqrt(0.5);
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if l <= -4e+68: tmp = math.sqrt(0.5) elif l <= 1.14e-26: tmp = 1.0 else: tmp = math.sqrt(0.5) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (l <= -4e+68) tmp = sqrt(0.5); elseif (l <= 1.14e-26) 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 <= -4e+68) tmp = sqrt(0.5); elseif (l <= 1.14e-26) tmp = 1.0; else tmp = sqrt(0.5); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[l, -4e+68], N[Sqrt[0.5], $MachinePrecision], If[LessEqual[l, 1.14e-26], 1.0, N[Sqrt[0.5], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -4 \cdot 10^{+68}:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{elif}\;\ell \leq 1.14 \cdot 10^{-26}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5}\\
\end{array}
\end{array}
if l < -3.99999999999999981e68 or 1.1399999999999999e-26 < l Initial program 97.2%
distribute-rgt-in97.2%
metadata-eval97.2%
metadata-eval97.2%
associate-/l*97.2%
metadata-eval97.2%
Simplified97.2%
Taylor expanded in l around -inf 69.5%
*-commutative69.5%
associate-*l*69.5%
unpow269.5%
unpow269.5%
hypot-def72.3%
Simplified72.3%
Taylor expanded in l around inf 76.8%
if -3.99999999999999981e68 < l < 1.1399999999999999e-26Initial 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%
*-commutative100.0%
associate-*l/100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in ky around 0 96.6%
Taylor expanded in kx around 0 89.7%
Final simplification84.3%
(FPCore (l Om kx ky) :precision binary64 (if (<= ky 9e+150) (+ 1.0 (* -0.5 (* (* (/ l Om) (/ l Om)) (* ky ky)))) (+ 1.0 (/ (* -0.5 (* l l)) (* (/ Om ky) (/ Om ky))))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (ky <= 9e+150) {
tmp = 1.0 + (-0.5 * (((l / Om) * (l / Om)) * (ky * ky)));
} else {
tmp = 1.0 + ((-0.5 * (l * l)) / ((Om / ky) * (Om / 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 (ky <= 9d+150) then
tmp = 1.0d0 + ((-0.5d0) * (((l / om) * (l / om)) * (ky * ky)))
else
tmp = 1.0d0 + (((-0.5d0) * (l * l)) / ((om / ky) * (om / ky)))
end if
code = tmp
end function
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if (ky <= 9e+150) {
tmp = 1.0 + (-0.5 * (((l / Om) * (l / Om)) * (ky * ky)));
} else {
tmp = 1.0 + ((-0.5 * (l * l)) / ((Om / ky) * (Om / ky)));
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if ky <= 9e+150: tmp = 1.0 + (-0.5 * (((l / Om) * (l / Om)) * (ky * ky))) else: tmp = 1.0 + ((-0.5 * (l * l)) / ((Om / ky) * (Om / ky))) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (ky <= 9e+150) tmp = Float64(1.0 + Float64(-0.5 * Float64(Float64(Float64(l / Om) * Float64(l / Om)) * Float64(ky * ky)))); else tmp = Float64(1.0 + Float64(Float64(-0.5 * Float64(l * l)) / Float64(Float64(Om / ky) * Float64(Om / ky)))); end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (ky <= 9e+150) tmp = 1.0 + (-0.5 * (((l / Om) * (l / Om)) * (ky * ky))); else tmp = 1.0 + ((-0.5 * (l * l)) / ((Om / ky) * (Om / ky))); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[ky, 9e+150], N[(1.0 + N[(-0.5 * N[(N[(N[(l / Om), $MachinePrecision] * N[(l / Om), $MachinePrecision]), $MachinePrecision] * N[(ky * ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(-0.5 * N[(l * l), $MachinePrecision]), $MachinePrecision] / N[(N[(Om / ky), $MachinePrecision] * N[(Om / ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 9 \cdot 10^{+150}:\\
\;\;\;\;1 + -0.5 \cdot \left(\left(\frac{\ell}{Om} \cdot \frac{\ell}{Om}\right) \cdot \left(ky \cdot ky\right)\right)\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{-0.5 \cdot \left(\ell \cdot \ell\right)}{\frac{Om}{ky} \cdot \frac{Om}{ky}}\\
\end{array}
\end{array}
if ky < 9.00000000000000001e150Initial program 98.7%
distribute-rgt-in98.7%
metadata-eval98.7%
metadata-eval98.7%
associate-/l*98.7%
metadata-eval98.7%
Simplified98.7%
expm1-log1p-u98.7%
expm1-udef98.7%
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%
Taylor expanded in kx around 0 94.0%
Taylor expanded in ky around 0 42.2%
associate-/l*41.4%
unpow241.4%
unpow241.4%
unpow241.4%
Simplified41.4%
Taylor expanded in l around 0 42.2%
associate-*l/42.5%
unpow242.5%
unpow242.5%
unpow242.5%
times-frac49.8%
Simplified49.8%
if 9.00000000000000001e150 < 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%
*-commutative100.0%
associate-*l/100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in kx around 0 99.5%
Taylor expanded in ky around 0 3.7%
associate-/l*3.7%
unpow23.7%
unpow23.7%
unpow23.7%
Simplified3.7%
associate-*r/3.7%
times-frac31.4%
Applied egg-rr31.4%
Final simplification47.7%
(FPCore (l Om kx ky) :precision binary64 (+ 1.0 (* -0.5 (* (* (/ l Om) (/ l Om)) (* ky ky)))))
double code(double l, double Om, double kx, double ky) {
return 1.0 + (-0.5 * (((l / Om) * (l / 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 / om) * (l / om)) * (ky * ky)))
end function
public static double code(double l, double Om, double kx, double ky) {
return 1.0 + (-0.5 * (((l / Om) * (l / Om)) * (ky * ky)));
}
def code(l, Om, kx, ky): return 1.0 + (-0.5 * (((l / Om) * (l / Om)) * (ky * ky)))
function code(l, Om, kx, ky) return Float64(1.0 + Float64(-0.5 * Float64(Float64(Float64(l / Om) * Float64(l / Om)) * Float64(ky * ky)))) end
function tmp = code(l, Om, kx, ky) tmp = 1.0 + (-0.5 * (((l / Om) * (l / Om)) * (ky * ky))); end
code[l_, Om_, kx_, ky_] := N[(1.0 + N[(-0.5 * N[(N[(N[(l / Om), $MachinePrecision] * N[(l / Om), $MachinePrecision]), $MachinePrecision] * N[(ky * ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + -0.5 \cdot \left(\left(\frac{\ell}{Om} \cdot \frac{\ell}{Om}\right) \cdot \left(ky \cdot ky\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.9%
unpow298.9%
unpow298.9%
+-commutative98.9%
unpow298.9%
unpow298.9%
hypot-def100.0%
*-commutative100.0%
associate-*l/100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in kx around 0 94.6%
Taylor expanded in ky around 0 37.9%
associate-/l*37.1%
unpow237.1%
unpow237.1%
unpow237.1%
Simplified37.1%
Taylor expanded in l around 0 37.9%
associate-*l/38.1%
unpow238.1%
unpow238.1%
unpow238.1%
times-frac44.6%
Simplified44.6%
Final simplification44.6%
herbie shell --seed 2023182
(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))))))))))