Average Error: 59.6 → 27.2
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} \mathbf{if}\;D \cdot D \leq 5.214799871769385 \cdot 10^{+210}:\\ \;\;\;\;0.25 \cdot \frac{\left(D \cdot D\right) \cdot \frac{M \cdot \left(h \cdot M\right)}{d}}{d}\\ \mathbf{else}:\\ \;\;\;\;0.25 \cdot \frac{D \cdot \left(D \cdot \frac{h \cdot \left(M \cdot M\right)}{d}\right)}{d}\\ \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 5.214799871769385 \cdot 10^{+210}:\\
\;\;\;\;0.25 \cdot \frac{\left(D \cdot D\right) \cdot \frac{M \cdot \left(h \cdot M\right)}{d}}{d}\\

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


\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) 5.214799871769385e+210)
   (* 0.25 (/ (* (* D D) (/ (* M (* h M)) d)) d))
   (* 0.25 (/ (* D (* D (/ (* h (* M M)) 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 tmp;
	if ((D * D) <= 5.214799871769385e+210) {
		tmp = 0.25 * (((D * D) * ((M * (h * M)) / d)) / d);
	} else {
		tmp = 0.25 * ((D * (D * ((h * (M * M)) / 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 2 regimes
  2. if (*.f64 D D) < 5.2147998717693848e210

    1. Initial program 59.4

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

      \[\leadsto \color{blue}{\frac{c0}{2 \cdot w} \cdot \left(0.5 \cdot \frac{\left(D \cdot D\right) \cdot \left(w \cdot \left(\left(M \cdot M\right) \cdot h\right)\right)}{c0 \cdot \left(d \cdot d\right)}\right)} \]
    4. Taylor expanded in c0 around 0 32.1

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

      \[\leadsto \color{blue}{0.25 \cdot \frac{\left(D \cdot D\right) \cdot \left(h \cdot \left(M \cdot M\right)\right)}{d \cdot d}} \]
    6. Using strategy rm
    7. Applied associate-/r*_binary6429.1

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

      \[\leadsto 0.25 \cdot \frac{\color{blue}{\left(D \cdot D\right) \cdot \frac{h \cdot \left(M \cdot M\right)}{d}}}{d} \]
    9. Using strategy rm
    10. Applied associate-*r*_binary6425.6

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

    if 5.2147998717693848e210 < (*.f64 D D)

    1. Initial program 60.5

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

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

      \[\leadsto \color{blue}{\frac{c0}{2 \cdot w} \cdot \left(0.5 \cdot \frac{\left(D \cdot D\right) \cdot \left(w \cdot \left(\left(M \cdot M\right) \cdot h\right)\right)}{c0 \cdot \left(d \cdot d\right)}\right)} \]
    4. Taylor expanded in c0 around 0 54.4

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

      \[\leadsto \color{blue}{0.25 \cdot \frac{\left(D \cdot D\right) \cdot \left(h \cdot \left(M \cdot M\right)\right)}{d \cdot d}} \]
    6. Using strategy rm
    7. Applied associate-/r*_binary6453.6

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

      \[\leadsto 0.25 \cdot \frac{\color{blue}{\left(D \cdot D\right) \cdot \frac{h \cdot \left(M \cdot M\right)}{d}}}{d} \]
    9. Using strategy rm
    10. Applied associate-*l*_binary6435.8

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;D \cdot D \leq 5.214799871769385 \cdot 10^{+210}:\\ \;\;\;\;0.25 \cdot \frac{\left(D \cdot D\right) \cdot \frac{M \cdot \left(h \cdot M\right)}{d}}{d}\\ \mathbf{else}:\\ \;\;\;\;0.25 \cdot \frac{D \cdot \left(D \cdot \frac{h \cdot \left(M \cdot M\right)}{d}\right)}{d}\\ \end{array} \]

Reproduce

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