
(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 (hypot 1.0 (* 2.0 (* (/ l Om) (hypot (sin kx) (sin ky)))))))))
double code(double l, double Om, double kx, double ky) {
return sqrt((0.5 + (0.5 / hypot(1.0, (2.0 * ((l / Om) * hypot(sin(kx), 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, (2.0 * ((l / Om) * Math.hypot(Math.sin(kx), Math.sin(ky))))))));
}
def code(l, Om, kx, ky): return math.sqrt((0.5 + (0.5 / math.hypot(1.0, (2.0 * ((l / Om) * math.hypot(math.sin(kx), math.sin(ky))))))))
function code(l, Om, kx, ky) return sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(2.0 * Float64(Float64(l / Om) * hypot(sin(kx), sin(ky)))))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 / hypot(1.0, (2.0 * ((l / Om) * hypot(sin(kx), sin(ky)))))))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(2.0 * N[(N[(l / Om), $MachinePrecision] * N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, 2 \cdot \left(\frac{\ell}{Om} \cdot \mathsf{hypot}\left(\sin kx, \sin ky\right)\right)\right)}}
\end{array}
Initial program 98.8%
Simplified98.8%
expm1-log1p-u98.8%
expm1-udef98.8%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
un-div-inv100.0%
associate-*r*100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (l Om kx ky) :precision binary64 (if (<= ky 2.8e+133) (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* 2.0 (/ (* l ky) Om)))))) (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* 2.0 (/ (* l (sin kx)) Om))))))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (ky <= 2.8e+133) {
tmp = sqrt((0.5 + (0.5 / hypot(1.0, (2.0 * ((l * ky) / Om))))));
} else {
tmp = sqrt((0.5 + (0.5 / hypot(1.0, (2.0 * ((l * sin(kx)) / Om))))));
}
return tmp;
}
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if (ky <= 2.8e+133) {
tmp = Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, (2.0 * ((l * ky) / Om))))));
} else {
tmp = Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, (2.0 * ((l * Math.sin(kx)) / Om))))));
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if ky <= 2.8e+133: tmp = math.sqrt((0.5 + (0.5 / math.hypot(1.0, (2.0 * ((l * ky) / Om)))))) else: tmp = math.sqrt((0.5 + (0.5 / math.hypot(1.0, (2.0 * ((l * math.sin(kx)) / Om)))))) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (ky <= 2.8e+133) tmp = sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(2.0 * Float64(Float64(l * ky) / Om)))))); else tmp = sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(2.0 * Float64(Float64(l * sin(kx)) / Om)))))); end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (ky <= 2.8e+133) tmp = sqrt((0.5 + (0.5 / hypot(1.0, (2.0 * ((l * ky) / Om)))))); else tmp = sqrt((0.5 + (0.5 / hypot(1.0, (2.0 * ((l * sin(kx)) / Om)))))); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[ky, 2.8e+133], 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], N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(2.0 * N[(N[(l * N[Sin[kx], $MachinePrecision]), $MachinePrecision] / Om), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 2.8 \cdot 10^{+133}:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, 2 \cdot \frac{\ell \cdot ky}{Om}\right)}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, 2 \cdot \frac{\ell \cdot \sin kx}{Om}\right)}}\\
\end{array}
\end{array}
if ky < 2.80000000000000016e133Initial program 98.6%
Simplified98.6%
expm1-log1p-u98.6%
expm1-udef98.6%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
un-div-inv100.0%
associate-*r*100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
Simplified100.0%
Taylor expanded in kx around 0 90.0%
Taylor expanded in ky around 0 83.9%
*-commutative83.9%
Simplified83.9%
if 2.80000000000000016e133 < ky Initial program 100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
un-div-inv100.0%
associate-*r*100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
Simplified100.0%
Taylor expanded in ky around 0 87.1%
Final simplification84.3%
(FPCore (l Om kx ky) :precision binary64 (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* 2.0 (/ (* l (sin ky)) Om)))))))
double code(double l, double Om, double kx, double ky) {
return sqrt((0.5 + (0.5 / hypot(1.0, (2.0 * ((l * sin(ky)) / 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 * ((l * Math.sin(ky)) / Om))))));
}
def code(l, Om, kx, ky): return math.sqrt((0.5 + (0.5 / math.hypot(1.0, (2.0 * ((l * math.sin(ky)) / Om))))))
function code(l, Om, kx, ky) return sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(2.0 * Float64(Float64(l * sin(ky)) / Om)))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 / hypot(1.0, (2.0 * ((l * sin(ky)) / Om)))))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(2.0 * N[(N[(l * N[Sin[ky], $MachinePrecision]), $MachinePrecision] / Om), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, 2 \cdot \frac{\ell \cdot \sin ky}{Om}\right)}}
\end{array}
Initial program 98.8%
Simplified98.8%
expm1-log1p-u98.8%
expm1-udef98.8%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
un-div-inv100.0%
associate-*r*100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
Simplified100.0%
Taylor expanded in kx around 0 91.4%
Final simplification91.4%
(FPCore (l Om kx ky) :precision binary64 (if (<= Om 1.8e+143) (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 <= 1.8e+143) {
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 <= 1.8e+143) {
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 <= 1.8e+143: 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 <= 1.8e+143) 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 <= 1.8e+143) 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[LessEqual[Om, 1.8e+143], 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 1.8 \cdot 10^{+143}:\\
\;\;\;\;\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 < 1.8e143Initial program 98.7%
Simplified98.7%
expm1-log1p-u98.7%
expm1-udef98.7%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
un-div-inv100.0%
associate-*r*100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
Simplified100.0%
Taylor expanded in kx around 0 91.2%
Taylor expanded in ky around 0 82.8%
*-commutative82.8%
Simplified82.8%
if 1.8e143 < Om Initial program 100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
un-div-inv100.0%
associate-*r*100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
Simplified100.0%
Taylor expanded in kx around 0 93.2%
Taylor expanded in l around 0 90.3%
Final simplification83.6%
(FPCore (l Om kx ky)
:precision binary64
(if (<= Om 6.2e-137)
(sqrt 0.5)
(if (or (<= Om 1.6e+58) (and (not (<= Om 4.8e+107)) (<= Om 8.8e+142)))
(sqrt
(+
0.5
(* 0.5 (/ 1.0 (+ 1.0 (/ (* 2.0 (* (* ky ky) (* l l))) (* Om Om)))))))
1.0)))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (Om <= 6.2e-137) {
tmp = sqrt(0.5);
} else if ((Om <= 1.6e+58) || (!(Om <= 4.8e+107) && (Om <= 8.8e+142))) {
tmp = sqrt((0.5 + (0.5 * (1.0 / (1.0 + ((2.0 * ((ky * ky) * (l * l))) / (Om * Om)))))));
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(l, om, kx, ky)
real(8), intent (in) :: l
real(8), intent (in) :: om
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8) :: tmp
if (om <= 6.2d-137) then
tmp = sqrt(0.5d0)
else if ((om <= 1.6d+58) .or. (.not. (om <= 4.8d+107)) .and. (om <= 8.8d+142)) then
tmp = sqrt((0.5d0 + (0.5d0 * (1.0d0 / (1.0d0 + ((2.0d0 * ((ky * ky) * (l * l))) / (om * om)))))))
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if (Om <= 6.2e-137) {
tmp = Math.sqrt(0.5);
} else if ((Om <= 1.6e+58) || (!(Om <= 4.8e+107) && (Om <= 8.8e+142))) {
tmp = Math.sqrt((0.5 + (0.5 * (1.0 / (1.0 + ((2.0 * ((ky * ky) * (l * l))) / (Om * Om)))))));
} else {
tmp = 1.0;
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if Om <= 6.2e-137: tmp = math.sqrt(0.5) elif (Om <= 1.6e+58) or (not (Om <= 4.8e+107) and (Om <= 8.8e+142)): tmp = math.sqrt((0.5 + (0.5 * (1.0 / (1.0 + ((2.0 * ((ky * ky) * (l * l))) / (Om * Om))))))) else: tmp = 1.0 return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (Om <= 6.2e-137) tmp = sqrt(0.5); elseif ((Om <= 1.6e+58) || (!(Om <= 4.8e+107) && (Om <= 8.8e+142))) tmp = sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / Float64(1.0 + Float64(Float64(2.0 * Float64(Float64(ky * ky) * Float64(l * l))) / Float64(Om * Om))))))); else tmp = 1.0; end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (Om <= 6.2e-137) tmp = sqrt(0.5); elseif ((Om <= 1.6e+58) || (~((Om <= 4.8e+107)) && (Om <= 8.8e+142))) tmp = sqrt((0.5 + (0.5 * (1.0 / (1.0 + ((2.0 * ((ky * ky) * (l * l))) / (Om * Om))))))); else tmp = 1.0; end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[Om, 6.2e-137], N[Sqrt[0.5], $MachinePrecision], If[Or[LessEqual[Om, 1.6e+58], And[N[Not[LessEqual[Om, 4.8e+107]], $MachinePrecision], LessEqual[Om, 8.8e+142]]], N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[(1.0 + N[(N[(2.0 * N[(N[(ky * ky), $MachinePrecision] * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(Om * Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;Om \leq 6.2 \cdot 10^{-137}:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{elif}\;Om \leq 1.6 \cdot 10^{+58} \lor \neg \left(Om \leq 4.8 \cdot 10^{+107}\right) \land Om \leq 8.8 \cdot 10^{+142}:\\
\;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{1 + \frac{2 \cdot \left(\left(ky \cdot ky\right) \cdot \left(\ell \cdot \ell\right)\right)}{Om \cdot Om}}}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if Om < 6.19999999999999955e-137Initial program 98.2%
Simplified98.2%
expm1-log1p-u98.2%
expm1-udef98.1%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
Simplified100.0%
Taylor expanded in l around inf 61.2%
if 6.19999999999999955e-137 < Om < 1.60000000000000008e58 or 4.8000000000000001e107 < Om < 8.79999999999999947e142Initial program 99.9%
Simplified99.9%
Taylor expanded in kx around 0 93.6%
associate-/l*91.7%
unpow291.7%
unpow291.7%
Simplified91.7%
Taylor expanded in ky around 0 77.7%
associate-*r/77.7%
unpow277.7%
unpow277.7%
unpow277.7%
Simplified77.7%
if 1.60000000000000008e58 < Om < 4.8000000000000001e107 or 8.79999999999999947e142 < Om Initial program 100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
un-div-inv100.0%
associate-*r*100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
Simplified100.0%
Taylor expanded in kx around 0 95.1%
Taylor expanded in l around 0 89.0%
Final simplification68.9%
(FPCore (l Om kx ky)
:precision binary64
(if (<= Om 3.5e-137)
(sqrt
(+
0.5
(* 0.5 (/ 1.0 (+ (* 0.25 (/ Om (* l ky))) (* 2.0 (/ (* l ky) Om)))))))
(if (or (<= Om 4.6e+58) (and (not (<= Om 4.8e+108)) (<= Om 5.6e+142)))
(sqrt
(+
0.5
(* 0.5 (/ 1.0 (+ 1.0 (/ (* 2.0 (* (* ky ky) (* l l))) (* Om Om)))))))
1.0)))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (Om <= 3.5e-137) {
tmp = sqrt((0.5 + (0.5 * (1.0 / ((0.25 * (Om / (l * ky))) + (2.0 * ((l * ky) / Om)))))));
} else if ((Om <= 4.6e+58) || (!(Om <= 4.8e+108) && (Om <= 5.6e+142))) {
tmp = sqrt((0.5 + (0.5 * (1.0 / (1.0 + ((2.0 * ((ky * ky) * (l * l))) / (Om * Om)))))));
} 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.5d-137) then
tmp = sqrt((0.5d0 + (0.5d0 * (1.0d0 / ((0.25d0 * (om / (l * ky))) + (2.0d0 * ((l * ky) / om)))))))
else if ((om <= 4.6d+58) .or. (.not. (om <= 4.8d+108)) .and. (om <= 5.6d+142)) then
tmp = sqrt((0.5d0 + (0.5d0 * (1.0d0 / (1.0d0 + ((2.0d0 * ((ky * ky) * (l * l))) / (om * om)))))))
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.5e-137) {
tmp = Math.sqrt((0.5 + (0.5 * (1.0 / ((0.25 * (Om / (l * ky))) + (2.0 * ((l * ky) / Om)))))));
} else if ((Om <= 4.6e+58) || (!(Om <= 4.8e+108) && (Om <= 5.6e+142))) {
tmp = Math.sqrt((0.5 + (0.5 * (1.0 / (1.0 + ((2.0 * ((ky * ky) * (l * l))) / (Om * Om)))))));
} else {
tmp = 1.0;
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if Om <= 3.5e-137: tmp = math.sqrt((0.5 + (0.5 * (1.0 / ((0.25 * (Om / (l * ky))) + (2.0 * ((l * ky) / Om))))))) elif (Om <= 4.6e+58) or (not (Om <= 4.8e+108) and (Om <= 5.6e+142)): tmp = math.sqrt((0.5 + (0.5 * (1.0 / (1.0 + ((2.0 * ((ky * ky) * (l * l))) / (Om * Om))))))) else: tmp = 1.0 return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (Om <= 3.5e-137) tmp = sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / Float64(Float64(0.25 * Float64(Om / Float64(l * ky))) + Float64(2.0 * Float64(Float64(l * ky) / Om))))))); elseif ((Om <= 4.6e+58) || (!(Om <= 4.8e+108) && (Om <= 5.6e+142))) tmp = sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / Float64(1.0 + Float64(Float64(2.0 * Float64(Float64(ky * ky) * Float64(l * l))) / Float64(Om * Om))))))); else tmp = 1.0; end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (Om <= 3.5e-137) tmp = sqrt((0.5 + (0.5 * (1.0 / ((0.25 * (Om / (l * ky))) + (2.0 * ((l * ky) / Om))))))); elseif ((Om <= 4.6e+58) || (~((Om <= 4.8e+108)) && (Om <= 5.6e+142))) tmp = sqrt((0.5 + (0.5 * (1.0 / (1.0 + ((2.0 * ((ky * ky) * (l * l))) / (Om * Om))))))); else tmp = 1.0; end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[Om, 3.5e-137], N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[(N[(0.25 * N[(Om / N[(l * ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[(N[(l * ky), $MachinePrecision] / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[Or[LessEqual[Om, 4.6e+58], And[N[Not[LessEqual[Om, 4.8e+108]], $MachinePrecision], LessEqual[Om, 5.6e+142]]], N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[(1.0 + N[(N[(2.0 * N[(N[(ky * ky), $MachinePrecision] * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(Om * Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;Om \leq 3.5 \cdot 10^{-137}:\\
\;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{0.25 \cdot \frac{Om}{\ell \cdot ky} + 2 \cdot \frac{\ell \cdot ky}{Om}}}\\
\mathbf{elif}\;Om \leq 4.6 \cdot 10^{+58} \lor \neg \left(Om \leq 4.8 \cdot 10^{+108}\right) \land Om \leq 5.6 \cdot 10^{+142}:\\
\;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{1 + \frac{2 \cdot \left(\left(ky \cdot ky\right) \cdot \left(\ell \cdot \ell\right)\right)}{Om \cdot Om}}}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if Om < 3.5000000000000001e-137Initial program 98.2%
Simplified98.2%
Taylor expanded in kx around 0 71.1%
associate-/l*70.4%
unpow270.4%
unpow270.4%
Simplified70.4%
Taylor expanded in ky around 0 61.1%
unpow261.1%
unpow261.1%
Simplified61.1%
Taylor expanded in l around inf 59.8%
if 3.5000000000000001e-137 < Om < 4.60000000000000005e58 or 4.80000000000000037e108 < Om < 5.6e142Initial program 99.9%
Simplified99.9%
Taylor expanded in kx around 0 93.6%
associate-/l*91.7%
unpow291.7%
unpow291.7%
Simplified91.7%
Taylor expanded in ky around 0 77.7%
associate-*r/77.7%
unpow277.7%
unpow277.7%
unpow277.7%
Simplified77.7%
if 4.60000000000000005e58 < Om < 4.80000000000000037e108 or 5.6e142 < Om Initial program 100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
un-div-inv100.0%
associate-*r*100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
Simplified100.0%
Taylor expanded in kx around 0 95.1%
Taylor expanded in l around 0 89.0%
Final simplification68.0%
(FPCore (l Om kx ky) :precision binary64 (if (<= Om 8.8e-93) (sqrt 0.5) (if (<= Om 1.2e-77) 1.0 (if (<= Om 1000000000.0) (sqrt 0.5) 1.0))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (Om <= 8.8e-93) {
tmp = sqrt(0.5);
} else if (Om <= 1.2e-77) {
tmp = 1.0;
} else if (Om <= 1000000000.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 <= 8.8d-93) then
tmp = sqrt(0.5d0)
else if (om <= 1.2d-77) then
tmp = 1.0d0
else if (om <= 1000000000.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 <= 8.8e-93) {
tmp = Math.sqrt(0.5);
} else if (Om <= 1.2e-77) {
tmp = 1.0;
} else if (Om <= 1000000000.0) {
tmp = Math.sqrt(0.5);
} else {
tmp = 1.0;
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if Om <= 8.8e-93: tmp = math.sqrt(0.5) elif Om <= 1.2e-77: tmp = 1.0 elif Om <= 1000000000.0: tmp = math.sqrt(0.5) else: tmp = 1.0 return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (Om <= 8.8e-93) tmp = sqrt(0.5); elseif (Om <= 1.2e-77) tmp = 1.0; elseif (Om <= 1000000000.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 <= 8.8e-93) tmp = sqrt(0.5); elseif (Om <= 1.2e-77) tmp = 1.0; elseif (Om <= 1000000000.0) tmp = sqrt(0.5); else tmp = 1.0; end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[Om, 8.8e-93], N[Sqrt[0.5], $MachinePrecision], If[LessEqual[Om, 1.2e-77], 1.0, If[LessEqual[Om, 1000000000.0], N[Sqrt[0.5], $MachinePrecision], 1.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;Om \leq 8.8 \cdot 10^{-93}:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{elif}\;Om \leq 1.2 \cdot 10^{-77}:\\
\;\;\;\;1\\
\mathbf{elif}\;Om \leq 1000000000:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if Om < 8.79999999999999983e-93 or 1.19999999999999995e-77 < Om < 1e9Initial program 98.5%
Simplified98.5%
expm1-log1p-u98.5%
expm1-udef98.5%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
Simplified100.0%
Taylor expanded in l around inf 62.3%
if 8.79999999999999983e-93 < Om < 1.19999999999999995e-77 or 1e9 < Om Initial program 100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
un-div-inv100.0%
associate-*r*100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
Simplified100.0%
Taylor expanded in kx around 0 95.2%
Taylor expanded in l around 0 84.0%
Final simplification67.2%
(FPCore (l Om kx ky) :precision binary64 1.0)
double code(double l, double Om, double kx, double ky) {
return 1.0;
}
real(8) function code(l, om, kx, ky)
real(8), intent (in) :: l
real(8), intent (in) :: om
real(8), intent (in) :: kx
real(8), intent (in) :: ky
code = 1.0d0
end function
public static double code(double l, double Om, double kx, double ky) {
return 1.0;
}
def code(l, Om, kx, ky): return 1.0
function code(l, Om, kx, ky) return 1.0 end
function tmp = code(l, Om, kx, ky) tmp = 1.0; end
code[l_, Om_, kx_, ky_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 98.8%
Simplified98.8%
expm1-log1p-u98.8%
expm1-udef98.8%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
un-div-inv100.0%
associate-*r*100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
Simplified100.0%
Taylor expanded in kx around 0 91.4%
Taylor expanded in l around 0 61.8%
Final simplification61.8%
herbie shell --seed 2023282
(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))))))))))