\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right)\begin{array}{l}
\mathbf{if}\;M \cdot M \leq 9.229951502073919 \cdot 10^{-113}:\\
\;\;\;\;\log 1\\
\mathbf{elif}\;M \cdot M \leq 5.490890537452743 \cdot 10^{+271}:\\
\;\;\;\;0.25 \cdot \frac{{M}^{2} \cdot \left({D}^{2} \cdot h\right)}{{d}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(0.5 \cdot \frac{M \cdot \left(M \cdot \left(w \cdot \left(h \cdot \left(D \cdot D\right)\right)\right)\right)}{c0 \cdot \left(d \cdot d\right)}\right)\\
\end{array}(FPCore (c0 w h D d M)
:precision binary64
(*
(/ c0 (* 2.0 w))
(+
(/ (* c0 (* d d)) (* (* w h) (* D D)))
(sqrt
(-
(*
(/ (* c0 (* d d)) (* (* w h) (* D D)))
(/ (* c0 (* d d)) (* (* w h) (* D D))))
(* M M))))))(FPCore (c0 w h D d M)
:precision binary64
(if (<= (* M M) 9.229951502073919e-113)
(log 1.0)
(if (<= (* M M) 5.490890537452743e+271)
(* 0.25 (/ (* (pow M 2.0) (* (pow D 2.0) h)) (pow d 2.0)))
(*
(/ c0 (* 2.0 w))
(* 0.5 (/ (* M (* M (* w (* h (* D D))))) (* c0 (* d d))))))))double code(double c0, double w, double h, double D, double d, double M) {
return (c0 / (2.0 * w)) * (((c0 * (d * d)) / ((w * h) * (D * D))) + sqrt((((c0 * (d * d)) / ((w * h) * (D * D))) * ((c0 * (d * d)) / ((w * h) * (D * D)))) - (M * M)));
}
double code(double c0, double w, double h, double D, double d, double M) {
double tmp;
if ((M * M) <= 9.229951502073919e-113) {
tmp = log(1.0);
} else if ((M * M) <= 5.490890537452743e+271) {
tmp = 0.25 * ((pow(M, 2.0) * (pow(D, 2.0) * h)) / pow(d, 2.0));
} else {
tmp = (c0 / (2.0 * w)) * (0.5 * ((M * (M * (w * (h * (D * D))))) / (c0 * (d * d))));
}
return tmp;
}



Bits error versus c0



Bits error versus w



Bits error versus h



Bits error versus D



Bits error versus d



Bits error versus M
Results
if (*.f64 M M) < 9.2299515020739188e-113Initial program 56.5
Taylor expanded around -inf 36.7
Simplified37.6
rmApplied add-log-exp_binary64_114038.0
Simplified28.8
Taylor expanded around inf 24.5
if 9.2299515020739188e-113 < (*.f64 M M) < 5.4908905374527431e271Initial program 62.2
Taylor expanded around -inf 39.5
Simplified39.9
Taylor expanded around 0 32.1
if 5.4908905374527431e271 < (*.f64 M M) Initial program 63.9
Taylor expanded around -inf 60.9
Simplified61.0
rmApplied associate-*l*_binary64_104248.8
Final simplification30.7
herbie shell --seed 2021025
(FPCore (c0 w h D d M)
:name "Henrywood and Agarwal, Equation (13)"
:precision binary64
(* (/ c0 (* 2.0 w)) (+ (/ (* c0 (* d d)) (* (* w h) (* D D))) (sqrt (- (* (/ (* c0 (* d d)) (* (* w h) (* D D))) (/ (* c0 (* d d)) (* (* w h) (* D D)))) (* M M))))))