(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 h) 0.5) (pow (/ d l) 0.5))
(- 1.0 (* (* 0.5 (pow (/ (* M D) (* d 2.0)) 2.0)) (/ h l)))))
(t_1 (sqrt (/ h l)))
(t_2 (/ (sqrt (/ d l)) (sqrt (/ h d))))
(t_3 (sqrt (/ (pow h -1.0) l))))
(if (<= t_0 -7.283059180255588e-249)
(* t_2 (- 1.0 (* 0.5 (pow (* (* (* 0.5 M) (/ D d)) t_1) 2.0))))
(if (<= t_0 0.0)
(fma
d
t_3
(* -0.125 (/ (sqrt (/ h (pow l 3.0))) (/ (/ d M) (* D (* M D))))))
(if (<= t_0 7.116611040597342e+245)
(* t_2 (- 1.0 (* 0.5 (pow (* 0.5 (* t_1 (/ (* M D) d))) 2.0))))
(* d t_3))))))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 / h), 0.5) * pow((d / l), 0.5)) * (1.0 - ((0.5 * pow(((M * D) / (d * 2.0)), 2.0)) * (h / l)));
double t_1 = sqrt((h / l));
double t_2 = sqrt((d / l)) / sqrt((h / d));
double t_3 = sqrt((pow(h, -1.0) / l));
double tmp;
if (t_0 <= -7.283059180255588e-249) {
tmp = t_2 * (1.0 - (0.5 * pow((((0.5 * M) * (D / d)) * t_1), 2.0)));
} else if (t_0 <= 0.0) {
tmp = fma(d, t_3, (-0.125 * (sqrt((h / pow(l, 3.0))) / ((d / M) / (D * (M * D))))));
} else if (t_0 <= 7.116611040597342e+245) {
tmp = t_2 * (1.0 - (0.5 * pow((0.5 * (t_1 * ((M * D) / d))), 2.0)));
} else {
tmp = d * t_3;
}
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(Float64((Float64(d / h) ^ 0.5) * (Float64(d / l) ^ 0.5)) * Float64(1.0 - Float64(Float64(0.5 * (Float64(Float64(M * D) / Float64(d * 2.0)) ^ 2.0)) * Float64(h / l)))) t_1 = sqrt(Float64(h / l)) t_2 = Float64(sqrt(Float64(d / l)) / sqrt(Float64(h / d))) t_3 = sqrt(Float64((h ^ -1.0) / l)) tmp = 0.0 if (t_0 <= -7.283059180255588e-249) tmp = Float64(t_2 * Float64(1.0 - Float64(0.5 * (Float64(Float64(Float64(0.5 * M) * Float64(D / d)) * t_1) ^ 2.0)))); elseif (t_0 <= 0.0) tmp = fma(d, t_3, Float64(-0.125 * Float64(sqrt(Float64(h / (l ^ 3.0))) / Float64(Float64(d / M) / Float64(D * Float64(M * D)))))); elseif (t_0 <= 7.116611040597342e+245) tmp = Float64(t_2 * Float64(1.0 - Float64(0.5 * (Float64(0.5 * Float64(t_1 * Float64(Float64(M * D) / d))) ^ 2.0)))); else tmp = Float64(d * t_3); end return 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[(N[(N[Power[N[(d / h), $MachinePrecision], 0.5], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision] * 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]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(h / d), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(N[Power[h, -1.0], $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, -7.283059180255588e-249], N[(t$95$2 * N[(1.0 - N[(0.5 * N[Power[N[(N[(N[(0.5 * M), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.0], N[(d * t$95$3 + N[(-0.125 * N[(N[Sqrt[N[(h / N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(N[(d / M), $MachinePrecision] / N[(D * N[(M * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 7.116611040597342e+245], N[(t$95$2 * N[(1.0 - N[(0.5 * N[Power[N[(0.5 * N[(t$95$1 * N[(N[(M * D), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * t$95$3), $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({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - \left(0.5 \cdot {\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \sqrt{\frac{h}{\ell}}\\
t_2 := \frac{\sqrt{\frac{d}{\ell}}}{\sqrt{\frac{h}{d}}}\\
t_3 := \sqrt{\frac{{h}^{-1}}{\ell}}\\
\mathbf{if}\;t_0 \leq -7.283059180255588 \cdot 10^{-249}:\\
\;\;\;\;t_2 \cdot \left(1 - 0.5 \cdot {\left(\left(\left(0.5 \cdot M\right) \cdot \frac{D}{d}\right) \cdot t_1\right)}^{2}\right)\\
\mathbf{elif}\;t_0 \leq 0:\\
\;\;\;\;\mathsf{fma}\left(d, t_3, -0.125 \cdot \frac{\sqrt{\frac{h}{{\ell}^{3}}}}{\frac{\frac{d}{M}}{D \cdot \left(M \cdot D\right)}}\right)\\
\mathbf{elif}\;t_0 \leq 7.116611040597342 \cdot 10^{+245}:\\
\;\;\;\;t_2 \cdot \left(1 - 0.5 \cdot {\left(0.5 \cdot \left(t_1 \cdot \frac{M \cdot D}{d}\right)\right)}^{2}\right)\\
\mathbf{else}:\\
\;\;\;\;d \cdot t_3\\
\end{array}



Bits error versus d



Bits error versus h



Bits error versus l



Bits error versus M



Bits error versus D
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)))) < -7.28305918025558773e-249Initial program 28.0
Applied egg-rr28.3
Applied egg-rr29.0
Applied egg-rr29.1
Applied egg-rr21.9
if -7.28305918025558773e-249 < (*.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 40.7
Taylor expanded in d around 0 29.8
Simplified28.1
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)))) < 7.11661104059734197e245Initial program 1.0
Applied egg-rr1.1
Applied egg-rr1.4
Applied egg-rr1.4
Taylor expanded in M around 0 1.0
if 7.11661104059734197e245 < (*.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 61.6
Taylor expanded in d around inf 43.7
Simplified43.7
Final simplification19.3
herbie shell --seed 2022159
(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)))))