Average Error: 59.3 → 36.4
Time: 12.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 \le 1.32032001807654067 \cdot 10^{-52}:\\ \;\;\;\;0\\ \mathbf{elif}\;D \cdot D \le 9.6196677732977827 \cdot 10^{278}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \frac{M \cdot M}{\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2} - \sqrt{\frac{c0}{w \cdot h} \cdot \left({\left(\frac{d}{D}\right)}^{2} \cdot \left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2}\right)\right) - M \cdot M}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\left(d \cdot \frac{d}{w}\right) \cdot \frac{c0}{\left(D \cdot D\right) \cdot h}\right)\right)\\ \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 \le 1.32032001807654067 \cdot 10^{-52}:\\
\;\;\;\;0\\

\mathbf{elif}\;D \cdot D \le 9.6196677732977827 \cdot 10^{278}:\\
\;\;\;\;\frac{c0}{2 \cdot w} \cdot \frac{M \cdot M}{\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2} - \sqrt{\frac{c0}{w \cdot h} \cdot \left({\left(\frac{d}{D}\right)}^{2} \cdot \left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2}\right)\right) - M \cdot M}}\\

\mathbf{else}:\\
\;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\left(d \cdot \frac{d}{w}\right) \cdot \frac{c0}{\left(D \cdot D\right) \cdot h}\right)\right)\\

