Average Error: 59.5 → 27.1
Time: 20.2s
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.9909816659836515 \cdot 10^{+146}:\\ \;\;\;\;0.25 \cdot \frac{\left(D \cdot D\right) \cdot \frac{M \cdot \left(M \cdot h\right)}{d}}{d}\\ \mathbf{elif}\;M \leq -6.128504964236849 \cdot 10^{+32}:\\ \;\;\;\;0.25 \cdot \frac{\left(\left(D \cdot D\right) \cdot \frac{M \cdot M}{\sqrt[3]{d} \cdot \sqrt[3]{d}}\right) \cdot \frac{h}{\sqrt[3]{d}}}{d}\\ \mathbf{elif}\;M \leq 9.128356389280072 \cdot 10^{+144}:\\ \;\;\;\;0.25 \cdot \frac{D \cdot \left(D \cdot \frac{h \cdot \left(M \cdot M\right)}{d}\right)}{d}\\ \mathbf{else}:\\ \;\;\;\;0.25 \cdot \left(\frac{D \cdot D}{\sqrt{d}} \cdot \frac{M}{\frac{{d}^{1.5}}{M \cdot h}}\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}\;M \leq -1.9909816659836515 \cdot 10^{+146}:\\
\;\;\;\;0.25 \cdot \frac{\left(D \cdot D\right) \cdot \frac{M \cdot \left(M \cdot h\right)}{d}}{d}\\

\mathbf{elif}\;M \leq -6.128504964236849 \cdot 10^{+32}:\\
\;\;\;\;0.25 \cdot \frac{\left(\left(D \cdot D\right) \cdot \frac{M \cdot M}{\sqrt[3]{d} \cdot \sqrt[3]{d}}\right) \cdot \frac{h}{\sqrt[3]{d}}}{d}\\

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

\mathbf{else}:\\
\;\;\;\;0.25 \cdot \left(\frac{D \cdot D}{\sqrt{d}} \cdot \frac{M}{\frac{{d}^{1.5}}{M \cdot h}}\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 (<= M -1.9909816659836515e+146)
   (* 0.25 (/ (* (* D D) (/ (* M (* M h)) d)) d))
   (if (<= M -6.128504964236849e+32)
     (*
      0.25
      (/ (* (* (* D D) (/ (* M M) (* (cbrt d) (cbrt d)))) (/ h (cbrt d))) d))
     (if (<= M 9.128356389280072e+144)
       (* 0.25 (/ (* D (* D (/ (* h (* M M)) d))) d))
       (* 0.25 (* (/ (* D D) (sqrt d)) (/ M (/ (pow d 1.5) (* M h)))))))))
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.9909816659836515e+146) {
		tmp = 0.25 * (((D * D) * ((M * (M * h)) / d)) / d);
	} else if (M <= -6.128504964236849e+32) {
		tmp = 0.25 * ((((D * D) * ((M * M) / (cbrt(d) * cbrt(d)))) * (h / cbrt(d))) / d);
	} else if (M <= 9.128356389280072e+144) {
		tmp = 0.25 * ((D * (D * ((h * (M * M)) / d))) / d);
	} else {
		tmp = 0.25 * (((D * D) / sqrt(d)) * (M / (pow(d, 1.5) / (M * h))));
	}
	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.99098166598365152e146

    1. Initial program 64.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 63.6

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(0.5 \cdot \frac{{D}^{2} \cdot \left(w \cdot \left(h \cdot {M}^{2}\right)\right)}{{d}^{2} \cdot c0}\right)} \]
    3. Simplified63.7

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(0.5 \cdot \frac{\left(D \cdot D\right) \cdot \left(\left(M \cdot M\right) \cdot \left(w \cdot h\right)\right)}{\left(d \cdot d\right) \cdot c0}\right)} \]
    4. Taylor expanded around 0 63.1

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

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

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

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

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

    if -1.99098166598365152e146 < M < -6.1285049642368493e32

    1. Initial program 62.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 48.2

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(0.5 \cdot \frac{{D}^{2} \cdot \left(w \cdot \left(h \cdot {M}^{2}\right)\right)}{{d}^{2} \cdot c0}\right)} \]
    3. Simplified47.7

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(0.5 \cdot \frac{\left(D \cdot D\right) \cdot \left(\left(M \cdot M\right) \cdot \left(w \cdot h\right)\right)}{\left(d \cdot d\right) \cdot c0}\right)} \]
    4. Taylor expanded around 0 38.0

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

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

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

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

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

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

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

    if -6.1285049642368493e32 < M < 9.1283563892800718e144

    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.6

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(0.5 \cdot \frac{{D}^{2} \cdot \left(w \cdot \left(h \cdot {M}^{2}\right)\right)}{{d}^{2} \cdot c0}\right)} \]
    3. Simplified39.8

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(0.5 \cdot \frac{\left(D \cdot D\right) \cdot \left(\left(M \cdot M\right) \cdot \left(w \cdot h\right)\right)}{\left(d \cdot d\right) \cdot c0}\right)} \]
    4. Taylor expanded around 0 30.2

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

      \[\leadsto \color{blue}{0.25 \cdot \frac{\left(D \cdot D\right) \cdot \left(\left(M \cdot M\right) \cdot h\right)}{d \cdot d}} \]
    6. Using strategy rm
    7. Applied associate-/r*_binary6427.0

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

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

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

    if 9.1283563892800718e144 < M

    1. Initial program 64.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 62.9

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(0.5 \cdot \frac{{D}^{2} \cdot \left(w \cdot \left(h \cdot {M}^{2}\right)\right)}{{d}^{2} \cdot c0}\right)} \]
    3. Simplified63.1

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(0.5 \cdot \frac{\left(D \cdot D\right) \cdot \left(\left(M \cdot M\right) \cdot \left(w \cdot h\right)\right)}{\left(d \cdot d\right) \cdot c0}\right)} \]
    4. Taylor expanded around 0 62.3

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

      \[\leadsto \color{blue}{0.25 \cdot \frac{\left(D \cdot D\right) \cdot \left(\left(M \cdot M\right) \cdot h\right)}{d \cdot d}} \]
    6. Using strategy rm
    7. Applied associate-/r*_binary6462.3

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq -1.9909816659836515 \cdot 10^{+146}:\\ \;\;\;\;0.25 \cdot \frac{\left(D \cdot D\right) \cdot \frac{M \cdot \left(M \cdot h\right)}{d}}{d}\\ \mathbf{elif}\;M \leq -6.128504964236849 \cdot 10^{+32}:\\ \;\;\;\;0.25 \cdot \frac{\left(\left(D \cdot D\right) \cdot \frac{M \cdot M}{\sqrt[3]{d} \cdot \sqrt[3]{d}}\right) \cdot \frac{h}{\sqrt[3]{d}}}{d}\\ \mathbf{elif}\;M \leq 9.128356389280072 \cdot 10^{+144}:\\ \;\;\;\;0.25 \cdot \frac{D \cdot \left(D \cdot \frac{h \cdot \left(M \cdot M\right)}{d}\right)}{d}\\ \mathbf{else}:\\ \;\;\;\;0.25 \cdot \left(\frac{D \cdot D}{\sqrt{d}} \cdot \frac{M}{\frac{{d}^{1.5}}{M \cdot h}}\right)\\ \end{array} \]

Reproduce

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