\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 5.901458979163336 \cdot 10^{+291}:\\
\;\;\;\;0.25 \cdot \left(\frac{D}{d} \cdot \left(\frac{D}{d} \cdot \left(\left(M \cdot M\right) \cdot h\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0.25 \cdot \frac{D \cdot \left(D \cdot \left(M \cdot \left(M \cdot h\right)\right)\right)}{{d}^{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 (if (<= (* M M) 5.901458979163336e+291) (* 0.25 (* (/ D d) (* (/ D d) (* (* M M) h)))) (* 0.25 (/ (* D (* D (* M (* M h)))) (pow d 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 tmp;
if ((M * M) <= 5.901458979163336e+291) {
tmp = 0.25 * ((D / d) * ((D / d) * ((M * M) * h)));
} else {
tmp = 0.25 * ((D * (D * (M * (M * h)))) / pow(d, 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 (*.f64 M M) < 5.9014589791633357e291Initial program 58.8
Taylor expanded in c0 around -inf 38.4
Taylor expanded in c0 around 0 31.1
Applied unpow2_binary6431.1
Applied associate-*l*_binary6427.9
Applied add-sqr-sqrt_binary6446.0
Applied unpow-prod-down_binary6446.0
Applied times-frac_binary6443.4
Simplified43.3
Simplified21.3
if 5.9014589791633357e291 < (*.f64 M M) Initial program 64.0
Taylor expanded in c0 around -inf 63.1
Taylor expanded in c0 around 0 62.8
Applied unpow2_binary6462.8
Applied associate-*l*_binary6462.7
Applied unpow2_binary6462.7
Applied associate-*l*_binary6449.6
Simplified49.6
Final simplification25.5
herbie shell --seed 2021280
(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))))))