(FPCore (d h l M D) :precision binary64 (* (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0))) (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (sqrt (- d)))
(t_1
(-
1.0
(pow (/ l (* h (* 0.5 (pow (/ (* M D) (* d 2.0)) 2.0)))) -1.0))))
(if (<= h -1.733687270610834e-182)
(* (* (sqrt (* d (/ 1.0 h))) (/ t_0 (sqrt (- l)))) t_1)
(if (<= h -5.96337956912148e-309)
(* t_1 (* (* t_0 (sqrt (/ -1.0 h))) (pow (/ d l) 0.5)))
(if (<= h 1.2123265266183649e-139)
(* d (sqrt (/ (/ 1.0 l) h)))
(* t_1 (* (pow (/ d h) 0.5) (/ (sqrt d) (sqrt l)))))))))double code(double d, double h, double l, double M, double D) {
return (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
double code(double d, double h, double l, double M, double D) {
double t_0 = sqrt(-d);
double t_1 = 1.0 - pow((l / (h * (0.5 * pow(((M * D) / (d * 2.0)), 2.0)))), -1.0);
double tmp;
if (h <= -1.733687270610834e-182) {
tmp = (sqrt((d * (1.0 / h))) * (t_0 / sqrt(-l))) * t_1;
} else if (h <= -5.96337956912148e-309) {
tmp = t_1 * ((t_0 * sqrt((-1.0 / h))) * pow((d / l), 0.5));
} else if (h <= 1.2123265266183649e-139) {
tmp = d * sqrt(((1.0 / l) / h));
} else {
tmp = t_1 * (pow((d / h), 0.5) * (sqrt(d) / sqrt(l)));
}
return tmp;
}
real(8) function code(d, h, l, m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
code = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
end function
real(8) function code(d, h, l, m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sqrt(-d)
t_1 = 1.0d0 - ((l / (h * (0.5d0 * (((m * d_1) / (d * 2.0d0)) ** 2.0d0)))) ** (-1.0d0))
if (h <= (-1.733687270610834d-182)) then
tmp = (sqrt((d * (1.0d0 / h))) * (t_0 / sqrt(-l))) * t_1
else if (h <= (-5.96337956912148d-309)) then
tmp = t_1 * ((t_0 * sqrt(((-1.0d0) / h))) * ((d / l) ** 0.5d0))
else if (h <= 1.2123265266183649d-139) then
tmp = d * sqrt(((1.0d0 / l) / h))
else
tmp = t_1 * (((d / h) ** 0.5d0) * (sqrt(d) / sqrt(l)))
end if
code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
return (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
public static double code(double d, double h, double l, double M, double D) {
double t_0 = Math.sqrt(-d);
double t_1 = 1.0 - Math.pow((l / (h * (0.5 * Math.pow(((M * D) / (d * 2.0)), 2.0)))), -1.0);
double tmp;
if (h <= -1.733687270610834e-182) {
tmp = (Math.sqrt((d * (1.0 / h))) * (t_0 / Math.sqrt(-l))) * t_1;
} else if (h <= -5.96337956912148e-309) {
tmp = t_1 * ((t_0 * Math.sqrt((-1.0 / h))) * Math.pow((d / l), 0.5));
} else if (h <= 1.2123265266183649e-139) {
tmp = d * Math.sqrt(((1.0 / l) / h));
} else {
tmp = t_1 * (Math.pow((d / h), 0.5) * (Math.sqrt(d) / Math.sqrt(l)));
}
return tmp;
}
def code(d, h, l, M, D): return (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)))
def code(d, h, l, M, D): t_0 = math.sqrt(-d) t_1 = 1.0 - math.pow((l / (h * (0.5 * math.pow(((M * D) / (d * 2.0)), 2.0)))), -1.0) tmp = 0 if h <= -1.733687270610834e-182: tmp = (math.sqrt((d * (1.0 / h))) * (t_0 / math.sqrt(-l))) * t_1 elif h <= -5.96337956912148e-309: tmp = t_1 * ((t_0 * math.sqrt((-1.0 / h))) * math.pow((d / l), 0.5)) elif h <= 1.2123265266183649e-139: tmp = d * math.sqrt(((1.0 / l) / h)) else: tmp = t_1 * (math.pow((d / h), 0.5) * (math.sqrt(d) / math.sqrt(l))) return tmp
function code(d, h, l, M, D) return Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) end
function code(d, h, l, M, D) t_0 = sqrt(Float64(-d)) t_1 = Float64(1.0 - (Float64(l / Float64(h * Float64(0.5 * (Float64(Float64(M * D) / Float64(d * 2.0)) ^ 2.0)))) ^ -1.0)) tmp = 0.0 if (h <= -1.733687270610834e-182) tmp = Float64(Float64(sqrt(Float64(d * Float64(1.0 / h))) * Float64(t_0 / sqrt(Float64(-l)))) * t_1); elseif (h <= -5.96337956912148e-309) tmp = Float64(t_1 * Float64(Float64(t_0 * sqrt(Float64(-1.0 / h))) * (Float64(d / l) ^ 0.5))); elseif (h <= 1.2123265266183649e-139) tmp = Float64(d * sqrt(Float64(Float64(1.0 / l) / h))); else tmp = Float64(t_1 * Float64((Float64(d / h) ^ 0.5) * Float64(sqrt(d) / sqrt(l)))); end return tmp end
function tmp = code(d, h, l, M, D) tmp = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l))); end
function tmp_2 = code(d, h, l, M, D) t_0 = sqrt(-d); t_1 = 1.0 - ((l / (h * (0.5 * (((M * D) / (d * 2.0)) ^ 2.0)))) ^ -1.0); tmp = 0.0; if (h <= -1.733687270610834e-182) tmp = (sqrt((d * (1.0 / h))) * (t_0 / sqrt(-l))) * t_1; elseif (h <= -5.96337956912148e-309) tmp = t_1 * ((t_0 * sqrt((-1.0 / h))) * ((d / l) ^ 0.5)); elseif (h <= 1.2123265266183649e-139) tmp = d * sqrt(((1.0 / l) / h)); else tmp = t_1 * (((d / h) ^ 0.5) * (sqrt(d) / sqrt(l))); end tmp_2 = tmp; end
code[d_, h_, l_, M_, D_] := N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[Sqrt[(-d)], $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[Power[N[(l / N[(h * N[(0.5 * N[Power[N[(N[(M * D), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[h, -1.733687270610834e-182], N[(N[(N[Sqrt[N[(d * N[(1.0 / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(t$95$0 / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[h, -5.96337956912148e-309], N[(t$95$1 * N[(N[(t$95$0 * N[Sqrt[N[(-1.0 / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[h, 1.2123265266183649e-139], N[(d * N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(N[Power[N[(d / h), $MachinePrecision], 0.5], $MachinePrecision] * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)
\begin{array}{l}
t_0 := \sqrt{-d}\\
t_1 := 1 - {\left(\frac{\ell}{h \cdot \left(0.5 \cdot {\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2}\right)}\right)}^{-1}\\
\mathbf{if}\;h \leq -1.733687270610834 \cdot 10^{-182}:\\
\;\;\;\;\left(\sqrt{d \cdot \frac{1}{h}} \cdot \frac{t_0}{\sqrt{-\ell}}\right) \cdot t_1\\
\mathbf{elif}\;h \leq -5.96337956912148 \cdot 10^{-309}:\\
\;\;\;\;t_1 \cdot \left(\left(t_0 \cdot \sqrt{\frac{-1}{h}}\right) \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right)\\
\mathbf{elif}\;h \leq 1.2123265266183649 \cdot 10^{-139}:\\
\;\;\;\;d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \left({\left(\frac{d}{h}\right)}^{0.5} \cdot \frac{\sqrt{d}}{\sqrt{\ell}}\right)\\
\end{array}



Bits error versus d



Bits error versus h



Bits error versus l



Bits error versus M



Bits error versus D
Results
if h < -1.7336872706108341e-182Initial program 24.0
Applied egg-rr23.3
Applied egg-rr22.8
Taylor expanded in h around -inf 22.7
Simplified22.9
Applied egg-rr16.9
if -1.7336872706108341e-182 < h < -5.9633795691214818e-309Initial program 36.3
Applied egg-rr37.2
Applied egg-rr36.3
Taylor expanded in h around -inf 23.6
Simplified36.3
Applied egg-rr19.6
if -5.9633795691214818e-309 < h < 1.21232652661836487e-139Initial program 31.7
Applied egg-rr32.4
Applied egg-rr31.7
Taylor expanded in d around inf 24.2
Simplified24.2
if 1.21232652661836487e-139 < h Initial program 23.5
Applied egg-rr23.0
Applied egg-rr22.9
Applied egg-rr16.8
Final simplification18.1
herbie shell --seed 2022150
(FPCore (d h l M D)
:name "Henrywood and Agarwal, Equation (12)"
:precision binary64
(* (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0))) (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))