\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}
t_0 := \frac{c0 \cdot d}{D \cdot \left(w \cdot h\right)}\\
t_1 := \frac{c0}{2 \cdot w}\\
\mathbf{if}\;M \leq -1.1426100242627277 \cdot 10^{-140}:\\
\;\;\;\;t_1 \cdot \left(2 \cdot \left(\frac{d}{D} \cdot t_0\right)\right)\\
\mathbf{elif}\;M \leq -9.618862001490325 \cdot 10^{-152}:\\
\;\;\;\;t_1 \cdot \left(0.5 \cdot \frac{{D}^{2} \cdot \left(w \cdot \left(h \cdot {M}^{2}\right)\right)}{c0 \cdot {d}^{2}}\right)\\
\mathbf{elif}\;M \leq -1.917101077054597 \cdot 10^{-308} \lor \neg \left(M \leq 5.887206475242185 \cdot 10^{-287}\right):\\
\;\;\;\;t_1 \cdot \left(2 \cdot \frac{d}{\frac{D}{t_0}}\right)\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \sqrt{-{M}^{2}}\\
\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
(let* ((t_0 (/ (* c0 d) (* D (* w h)))) (t_1 (/ c0 (* 2.0 w))))
(if (<= M -1.1426100242627277e-140)
(* t_1 (* 2.0 (* (/ d D) t_0)))
(if (<= M -9.618862001490325e-152)
(*
t_1
(* 0.5 (/ (* (pow D 2.0) (* w (* h (pow M 2.0)))) (* c0 (pow d 2.0)))))
(if (or (<= M -1.917101077054597e-308)
(not (<= M 5.887206475242185e-287)))
(* t_1 (* 2.0 (/ d (/ D t_0))))
(* t_1 (sqrt (- (pow M 2.0)))))))))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 t_0 = (c0 * d) / (D * (w * h));
double t_1 = c0 / (2.0 * w);
double tmp;
if (M <= -1.1426100242627277e-140) {
tmp = t_1 * (2.0 * ((d / D) * t_0));
} else if (M <= -9.618862001490325e-152) {
tmp = t_1 * (0.5 * ((pow(D, 2.0) * (w * (h * pow(M, 2.0)))) / (c0 * pow(d, 2.0))));
} else if ((M <= -1.917101077054597e-308) || !(M <= 5.887206475242185e-287)) {
tmp = t_1 * (2.0 * (d / (D / t_0)));
} else {
tmp = t_1 * sqrt(-pow(M, 2.0));
}
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 M < -1.14261002426272765e-140Initial program 50.7
Taylor expanded in c0 around inf 43.0
Applied unpow2_binary6443.0
Applied associate-*l*_binary6440.9
Applied unpow2_binary6440.9
Applied associate-*l*_binary6438.3
Applied times-frac_binary6435.4
if -1.14261002426272765e-140 < M < -9.61886200149032494e-152Initial program 46.5
Taylor expanded in c0 around -inf 39.0
if -9.61886200149032494e-152 < M < -1.9171010770545972e-308 or 5.8872064752421847e-287 < M Initial program 47.9
Taylor expanded in c0 around inf 43.9
Applied unpow2_binary6443.9
Applied associate-*l*_binary6441.5
Applied unpow2_binary6441.5
Applied associate-*l*_binary6439.0
Applied associate-/l*_binary6436.5
Simplified34.6
if -1.9171010770545972e-308 < M < 5.8872064752421847e-287Initial program 41.8
Taylor expanded in c0 around 0 34.9
Final simplification34.9
herbie shell --seed 2022088
(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))))))