\end{array}
double code(double c0, double w, double h, double D, double d, double M) {
	return ((double) (((double) (c0 / ((double) (2.0 * w)))) * ((double) (((double) (((double) (c0 * ((double) (d * d)))) / ((double) (((double) (w * h)) * ((double) (D * D)))))) + ((double) sqrt(((double) (((double) (((double) (((double) (c0 * ((double) (d * d)))) / ((double) (((double) (w * h)) * ((double) (D * D)))))) * ((double) (((double) (c0 * ((double) (d * d)))) / ((double) (((double) (w * h)) * ((double) (D * D)))))))) - ((double) (M * M))))))))));
}
double code(double c0, double w, double h, double D, double d, double M) {
	double VAR;
	if ((((double) (D * D)) <= 1.3203200180765407e-52)) {
		VAR = 0.0;
	} else {
		double VAR_1;
		if ((((double) (D * D)) <= 9.619667773297783e+278)) {
			VAR_1 = ((double) (((double) (c0 / ((double) (2.0 * w)))) * ((double) (((double) (M * M)) / ((double) (((double) (((double) (c0 / ((double) (w * h)))) * ((double) pow(((double) (d / D)), 2.0)))) - ((double) sqrt(((double) (((double) (((double) (c0 / ((double) (w * h)))) * ((double) (((double) pow(((double) (d / D)), 2.0)) * ((double) (((double) (c0 / ((double) (w * h)))) * ((double) pow(((double) (d / D)), 2.0)))))))) - ((double) (M * M))))))))))));
		} else {
			VAR_1 = ((double) (((double) (c0 / ((double) (2.0 * w)))) * ((double) (2.0 * ((double) (((double) (d * ((double) (d / w)))) * ((double) (c0 / ((double) (((double) (D * D)) * h))))))))));
		}
		VAR = VAR_1;
	}
	return VAR;
}

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 (* D D) < 1.32032001807654067e-52

    1. Initial program 60.6

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

      \[\leadsto \color{blue}{\frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2} + \sqrt{\frac{c0}{w \cdot h} \cdot \left({\left(\frac{d}{D}\right)}^{4} \cdot \frac{c0}{w \cdot h}\right) - M \cdot M}\right)}\]
    3. Taylor expanded around inf 31.4

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{0}\]
    4. Using strategy rm
    5. Applied mul029.8

      \[\leadsto \color{blue}{0}\]

    if 1.32032001807654067e-52 < (* D D) < 9.6196677732977827e278

    1. Initial program 54.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. Simplified57.1

      \[\leadsto \color{blue}{\frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2} + \sqrt{\frac{c0}{w \cdot h} \cdot \left({\left(\frac{d}{D}\right)}^{4} \cdot \frac{c0}{w \cdot h}\right) - M \cdot M}\right)}\]
    3. Using strategy rm
    4. Applied flip-+61.0

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\frac{\left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2}\right) \cdot \left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2}\right) - \sqrt{\frac{c0}{w \cdot h} \cdot \left({\left(\frac{d}{D}\right)}^{4} \cdot \frac{c0}{w \cdot h}\right) - M \cdot M} \cdot \sqrt{\frac{c0}{w \cdot h} \cdot \left({\left(\frac{d}{D}\right)}^{4} \cdot \frac{c0}{w \cdot h}\right) - M \cdot M}}{\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2} - \sqrt{\frac{c0}{w \cdot h} \cdot \left({\left(\frac{d}{D}\right)}^{4} \cdot \frac{c0}{w \cdot h}\right) - M \cdot M}}}\]
    5. Simplified44.5

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{\color{blue}{0 + M \cdot M}}{\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2} - \sqrt{\frac{c0}{w \cdot h} \cdot \left({\left(\frac{d}{D}\right)}^{4} \cdot \frac{c0}{w \cdot h}\right) - M \cdot M}}\]
    6. Simplified44.5

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{0 + M \cdot M}{\color{blue}{\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2} - \sqrt{\frac{c0}{w \cdot h} \cdot \left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{4}\right) - M \cdot M}}}\]
    7. Using strategy rm
    8. Applied sqr-pow44.5

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{0 + M \cdot M}{\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2} - \sqrt{\frac{c0}{w \cdot h} \cdot \left(\frac{c0}{w \cdot h} \cdot \color{blue}{\left({\left(\frac{d}{D}\right)}^{\left(\frac{4}{2}\right)} \cdot {\left(\frac{d}{D}\right)}^{\left(\frac{4}{2}\right)}\right)}\right) - M \cdot M}}\]
    9. Applied associate-*r*43.5

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{0 + M \cdot M}{\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2} - \sqrt{\frac{c0}{w \cdot h} \cdot \color{blue}{\left(\left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{\left(\frac{4}{2}\right)}\right) \cdot {\left(\frac{d}{D}\right)}^{\left(\frac{4}{2}\right)}\right)} - M \cdot M}}\]
    10. Simplified43.5

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{0 + M \cdot M}{\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2} - \sqrt{\frac{c0}{w \cdot h} \cdot \left(\color{blue}{\left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2}\right)} \cdot {\left(\frac{d}{D}\right)}^{\left(\frac{4}{2}\right)}\right) - M \cdot M}}\]

    if 9.6196677732977827e278 < (* D D)

    1. Initial program 62.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. Simplified51.1

      \[\leadsto \color{blue}{\frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2} + \sqrt{\frac{c0}{w \cdot h} \cdot \left({\left(\frac{d}{D}\right)}^{4} \cdot \frac{c0}{w \cdot h}\right) - M \cdot M}\right)}\]
    3. Using strategy rm
    4. Applied flip-+57.6

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\frac{\left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2}\right) \cdot \left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2}\right) - \sqrt{\frac{c0}{w \cdot h} \cdot \left({\left(\frac{d}{D}\right)}^{4} \cdot \frac{c0}{w \cdot h}\right) - M \cdot M} \cdot \sqrt{\frac{c0}{w \cdot h} \cdot \left({\left(\frac{d}{D}\right)}^{4} \cdot \frac{c0}{w \cdot h}\right) - M \cdot M}}{\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2} - \sqrt{\frac{c0}{w \cdot h} \cdot \left({\left(\frac{d}{D}\right)}^{4} \cdot \frac{c0}{w \cdot h}\right) - M \cdot M}}}\]
    5. Simplified46.6

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{\color{blue}{0 + M \cdot M}}{\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2} - \sqrt{\frac{c0}{w \cdot h} \cdot \left({\left(\frac{d}{D}\right)}^{4} \cdot \frac{c0}{w \cdot h}\right) - M \cdot M}}\]
    6. Simplified46.6

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{0 + M \cdot M}{\color{blue}{\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2} - \sqrt{\frac{c0}{w \cdot h} \cdot \left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{4}\right) - M \cdot M}}}\]
    7. Taylor expanded around 0 60.8

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(2 \cdot \frac{{d}^{2} \cdot c0}{w \cdot \left({D}^{2} \cdot h\right)}\right)}\]
    8. Simplified58.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;D \cdot D \le 1.32032001807654067 \cdot 10^{-52}:\\ \;\;\;\;0\\ \mathbf{elif}\;D \cdot D \le 9.6196677732977827 \cdot 10^{278}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \frac{M \cdot M}{\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2} - \sqrt{\frac{c0}{w \cdot h} \cdot \left({\left(\frac{d}{D}\right)}^{2} \cdot \left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2}\right)\right) - M \cdot M}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\left(d \cdot \frac{d}{w}\right) \cdot \frac{c0}{\left(D \cdot D\right) \cdot h}\right)\right)\\ \end{array}\]

Reproduce

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