Average Error: 59.5 → 26.7
Time: 16.6s
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 \left(\frac{D}{\sqrt[3]{d} \cdot \sqrt[3]{d}} \cdot \left(\frac{D}{\sqrt[3]{d}} \cdot \frac{\left(M \cdot M\right) \cdot h}{d}\right)\right)\\ \mathbf{if}\;M \cdot M \leq 205532364386197380:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_1 := \frac{D \cdot D}{d}\\ \mathbf{if}\;M \cdot M \leq 3.223267092491908 \cdot 10^{+241}:\\ \;\;\;\;0.25 \cdot \left(\left(h \cdot t_1\right) \cdot \frac{M \cdot M}{d}\right)\\ \mathbf{elif}\;M \cdot M \leq 2.594161242097384 \cdot 10^{+295}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;0.25 \cdot \left(t_1 \cdot \frac{M \cdot \left(M \cdot h\right)}{d}\right)\\ \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 \left(\frac{D}{\sqrt[3]{d} \cdot \sqrt[3]{d}} \cdot \left(\frac{D}{\sqrt[3]{d}} \cdot \frac{\left(M \cdot M\right) \cdot h}{d}\right)\right)\\
\mathbf{if}\;M \cdot M \leq 205532364386197380:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;M \cdot M \leq 2.594161242097384 \cdot 10^{+295}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;0.25 \cdot \left(t_1 \cdot \frac{M \cdot \left(M \cdot h\right)}{d}\right)\\


\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
          (*
           (/ D (* (cbrt d) (cbrt d)))
           (* (/ D (cbrt d)) (/ (* (* M M) h) d))))))
   (if (<= (* M M) 205532364386197380.0)
     t_0
     (let* ((t_1 (/ (* D D) d)))
       (if (<= (* M M) 3.223267092491908e+241)
         (* 0.25 (* (* h t_1) (/ (* M M) d)))
         (if (<= (* M M) 2.594161242097384e+295)
           t_0
           (* 0.25 (* t_1 (/ (* M (* M h)) 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 = 0.25 * ((D / (cbrt(d) * cbrt(d))) * ((D / cbrt(d)) * (((M * M) * h) / d)));
	double tmp;
	if ((M * M) <= 205532364386197380.0) {
		tmp = t_0;
	} else {
		double t_1 = (D * D) / d;
		double tmp_1;
		if ((M * M) <= 3.223267092491908e+241) {
			tmp_1 = 0.25 * ((h * t_1) * ((M * M) / d));
		} else if ((M * M) <= 2.594161242097384e+295) {
			tmp_1 = t_0;
		} else {
			tmp_1 = 0.25 * (t_1 * ((M * (M * h)) / d));
		}
		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 3 regimes
  2. if (*.f64 M M) < 205532364386197380 or 3.2232670924919083e241 < (*.f64 M M) < 2.5941612420973839e295

    1. Initial program 57.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 37.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. Taylor expanded in c0 around 0 30.1

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

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

      \[\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}}} \]
    6. Applied times-frac_binary6445.3

      \[\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)} \]
    7. Simplified45.3

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

      \[\leadsto 0.25 \cdot \left(\frac{D \cdot D}{d} \cdot \color{blue}{\frac{h \cdot \left(M \cdot M\right)}{d}}\right) \]
    9. Applied add-cube-cbrt_binary6426.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) \]
    10. Applied times-frac_binary6422.9

      \[\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) \]
    11. Applied associate-*l*_binary6421.7

      \[\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)} \]

    if 205532364386197380 < (*.f64 M M) < 3.2232670924919083e241

    1. Initial program 62.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 in c0 around -inf 45.4

      \[\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. Taylor expanded in c0 around 0 34.7

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

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

      \[\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}}} \]
    6. Applied times-frac_binary6447.0

      \[\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)} \]
    7. Simplified47.0

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

      \[\leadsto 0.25 \cdot \left(\frac{D \cdot D}{d} \cdot \color{blue}{\frac{h \cdot \left(M \cdot M\right)}{d}}\right) \]
    9. Applied *-un-lft-identity_binary6430.1

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

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

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

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

    if 2.5941612420973839e295 < (*.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.5

      \[\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. Taylor expanded in c0 around 0 63.3

      \[\leadsto \color{blue}{0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}} \]
    4. Applied add-sqr-sqrt_binary6463.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}} \]
    5. Applied unpow-prod-down_binary6463.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}}} \]
    6. Applied times-frac_binary6463.3

      \[\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)} \]
    7. Simplified63.3

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \cdot M \leq 205532364386197380:\\ \;\;\;\;0.25 \cdot \left(\frac{D}{\sqrt[3]{d} \cdot \sqrt[3]{d}} \cdot \left(\frac{D}{\sqrt[3]{d}} \cdot \frac{\left(M \cdot M\right) \cdot h}{d}\right)\right)\\ \mathbf{elif}\;M \cdot M \leq 3.223267092491908 \cdot 10^{+241}:\\ \;\;\;\;0.25 \cdot \left(\left(h \cdot \frac{D \cdot D}{d}\right) \cdot \frac{M \cdot M}{d}\right)\\ \mathbf{elif}\;M \cdot M \leq 2.594161242097384 \cdot 10^{+295}:\\ \;\;\;\;0.25 \cdot \left(\frac{D}{\sqrt[3]{d} \cdot \sqrt[3]{d}} \cdot \left(\frac{D}{\sqrt[3]{d}} \cdot \frac{\left(M \cdot M\right) \cdot h}{d}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.25 \cdot \left(\frac{D \cdot D}{d} \cdot \frac{M \cdot \left(M \cdot h\right)}{d}\right)\\ \end{array} \]

Reproduce

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