Average Error: 59.7 → 23.7
Time: 24.0s
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 := \frac{M \cdot \left(M \cdot h\right)}{d}\\ t_1 := \frac{D}{\sqrt[3]{d} \cdot \sqrt[3]{d}}\\ \mathbf{if}\;M \cdot M \leq 2.5 \cdot 10^{-323}:\\ \;\;\;\;0.25 \cdot \left(t_1 \cdot \left(\frac{D}{\sqrt[3]{d}} \cdot t_0\right)\right)\\ \mathbf{elif}\;M \cdot M \leq 7.722402878706791 \cdot 10^{+305}:\\ \;\;\;\;0.25 \cdot \left(t_1 \cdot \left(\left(h \cdot \frac{D}{d}\right) \cdot \frac{M \cdot M}{\sqrt[3]{d}}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.25 \cdot \left(t_0 \cdot \frac{D \cdot D}{d}\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}
t_0 := \frac{M \cdot \left(M \cdot h\right)}{d}\\
t_1 := \frac{D}{\sqrt[3]{d} \cdot \sqrt[3]{d}}\\
\mathbf{if}\;M \cdot M \leq 2.5 \cdot 10^{-323}:\\
\;\;\;\;0.25 \cdot \left(t_1 \cdot \left(\frac{D}{\sqrt[3]{d}} \cdot t_0\right)\right)\\

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

\mathbf{else}:\\
\;\;\;\;0.25 \cdot \left(t_0 \cdot \frac{D \cdot D}{d}\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
 (let* ((t_0 (/ (* M (* M h)) d)) (t_1 (/ D (* (cbrt d) (cbrt d)))))
   (if (<= (* M M) 2.5e-323)
     (* 0.25 (* t_1 (* (/ D (cbrt d)) t_0)))
     (if (<= (* M M) 7.722402878706791e+305)
       (* 0.25 (* t_1 (* (* h (/ D d)) (/ (* M M) (cbrt d)))))
       (* 0.25 (* t_0 (/ (* D 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 t_0 = (M * (M * h)) / d;
	double t_1 = D / (cbrt(d) * cbrt(d));
	double tmp;
	if ((M * M) <= 2.5e-323) {
		tmp = 0.25 * (t_1 * ((D / cbrt(d)) * t_0));
	} else if ((M * M) <= 7.722402878706791e+305) {
		tmp = 0.25 * (t_1 * ((h * (D / d)) * ((M * M) / cbrt(d))));
	} else {
		tmp = 0.25 * (t_0 * ((D * 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 (*.f64 M M) < 2.47033e-323

    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 in c0 around -inf 31.1

      \[\leadsto \color{blue}{0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}} \]
    3. Applied add-sqr-sqrt_binary6447.1

      \[\leadsto 0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{\color{blue}{\left(\sqrt{d} \cdot \sqrt{d}\right)}}^{2}} \]
    4. Applied unpow-prod-down_binary6447.1

      \[\leadsto 0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{\color{blue}{{\left(\sqrt{d}\right)}^{2} \cdot {\left(\sqrt{d}\right)}^{2}}} \]
    5. Applied times-frac_binary6445.5

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

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

      \[\leadsto 0.25 \cdot \left(\frac{D \cdot D}{d} \cdot \color{blue}{\frac{h \cdot \left(M \cdot M\right)}{d}}\right) \]
    8. Applied add-cube-cbrt_binary6427.3

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

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

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

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

    if 2.47033e-323 < (*.f64 M M) < 7.72240287870679086e305

    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 in c0 around -inf 31.9

      \[\leadsto \color{blue}{0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}} \]
    3. Applied add-sqr-sqrt_binary6448.4

      \[\leadsto 0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{\color{blue}{\left(\sqrt{d} \cdot \sqrt{d}\right)}}^{2}} \]
    4. Applied unpow-prod-down_binary6448.4

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

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

      \[\leadsto 0.25 \cdot \left(\color{blue}{\frac{D \cdot D}{d}} \cdot \frac{{M}^{2} \cdot h}{{\left(\sqrt{d}\right)}^{2}}\right) \]
    7. Simplified28.4

      \[\leadsto 0.25 \cdot \left(\frac{D \cdot D}{d} \cdot \color{blue}{\frac{h \cdot \left(M \cdot M\right)}{d}}\right) \]
    8. Applied add-cube-cbrt_binary6428.5

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

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

      \[\leadsto 0.25 \cdot \color{blue}{\left(\frac{D}{\sqrt[3]{d} \cdot \sqrt[3]{d}} \cdot \left(\frac{D}{\sqrt[3]{d}} \cdot \frac{h \cdot \left(M \cdot M\right)}{d}\right)\right)} \]
    11. Applied add-cube-cbrt_binary6422.5

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

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

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

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

    if 7.72240287870679086e305 < (*.f64 M 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 in c0 around -inf 63.8

      \[\leadsto \color{blue}{0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}} \]
    3. Applied add-sqr-sqrt_binary6463.9

      \[\leadsto 0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{\color{blue}{\left(\sqrt{d} \cdot \sqrt{d}\right)}}^{2}} \]
    4. Applied unpow-prod-down_binary6463.9

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \cdot M \leq 2.5 \cdot 10^{-323}:\\ \;\;\;\;0.25 \cdot \left(\frac{D}{\sqrt[3]{d} \cdot \sqrt[3]{d}} \cdot \left(\frac{D}{\sqrt[3]{d}} \cdot \frac{M \cdot \left(M \cdot h\right)}{d}\right)\right)\\ \mathbf{elif}\;M \cdot M \leq 7.722402878706791 \cdot 10^{+305}:\\ \;\;\;\;0.25 \cdot \left(\frac{D}{\sqrt[3]{d} \cdot \sqrt[3]{d}} \cdot \left(\left(h \cdot \frac{D}{d}\right) \cdot \frac{M \cdot M}{\sqrt[3]{d}}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.25 \cdot \left(\frac{M \cdot \left(M \cdot h\right)}{d} \cdot \frac{D \cdot D}{d}\right)\\ \end{array} \]

Reproduce

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