Average Error: 59.8 → 27.2
Time: 25.1s
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}\;D \cdot D \leq 7.67481086807114 \cdot 10^{+34}:\\ \;\;\;\;0.25 \cdot \frac{\left(\left(D \cdot D\right) \cdot h\right) \cdot \left(\frac{M}{d} \cdot \frac{M}{\sqrt[3]{d} \cdot \sqrt[3]{d}}\right)}{\sqrt[3]{d}}\\ \mathbf{elif}\;D \cdot D \leq 1.6417217542531383 \cdot 10^{+193}:\\ \;\;\;\;0.25 \cdot \frac{h \cdot \left(\left(D \cdot D\right) \cdot \frac{M \cdot M}{d}\right)}{d}\\ \mathbf{else}:\\ \;\;\;\;0.25 \cdot \frac{\frac{M \cdot M}{d} \cdot \left(D \cdot \left(D \cdot h\right)\right)}{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 7.67481086807114 \cdot 10^{+34}:\\
\;\;\;\;0.25 \cdot \frac{\left(\left(D \cdot D\right) \cdot h\right) \cdot \left(\frac{M}{d} \cdot \frac{M}{\sqrt[3]{d} \cdot \sqrt[3]{d}}\right)}{\sqrt[3]{d}}\\

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

\mathbf{else}:\\
\;\;\;\;0.25 \cdot \frac{\frac{M \cdot M}{d} \cdot \left(D \cdot \left(D \cdot h\right)\right)}{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) 7.67481086807114e+34)
   (*
    0.25
    (/ (* (* (* D D) h) (* (/ M d) (/ M (* (cbrt d) (cbrt d))))) (cbrt d)))
   (if (<= (* D D) 1.6417217542531383e+193)
     (* 0.25 (/ (* h (* (* D D) (/ (* M M) d))) d))
     (* 0.25 (/ (* (/ (* M M) d) (* D (* D h))) 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) <= 7.67481086807114e+34) {
		tmp = 0.25 * ((((D * D) * h) * ((M / d) * (M / (cbrt(d) * cbrt(d))))) / cbrt(d));
	} else if ((D * D) <= 1.6417217542531383e+193) {
		tmp = 0.25 * ((h * ((D * D) * ((M * M) / d))) / d);
	} else {
		tmp = 0.25 * ((((M * M) / d) * (D * (D * h))) / 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 D D) < 7.6748108680711399e34

    1. Initial program 60.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 38.1

      \[\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.4

      \[\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 31.9

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

      \[\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 associate-/r*_binary64_104528.6

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

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

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

      \[\leadsto 0.25 \cdot \color{blue}{\frac{\frac{\frac{M \cdot M}{d} \cdot \left(\left(D \cdot D\right) \cdot h\right)}{\sqrt[3]{d} \cdot \sqrt[3]{d}}}{\sqrt[3]{d}}}\]
    12. Simplified23.9

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

    if 7.6748108680711399e34 < (*.f64 D D) < 1.6417217542531383e193

    1. Initial program 54.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 41.1

      \[\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. Simplified43.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 33.6

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

      \[\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 associate-/r*_binary64_104531.0

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

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

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

    if 1.6417217542531383e193 < (*.f64 D D)

    1. Initial program 61.0

      \[\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 55.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. Simplified57.0

      \[\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 53.9

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

      \[\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 associate-/r*_binary64_104553.2

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;D \cdot D \leq 7.67481086807114 \cdot 10^{+34}:\\ \;\;\;\;0.25 \cdot \frac{\left(\left(D \cdot D\right) \cdot h\right) \cdot \left(\frac{M}{d} \cdot \frac{M}{\sqrt[3]{d} \cdot \sqrt[3]{d}}\right)}{\sqrt[3]{d}}\\ \mathbf{elif}\;D \cdot D \leq 1.6417217542531383 \cdot 10^{+193}:\\ \;\;\;\;0.25 \cdot \frac{h \cdot \left(\left(D \cdot D\right) \cdot \frac{M \cdot M}{d}\right)}{d}\\ \mathbf{else}:\\ \;\;\;\;0.25 \cdot \frac{\frac{M \cdot M}{d} \cdot \left(D \cdot \left(D \cdot h\right)\right)}{d}\\ \end{array}\]

Reproduce

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