Average Error: 59.5 → 29.4
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}\;M \leq -1.37686047095334 \cdot 10^{+133}:\\ \;\;\;\;0.25 \cdot \frac{M \cdot \left(M \cdot \left(D \cdot \left(D \cdot h\right)\right)\right)}{d \cdot d}\\ \mathbf{elif}\;M \leq -3.931039808045266 \cdot 10^{-166}:\\ \;\;\;\;\left(0.25 \cdot \frac{M \cdot M}{d}\right) \cdot \frac{D \cdot \left(D \cdot h\right)}{d}\\ \mathbf{elif}\;M \leq -5.2181161000346884 \cdot 10^{-298}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \sqrt{-M \cdot M}\\ \mathbf{elif}\;M \leq 6.901359139380613 \cdot 10^{+123}:\\ \;\;\;\;0.25 \cdot \frac{\left(D \cdot h\right) \cdot \left(D \cdot \left(M \cdot M\right)\right)}{d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;0.25 \cdot \frac{M \cdot \left(M \cdot \left(D \cdot \left(D \cdot h\right)\right)\right)}{d \cdot 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 -1.37686047095334 \cdot 10^{+133}:\\
\;\;\;\;0.25 \cdot \frac{M \cdot \left(M \cdot \left(D \cdot \left(D \cdot h\right)\right)\right)}{d \cdot d}\\

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

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

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

\mathbf{else}:\\
\;\;\;\;0.25 \cdot \frac{M \cdot \left(M \cdot \left(D \cdot \left(D \cdot h\right)\right)\right)}{d \cdot 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 -1.37686047095334e+133)
   (* 0.25 (/ (* M (* M (* D (* D h)))) (* d d)))
   (if (<= M -3.931039808045266e-166)
     (* (* 0.25 (/ (* M M) d)) (/ (* D (* D h)) d))
     (if (<= M -5.2181161000346884e-298)
       (* (/ c0 (* 2.0 w)) (sqrt (- (* M M))))
       (if (<= M 6.901359139380613e+123)
         (* 0.25 (/ (* (* D h) (* D (* M M))) (* 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 <= -1.37686047095334e+133) {
		tmp = 0.25 * ((M * (M * (D * (D * h)))) / (d * d));
	} else if (M <= -3.931039808045266e-166) {
		tmp = (0.25 * ((M * M) / d)) * ((D * (D * h)) / d);
	} else if (M <= -5.2181161000346884e-298) {
		tmp = (c0 / (2.0 * w)) * sqrt(-(M * M));
	} else if (M <= 6.901359139380613e+123) {
		tmp = 0.25 * (((D * h) * (D * (M * M))) / (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 4 regimes
  2. if M < -1.37686047095334e133 or 6.90135913938061331e123 < 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 60.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. 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*_binary64_104258.9

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

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

    if -1.37686047095334e133 < M < -3.93103980804526629e-166

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

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

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

      \[\leadsto 0.25 \cdot \frac{\left(M \cdot M\right) \cdot \color{blue}{\left(D \cdot \left(D \cdot h\right)\right)}}{d \cdot d}\]
    8. Using strategy rm
    9. Applied times-frac_binary64_110724.4

      \[\leadsto 0.25 \cdot \color{blue}{\left(\frac{M \cdot M}{d} \cdot \frac{D \cdot \left(D \cdot h\right)}{d}\right)}\]
    10. Applied associate-*r*_binary64_104124.4

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

    if -3.93103980804526629e-166 < M < -5.2181161000346884e-298

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\sqrt{-{M}^{2}}}\]
    3. Simplified28.3

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\sqrt{-M \cdot M}}\]

    if -5.2181161000346884e-298 < M < 6.90135913938061331e123

    1. Initial program 58.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.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 31.0

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq -1.37686047095334 \cdot 10^{+133}:\\ \;\;\;\;0.25 \cdot \frac{M \cdot \left(M \cdot \left(D \cdot \left(D \cdot h\right)\right)\right)}{d \cdot d}\\ \mathbf{elif}\;M \leq -3.931039808045266 \cdot 10^{-166}:\\ \;\;\;\;\left(0.25 \cdot \frac{M \cdot M}{d}\right) \cdot \frac{D \cdot \left(D \cdot h\right)}{d}\\ \mathbf{elif}\;M \leq -5.2181161000346884 \cdot 10^{-298}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \sqrt{-M \cdot M}\\ \mathbf{elif}\;M \leq 6.901359139380613 \cdot 10^{+123}:\\ \;\;\;\;0.25 \cdot \frac{\left(D \cdot h\right) \cdot \left(D \cdot \left(M \cdot M\right)\right)}{d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;0.25 \cdot \frac{M \cdot \left(M \cdot \left(D \cdot \left(D \cdot h\right)\right)\right)}{d \cdot d}\\ \end{array}\]

Reproduce

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