
(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
(sqrt (+ (pow (* (* l (/ 2.0 Om)) (hypot (sin kx) (sin ky))) 2.0) 1.0))))))
double code(double l, double Om, double kx, double ky) {
return sqrt((0.5 + (0.5 / sqrt((pow(((l * (2.0 / Om)) * hypot(sin(kx), sin(ky))), 2.0) + 1.0)))));
}
public static double code(double l, double Om, double kx, double ky) {
return Math.sqrt((0.5 + (0.5 / Math.sqrt((Math.pow(((l * (2.0 / Om)) * Math.hypot(Math.sin(kx), Math.sin(ky))), 2.0) + 1.0)))));
}
def code(l, Om, kx, ky): return math.sqrt((0.5 + (0.5 / math.sqrt((math.pow(((l * (2.0 / Om)) * math.hypot(math.sin(kx), math.sin(ky))), 2.0) + 1.0)))))
function code(l, Om, kx, ky) return sqrt(Float64(0.5 + Float64(0.5 / sqrt(Float64((Float64(Float64(l * Float64(2.0 / Om)) * hypot(sin(kx), sin(ky))) ^ 2.0) + 1.0))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 / sqrt(((((l * (2.0 / Om)) * hypot(sin(kx), sin(ky))) ^ 2.0) + 1.0))))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[N[(N[Power[N[(N[(l * N[(2.0 / Om), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + \frac{0.5}{\sqrt{{\left(\left(\ell \cdot \frac{2}{Om}\right) \cdot \mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{2} + 1}}}
\end{array}
Initial program 98.4%
distribute-lft-in98.4%
metadata-eval98.4%
metadata-eval98.4%
associate-*r/98.4%
metadata-eval98.4%
metadata-eval98.4%
+-commutative98.4%
fma-def98.4%
*-commutative98.4%
associate-*l/98.4%
*-commutative98.4%
Simplified98.4%
fma-udef98.4%
clear-num98.4%
div-inv98.4%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (l Om kx ky) :precision binary64 (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* (* l (/ 2.0 Om)) (hypot (sin ky) (sin kx))))))))
double code(double l, double Om, double kx, double ky) {
return sqrt((0.5 + (0.5 / hypot(1.0, ((l * (2.0 / Om)) * hypot(sin(ky), sin(kx)))))));
}
public static double code(double l, double Om, double kx, double ky) {
return Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, ((l * (2.0 / Om)) * Math.hypot(Math.sin(ky), Math.sin(kx)))))));
}
def code(l, Om, kx, ky): return math.sqrt((0.5 + (0.5 / math.hypot(1.0, ((l * (2.0 / Om)) * math.hypot(math.sin(ky), math.sin(kx)))))))
function code(l, Om, kx, ky) return sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(Float64(l * Float64(2.0 / Om)) * hypot(sin(ky), sin(kx))))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 / hypot(1.0, ((l * (2.0 / Om)) * hypot(sin(ky), sin(kx))))))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(N[(l * N[(2.0 / Om), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \left(\ell \cdot \frac{2}{Om}\right) \cdot \mathsf{hypot}\left(\sin ky, \sin kx\right)\right)}}
\end{array}
Initial program 98.4%
distribute-lft-in98.4%
metadata-eval98.4%
metadata-eval98.4%
associate-*r/98.4%
metadata-eval98.4%
metadata-eval98.4%
+-commutative98.4%
fma-def98.4%
*-commutative98.4%
associate-*l/98.4%
*-commutative98.4%
Simplified98.4%
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%
Simplified100.0%
Final simplification100.0%
(FPCore (l Om kx ky) :precision binary64 (sqrt (+ 0.5 (/ 0.5 (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 / 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 / Math.hypot(1.0, ((l * (2.0 / Om)) * Math.sin(ky))))));
}
def code(l, Om, kx, ky): return math.sqrt((0.5 + (0.5 / 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 / hypot(1.0, Float64(Float64(l * Float64(2.0 / Om)) * sin(ky)))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 / hypot(1.0, ((l * (2.0 / Om)) * sin(ky)))))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(N[(l * N[(2.0 / Om), $MachinePrecision]), $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \left(\ell \cdot \frac{2}{Om}\right) \cdot \sin ky\right)}}
\end{array}
Initial program 98.4%
distribute-lft-in98.4%
metadata-eval98.4%
metadata-eval98.4%
associate-*r/98.4%
metadata-eval98.4%
metadata-eval98.4%
+-commutative98.4%
fma-def98.4%
*-commutative98.4%
associate-*l/98.4%
*-commutative98.4%
Simplified98.4%
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%
Simplified100.0%
Taylor expanded in kx around 0 94.9%
Final simplification94.9%
(FPCore (l Om kx ky) :precision binary64 (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (/ (* (sin ky) (* l 2.0)) Om))))))
double code(double l, double Om, double kx, double ky) {
return sqrt((0.5 + (0.5 / hypot(1.0, ((sin(ky) * (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(ky) * (l * 2.0)) / Om)))));
}
def code(l, Om, kx, ky): return math.sqrt((0.5 + (0.5 / math.hypot(1.0, ((math.sin(ky) * (l * 2.0)) / Om)))))
function code(l, Om, kx, ky) return sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(Float64(sin(ky) * Float64(l * 2.0)) / Om))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 / hypot(1.0, ((sin(ky) * (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[(N[Sin[ky], $MachinePrecision] * N[(l * 2.0), $MachinePrecision]), $MachinePrecision] / Om), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \frac{\sin ky \cdot \left(\ell \cdot 2\right)}{Om}\right)}}
\end{array}
Initial program 98.4%
distribute-lft-in98.4%
metadata-eval98.4%
metadata-eval98.4%
associate-*r/98.4%
metadata-eval98.4%
metadata-eval98.4%
+-commutative98.4%
fma-def98.4%
*-commutative98.4%
associate-*l/98.4%
*-commutative98.4%
Simplified98.4%
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%
Simplified100.0%
Taylor expanded in kx around 0 94.9%
Taylor expanded in ky around inf 94.9%
associate-*r/94.9%
associate-*r*94.9%
Simplified94.9%
Final simplification94.9%
(FPCore (l Om kx ky) :precision binary64 (if (or (<= Om 0.00028) (and (not (<= Om 2.7e+69)) (<= Om 2e+169))) (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* 2.0 (/ (* l ky) Om)))))) 1.0))
double code(double l, double Om, double kx, double ky) {
double tmp;
if ((Om <= 0.00028) || (!(Om <= 2.7e+69) && (Om <= 2e+169))) {
tmp = sqrt((0.5 + (0.5 / hypot(1.0, (2.0 * ((l * ky) / Om))))));
} else {
tmp = 1.0;
}
return tmp;
}
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if ((Om <= 0.00028) || (!(Om <= 2.7e+69) && (Om <= 2e+169))) {
tmp = Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, (2.0 * ((l * ky) / Om))))));
} else {
tmp = 1.0;
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if (Om <= 0.00028) or (not (Om <= 2.7e+69) and (Om <= 2e+169)): tmp = math.sqrt((0.5 + (0.5 / math.hypot(1.0, (2.0 * ((l * ky) / Om)))))) else: tmp = 1.0 return tmp
function code(l, Om, kx, ky) tmp = 0.0 if ((Om <= 0.00028) || (!(Om <= 2.7e+69) && (Om <= 2e+169))) tmp = sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(2.0 * Float64(Float64(l * ky) / Om)))))); else tmp = 1.0; end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if ((Om <= 0.00028) || (~((Om <= 2.7e+69)) && (Om <= 2e+169))) tmp = sqrt((0.5 + (0.5 / hypot(1.0, (2.0 * ((l * ky) / Om)))))); else tmp = 1.0; end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[Or[LessEqual[Om, 0.00028], And[N[Not[LessEqual[Om, 2.7e+69]], $MachinePrecision], LessEqual[Om, 2e+169]]], N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(2.0 * N[(N[(l * ky), $MachinePrecision] / Om), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;Om \leq 0.00028 \lor \neg \left(Om \leq 2.7 \cdot 10^{+69}\right) \land Om \leq 2 \cdot 10^{+169}:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, 2 \cdot \frac{\ell \cdot ky}{Om}\right)}}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if Om < 2.7999999999999998e-4 or 2.6999999999999998e69 < Om < 1.99999999999999987e169Initial program 98.1%
distribute-lft-in98.1%
metadata-eval98.1%
metadata-eval98.1%
associate-*r/98.1%
metadata-eval98.1%
metadata-eval98.1%
+-commutative98.1%
fma-def98.1%
*-commutative98.1%
associate-*l/98.1%
*-commutative98.1%
Simplified98.1%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
hypot-def98.7%
unpow298.7%
unpow298.7%
+-commutative98.7%
unpow298.7%
unpow298.7%
hypot-def100.0%
Simplified100.0%
Taylor expanded in kx around 0 94.0%
Taylor expanded in ky around 0 84.1%
if 2.7999999999999998e-4 < Om < 2.6999999999999998e69 or 1.99999999999999987e169 < Om Initial program 100.0%
distribute-lft-in100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-*r/100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
fma-def100.0%
*-commutative100.0%
associate-*l/100.0%
*-commutative100.0%
Simplified100.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 98.9%
Taylor expanded in ky around 0 89.5%
Final simplification85.0%
(FPCore (l Om kx ky)
:precision binary64
(let* ((t_0 (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* 2.0 (/ (* l ky) Om))))))))
(if (<= Om 10500000.0)
t_0
(if (<= Om 8.2e+68)
(+ 1.0 (* -0.5 (* (pow (sin ky) 2.0) (* (/ l Om) (/ l Om)))))
(if (<= Om 1.12e+170) t_0 1.0)))))
double code(double l, double Om, double kx, double ky) {
double t_0 = sqrt((0.5 + (0.5 / hypot(1.0, (2.0 * ((l * ky) / Om))))));
double tmp;
if (Om <= 10500000.0) {
tmp = t_0;
} else if (Om <= 8.2e+68) {
tmp = 1.0 + (-0.5 * (pow(sin(ky), 2.0) * ((l / Om) * (l / Om))));
} else if (Om <= 1.12e+170) {
tmp = t_0;
} else {
tmp = 1.0;
}
return tmp;
}
public static double code(double l, double Om, double kx, double ky) {
double t_0 = Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, (2.0 * ((l * ky) / Om))))));
double tmp;
if (Om <= 10500000.0) {
tmp = t_0;
} else if (Om <= 8.2e+68) {
tmp = 1.0 + (-0.5 * (Math.pow(Math.sin(ky), 2.0) * ((l / Om) * (l / Om))));
} else if (Om <= 1.12e+170) {
tmp = t_0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(l, Om, kx, ky): t_0 = math.sqrt((0.5 + (0.5 / math.hypot(1.0, (2.0 * ((l * ky) / Om)))))) tmp = 0 if Om <= 10500000.0: tmp = t_0 elif Om <= 8.2e+68: tmp = 1.0 + (-0.5 * (math.pow(math.sin(ky), 2.0) * ((l / Om) * (l / Om)))) elif Om <= 1.12e+170: tmp = t_0 else: tmp = 1.0 return tmp
function code(l, Om, kx, ky) t_0 = sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(2.0 * Float64(Float64(l * ky) / Om)))))) tmp = 0.0 if (Om <= 10500000.0) tmp = t_0; elseif (Om <= 8.2e+68) tmp = Float64(1.0 + Float64(-0.5 * Float64((sin(ky) ^ 2.0) * Float64(Float64(l / Om) * Float64(l / Om))))); elseif (Om <= 1.12e+170) tmp = t_0; else tmp = 1.0; end return tmp end
function tmp_2 = code(l, Om, kx, ky) t_0 = sqrt((0.5 + (0.5 / hypot(1.0, (2.0 * ((l * ky) / Om)))))); tmp = 0.0; if (Om <= 10500000.0) tmp = t_0; elseif (Om <= 8.2e+68) tmp = 1.0 + (-0.5 * ((sin(ky) ^ 2.0) * ((l / Om) * (l / Om)))); elseif (Om <= 1.12e+170) tmp = t_0; else tmp = 1.0; end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := Block[{t$95$0 = N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(2.0 * N[(N[(l * ky), $MachinePrecision] / Om), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[Om, 10500000.0], t$95$0, If[LessEqual[Om, 8.2e+68], N[(1.0 + N[(-0.5 * N[(N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision] * N[(N[(l / Om), $MachinePrecision] * N[(l / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[Om, 1.12e+170], t$95$0, 1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, 2 \cdot \frac{\ell \cdot ky}{Om}\right)}}\\
\mathbf{if}\;Om \leq 10500000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;Om \leq 8.2 \cdot 10^{+68}:\\
\;\;\;\;1 + -0.5 \cdot \left({\sin ky}^{2} \cdot \left(\frac{\ell}{Om} \cdot \frac{\ell}{Om}\right)\right)\\
\mathbf{elif}\;Om \leq 1.12 \cdot 10^{+170}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if Om < 1.05e7 or 8.1999999999999998e68 < Om < 1.1200000000000001e170Initial program 98.1%
distribute-lft-in98.1%
metadata-eval98.1%
metadata-eval98.1%
associate-*r/98.1%
metadata-eval98.1%
metadata-eval98.1%
+-commutative98.1%
fma-def98.1%
*-commutative98.1%
associate-*l/98.1%
*-commutative98.1%
Simplified98.1%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
hypot-def98.7%
unpow298.7%
unpow298.7%
+-commutative98.7%
unpow298.7%
unpow298.7%
hypot-def100.0%
Simplified100.0%
Taylor expanded in kx around 0 94.2%
Taylor expanded in ky around 0 84.4%
if 1.05e7 < Om < 8.1999999999999998e68Initial program 100.0%
distribute-lft-in100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-*r/100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
fma-def100.0%
*-commutative100.0%
associate-*l/100.0%
*-commutative100.0%
Simplified100.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 94.6%
Taylor expanded in l around 0 82.1%
associate-/l*82.1%
unpow282.1%
unpow282.1%
Simplified82.1%
Taylor expanded in l around 0 82.1%
associate-*l/82.1%
unpow282.1%
unpow282.1%
*-commutative82.1%
times-frac82.2%
Simplified82.2%
if 1.1200000000000001e170 < Om Initial program 100.0%
distribute-lft-in100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-*r/100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
fma-def100.0%
*-commutative100.0%
associate-*l/100.0%
*-commutative100.0%
Simplified100.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.9%
Taylor expanded in ky around 0 94.2%
Final simplification85.6%
(FPCore (l Om kx ky)
:precision binary64
(if (<= Om 7.1e-159)
(sqrt 0.5)
(if (or (<= Om 6.5e-19) (and (not (<= Om 6.6e+81)) (<= Om 2.7e+138)))
(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 <= 7.1e-159) {
tmp = sqrt(0.5);
} else if ((Om <= 6.5e-19) || (!(Om <= 6.6e+81) && (Om <= 2.7e+138))) {
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 <= 7.1d-159) then
tmp = sqrt(0.5d0)
else if ((om <= 6.5d-19) .or. (.not. (om <= 6.6d+81)) .and. (om <= 2.7d+138)) 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 <= 7.1e-159) {
tmp = Math.sqrt(0.5);
} else if ((Om <= 6.5e-19) || (!(Om <= 6.6e+81) && (Om <= 2.7e+138))) {
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 <= 7.1e-159: tmp = math.sqrt(0.5) elif (Om <= 6.5e-19) or (not (Om <= 6.6e+81) and (Om <= 2.7e+138)): 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 <= 7.1e-159) tmp = sqrt(0.5); elseif ((Om <= 6.5e-19) || (!(Om <= 6.6e+81) && (Om <= 2.7e+138))) tmp = sqrt(Float64(0.5 + Float64(0.5 / Float64(1.0 + Float64(2.0 * Float64(Float64(l * l) / Float64(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 <= 7.1e-159) tmp = sqrt(0.5); elseif ((Om <= 6.5e-19) || (~((Om <= 6.6e+81)) && (Om <= 2.7e+138))) 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, 7.1e-159], N[Sqrt[0.5], $MachinePrecision], If[Or[LessEqual[Om, 6.5e-19], And[N[Not[LessEqual[Om, 6.6e+81]], $MachinePrecision], LessEqual[Om, 2.7e+138]]], N[Sqrt[N[(0.5 + N[(0.5 / N[(1.0 + N[(2.0 * N[(N[(l * l), $MachinePrecision] / N[(N[(Om * Om), $MachinePrecision] / N[(ky * ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;Om \leq 7.1 \cdot 10^{-159}:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{elif}\;Om \leq 6.5 \cdot 10^{-19} \lor \neg \left(Om \leq 6.6 \cdot 10^{+81}\right) \land Om \leq 2.7 \cdot 10^{+138}:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{1 + 2 \cdot \frac{\ell \cdot \ell}{\frac{Om \cdot Om}{ky \cdot ky}}}}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if Om < 7.10000000000000024e-159Initial 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 53.4%
*-commutative53.4%
associate-*l*53.4%
unpow253.4%
unpow253.4%
hypot-def54.7%
Simplified54.7%
Taylor expanded in l around inf 61.9%
if 7.10000000000000024e-159 < Om < 6.5000000000000001e-19 or 6.6e81 < Om < 2.70000000000000009e138Initial program 97.4%
distribute-lft-in97.4%
metadata-eval97.4%
metadata-eval97.4%
associate-*r/97.4%
metadata-eval97.4%
metadata-eval97.4%
+-commutative97.4%
fma-def97.4%
*-commutative97.4%
associate-*l/97.4%
*-commutative97.4%
Simplified97.4%
Taylor expanded in kx around 0 94.7%
associate-/l*94.7%
unpow294.7%
unpow294.7%
Simplified94.7%
Taylor expanded in ky around 0 89.3%
associate-/l*84.0%
unpow284.0%
unpow284.0%
unpow284.0%
Simplified84.0%
if 6.5000000000000001e-19 < Om < 6.6e81 or 2.70000000000000009e138 < Om Initial program 100.0%
distribute-lft-in100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-*r/100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
fma-def100.0%
*-commutative100.0%
associate-*l/100.0%
*-commutative100.0%
Simplified100.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 95.1%
Taylor expanded in ky around 0 85.1%
Final simplification70.5%
(FPCore (l Om kx ky) :precision binary64 (if (<= Om 3.8e-19) (sqrt 0.5) 1.0))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (Om <= 3.8e-19) {
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 <= 3.8d-19) 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 <= 3.8e-19) {
tmp = Math.sqrt(0.5);
} else {
tmp = 1.0;
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if Om <= 3.8e-19: tmp = math.sqrt(0.5) else: tmp = 1.0 return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (Om <= 3.8e-19) 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 <= 3.8e-19) tmp = sqrt(0.5); else tmp = 1.0; end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[Om, 3.8e-19], N[Sqrt[0.5], $MachinePrecision], 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;Om \leq 3.8 \cdot 10^{-19}:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if Om < 3.8e-19Initial program 97.9%
distribute-rgt-in97.9%
metadata-eval97.9%
metadata-eval97.9%
associate-/l*97.9%
metadata-eval97.9%
Simplified97.9%
Taylor expanded in Om around 0 56.0%
*-commutative56.0%
associate-*l*56.0%
unpow256.0%
unpow256.0%
hypot-def57.6%
Simplified57.6%
Taylor expanded in l around inf 64.3%
if 3.8e-19 < Om Initial program 100.0%
distribute-lft-in100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-*r/100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
fma-def100.0%
*-commutative100.0%
associate-*l/100.0%
*-commutative100.0%
Simplified100.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 94.5%
Taylor expanded in ky around 0 80.9%
Final simplification68.6%
(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-lft-in98.4%
metadata-eval98.4%
metadata-eval98.4%
associate-*r/98.4%
metadata-eval98.4%
metadata-eval98.4%
+-commutative98.4%
fma-def98.4%
*-commutative98.4%
associate-*l/98.4%
*-commutative98.4%
Simplified98.4%
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%
Simplified100.0%
Taylor expanded in kx around 0 94.9%
Taylor expanded in ky around 0 61.0%
Final simplification61.0%
herbie shell --seed 2023255
(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))))))))))