(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 (sqrt (/ d h))))
(t_1 (- 1.0 (* (* 0.5 (pow (/ (* M D) (* d 2.0)) 2.0)) (/ h l))))
(t_2 (pow (/ d h) 0.5))
(t_3 (pow (/ d l) 0.5))
(t_4 (* t_2 t_3))
(t_5 (* t_4 t_1)))
(if (<= t_5 (- INFINITY))
(* t_4 (+ 1.0 (* (/ (* h (* D (/ D l))) (* d (/ (/ d M) M))) -0.125)))
(if (<= t_5 0.0)
(* t_1 (* t_3 (* t_0 t_0)))
(if (<= t_5 2e+263)
(*
t_2
(*
(sqrt (/ d l))
(+ 1.0 (/ (* (pow (/ M (/ 2.0 (/ D d))) 2.0) -0.5) (/ l h)))))
(* d (sqrt (/ 1.0 (* h 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(sqrt((d / h)));
double t_1 = 1.0 - ((0.5 * pow(((M * D) / (d * 2.0)), 2.0)) * (h / l));
double t_2 = pow((d / h), 0.5);
double t_3 = pow((d / l), 0.5);
double t_4 = t_2 * t_3;
double t_5 = t_4 * t_1;
double tmp;
if (t_5 <= -((double) INFINITY)) {
tmp = t_4 * (1.0 + (((h * (D * (D / l))) / (d * ((d / M) / M))) * -0.125));
} else if (t_5 <= 0.0) {
tmp = t_1 * (t_3 * (t_0 * t_0));
} else if (t_5 <= 2e+263) {
tmp = t_2 * (sqrt((d / l)) * (1.0 + ((pow((M / (2.0 / (D / d))), 2.0) * -0.5) / (l / h))));
} else {
tmp = d * sqrt((1.0 / (h * l)));
}
return tmp;
}
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(Math.sqrt((d / h)));
double t_1 = 1.0 - ((0.5 * Math.pow(((M * D) / (d * 2.0)), 2.0)) * (h / l));
double t_2 = Math.pow((d / h), 0.5);
double t_3 = Math.pow((d / l), 0.5);
double t_4 = t_2 * t_3;
double t_5 = t_4 * t_1;
double tmp;
if (t_5 <= -Double.POSITIVE_INFINITY) {
tmp = t_4 * (1.0 + (((h * (D * (D / l))) / (d * ((d / M) / M))) * -0.125));
} else if (t_5 <= 0.0) {
tmp = t_1 * (t_3 * (t_0 * t_0));
} else if (t_5 <= 2e+263) {
tmp = t_2 * (Math.sqrt((d / l)) * (1.0 + ((Math.pow((M / (2.0 / (D / d))), 2.0) * -0.5) / (l / h))));
} else {
tmp = d * Math.sqrt((1.0 / (h * 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(math.sqrt((d / h))) t_1 = 1.0 - ((0.5 * math.pow(((M * D) / (d * 2.0)), 2.0)) * (h / l)) t_2 = math.pow((d / h), 0.5) t_3 = math.pow((d / l), 0.5) t_4 = t_2 * t_3 t_5 = t_4 * t_1 tmp = 0 if t_5 <= -math.inf: tmp = t_4 * (1.0 + (((h * (D * (D / l))) / (d * ((d / M) / M))) * -0.125)) elif t_5 <= 0.0: tmp = t_1 * (t_3 * (t_0 * t_0)) elif t_5 <= 2e+263: tmp = t_2 * (math.sqrt((d / l)) * (1.0 + ((math.pow((M / (2.0 / (D / d))), 2.0) * -0.5) / (l / h)))) else: tmp = d * math.sqrt((1.0 / (h * 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(sqrt(Float64(d / h))) t_1 = Float64(1.0 - Float64(Float64(0.5 * (Float64(Float64(M * D) / Float64(d * 2.0)) ^ 2.0)) * Float64(h / l))) t_2 = Float64(d / h) ^ 0.5 t_3 = Float64(d / l) ^ 0.5 t_4 = Float64(t_2 * t_3) t_5 = Float64(t_4 * t_1) tmp = 0.0 if (t_5 <= Float64(-Inf)) tmp = Float64(t_4 * Float64(1.0 + Float64(Float64(Float64(h * Float64(D * Float64(D / l))) / Float64(d * Float64(Float64(d / M) / M))) * -0.125))); elseif (t_5 <= 0.0) tmp = Float64(t_1 * Float64(t_3 * Float64(t_0 * t_0))); elseif (t_5 <= 2e+263) tmp = Float64(t_2 * Float64(sqrt(Float64(d / l)) * Float64(1.0 + Float64(Float64((Float64(M / Float64(2.0 / Float64(D / d))) ^ 2.0) * -0.5) / Float64(l / h))))); else tmp = Float64(d * sqrt(Float64(1.0 / Float64(h * 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(sqrt((d / h))); t_1 = 1.0 - ((0.5 * (((M * D) / (d * 2.0)) ^ 2.0)) * (h / l)); t_2 = (d / h) ^ 0.5; t_3 = (d / l) ^ 0.5; t_4 = t_2 * t_3; t_5 = t_4 * t_1; tmp = 0.0; if (t_5 <= -Inf) tmp = t_4 * (1.0 + (((h * (D * (D / l))) / (d * ((d / M) / M))) * -0.125)); elseif (t_5 <= 0.0) tmp = t_1 * (t_3 * (t_0 * t_0)); elseif (t_5 <= 2e+263) tmp = t_2 * (sqrt((d / l)) * (1.0 + ((((M / (2.0 / (D / d))) ^ 2.0) * -0.5) / (l / h)))); else tmp = d * sqrt((1.0 / (h * 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[N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(N[(0.5 * N[Power[N[(N[(M * D), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[(d / h), $MachinePrecision], 0.5], $MachinePrecision]}, Block[{t$95$3 = N[Power[N[(d / l), $MachinePrecision], 0.5], $MachinePrecision]}, Block[{t$95$4 = N[(t$95$2 * t$95$3), $MachinePrecision]}, Block[{t$95$5 = N[(t$95$4 * t$95$1), $MachinePrecision]}, If[LessEqual[t$95$5, (-Infinity)], N[(t$95$4 * N[(1.0 + N[(N[(N[(h * N[(D * N[(D / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d * N[(N[(d / M), $MachinePrecision] / M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$5, 0.0], N[(t$95$1 * N[(t$95$3 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$5, 2e+263], N[(t$95$2 * N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(N[(N[Power[N[(M / N[(2.0 / N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * -0.5), $MachinePrecision] / N[(l / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[Sqrt[N[(1.0 / N[(h * 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{\sqrt{\frac{d}{h}}}\\
t_1 := 1 - \left(0.5 \cdot {\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2}\right) \cdot \frac{h}{\ell}\\
t_2 := {\left(\frac{d}{h}\right)}^{0.5}\\
t_3 := {\left(\frac{d}{\ell}\right)}^{0.5}\\
t_4 := t_2 \cdot t_3\\
t_5 := t_4 \cdot t_1\\
\mathbf{if}\;t_5 \leq -\infty:\\
\;\;\;\;t_4 \cdot \left(1 + \frac{h \cdot \left(D \cdot \frac{D}{\ell}\right)}{d \cdot \frac{\frac{d}{M}}{M}} \cdot -0.125\right)\\
\mathbf{elif}\;t_5 \leq 0:\\
\;\;\;\;t_1 \cdot \left(t_3 \cdot \left(t_0 \cdot t_0\right)\right)\\
\mathbf{elif}\;t_5 \leq 2 \cdot 10^{+263}:\\
\;\;\;\;t_2 \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{{\left(\frac{M}{\frac{2}{\frac{D}{d}}}\right)}^{2} \cdot -0.5}{\frac{\ell}{h}}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;d \cdot \sqrt{\frac{1}{h \cdot \ell}}\\
\end{array}



Bits error versus d



Bits error versus h



Bits error versus l



Bits error versus M



Bits error versus D
Results
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 1 2)) (pow.f64 (/.f64 d l) (/.f64 1 2))) (-.f64 1 (*.f64 (*.f64 (/.f64 1 2) (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)) (/.f64 h l)))) < -inf.0Initial program 64.0
Applied egg-rr53.4
Taylor expanded in M around 0 59.4
Simplified50.9
if -inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 1 2)) (pow.f64 (/.f64 d l) (/.f64 1 2))) (-.f64 1 (*.f64 (*.f64 (/.f64 1 2) (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)) (/.f64 h l)))) < -0.0Initial program 21.8
Applied egg-rr21.9
if -0.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 1 2)) (pow.f64 (/.f64 d l) (/.f64 1 2))) (-.f64 1 (*.f64 (*.f64 (/.f64 1 2) (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)) (/.f64 h l)))) < 2.00000000000000003e263Initial program 0.9
Applied egg-rr1.1
Applied egg-rr1.3
Applied egg-rr1.2
if 2.00000000000000003e263 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 1 2)) (pow.f64 (/.f64 d l) (/.f64 1 2))) (-.f64 1 (*.f64 (*.f64 (/.f64 1 2) (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)) (/.f64 h l)))) Initial program 62.6
Taylor expanded in d around inf 44.9
Final simplification21.1
herbie shell --seed 2022165
(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)))))