Average Error: 59.8 → 27.6
Time: 16.8s
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 -2.792856815890184 \cdot 10^{+131}:\\ \;\;\;\;0.25 \cdot \frac{M \cdot \left(M \cdot \left(\left(D \cdot D\right) \cdot h\right)\right)}{d \cdot d}\\ \mathbf{elif}\;M \leq -5.0466503514205154 \cdot 10^{-176}:\\ \;\;\;\;0.25 \cdot \frac{\frac{M \cdot M}{d} \cdot \left(D \cdot \left(D \cdot h\right)\right)}{d}\\ \mathbf{elif}\;M \leq -4.892077319176114 \cdot 10^{-253}:\\ \;\;\;\;0.25 \cdot \frac{M \cdot \left(\left(\left(D \cdot D\right) \cdot h\right) \cdot \frac{M}{d}\right)}{d}\\ \mathbf{elif}\;M \leq 2.93864576183954 \cdot 10^{-163}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \sqrt{-{M}^{2}}\\ \mathbf{elif}\;M \leq 5.756608776233024 \cdot 10^{+116}:\\ \;\;\;\;0.25 \cdot \frac{\frac{M \cdot M}{d} \cdot \left(D \cdot \left(D \cdot h\right)\right)}{d}\\ \mathbf{else}:\\ \;\;\;\;0.25 \cdot \frac{M \cdot \left(\left(\left(D \cdot D\right) \cdot h\right) \cdot \frac{M}{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 -2.792856815890184 \cdot 10^{+131}:\\
\;\;\;\;0.25 \cdot \frac{M \cdot \left(M \cdot \left(\left(D \cdot D\right) \cdot h\right)\right)}{d \cdot d}\\

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

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

\mathbf{elif}\;M \leq 2.93864576183954 \cdot 10^{-163}:\\
\;\;\;\;\frac{c0}{2 \cdot w} \cdot \sqrt{-{M}^{2}}\\

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

\mathbf{else}:\\
\;\;\;\;0.25 \cdot \frac{M \cdot \left(\left(\left(D \cdot D\right) \cdot h\right) \cdot \frac{M}{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 -2.792856815890184e+131)
   (* 0.25 (/ (* M (* M (* (* D D) h))) (* d d)))
   (if (<= M -5.0466503514205154e-176)
     (* 0.25 (/ (* (/ (* M M) d) (* D (* D h))) d))
     (if (<= M -4.892077319176114e-253)
       (* 0.25 (/ (* M (* (* (* D D) h) (/ M d))) d))
       (if (<= M 2.93864576183954e-163)
         (* (/ c0 (* 2.0 w)) (sqrt (- (pow M 2.0))))
         (if (<= M 5.756608776233024e+116)
           (* 0.25 (/ (* (/ (* M M) d) (* D (* D h))) d))
           (* 0.25 (/ (* M (* (* (* D D) h) (/ M 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 <= -2.792856815890184e+131) {
		tmp = 0.25 * ((M * (M * ((D * D) * h))) / (d * d));
	} else if (M <= -5.0466503514205154e-176) {
		tmp = 0.25 * ((((M * M) / d) * (D * (D * h))) / d);
	} else if (M <= -4.892077319176114e-253) {
		tmp = 0.25 * ((M * (((D * D) * h) * (M / d))) / d);
	} else if (M <= 2.93864576183954e-163) {
		tmp = (c0 / (2.0 * w)) * sqrt(-pow(M, 2.0));
	} else if (M <= 5.756608776233024e+116) {
		tmp = 0.25 * ((((M * M) / d) * (D * (D * h))) / d);
	} else {
		tmp = 0.25 * ((M * (((D * D) * h) * (M / 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 4 regimes
  2. if M < -2.79285681589018382e131

    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 60.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. Simplified60.5

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

      \[\leadsto \color{blue}{0.25 \cdot \frac{{M}^{2} \cdot \left({D}^{2} \cdot h\right)}{{d}^{2}}}\]
    5. Simplified59.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-*l*_binary6444.8

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

    if -2.79285681589018382e131 < M < -5.0466503514205154e-176 or 2.93864576183954e-163 < M < 5.756608776233024e116

    1. Initial program 60.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 37.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. Simplified37.9

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

      \[\leadsto \color{blue}{0.25 \cdot \frac{{M}^{2} \cdot \left({D}^{2} \cdot h\right)}{{d}^{2}}}\]
    5. Simplified30.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*_binary6428.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. Simplified27.1

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

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

    if -5.0466503514205154e-176 < M < -4.8920773191761141e-253 or 5.756608776233024e116 < M

    1. Initial program 61.1

      \[\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.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. Simplified48.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 43.8

      \[\leadsto \color{blue}{0.25 \cdot \frac{{M}^{2} \cdot \left({D}^{2} \cdot h\right)}{{d}^{2}}}\]
    5. Simplified43.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*_binary6441.5

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

      \[\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 *-un-lft-identity_binary6441.2

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

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

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

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

    if -4.8920773191761141e-253 < M < 2.93864576183954e-163

    1. Initial program 55.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 0 28.0

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\sqrt{-{M}^{2}}}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification27.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq -2.792856815890184 \cdot 10^{+131}:\\ \;\;\;\;0.25 \cdot \frac{M \cdot \left(M \cdot \left(\left(D \cdot D\right) \cdot h\right)\right)}{d \cdot d}\\ \mathbf{elif}\;M \leq -5.0466503514205154 \cdot 10^{-176}:\\ \;\;\;\;0.25 \cdot \frac{\frac{M \cdot M}{d} \cdot \left(D \cdot \left(D \cdot h\right)\right)}{d}\\ \mathbf{elif}\;M \leq -4.892077319176114 \cdot 10^{-253}:\\ \;\;\;\;0.25 \cdot \frac{M \cdot \left(\left(\left(D \cdot D\right) \cdot h\right) \cdot \frac{M}{d}\right)}{d}\\ \mathbf{elif}\;M \leq 2.93864576183954 \cdot 10^{-163}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \sqrt{-{M}^{2}}\\ \mathbf{elif}\;M \leq 5.756608776233024 \cdot 10^{+116}:\\ \;\;\;\;0.25 \cdot \frac{\frac{M \cdot M}{d} \cdot \left(D \cdot \left(D \cdot h\right)\right)}{d}\\ \mathbf{else}:\\ \;\;\;\;0.25 \cdot \frac{M \cdot \left(\left(\left(D \cdot D\right) \cdot h\right) \cdot \frac{M}{d}\right)}{d}\\ \end{array}\]

Reproduce

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