Average Error: 59.5 → 27.3
Time: 17.5s
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} t_0 := 0.25 \cdot \frac{M \cdot \left(M \cdot \frac{\left(D \cdot D\right) \cdot h}{d}\right)}{d}\\ \mathbf{if}\;M \leq -4.875423653967228 \cdot 10^{+48}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;M \leq -3.1905588265615016 \cdot 10^{-137}:\\ \;\;\;\;0.25 \cdot \frac{\left(\left(M \cdot M\right) \cdot \frac{D \cdot D}{\sqrt[3]{d} \cdot \sqrt[3]{d}}\right) \cdot \frac{h}{\sqrt[3]{d}}}{d}\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_1 := 0.25 \cdot \frac{\left(M \cdot M\right) \cdot \frac{D \cdot \left(D \cdot h\right)}{d}}{d}\\ \mathbf{if}\;M \leq -9.169952495142169 \cdot 10^{-295}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;M \leq 7.259802738012728 \cdot 10^{-177}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \sqrt{-M \cdot M}\\ \mathbf{elif}\;M \leq 5.5286507786806465 \cdot 10^{+119}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array}\\ \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}
t_0 := 0.25 \cdot \frac{M \cdot \left(M \cdot \frac{\left(D \cdot D\right) \cdot h}{d}\right)}{d}\\
\mathbf{if}\;M \leq -4.875423653967228 \cdot 10^{+48}:\\
\;\;\;\;t_0\\

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

\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_1 := 0.25 \cdot \frac{\left(M \cdot M\right) \cdot \frac{D \cdot \left(D \cdot h\right)}{d}}{d}\\
\mathbf{if}\;M \leq -9.169952495142169 \cdot 10^{-295}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;M \leq 5.5286507786806465 \cdot 10^{+119}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}\\


\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
 (let* ((t_0 (* 0.25 (/ (* M (* M (/ (* (* D D) h) d))) d))))
   (if (<= M -4.875423653967228e+48)
     t_0
     (if (<= M -3.1905588265615016e-137)
       (*
        0.25
        (/ (* (* (* M M) (/ (* D D) (* (cbrt d) (cbrt d)))) (/ h (cbrt d))) d))
       (let* ((t_1 (* 0.25 (/ (* (* M M) (/ (* D (* D h)) d)) d))))
         (if (<= M -9.169952495142169e-295)
           t_1
           (if (<= M 7.259802738012728e-177)
             (* (/ c0 (* 2.0 w)) (sqrt (- (* M M))))
             (if (<= M 5.5286507786806465e+119) t_1 t_0))))))))
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 t_0 = 0.25 * ((M * (M * (((D * D) * h) / d))) / d);
	double tmp;
	if (M <= -4.875423653967228e+48) {
		tmp = t_0;
	} else if (M <= -3.1905588265615016e-137) {
		tmp = 0.25 * ((((M * M) * ((D * D) / (cbrt(d) * cbrt(d)))) * (h / cbrt(d))) / d);
	} else {
		double t_1 = 0.25 * (((M * M) * ((D * (D * h)) / d)) / d);
		double tmp_1;
		if (M <= -9.169952495142169e-295) {
			tmp_1 = t_1;
		} else if (M <= 7.259802738012728e-177) {
			tmp_1 = (c0 / (2.0 * w)) * sqrt(-(M * M));
		} else if (M <= 5.5286507786806465e+119) {
			tmp_1 = t_1;
		} else {
			tmp_1 = t_0;
		}
		tmp = tmp_1;
	}
	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 < -4.8754236539672279e48 or 5.5286507786806465e119 < 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 55.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. Simplified56.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 53.0

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

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

      \[\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.8754236539672279e48 < M < -3.19055882656150157e-137

    1. Initial program 60.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 35.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. Simplified35.8

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

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

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

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

      \[\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 add-cube-cbrt_binary6424.8

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

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

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

    if -3.19055882656150157e-137 < M < -9.16995249514216853e-295 or 7.2598027380127283e-177 < M < 5.5286507786806465e119

    1. Initial program 58.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 37.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. Simplified38.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.4

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

      \[\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. Simplified26.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 associate-*l*_binary6424.4

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

    if -9.16995249514216853e-295 < M < 7.2598027380127283e-177

    1. Initial program 54.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 0 27.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq -4.875423653967228 \cdot 10^{+48}:\\ \;\;\;\;0.25 \cdot \frac{M \cdot \left(M \cdot \frac{\left(D \cdot D\right) \cdot h}{d}\right)}{d}\\ \mathbf{elif}\;M \leq -3.1905588265615016 \cdot 10^{-137}:\\ \;\;\;\;0.25 \cdot \frac{\left(\left(M \cdot M\right) \cdot \frac{D \cdot D}{\sqrt[3]{d} \cdot \sqrt[3]{d}}\right) \cdot \frac{h}{\sqrt[3]{d}}}{d}\\ \mathbf{elif}\;M \leq -9.169952495142169 \cdot 10^{-295}:\\ \;\;\;\;0.25 \cdot \frac{\left(M \cdot M\right) \cdot \frac{D \cdot \left(D \cdot h\right)}{d}}{d}\\ \mathbf{elif}\;M \leq 7.259802738012728 \cdot 10^{-177}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \sqrt{-M \cdot M}\\ \mathbf{elif}\;M \leq 5.5286507786806465 \cdot 10^{+119}:\\ \;\;\;\;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 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))))))