(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 (* 0.5 (pow (/ (* M D) (* d 2.0)) 2.0)))
(t_1 (- 1.0 (/ (* h t_0) l))))
(if (<= l -3.170040707759249e-296)
(* (* (/ (sqrt (- d)) (sqrt (- h))) (/ 1.0 (sqrt (/ l d)))) t_1)
(if (<= l 1.9115375279058692e+23)
(* t_1 (* (pow (/ d h) 0.5) (/ 1.0 (/ (sqrt l) (sqrt d)))))
(*
(* (/ (sqrt d) (sqrt h)) (pow (/ d l) 0.5))
(- 1.0 (* t_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 = 0.5 * pow(((M * D) / (d * 2.0)), 2.0);
double t_1 = 1.0 - ((h * t_0) / l);
double tmp;
if (l <= -3.170040707759249e-296) {
tmp = ((sqrt(-d) / sqrt(-h)) * (1.0 / sqrt((l / d)))) * t_1;
} else if (l <= 1.9115375279058692e+23) {
tmp = t_1 * (pow((d / h), 0.5) * (1.0 / (sqrt(l) / sqrt(d))));
} else {
tmp = ((sqrt(d) / sqrt(h)) * pow((d / l), 0.5)) * (1.0 - (t_0 * (h / 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 = 0.5d0 * (((m * d_1) / (d * 2.0d0)) ** 2.0d0)
t_1 = 1.0d0 - ((h * t_0) / l)
if (l <= (-3.170040707759249d-296)) then
tmp = ((sqrt(-d) / sqrt(-h)) * (1.0d0 / sqrt((l / d)))) * t_1
else if (l <= 1.9115375279058692d+23) then
tmp = t_1 * (((d / h) ** 0.5d0) * (1.0d0 / (sqrt(l) / sqrt(d))))
else
tmp = ((sqrt(d) / sqrt(h)) * ((d / l) ** 0.5d0)) * (1.0d0 - (t_0 * (h / 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 = 0.5 * Math.pow(((M * D) / (d * 2.0)), 2.0);
double t_1 = 1.0 - ((h * t_0) / l);
double tmp;
if (l <= -3.170040707759249e-296) {
tmp = ((Math.sqrt(-d) / Math.sqrt(-h)) * (1.0 / Math.sqrt((l / d)))) * t_1;
} else if (l <= 1.9115375279058692e+23) {
tmp = t_1 * (Math.pow((d / h), 0.5) * (1.0 / (Math.sqrt(l) / Math.sqrt(d))));
} else {
tmp = ((Math.sqrt(d) / Math.sqrt(h)) * Math.pow((d / l), 0.5)) * (1.0 - (t_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 = 0.5 * math.pow(((M * D) / (d * 2.0)), 2.0) t_1 = 1.0 - ((h * t_0) / l) tmp = 0 if l <= -3.170040707759249e-296: tmp = ((math.sqrt(-d) / math.sqrt(-h)) * (1.0 / math.sqrt((l / d)))) * t_1 elif l <= 1.9115375279058692e+23: tmp = t_1 * (math.pow((d / h), 0.5) * (1.0 / (math.sqrt(l) / math.sqrt(d)))) else: tmp = ((math.sqrt(d) / math.sqrt(h)) * math.pow((d / l), 0.5)) * (1.0 - (t_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 = Float64(0.5 * (Float64(Float64(M * D) / Float64(d * 2.0)) ^ 2.0)) t_1 = Float64(1.0 - Float64(Float64(h * t_0) / l)) tmp = 0.0 if (l <= -3.170040707759249e-296) tmp = Float64(Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * Float64(1.0 / sqrt(Float64(l / d)))) * t_1); elseif (l <= 1.9115375279058692e+23) tmp = Float64(t_1 * Float64((Float64(d / h) ^ 0.5) * Float64(1.0 / Float64(sqrt(l) / sqrt(d))))); else tmp = Float64(Float64(Float64(sqrt(d) / sqrt(h)) * (Float64(d / l) ^ 0.5)) * Float64(1.0 - Float64(t_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 = 0.5 * (((M * D) / (d * 2.0)) ^ 2.0); t_1 = 1.0 - ((h * t_0) / l); tmp = 0.0; if (l <= -3.170040707759249e-296) tmp = ((sqrt(-d) / sqrt(-h)) * (1.0 / sqrt((l / d)))) * t_1; elseif (l <= 1.9115375279058692e+23) tmp = t_1 * (((d / h) ^ 0.5) * (1.0 / (sqrt(l) / sqrt(d)))); else tmp = ((sqrt(d) / sqrt(h)) * ((d / l) ^ 0.5)) * (1.0 - (t_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[(0.5 * N[Power[N[(N[(M * D), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(N[(h * t$95$0), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -3.170040707759249e-296], N[(N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[Sqrt[N[(l / d), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[l, 1.9115375279058692e+23], N[(t$95$1 * N[(N[Power[N[(d / h), $MachinePrecision], 0.5], $MachinePrecision] * N[(1.0 / N[(N[Sqrt[l], $MachinePrecision] / N[Sqrt[d], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(t$95$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 := 0.5 \cdot {\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2}\\
t_1 := 1 - \frac{h \cdot t_0}{\ell}\\
\mathbf{if}\;\ell \leq -3.170040707759249 \cdot 10^{-296}:\\
\;\;\;\;\left(\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \frac{1}{\sqrt{\frac{\ell}{d}}}\right) \cdot t_1\\
\mathbf{elif}\;\ell \leq 1.9115375279058692 \cdot 10^{+23}:\\
\;\;\;\;t_1 \cdot \left({\left(\frac{d}{h}\right)}^{0.5} \cdot \frac{1}{\frac{\sqrt{\ell}}{\sqrt{d}}}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\sqrt{d}}{\sqrt{h}} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - t_0 \cdot \frac{h}{\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 l < -3.170040707759249e-296Initial program 26.9
Applied egg-rr27.0
Applied egg-rr26.6
Applied egg-rr20.1
if -3.170040707759249e-296 < l < 1.9115375279058692e23Initial program 27.1
Applied egg-rr26.6
Applied egg-rr22.0
Applied egg-rr14.9
if 1.9115375279058692e23 < l Initial program 26.7
Applied egg-rr18.7
Final simplification18.6
herbie shell --seed 2022138
(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)))))