Average Error: 59.7 → 28.6
Time: 17.0s
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 \leq -1.3535396070238666 \cdot 10^{+154}:\\ \;\;\;\;0.25 \cdot \frac{\left(M \cdot M\right) \cdot \frac{D \cdot \left(D \cdot h\right)}{d}}{d}\\ \mathbf{elif}\;D \leq 3.601076346426854 \cdot 10^{-175}:\\ \;\;\;\;0.25 \cdot \frac{M \cdot \left(M \cdot \frac{h \cdot \left(D \cdot D\right)}{d}\right)}{d}\\ \mathbf{elif}\;D \leq 2.921876147211044 \cdot 10^{-162}:\\ \;\;\;\;0.25 \cdot \frac{\left(M \cdot M\right) \cdot \frac{D \cdot \left(D \cdot h\right)}{d}}{d}\\ \mathbf{elif}\;D \leq 3.8477647255578 \cdot 10^{-32}:\\ \;\;\;\;0.25 \cdot \frac{\left(\left(M \cdot M\right) \cdot \left(D \cdot D\right)\right) \cdot \frac{h}{d}}{d}\\ \mathbf{else}:\\ \;\;\;\;0.25 \cdot \left(\frac{h \cdot \left(D \cdot D\right)}{d} \cdot \frac{M \cdot M}{d}\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}\;D \leq -1.3535396070238666 \cdot 10^{+154}:\\
\;\;\;\;0.25 \cdot \frac{\left(M \cdot M\right) \cdot \frac{D \cdot \left(D \cdot h\right)}{d}}{d}\\

\mathbf{elif}\;D \leq 3.601076346426854 \cdot 10^{-175}:\\
\;\;\;\;0.25 \cdot \frac{M \cdot \left(M \cdot \frac{h \cdot \left(D \cdot D\right)}{d}\right)}{d}\\

\mathbf{elif}\;D \leq 2.921876147211044 \cdot 10^{-162}:\\
\;\;\;\;0.25 \cdot \frac{\left(M \cdot M\right) \cdot \frac{D \cdot \left(D \cdot h\right)}{d}}{d}\\

\mathbf{elif}\;D \leq 3.8477647255578 \cdot 10^{-32}:\\
\;\;\;\;0.25 \cdot \frac{\left(\left(M \cdot M\right) \cdot \left(D \cdot D\right)\right) \cdot \frac{h}{d}}{d}\\

\mathbf{else}:\\
\;\;\;\;0.25 \cdot \left(\frac{h \cdot \left(D \cdot D\right)}{d} \cdot \frac{M \cdot M}{d}\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 (<= D -1.3535396070238666e+154)
   (* 0.25 (/ (* (* M M) (/ (* D (* D h)) d)) d))
   (if (<= D 3.601076346426854e-175)
     (* 0.25 (/ (* M (* M (/ (* h (* D D)) d))) d))
     (if (<= D 2.921876147211044e-162)
       (* 0.25 (/ (* (* M M) (/ (* D (* D h)) d)) d))
       (if (<= D 3.8477647255578e-32)
         (* 0.25 (/ (* (* (* M M) (* D D)) (/ h d)) d))
         (* 0.25 (* (/ (* h (* D D)) d) (/ (* M M) 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 <= -1.3535396070238666e+154) {
		tmp = 0.25 * (((M * M) * ((D * (D * h)) / d)) / d);
	} else if (D <= 3.601076346426854e-175) {
		tmp = 0.25 * ((M * (M * ((h * (D * D)) / d))) / d);
	} else if (D <= 2.921876147211044e-162) {
		tmp = 0.25 * (((M * M) * ((D * (D * h)) / d)) / d);
	} else if (D <= 3.8477647255578e-32) {
		tmp = 0.25 * ((((M * M) * (D * D)) * (h / d)) / d);
	} else {
		tmp = 0.25 * (((h * (D * D)) / d) * ((M * M) / 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 4 regimes
  2. if D < -1.3535396070238666e154 or 3.6010763464268542e-175 < D < 2.92187614721104395e-162

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

      \[\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. Simplified58.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 57.4

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

      \[\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*_binary6457.1

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

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

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

    if -1.3535396070238666e154 < D < 3.6010763464268542e-175

    1. Initial program 60.5

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

      \[\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. Simplified39.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 31.8

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

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

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

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

    if 2.92187614721104395e-162 < D < 3.84776472555779985e-32

    1. Initial program 57.2

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

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

      \[\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*_binary6428.1

      \[\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. Simplified27.8

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

      \[\leadsto 0.25 \cdot \frac{\left(M \cdot M\right) \cdot \frac{\left(D \cdot D\right) \cdot h}{\color{blue}{1 \cdot d}}}{d}\]
    11. Applied times-frac_binary6427.6

      \[\leadsto 0.25 \cdot \frac{\left(M \cdot M\right) \cdot \color{blue}{\left(\frac{D \cdot D}{1} \cdot \frac{h}{d}\right)}}{d}\]
    12. Applied associate-*r*_binary6427.2

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

    if 3.84776472555779985e-32 < D

    1. Initial program 57.8

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

      \[\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. Simplified49.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 42.3

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;D \leq -1.3535396070238666 \cdot 10^{+154}:\\ \;\;\;\;0.25 \cdot \frac{\left(M \cdot M\right) \cdot \frac{D \cdot \left(D \cdot h\right)}{d}}{d}\\ \mathbf{elif}\;D \leq 3.601076346426854 \cdot 10^{-175}:\\ \;\;\;\;0.25 \cdot \frac{M \cdot \left(M \cdot \frac{h \cdot \left(D \cdot D\right)}{d}\right)}{d}\\ \mathbf{elif}\;D \leq 2.921876147211044 \cdot 10^{-162}:\\ \;\;\;\;0.25 \cdot \frac{\left(M \cdot M\right) \cdot \frac{D \cdot \left(D \cdot h\right)}{d}}{d}\\ \mathbf{elif}\;D \leq 3.8477647255578 \cdot 10^{-32}:\\ \;\;\;\;0.25 \cdot \frac{\left(\left(M \cdot M\right) \cdot \left(D \cdot D\right)\right) \cdot \frac{h}{d}}{d}\\ \mathbf{else}:\\ \;\;\;\;0.25 \cdot \left(\frac{h \cdot \left(D \cdot D\right)}{d} \cdot \frac{M \cdot M}{d}\right)\\ \end{array}\]

Alternatives

Reproduce

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