
(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
(pow
(sqrt (hypot 1.0 (* (hypot (sin ky) (sin kx)) (* l (/ 2.0 Om)))))
-2.0)))))
double code(double l, double Om, double kx, double ky) {
return sqrt((0.5 + (0.5 * pow(sqrt(hypot(1.0, (hypot(sin(ky), sin(kx)) * (l * (2.0 / Om))))), -2.0))));
}
public static double code(double l, double Om, double kx, double ky) {
return Math.sqrt((0.5 + (0.5 * Math.pow(Math.sqrt(Math.hypot(1.0, (Math.hypot(Math.sin(ky), Math.sin(kx)) * (l * (2.0 / Om))))), -2.0))));
}
def code(l, Om, kx, ky): return math.sqrt((0.5 + (0.5 * math.pow(math.sqrt(math.hypot(1.0, (math.hypot(math.sin(ky), math.sin(kx)) * (l * (2.0 / Om))))), -2.0))))
function code(l, Om, kx, ky) return sqrt(Float64(0.5 + Float64(0.5 * (sqrt(hypot(1.0, Float64(hypot(sin(ky), sin(kx)) * Float64(l * Float64(2.0 / Om))))) ^ -2.0)))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 * (sqrt(hypot(1.0, (hypot(sin(ky), sin(kx)) * (l * (2.0 / Om))))) ^ -2.0)))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(0.5 + N[(0.5 * N[Power[N[Sqrt[N[Sqrt[1.0 ^ 2 + N[(N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision] * N[(l * N[(2.0 / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]], $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + 0.5 \cdot {\left(\sqrt{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}\right)}^{-2}}
\end{array}
Initial program 100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-/l*100.0%
metadata-eval100.0%
Simplified100.0%
inv-pow100.0%
add-sqr-sqrt100.0%
unpow-prod-down100.0%
Applied egg-rr100.0%
pow-sqr100.0%
Simplified100.0%
Final simplification100.0%
(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 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%
Final simplification100.0%
(FPCore (l Om kx ky) :precision binary64 (sqrt (+ 0.5 (* 0.5 (pow (sqrt (hypot 1.0 (* 2.0 (/ (* (sin kx) l) Om)))) -2.0)))))
double code(double l, double Om, double kx, double ky) {
return sqrt((0.5 + (0.5 * pow(sqrt(hypot(1.0, (2.0 * ((sin(kx) * l) / Om)))), -2.0))));
}
public static double code(double l, double Om, double kx, double ky) {
return Math.sqrt((0.5 + (0.5 * Math.pow(Math.sqrt(Math.hypot(1.0, (2.0 * ((Math.sin(kx) * l) / Om)))), -2.0))));
}
def code(l, Om, kx, ky): return math.sqrt((0.5 + (0.5 * math.pow(math.sqrt(math.hypot(1.0, (2.0 * ((math.sin(kx) * l) / Om)))), -2.0))))
function code(l, Om, kx, ky) return sqrt(Float64(0.5 + Float64(0.5 * (sqrt(hypot(1.0, Float64(2.0 * Float64(Float64(sin(kx) * l) / Om)))) ^ -2.0)))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 * (sqrt(hypot(1.0, (2.0 * ((sin(kx) * l) / Om)))) ^ -2.0)))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(0.5 + N[(0.5 * N[Power[N[Sqrt[N[Sqrt[1.0 ^ 2 + N[(2.0 * N[(N[(N[Sin[kx], $MachinePrecision] * l), $MachinePrecision] / Om), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]], $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + 0.5 \cdot {\left(\sqrt{\mathsf{hypot}\left(1, 2 \cdot \frac{\sin kx \cdot \ell}{Om}\right)}\right)}^{-2}}
\end{array}
Initial program 100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-/l*100.0%
metadata-eval100.0%
Simplified100.0%
inv-pow100.0%
add-sqr-sqrt100.0%
unpow-prod-down100.0%
Applied egg-rr100.0%
pow-sqr100.0%
Simplified100.0%
Taylor expanded in ky around 0 94.5%
Final simplification94.5%
(FPCore (l Om kx ky) :precision binary64 (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* 2.0 (/ (sin kx) (/ Om l))))))))
double code(double l, double Om, double kx, double ky) {
return sqrt((0.5 + (0.5 / hypot(1.0, (2.0 * (sin(kx) / (Om / l)))))));
}
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 * (Math.sin(kx) / (Om / l)))))));
}
def code(l, Om, kx, ky): return math.sqrt((0.5 + (0.5 / math.hypot(1.0, (2.0 * (math.sin(kx) / (Om / l)))))))
function code(l, Om, kx, ky) return sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(2.0 * Float64(sin(kx) / Float64(Om / l))))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 / hypot(1.0, (2.0 * (sin(kx) / (Om / l))))))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(2.0 * N[(N[Sin[kx], $MachinePrecision] / N[(Om / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, 2 \cdot \frac{\sin kx}{\frac{Om}{\ell}}\right)}}
\end{array}
Initial program 100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-/l*100.0%
metadata-eval100.0%
Simplified100.0%
add-log-exp100.0%
add-sqr-sqrt100.0%
hypot-1-def100.0%
sqrt-prod100.0%
unpow2100.0%
sqrt-prod57.8%
add-sqr-sqrt100.0%
div-inv100.0%
clear-num100.0%
Applied egg-rr100.0%
Taylor expanded in ky around 0 94.5%
*-un-lft-identity94.5%
add-log-exp94.5%
associate-*l*94.5%
Applied egg-rr94.5%
*-lft-identity94.5%
associate-*l/94.5%
metadata-eval94.5%
associate-*l/94.5%
*-commutative94.5%
associate-/l*94.5%
Simplified94.5%
Final simplification94.5%
(FPCore (l Om kx ky)
:precision binary64
(let* ((t_0
(sqrt
(+
0.5
(*
0.5
(/ 1.0 (+ 1.0 (* 2.0 (/ (* l l) (/ (* Om Om) (* kx kx)))))))))))
(if (<= l -9e+153)
(sqrt 0.5)
(if (<= l -1.15e-35)
t_0
(if (<= l 1.15e-67)
1.0
(if (<= l 1.65e+40) t_0 (if (<= l 1.1e+85) 1.0 (sqrt 0.5))))))))
double code(double l, double Om, double kx, double ky) {
double t_0 = sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((l * l) / ((Om * Om) / (kx * kx)))))))));
double tmp;
if (l <= -9e+153) {
tmp = sqrt(0.5);
} else if (l <= -1.15e-35) {
tmp = t_0;
} else if (l <= 1.15e-67) {
tmp = 1.0;
} else if (l <= 1.65e+40) {
tmp = t_0;
} else if (l <= 1.1e+85) {
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) :: t_0
real(8) :: tmp
t_0 = sqrt((0.5d0 + (0.5d0 * (1.0d0 / (1.0d0 + (2.0d0 * ((l * l) / ((om * om) / (kx * kx)))))))))
if (l <= (-9d+153)) then
tmp = sqrt(0.5d0)
else if (l <= (-1.15d-35)) then
tmp = t_0
else if (l <= 1.15d-67) then
tmp = 1.0d0
else if (l <= 1.65d+40) then
tmp = t_0
else if (l <= 1.1d+85) 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 t_0 = Math.sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((l * l) / ((Om * Om) / (kx * kx)))))))));
double tmp;
if (l <= -9e+153) {
tmp = Math.sqrt(0.5);
} else if (l <= -1.15e-35) {
tmp = t_0;
} else if (l <= 1.15e-67) {
tmp = 1.0;
} else if (l <= 1.65e+40) {
tmp = t_0;
} else if (l <= 1.1e+85) {
tmp = 1.0;
} else {
tmp = Math.sqrt(0.5);
}
return tmp;
}
def code(l, Om, kx, ky): t_0 = math.sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((l * l) / ((Om * Om) / (kx * kx))))))))) tmp = 0 if l <= -9e+153: tmp = math.sqrt(0.5) elif l <= -1.15e-35: tmp = t_0 elif l <= 1.15e-67: tmp = 1.0 elif l <= 1.65e+40: tmp = t_0 elif l <= 1.1e+85: tmp = 1.0 else: tmp = math.sqrt(0.5) return tmp
function code(l, Om, kx, ky) t_0 = sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / Float64(1.0 + Float64(2.0 * Float64(Float64(l * l) / Float64(Float64(Om * Om) / Float64(kx * kx))))))))) tmp = 0.0 if (l <= -9e+153) tmp = sqrt(0.5); elseif (l <= -1.15e-35) tmp = t_0; elseif (l <= 1.15e-67) tmp = 1.0; elseif (l <= 1.65e+40) tmp = t_0; elseif (l <= 1.1e+85) tmp = 1.0; else tmp = sqrt(0.5); end return tmp end
function tmp_2 = code(l, Om, kx, ky) t_0 = sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((l * l) / ((Om * Om) / (kx * kx))))))))); tmp = 0.0; if (l <= -9e+153) tmp = sqrt(0.5); elseif (l <= -1.15e-35) tmp = t_0; elseif (l <= 1.15e-67) tmp = 1.0; elseif (l <= 1.65e+40) tmp = t_0; elseif (l <= 1.1e+85) tmp = 1.0; else tmp = sqrt(0.5); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := Block[{t$95$0 = N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[(1.0 + N[(2.0 * N[(N[(l * l), $MachinePrecision] / N[(N[(Om * Om), $MachinePrecision] / N[(kx * kx), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -9e+153], N[Sqrt[0.5], $MachinePrecision], If[LessEqual[l, -1.15e-35], t$95$0, If[LessEqual[l, 1.15e-67], 1.0, If[LessEqual[l, 1.65e+40], t$95$0, If[LessEqual[l, 1.1e+85], 1.0, N[Sqrt[0.5], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{0.5 + 0.5 \cdot \frac{1}{1 + 2 \cdot \frac{\ell \cdot \ell}{\frac{Om \cdot Om}{kx \cdot kx}}}}\\
\mathbf{if}\;\ell \leq -9 \cdot 10^{+153}:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{elif}\;\ell \leq -1.15 \cdot 10^{-35}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\ell \leq 1.15 \cdot 10^{-67}:\\
\;\;\;\;1\\
\mathbf{elif}\;\ell \leq 1.65 \cdot 10^{+40}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\ell \leq 1.1 \cdot 10^{+85}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5}\\
\end{array}
\end{array}
if l < -9.0000000000000002e153 or 1.1000000000000001e85 < l Initial program 100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-/l*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in l around -inf 76.4%
*-commutative76.4%
associate-*l*76.4%
unpow276.4%
unpow276.4%
hypot-def76.4%
Simplified76.4%
Taylor expanded in l around inf 80.2%
if -9.0000000000000002e153 < l < -1.1499999999999999e-35 or 1.15e-67 < l < 1.6499999999999999e40Initial program 100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-/l*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in ky around 0 90.1%
associate-/l*91.7%
associate-*r/91.7%
unpow291.7%
unpow291.7%
times-frac91.7%
Simplified91.7%
Taylor expanded in kx around 0 78.3%
associate-/l*81.5%
unpow281.5%
unpow281.5%
unpow281.5%
Simplified81.5%
if -1.1499999999999999e-35 < l < 1.15e-67 or 1.6499999999999999e40 < l < 1.1000000000000001e85Initial program 100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-/l*100.0%
metadata-eval100.0%
Simplified100.0%
add-log-exp100.0%
add-sqr-sqrt100.0%
hypot-1-def100.0%
sqrt-prod100.0%
unpow2100.0%
sqrt-prod61.6%
add-sqr-sqrt100.0%
div-inv100.0%
clear-num100.0%
Applied egg-rr100.0%
Taylor expanded in l around 0 89.8%
Final simplification85.2%
(FPCore (l Om kx ky)
:precision binary64
(if (<= l -7.8e+149)
(sqrt 0.5)
(if (<= l -9e-37)
(sqrt
(+
0.5
(* 0.5 (/ 1.0 (+ 1.0 (* 2.0 (/ (* l l) (/ (* Om Om) (* kx kx)))))))))
(if (<= l 4.7e-92)
1.0
(if (<= l 1.8e+128)
(sqrt
(+
0.5
(*
0.5
(/ 1.0 (+ 1.0 (* 2.0 (/ (* l l) (/ (* Om Om) (* ky ky)))))))))
(sqrt 0.5))))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= -7.8e+149) {
tmp = sqrt(0.5);
} else if (l <= -9e-37) {
tmp = sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((l * l) / ((Om * Om) / (kx * kx)))))))));
} else if (l <= 4.7e-92) {
tmp = 1.0;
} else if (l <= 1.8e+128) {
tmp = sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((l * l) / ((Om * Om) / (ky * 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 <= (-7.8d+149)) then
tmp = sqrt(0.5d0)
else if (l <= (-9d-37)) then
tmp = sqrt((0.5d0 + (0.5d0 * (1.0d0 / (1.0d0 + (2.0d0 * ((l * l) / ((om * om) / (kx * kx)))))))))
else if (l <= 4.7d-92) then
tmp = 1.0d0
else if (l <= 1.8d+128) then
tmp = sqrt((0.5d0 + (0.5d0 * (1.0d0 / (1.0d0 + (2.0d0 * ((l * l) / ((om * om) / (ky * 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 <= -7.8e+149) {
tmp = Math.sqrt(0.5);
} else if (l <= -9e-37) {
tmp = Math.sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((l * l) / ((Om * Om) / (kx * kx)))))))));
} else if (l <= 4.7e-92) {
tmp = 1.0;
} else if (l <= 1.8e+128) {
tmp = Math.sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((l * l) / ((Om * Om) / (ky * ky)))))))));
} else {
tmp = Math.sqrt(0.5);
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if l <= -7.8e+149: tmp = math.sqrt(0.5) elif l <= -9e-37: tmp = math.sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((l * l) / ((Om * Om) / (kx * kx))))))))) elif l <= 4.7e-92: tmp = 1.0 elif l <= 1.8e+128: tmp = math.sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((l * l) / ((Om * Om) / (ky * ky))))))))) else: tmp = math.sqrt(0.5) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (l <= -7.8e+149) tmp = sqrt(0.5); elseif (l <= -9e-37) tmp = sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / Float64(1.0 + Float64(2.0 * Float64(Float64(l * l) / Float64(Float64(Om * Om) / Float64(kx * kx))))))))); elseif (l <= 4.7e-92) tmp = 1.0; elseif (l <= 1.8e+128) tmp = sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / Float64(1.0 + Float64(2.0 * Float64(Float64(l * l) / Float64(Float64(Om * Om) / Float64(ky * ky))))))))); else tmp = sqrt(0.5); end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (l <= -7.8e+149) tmp = sqrt(0.5); elseif (l <= -9e-37) tmp = sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((l * l) / ((Om * Om) / (kx * kx))))))))); elseif (l <= 4.7e-92) tmp = 1.0; elseif (l <= 1.8e+128) tmp = sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((l * l) / ((Om * Om) / (ky * ky))))))))); else tmp = sqrt(0.5); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[l, -7.8e+149], N[Sqrt[0.5], $MachinePrecision], If[LessEqual[l, -9e-37], N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[(1.0 + N[(2.0 * N[(N[(l * l), $MachinePrecision] / N[(N[(Om * Om), $MachinePrecision] / N[(kx * kx), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[l, 4.7e-92], 1.0, If[LessEqual[l, 1.8e+128], N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / 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]], $MachinePrecision], N[Sqrt[0.5], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -7.8 \cdot 10^{+149}:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{elif}\;\ell \leq -9 \cdot 10^{-37}:\\
\;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{1 + 2 \cdot \frac{\ell \cdot \ell}{\frac{Om \cdot Om}{kx \cdot kx}}}}\\
\mathbf{elif}\;\ell \leq 4.7 \cdot 10^{-92}:\\
\;\;\;\;1\\
\mathbf{elif}\;\ell \leq 1.8 \cdot 10^{+128}:\\
\;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{1 + 2 \cdot \frac{\ell \cdot \ell}{\frac{Om \cdot Om}{ky \cdot ky}}}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5}\\
\end{array}
\end{array}
if l < -7.7999999999999998e149 or 1.80000000000000014e128 < l Initial program 100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-/l*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in l around -inf 77.7%
*-commutative77.7%
associate-*l*77.7%
unpow277.7%
unpow277.7%
hypot-def77.7%
Simplified77.7%
Taylor expanded in l around inf 81.1%
if -7.7999999999999998e149 < l < -9.00000000000000081e-37Initial program 99.9%
distribute-rgt-in99.9%
metadata-eval99.9%
metadata-eval99.9%
associate-/l*99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in ky around 0 88.3%
associate-/l*88.3%
associate-*r/88.3%
unpow288.3%
unpow288.3%
times-frac88.3%
Simplified88.3%
Taylor expanded in kx around 0 77.9%
associate-/l*81.1%
unpow281.1%
unpow281.1%
unpow281.1%
Simplified81.1%
if -9.00000000000000081e-37 < l < 4.69999999999999993e-92Initial program 100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-/l*100.0%
metadata-eval100.0%
Simplified100.0%
add-log-exp100.0%
add-sqr-sqrt100.0%
hypot-1-def100.0%
sqrt-prod100.0%
unpow2100.0%
sqrt-prod64.0%
add-sqr-sqrt100.0%
div-inv100.0%
clear-num100.0%
Applied egg-rr100.0%
Taylor expanded in l around 0 90.2%
if 4.69999999999999993e-92 < l < 1.80000000000000014e128Initial program 100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-/l*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in kx around 0 96.2%
associate-*r/96.2%
*-commutative96.2%
associate-*r*96.2%
unpow296.2%
unpow296.2%
Simplified96.2%
Taylor expanded in ky around 0 76.6%
associate-/l*78.7%
unpow278.7%
unpow278.7%
unpow278.7%
Simplified78.7%
Final simplification84.7%
(FPCore (l Om kx ky)
:precision binary64
(if (<= Om -1.02e+80)
1.0
(if (<= Om -1.55e+65)
(sqrt 0.5)
(if (<= Om -2.5e-86) 1.0 (if (<= Om 1e-37) (sqrt 0.5) 1.0)))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (Om <= -1.02e+80) {
tmp = 1.0;
} else if (Om <= -1.55e+65) {
tmp = sqrt(0.5);
} else if (Om <= -2.5e-86) {
tmp = 1.0;
} else if (Om <= 1e-37) {
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 <= (-1.02d+80)) then
tmp = 1.0d0
else if (om <= (-1.55d+65)) then
tmp = sqrt(0.5d0)
else if (om <= (-2.5d-86)) then
tmp = 1.0d0
else if (om <= 1d-37) 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 <= -1.02e+80) {
tmp = 1.0;
} else if (Om <= -1.55e+65) {
tmp = Math.sqrt(0.5);
} else if (Om <= -2.5e-86) {
tmp = 1.0;
} else if (Om <= 1e-37) {
tmp = Math.sqrt(0.5);
} else {
tmp = 1.0;
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if Om <= -1.02e+80: tmp = 1.0 elif Om <= -1.55e+65: tmp = math.sqrt(0.5) elif Om <= -2.5e-86: tmp = 1.0 elif Om <= 1e-37: tmp = math.sqrt(0.5) else: tmp = 1.0 return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (Om <= -1.02e+80) tmp = 1.0; elseif (Om <= -1.55e+65) tmp = sqrt(0.5); elseif (Om <= -2.5e-86) tmp = 1.0; elseif (Om <= 1e-37) 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 <= -1.02e+80) tmp = 1.0; elseif (Om <= -1.55e+65) tmp = sqrt(0.5); elseif (Om <= -2.5e-86) tmp = 1.0; elseif (Om <= 1e-37) tmp = sqrt(0.5); else tmp = 1.0; end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[Om, -1.02e+80], 1.0, If[LessEqual[Om, -1.55e+65], N[Sqrt[0.5], $MachinePrecision], If[LessEqual[Om, -2.5e-86], 1.0, If[LessEqual[Om, 1e-37], N[Sqrt[0.5], $MachinePrecision], 1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;Om \leq -1.02 \cdot 10^{+80}:\\
\;\;\;\;1\\
\mathbf{elif}\;Om \leq -1.55 \cdot 10^{+65}:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{elif}\;Om \leq -2.5 \cdot 10^{-86}:\\
\;\;\;\;1\\
\mathbf{elif}\;Om \leq 10^{-37}:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if Om < -1.02e80 or -1.54999999999999995e65 < Om < -2.4999999999999999e-86 or 1.00000000000000007e-37 < Om Initial program 100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-/l*100.0%
metadata-eval100.0%
Simplified100.0%
add-log-exp100.0%
add-sqr-sqrt100.0%
hypot-1-def100.0%
sqrt-prod100.0%
unpow2100.0%
sqrt-prod62.7%
add-sqr-sqrt100.0%
div-inv100.0%
clear-num100.0%
Applied egg-rr100.0%
Taylor expanded in l around 0 87.9%
if -1.02e80 < Om < -1.54999999999999995e65 or -2.4999999999999999e-86 < Om < 1.00000000000000007e-37Initial program 100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-/l*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in l around -inf 76.3%
*-commutative76.3%
associate-*l*76.3%
unpow276.3%
unpow276.3%
hypot-def76.3%
Simplified76.3%
Taylor expanded in l around inf 80.1%
Final simplification84.8%
(FPCore (l Om kx ky) :precision binary64 (sqrt 0.5))
double code(double l, double Om, double kx, double ky) {
return sqrt(0.5);
}
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(0.5d0)
end function
public static double code(double l, double Om, double kx, double ky) {
return Math.sqrt(0.5);
}
def code(l, Om, kx, ky): return math.sqrt(0.5)
function code(l, Om, kx, ky) return sqrt(0.5) end
function tmp = code(l, Om, kx, ky) tmp = sqrt(0.5); end
code[l_, Om_, kx_, ky_] := N[Sqrt[0.5], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5}
\end{array}
Initial program 100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-/l*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in l around -inf 40.4%
*-commutative40.4%
associate-*l*40.4%
unpow240.4%
unpow240.4%
hypot-def40.4%
Simplified40.4%
Taylor expanded in l around inf 50.5%
Final simplification50.5%
herbie shell --seed 2023178
(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))))))))))