Average Error: 59.7 → 27.6
Time: 28.9s
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 \leq -4.837877690709628 \cdot 10^{+111}:\\ \;\;\;\;0.25 \cdot \frac{M \cdot \left(M \cdot \frac{\left(D \cdot D\right) \cdot h}{d}\right)}{d}\\ \mathbf{elif}\;M \leq -7.670814269380083 \cdot 10^{-225}:\\ \;\;\;\;0.25 \cdot \frac{\left(M \cdot M\right) \cdot \frac{D \cdot \left(D \cdot h\right)}{d}}{d}\\ \mathbf{elif}\;M \leq 4.8789530201336614 \cdot 10^{-253}:\\ \;\;\;\;0.25 \cdot \frac{\left(\left(D \cdot D\right) \cdot \left(M \cdot M\right)\right) \cdot \frac{h}{d}}{d}\\ \mathbf{elif}\;M \leq 8.527469105065078 \cdot 10^{+35}:\\ \;\;\;\;0.25 \cdot \frac{\left(M \cdot M\right) \cdot \frac{D \cdot \left(D \cdot h\right)}{d}}{d}\\ \mathbf{else}:\\ \;\;\;\;0.25 \cdot \frac{M \cdot \left(M \cdot \frac{\left(D \cdot D\right) \cdot h}{d}\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}\;M \leq -4.837877690709628 \cdot 10^{+111}:\\
\;\;\;\;0.25 \cdot \frac{M \cdot \left(M \cdot \frac{\left(D \cdot D\right) \cdot h}{d}\right)}{d}\\

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

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

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

\mathbf{else}:\\
\;\;\;\;0.25 \cdot \frac{M \cdot \left(M \cdot \frac{\left(D \cdot D\right) \cdot h}{d}\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 (<= M -4.837877690709628e+111)
   (* 0.25 (/ (* M (* M (/ (* (* D D) h) d))) d))
   (if (<= M -7.670814269380083e-225)
     (* 0.25 (/ (* (* M M) (/ (* D (* D h)) d)) d))
     (if (<= M 4.8789530201336614e-253)
       (* 0.25 (/ (* (* (* D D) (* M M)) (/ h d)) d))
       (if (<= M 8.527469105065078e+35)
         (* 0.25 (/ (* (* M M) (/ (* D (* D h)) 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 <= -4.837877690709628e+111) {
		tmp = 0.25 * ((M * (M * (((D * D) * h) / d))) / d);
	} else if (M <= -7.670814269380083e-225) {
		tmp = 0.25 * (((M * M) * ((D * (D * h)) / d)) / d);
	} else if (M <= 4.8789530201336614e-253) {
		tmp = 0.25 * ((((D * D) * (M * M)) * (h / d)) / d);
	} else if (M <= 8.527469105065078e+35) {
		tmp = 0.25 * (((M * M) * ((D * (D * h)) / d)) / d);
	} 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 3 regimes
  2. if M < -4.837877690709628e111 or 8.52746910506507779e35 < M

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

      \[\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. Simplified54.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 51.5

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

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

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

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

    if -4.837877690709628e111 < M < -7.67081426938008302e-225 or 4.8789530201336614e-253 < M < 8.52746910506507779e35

    1. Initial program 59.3

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

      \[\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.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 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 associate-/r*_binary64_138627.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. Simplified27.1

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

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

    if -7.67081426938008302e-225 < M < 4.8789530201336614e-253

    1. Initial program 55.7

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

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

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

      \[\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_138627.9

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

      \[\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_binary64_144227.9

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

      \[\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}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification27.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq -4.837877690709628 \cdot 10^{+111}:\\ \;\;\;\;0.25 \cdot \frac{M \cdot \left(M \cdot \frac{\left(D \cdot D\right) \cdot h}{d}\right)}{d}\\ \mathbf{elif}\;M \leq -7.670814269380083 \cdot 10^{-225}:\\ \;\;\;\;0.25 \cdot \frac{\left(M \cdot M\right) \cdot \frac{D \cdot \left(D \cdot h\right)}{d}}{d}\\ \mathbf{elif}\;M \leq 4.8789530201336614 \cdot 10^{-253}:\\ \;\;\;\;0.25 \cdot \frac{\left(\left(D \cdot D\right) \cdot \left(M \cdot M\right)\right) \cdot \frac{h}{d}}{d}\\ \mathbf{elif}\;M \leq 8.527469105065078 \cdot 10^{+35}:\\ \;\;\;\;0.25 \cdot \frac{\left(M \cdot M\right) \cdot \frac{D \cdot \left(D \cdot h\right)}{d}}{d}\\ \mathbf{else}:\\ \;\;\;\;0.25 \cdot \frac{M \cdot \left(M \cdot \frac{\left(D \cdot D\right) \cdot h}{d}\right)}{d}\\ \end{array}\]

Reproduce

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