Average Error: 59.7 → 25.8
Time: 50.3s
Precision: binary64
\[\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.5822644280914283 \cdot 10^{-267}:\\ \;\;\;\;0\\ \mathbf{elif}\;M \cdot M \leq 2.6485169208209805 \cdot 10^{+298}:\\ \;\;\;\;0.25 \cdot \left(\frac{M \cdot M}{d} \cdot \frac{D \cdot \left(D \cdot h\right)}{d}\right)\\ \mathbf{else}:\\ \;\;\;\;0.25 \cdot \left(\frac{M}{\sqrt[3]{d} \cdot \sqrt[3]{d}} \cdot \left(\frac{M}{\sqrt[3]{d}} \cdot \frac{h \cdot \left(D \cdot D\right)}{d}\right)\right)\\ \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}\;M \cdot M \leq 2.5822644280914283 \cdot 10^{-267}:\\
\;\;\;\;0\\

\mathbf{elif}\;M \cdot M \leq 2.6485169208209805 \cdot 10^{+298}:\\
\;\;\;\;0.25 \cdot \left(\frac{M \cdot M}{d} \cdot \frac{D \cdot \left(D \cdot h\right)}{d}\right)\\

\mathbf{else}:\\
\;\;\;\;0.25 \cdot \left(\frac{M}{\sqrt[3]{d} \cdot \sqrt[3]{d}} \cdot \left(\frac{M}{\sqrt[3]{d}} \cdot \frac{h \cdot \left(D \cdot D\right)}{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) 2.5822644280914283e-267)
   0.0
   (if (<= (* M M) 2.6485169208209805e+298)
     (* 0.25 (* (/ (* M M) d) (/ (* D (* D h)) d)))
     (*
      0.25
      (*
       (/ M (* (cbrt d) (cbrt d)))
       (* (/ M (cbrt d)) (/ (* h (* D 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.5822644280914283e-267) {
		tmp = 0.0;
	} else if ((M * M) <= 2.6485169208209805e+298) {
		tmp = 0.25 * (((M * M) / d) * ((D * (D * h)) / d));
	} else {
		tmp = 0.25 * ((M / (cbrt(d) * cbrt(d))) * ((M / cbrt(d)) * ((h * (D * 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 3 regimes
  2. if (*.f64 M M) < 2.58226442809142829e-267

    1. Initial program 23.6

      \[0\]

    if 2.58226442809142829e-267 < (*.f64 M M) < 2.64851692082098045e298

    1. Initial program 61.4

      \[\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. Simplified38.2

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

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

      \[\leadsto \color{blue}{0.25 \cdot \frac{\left(M \cdot M\right) \cdot \left(\left(D \cdot D\right) \cdot h\right)}{d \cdot d}}\]
    6. Using strategy rm
    7. Applied times-frac_binary64_110727.2

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

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

    if 2.64851692082098045e298 < (*.f64 M M)

    1. Initial program 63.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 63.3

      \[\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. Simplified63.3

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

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

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

      \[\leadsto 0.25 \cdot \color{blue}{\left(\frac{M \cdot M}{d} \cdot \frac{\left(D \cdot D\right) \cdot h}{d}\right)}\]
    8. Using strategy rm
    9. Applied add-cube-cbrt_binary64_113662.7

      \[\leadsto 0.25 \cdot \left(\frac{M \cdot M}{\color{blue}{\left(\sqrt[3]{d} \cdot \sqrt[3]{d}\right) \cdot \sqrt[3]{d}}} \cdot \frac{\left(D \cdot D\right) \cdot h}{d}\right)\]
    10. Applied times-frac_binary64_110745.4

      \[\leadsto 0.25 \cdot \left(\color{blue}{\left(\frac{M}{\sqrt[3]{d} \cdot \sqrt[3]{d}} \cdot \frac{M}{\sqrt[3]{d}}\right)} \cdot \frac{\left(D \cdot D\right) \cdot h}{d}\right)\]
    11. Applied associate-*l*_binary64_104237.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \cdot M \leq 2.5822644280914283 \cdot 10^{-267}:\\ \;\;\;\;0\\ \mathbf{elif}\;M \cdot M \leq 2.6485169208209805 \cdot 10^{+298}:\\ \;\;\;\;0.25 \cdot \left(\frac{M \cdot M}{d} \cdot \frac{D \cdot \left(D \cdot h\right)}{d}\right)\\ \mathbf{else}:\\ \;\;\;\;0.25 \cdot \left(\frac{M}{\sqrt[3]{d} \cdot \sqrt[3]{d}} \cdot \left(\frac{M}{\sqrt[3]{d}} \cdot \frac{h \cdot \left(D \cdot D\right)}{d}\right)\right)\\ \end{array}\]

Reproduce

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