\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 2.859175354539147 \cdot 10^{-206} \lor \neg \left(M \cdot M \leq 1.7772243551819437 \cdot 10^{+277}\right):\\
\;\;\;\;\log \left({1}^{\left(\frac{1}{c0 \cdot \left(d \cdot d\right)}\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;0.25 \cdot \frac{\left(M \cdot M\right) \cdot \left(\left(D \cdot D\right) \cdot h\right)}{d \cdot d}\\
\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 (or (<= (* M M) 2.859175354539147e-206)
(not (<= (* M M) 1.7772243551819437e+277)))
(log (pow 1.0 (/ 1.0 (* c0 (* d d)))))
(* 0.25 (/ (* (* M M) (* (* D D) h)) (* 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) <= 2.859175354539147e-206) || !((M * M) <= 1.7772243551819437e+277)) {
tmp = log(pow(1.0, (1.0 / (c0 * (d * d)))));
} else {
tmp = 0.25 * (((M * M) * ((D * D) * h)) / (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) < 2.85917535453914678e-206 or 1.7772243551819437e277 < (*.f64 M M) Initial program 58.7
Taylor expanded around -inf 43.7
Simplified44.7
rmApplied add-log-exp_binary6445.0
Simplified35.3
rmApplied div-inv_binary6435.4
Applied pow-unpow_binary6430.6
Simplified30.6
Taylor expanded around 0 29.9
if 2.85917535453914678e-206 < (*.f64 M M) < 1.7772243551819437e277Initial program 61.5
Taylor expanded around -inf 37.6
Simplified38.0
Taylor expanded around 0 30.3
Simplified30.3
Final simplification30.1
herbie shell --seed 2021176
(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))))))