Average Error: 59.4 → 27.3
Time: 28.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} \mathbf{if}\;D \cdot D \leq 1.0439977634415203 \cdot 10^{+285}:\\ \;\;\;\;0.25 \cdot \left(\frac{M}{\sqrt[3]{d} \cdot \sqrt[3]{d}} \cdot \left(\frac{\left(D \cdot D\right) \cdot h}{d} \cdot \frac{M}{\sqrt[3]{d}}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \sqrt{-{M}^{2}}\\ \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}\;D \cdot D \leq 1.0439977634415203 \cdot 10^{+285}:\\
\;\;\;\;0.25 \cdot \left(\frac{M}{\sqrt[3]{d} \cdot \sqrt[3]{d}} \cdot \left(\frac{\left(D \cdot D\right) \cdot h}{d} \cdot \frac{M}{\sqrt[3]{d}}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{c0}{2 \cdot w} \cdot \sqrt{-{M}^{2}}\\

\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 (<= (* D D) 1.0439977634415203e+285)
   (*
    0.25
    (* (/ M (* (cbrt d) (cbrt d))) (* (/ (* (* D D) h) d) (/ M (cbrt d)))))
   (* (/ c0 (* 2.0 w)) (sqrt (- (pow M 2.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 tmp;
	if ((D * D) <= 1.0439977634415203e+285) {
		tmp = 0.25 * ((M / (cbrt(d) * cbrt(d))) * ((((D * D) * h) / d) * (M / cbrt(d))));
	} else {
		tmp = (c0 / (2.0 * w)) * sqrt(-pow(M, 2.0));
	}
	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 D D) < 1.04399776344152031e285

    1. Initial program 59.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 around -inf 38.7

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

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

      \[\leadsto \color{blue}{0.25 \cdot \frac{{M}^{2} \cdot \left({D}^{2} \cdot h\right)}{{d}^{2}}}\]
    5. Simplified32.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 times-frac_binary64_110729.0

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

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

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

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

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

    if 1.04399776344152031e285 < (*.f64 D D)

    1. Initial program 61.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 0 51.9

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;D \cdot D \leq 1.0439977634415203 \cdot 10^{+285}:\\ \;\;\;\;0.25 \cdot \left(\frac{M}{\sqrt[3]{d} \cdot \sqrt[3]{d}} \cdot \left(\frac{\left(D \cdot D\right) \cdot h}{d} \cdot \frac{M}{\sqrt[3]{d}}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \sqrt{-{M}^{2}}\\ \end{array}\]

Reproduce

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