Average Error: 59.5 → 23.2
Time: 21.7s
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{D}{\sqrt[3]{d} \cdot \sqrt[3]{d}}\\ t_1 := 0.25 \cdot \left(t_0 \cdot \left(\frac{D}{\sqrt[3]{d}} \cdot \frac{M \cdot \left(M \cdot h\right)}{d}\right)\right)\\ \mathbf{if}\;M \cdot M \leq 8.526455075433164 \cdot 10^{-236}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;M \cdot M \leq 4.548310196455184 \cdot 10^{+300}:\\ \;\;\;\;0.25 \cdot \left(t_0 \cdot \left(\left(h \cdot \frac{D}{d}\right) \cdot \frac{M \cdot M}{\sqrt[3]{d}}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \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{D}{\sqrt[3]{d} \cdot \sqrt[3]{d}}\\
t_1 := 0.25 \cdot \left(t_0 \cdot \left(\frac{D}{\sqrt[3]{d}} \cdot \frac{M \cdot \left(M \cdot h\right)}{d}\right)\right)\\
\mathbf{if}\;M \cdot M \leq 8.526455075433164 \cdot 10^{-236}:\\
\;\;\;\;t_1\\

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

\mathbf{else}:\\
\;\;\;\;t_1\\


\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 (/ D (* (cbrt d) (cbrt d))))
        (t_1 (* 0.25 (* t_0 (* (/ D (cbrt d)) (/ (* M (* M h)) d))))))
   (if (<= (* M M) 8.526455075433164e-236)
     t_1
     (if (<= (* M M) 4.548310196455184e+300)
       (* 0.25 (* t_0 (* (* h (/ D d)) (/ (* M M) (cbrt d)))))
       t_1))))
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 = D / (cbrt(d) * cbrt(d));
	double t_1 = 0.25 * (t_0 * ((D / cbrt(d)) * ((M * (M * h)) / d)));
	double tmp;
	if ((M * M) <= 8.526455075433164e-236) {
		tmp = t_1;
	} else if ((M * M) <= 4.548310196455184e+300) {
		tmp = 0.25 * (t_0 * ((h * (D / d)) * ((M * M) / cbrt(d))));
	} else {
		tmp = t_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 2 regimes
  2. if (*.f64 M M) < 8.5264550754331636e-236 or 4.54831019645518388e300 < (*.f64 M M)

    1. Initial program 58.3

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

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

      \[\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_binary6451.5

      \[\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_binary6450.1

      \[\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. Simplified50.1

      \[\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. Simplified35.9

      \[\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_binary6435.9

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

      \[\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*_binary6432.8

      \[\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*_binary6428.0

      \[\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 8.5264550754331636e-236 < (*.f64 M M) < 4.54831019645518388e300

    1. Initial program 61.2

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

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

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

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

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

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

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

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

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

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

      \[\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_binary6419.8

      \[\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*_binary6417.8

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

      \[\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) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification23.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \cdot M \leq 8.526455075433164 \cdot 10^{-236}:\\ \;\;\;\;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 4.548310196455184 \cdot 10^{+300}:\\ \;\;\;\;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{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)\\ \end{array} \]

Reproduce

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