Average Error: 59.6 → 27.2
Time: 16.9s
Precision: binary64
Cost: 1409
\[\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}\;D \cdot D \leq 9.05100518124077 \cdot 10^{+73}:\\ \;\;\;\;\left(\frac{M \cdot \left(\left(D \cdot D\right) \cdot h\right)}{d} \cdot \frac{M}{d}\right) \cdot 0.25\\ \mathbf{else}:\\ \;\;\;\;0.25 \cdot \frac{M \cdot \left(M \cdot \left(D \cdot \left(D \cdot h\right)\right)\right)}{d \cdot d}\\ \end{array}\]
\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}\;D \cdot D \leq 9.05100518124077 \cdot 10^{+73}:\\
\;\;\;\;\left(\frac{M \cdot \left(\left(D \cdot D\right) \cdot h\right)}{d} \cdot \frac{M}{d}\right) \cdot 0.25\\

\mathbf{else}:\\
\;\;\;\;0.25 \cdot \frac{M \cdot \left(M \cdot \left(D \cdot \left(D \cdot h\right)\right)\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 (<= (* D D) 9.05100518124077e+73)
   (* (* (/ (* M (* (* D D) h)) d) (/ M d)) 0.25)
   (* 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 ((D * D) <= 9.05100518124077e+73) {
		tmp = (((M * ((D * D) * h)) / d) * (M / d)) * 0.25;
	} else {
		tmp = 0.25 * ((M * (M * (D * (D * h)))) / (d * d));
	}
	return tmp;
}

Error

Bits error versus c0

Bits error versus w

Bits error versus h

Bits error versus D

Bits error versus d

Bits error versus M

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if (*.f64 D D) < 9.05100518124077008e73

    1. Initial program 59.9

      \[\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)\]
    2. Taylor expanded around -inf 37.6

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(0.5 \cdot \frac{w \cdot \left({M}^{2} \cdot \left({D}^{2} \cdot h\right)\right)}{c0 \cdot {d}^{2}}\right)}\]
    3. Simplified37.6

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(0.5 \cdot \frac{w \cdot \left(\left(M \cdot M\right) \cdot \left(h \cdot \left(D \cdot D\right)\right)\right)}{c0 \cdot \left(d \cdot d\right)}\right)}\]
    4. Taylor expanded around 0 31.0

      \[\leadsto \color{blue}{0.25 \cdot \frac{{M}^{2} \cdot \left({D}^{2} \cdot h\right)}{{d}^{2}}}\]
    5. Simplified31.0

      \[\leadsto \color{blue}{\frac{\left(h \cdot \left(D \cdot D\right)\right) \cdot \left(M \cdot M\right)}{d \cdot d} \cdot 0.25}\]
    6. Using strategy rm
    7. Applied associate-*r*_binary64_101027.4

      \[\leadsto \frac{\color{blue}{\left(\left(h \cdot \left(D \cdot D\right)\right) \cdot M\right) \cdot M}}{d \cdot d} \cdot 0.25\]
    8. Simplified27.4

      \[\leadsto \frac{\color{blue}{\left(M \cdot \left(h \cdot \left(D \cdot D\right)\right)\right)} \cdot M}{d \cdot d} \cdot 0.25\]
    9. Using strategy rm
    10. Applied times-frac_binary64_107622.4

      \[\leadsto \color{blue}{\left(\frac{M \cdot \left(h \cdot \left(D \cdot D\right)\right)}{d} \cdot \frac{M}{d}\right)} \cdot 0.25\]

    if 9.05100518124077008e73 < (*.f64 D D)

    1. Initial program 58.6

      \[\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)\]
    2. Taylor expanded around -inf 52.0

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(0.5 \cdot \frac{w \cdot \left({M}^{2} \cdot \left({D}^{2} \cdot h\right)\right)}{c0 \cdot {d}^{2}}\right)}\]
    3. Simplified52.0

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(0.5 \cdot \frac{w \cdot \left(\left(M \cdot M\right) \cdot \left(h \cdot \left(D \cdot D\right)\right)\right)}{c0 \cdot \left(d \cdot d\right)}\right)}\]
    4. Taylor expanded around 0 48.4

      \[\leadsto \color{blue}{0.25 \cdot \frac{{M}^{2} \cdot \left({D}^{2} \cdot h\right)}{{d}^{2}}}\]
    5. Simplified48.4

      \[\leadsto \color{blue}{\frac{\left(h \cdot \left(D \cdot D\right)\right) \cdot \left(M \cdot M\right)}{d \cdot d} \cdot 0.25}\]
    6. Using strategy rm
    7. Applied associate-*r*_binary64_101047.6

      \[\leadsto \frac{\color{blue}{\left(\left(h \cdot \left(D \cdot D\right)\right) \cdot M\right) \cdot M}}{d \cdot d} \cdot 0.25\]
    8. Simplified47.6

      \[\leadsto \frac{\color{blue}{\left(M \cdot \left(h \cdot \left(D \cdot D\right)\right)\right)} \cdot M}{d \cdot d} \cdot 0.25\]
    9. Using strategy rm
    10. Applied associate-*r*_binary64_101041.5

      \[\leadsto \frac{\left(M \cdot \color{blue}{\left(\left(h \cdot D\right) \cdot D\right)}\right) \cdot M}{d \cdot d} \cdot 0.25\]
  3. Recombined 2 regimes into one program.
  4. Final simplification27.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;D \cdot D \leq 9.05100518124077 \cdot 10^{+73}:\\ \;\;\;\;\left(\frac{M \cdot \left(\left(D \cdot D\right) \cdot h\right)}{d} \cdot \frac{M}{d}\right) \cdot 0.25\\ \mathbf{else}:\\ \;\;\;\;0.25 \cdot \frac{M \cdot \left(M \cdot \left(D \cdot \left(D \cdot h\right)\right)\right)}{d \cdot d}\\ \end{array}\]

Reproduce

herbie shell --seed 2021042 
(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))))))