(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 (pow (/ d l) 0.5))
(t_1 (* (/ M (* d 2.0)) D))
(t_2 (- 1.0 (pow (* (sqrt (/ h l)) (* t_1 (sqrt 0.5))) 2.0))))
(if (<= l -4.279388089894161e-103)
(* (* (/ (sqrt (- d)) (sqrt (- h))) t_0) t_2)
(if (<= l 4.8269720407177665e-122)
(*
(* t_0 (pow (/ d h) 0.5))
(- 1.0 (/ 1.0 (/ l (* h (* 0.5 (pow t_1 2.0)))))))
(* t_2 (* t_0 (/ (sqrt d) (sqrt h))))))))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 = pow((d / l), 0.5);
double t_1 = (M / (d * 2.0)) * D;
double t_2 = 1.0 - pow((sqrt((h / l)) * (t_1 * sqrt(0.5))), 2.0);
double tmp;
if (l <= -4.279388089894161e-103) {
tmp = ((sqrt(-d) / sqrt(-h)) * t_0) * t_2;
} else if (l <= 4.8269720407177665e-122) {
tmp = (t_0 * pow((d / h), 0.5)) * (1.0 - (1.0 / (l / (h * (0.5 * pow(t_1, 2.0))))));
} else {
tmp = t_2 * (t_0 * (sqrt(d) / sqrt(h)));
}
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) :: t_2
real(8) :: tmp
t_0 = (d / l) ** 0.5d0
t_1 = (m / (d * 2.0d0)) * d_1
t_2 = 1.0d0 - ((sqrt((h / l)) * (t_1 * sqrt(0.5d0))) ** 2.0d0)
if (l <= (-4.279388089894161d-103)) then
tmp = ((sqrt(-d) / sqrt(-h)) * t_0) * t_2
else if (l <= 4.8269720407177665d-122) then
tmp = (t_0 * ((d / h) ** 0.5d0)) * (1.0d0 - (1.0d0 / (l / (h * (0.5d0 * (t_1 ** 2.0d0))))))
else
tmp = t_2 * (t_0 * (sqrt(d) / sqrt(h)))
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.pow((d / l), 0.5);
double t_1 = (M / (d * 2.0)) * D;
double t_2 = 1.0 - Math.pow((Math.sqrt((h / l)) * (t_1 * Math.sqrt(0.5))), 2.0);
double tmp;
if (l <= -4.279388089894161e-103) {
tmp = ((Math.sqrt(-d) / Math.sqrt(-h)) * t_0) * t_2;
} else if (l <= 4.8269720407177665e-122) {
tmp = (t_0 * Math.pow((d / h), 0.5)) * (1.0 - (1.0 / (l / (h * (0.5 * Math.pow(t_1, 2.0))))));
} else {
tmp = t_2 * (t_0 * (Math.sqrt(d) / Math.sqrt(h)));
}
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.pow((d / l), 0.5) t_1 = (M / (d * 2.0)) * D t_2 = 1.0 - math.pow((math.sqrt((h / l)) * (t_1 * math.sqrt(0.5))), 2.0) tmp = 0 if l <= -4.279388089894161e-103: tmp = ((math.sqrt(-d) / math.sqrt(-h)) * t_0) * t_2 elif l <= 4.8269720407177665e-122: tmp = (t_0 * math.pow((d / h), 0.5)) * (1.0 - (1.0 / (l / (h * (0.5 * math.pow(t_1, 2.0)))))) else: tmp = t_2 * (t_0 * (math.sqrt(d) / math.sqrt(h))) 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 = Float64(d / l) ^ 0.5 t_1 = Float64(Float64(M / Float64(d * 2.0)) * D) t_2 = Float64(1.0 - (Float64(sqrt(Float64(h / l)) * Float64(t_1 * sqrt(0.5))) ^ 2.0)) tmp = 0.0 if (l <= -4.279388089894161e-103) tmp = Float64(Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * t_0) * t_2); elseif (l <= 4.8269720407177665e-122) tmp = Float64(Float64(t_0 * (Float64(d / h) ^ 0.5)) * Float64(1.0 - Float64(1.0 / Float64(l / Float64(h * Float64(0.5 * (t_1 ^ 2.0))))))); else tmp = Float64(t_2 * Float64(t_0 * Float64(sqrt(d) / sqrt(h)))); 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 = (d / l) ^ 0.5; t_1 = (M / (d * 2.0)) * D; t_2 = 1.0 - ((sqrt((h / l)) * (t_1 * sqrt(0.5))) ^ 2.0); tmp = 0.0; if (l <= -4.279388089894161e-103) tmp = ((sqrt(-d) / sqrt(-h)) * t_0) * t_2; elseif (l <= 4.8269720407177665e-122) tmp = (t_0 * ((d / h) ^ 0.5)) * (1.0 - (1.0 / (l / (h * (0.5 * (t_1 ^ 2.0)))))); else tmp = t_2 * (t_0 * (sqrt(d) / sqrt(h))); 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[Power[N[(d / l), $MachinePrecision], 0.5], $MachinePrecision]}, Block[{t$95$1 = N[(N[(M / N[(d * 2.0), $MachinePrecision]), $MachinePrecision] * D), $MachinePrecision]}, Block[{t$95$2 = N[(1.0 - N[Power[N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * N[(t$95$1 * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -4.279388089894161e-103], N[(N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$2), $MachinePrecision], If[LessEqual[l, 4.8269720407177665e-122], N[(N[(t$95$0 * N[Power[N[(d / h), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(1.0 / N[(l / N[(h * N[(0.5 * N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$2 * N[(t$95$0 * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $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 := {\left(\frac{d}{\ell}\right)}^{0.5}\\
t_1 := \frac{M}{d \cdot 2} \cdot D\\
t_2 := 1 - {\left(\sqrt{\frac{h}{\ell}} \cdot \left(t_1 \cdot \sqrt{0.5}\right)\right)}^{2}\\
\mathbf{if}\;\ell \leq -4.279388089894161 \cdot 10^{-103}:\\
\;\;\;\;\left(\frac{\sqrt{-d}}{\sqrt{-h}} \cdot t_0\right) \cdot t_2\\
\mathbf{elif}\;\ell \leq 4.8269720407177665 \cdot 10^{-122}:\\
\;\;\;\;\left(t_0 \cdot {\left(\frac{d}{h}\right)}^{0.5}\right) \cdot \left(1 - \frac{1}{\frac{\ell}{h \cdot \left(0.5 \cdot {t_1}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;t_2 \cdot \left(t_0 \cdot \frac{\sqrt{d}}{\sqrt{h}}\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 l < -4.27938808989416096e-103Initial program 25.5
Applied egg-rr24.1
Applied egg-rr16.4
if -4.27938808989416096e-103 < l < 4.82697204071776654e-122Initial program 33.2
Applied egg-rr27.8
if 4.82697204071776654e-122 < l Initial program 25.4
Applied egg-rr24.2
Applied egg-rr17.1
Final simplification18.9
herbie shell --seed 2022153
(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)))))