Average Error: 59.6 → 25.7
Time: 30.1s
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 3.402992039699089 \cdot 10^{+236}:\\ \;\;\;\;\left(\frac{M}{d} \cdot \left(\frac{M}{d} \cdot \left(\left(D \cdot D\right) \cdot h\right)\right)\right) \cdot 0.25\\ \mathbf{else}:\\ \;\;\;\;0.25 \cdot \frac{M \cdot \left(M \cdot \left(D \cdot \left(D \cdot h\right)\right)\right)}{d \cdot 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 3.402992039699089 \cdot 10^{+236}:\\
\;\;\;\;\left(\frac{M}{d} \cdot \left(\frac{M}{d} \cdot \left(\left(D \cdot D\right) \cdot h\right)\right)\right) \cdot 0.25\\

\mathbf{else}:\\
\;\;\;\;0.25 \cdot \frac{M \cdot \left(M \cdot \left(D \cdot \left(D \cdot h\right)\right)\right)}{d \cdot 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) 3.402992039699089e+236)
   (* (* (/ M d) (* (/ M d) (* (* D D) h))) 0.25)
   (* 0.25 (/ (* M (* M (* D (* D h)))) (* 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) <= 3.402992039699089e+236) {
		tmp = ((M / d) * ((M / d) * ((D * D) * h))) * 0.25;
	} else {
		tmp = 0.25 * ((M * (M * (D * (D * h)))) / (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) < 3.40299203969908883e236

    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 around -inf 38.1

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

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

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

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

      \[\leadsto \frac{\color{blue}{M \cdot \left(M \cdot \left(h \cdot \left(D \cdot D\right)\right)\right)}}{d \cdot d} \cdot 0.25\]
    8. Using strategy rm
    9. Applied times-frac_binary64_110723.2

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

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

    if 3.40299203969908883e236 < (*.f64 D D)

    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 around -inf 59.2

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

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

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

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

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

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

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

Reproduce

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