Henrywood and Agarwal, Equation (13)

?

Percentage Accurate: 24.5% → 66.3%
Time: 37.1s
Precision: binary64
Cost: 17092

?

\[\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{c0}{2 \cdot w}\\ t_1 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\ \mathbf{if}\;t_0 \cdot \left(t_1 + \sqrt{t_1 \cdot t_1 - M \cdot M}\right) \leq \infty:\\ \;\;\;\;t_0 \cdot \left(2 \cdot \frac{d \cdot \left(\frac{c0}{w} \cdot \frac{d}{h \cdot D}\right)}{D}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(0.25, \frac{\frac{D}{d} \cdot \left(h \cdot \left(M \cdot M\right)\right)}{\frac{d}{D}}, 0\right)\\ \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 (/ c0 (* 2.0 w))) (t_1 (/ (* c0 (* d d)) (* (* w h) (* D D)))))
   (if (<= (* t_0 (+ t_1 (sqrt (- (* t_1 t_1) (* M M))))) INFINITY)
     (* t_0 (* 2.0 (/ (* d (* (/ c0 w) (/ d (* h D)))) D)))
     (fma 0.25 (/ (* (/ D d) (* h (* M M))) (/ d D)) 0.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 t_0 = c0 / (2.0 * w);
	double t_1 = (c0 * (d * d)) / ((w * h) * (D * D));
	double tmp;
	if ((t_0 * (t_1 + sqrt(((t_1 * t_1) - (M * M))))) <= ((double) INFINITY)) {
		tmp = t_0 * (2.0 * ((d * ((c0 / w) * (d / (h * D)))) / D));
	} else {
		tmp = fma(0.25, (((D / d) * (h * (M * M))) / (d / D)), 0.0);
	}
	return tmp;
}
function code(c0, w, h, D, d, M)
	return Float64(Float64(c0 / Float64(2.0 * w)) * Float64(Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D))) + sqrt(Float64(Float64(Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D))) * Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D)))) - Float64(M * M)))))
end
function code(c0, w, h, D, d, M)
	t_0 = Float64(c0 / Float64(2.0 * w))
	t_1 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D)))
	tmp = 0.0
	if (Float64(t_0 * Float64(t_1 + sqrt(Float64(Float64(t_1 * t_1) - Float64(M * M))))) <= Inf)
		tmp = Float64(t_0 * Float64(2.0 * Float64(Float64(d * Float64(Float64(c0 / w) * Float64(d / Float64(h * D)))) / D)));
	else
		tmp = fma(0.25, Float64(Float64(Float64(D / d) * Float64(h * Float64(M * M))) / Float64(d / D)), 0.0);
	end
	return tmp
end
code[c0_, w_, h_, D_, d_, M_] := N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Sqrt[N[(N[(N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 * N[(t$95$1 + N[Sqrt[N[(N[(t$95$1 * t$95$1), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(t$95$0 * N[(2.0 * N[(N[(d * N[(N[(c0 / w), $MachinePrecision] * N[(d / N[(h * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.25 * N[(N[(N[(D / d), $MachinePrecision] * N[(h * N[(M * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d / D), $MachinePrecision]), $MachinePrecision] + 0.0), $MachinePrecision]]]]
\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{c0}{2 \cdot w}\\
t_1 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
\mathbf{if}\;t_0 \cdot \left(t_1 + \sqrt{t_1 \cdot t_1 - M \cdot M}\right) \leq \infty:\\
\;\;\;\;t_0 \cdot \left(2 \cdot \frac{d \cdot \left(\frac{c0}{w} \cdot \frac{d}{h \cdot D}\right)}{D}\right)\\

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


\end{array}

Local Percentage Accuracy?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Herbie found 8 alternatives:

AlternativeAccuracySpeedup

Accuracy vs Speed

The accuracy (vertical axis) and speed (horizontal axis) of each of Herbie's proposed alternatives. Up and to the right is better. Each dot represents an alternative program; the red square represents the initial program.

Bogosity?

Bogosity

Derivation?

  1. Split input into 2 regimes
  2. if (*.f64 (/.f64 c0 (*.f64 2 w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) < +inf.0

    1. Initial program 69.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 72.3%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(2 \cdot \frac{{d}^{2} \cdot c0}{{D}^{2} \cdot \left(w \cdot h\right)}\right)} \]
    3. Simplified69.4%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(2 \cdot \left(\frac{c0}{w} \cdot \left(\frac{\frac{d}{D}}{h} \cdot \frac{d}{D}\right)\right)\right)} \]
      Step-by-step derivation

      [Start]72.3

      \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{{d}^{2} \cdot c0}{{D}^{2} \cdot \left(w \cdot h\right)}\right) \]

      unpow2 [=>]72.3

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

      associate-/r* [=>]70.8

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

      unpow2 [=>]70.8

      \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{\frac{\color{blue}{\left(d \cdot d\right)} \cdot c0}{D \cdot D}}{w \cdot h}\right) \]

      *-commutative [=>]70.8

      \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{\frac{\color{blue}{c0 \cdot \left(d \cdot d\right)}}{D \cdot D}}{w \cdot h}\right) \]

      *-lft-identity [<=]70.8

      \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{\color{blue}{1 \cdot \frac{c0 \cdot \left(d \cdot d\right)}{D \cdot D}}}{w \cdot h}\right) \]

      associate-*l/ [<=]69.9

      \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \color{blue}{\left(\frac{1}{w \cdot h} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{D \cdot D}\right)}\right) \]

      associate-*r/ [=>]72.3

      \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \color{blue}{\frac{\frac{1}{w \cdot h} \cdot \left(c0 \cdot \left(d \cdot d\right)\right)}{D \cdot D}}\right) \]

      associate-/r* [=>]72.3

      \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{\color{blue}{\frac{\frac{1}{w}}{h}} \cdot \left(c0 \cdot \left(d \cdot d\right)\right)}{D \cdot D}\right) \]

      associate-*l/ [=>]73.4

      \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{\color{blue}{\frac{\frac{1}{w} \cdot \left(c0 \cdot \left(d \cdot d\right)\right)}{h}}}{D \cdot D}\right) \]

      associate-/r* [<=]72.2

      \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \color{blue}{\frac{\frac{1}{w} \cdot \left(c0 \cdot \left(d \cdot d\right)\right)}{h \cdot \left(D \cdot D\right)}}\right) \]

      associate-*l* [<=]74.5

      \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{\frac{1}{w} \cdot \left(c0 \cdot \left(d \cdot d\right)\right)}{\color{blue}{\left(h \cdot D\right) \cdot D}}\right) \]

      associate-*r/ [<=]71.9

      \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \color{blue}{\left(\frac{1}{w} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(h \cdot D\right) \cdot D}\right)}\right) \]

      associate-*l/ [=>]71.9

      \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \color{blue}{\frac{1 \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(h \cdot D\right) \cdot D}}{w}}\right) \]

      *-lft-identity [=>]71.9

      \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{\color{blue}{\frac{c0 \cdot \left(d \cdot d\right)}{\left(h \cdot D\right) \cdot D}}}{w}\right) \]

      associate-*r/ [<=]66.9

      \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{\color{blue}{c0 \cdot \frac{d \cdot d}{\left(h \cdot D\right) \cdot D}}}{w}\right) \]

      associate-*l/ [<=]66.9

      \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \color{blue}{\left(\frac{c0}{w} \cdot \frac{d \cdot d}{\left(h \cdot D\right) \cdot D}\right)}\right) \]

      times-frac [=>]69.4

      \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{c0}{w} \cdot \color{blue}{\left(\frac{d}{h \cdot D} \cdot \frac{d}{D}\right)}\right)\right) \]
    4. Applied egg-rr81.7%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \color{blue}{\frac{\left(\frac{c0}{w} \cdot \frac{d}{D \cdot h}\right) \cdot d}{D}}\right) \]
      Step-by-step derivation

      [Start]69.4

      \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{c0}{w} \cdot \left(\frac{\frac{d}{D}}{h} \cdot \frac{d}{D}\right)\right)\right) \]

      associate-*r* [=>]79.4

      \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \color{blue}{\left(\left(\frac{c0}{w} \cdot \frac{\frac{d}{D}}{h}\right) \cdot \frac{d}{D}\right)}\right) \]

      associate-*r/ [=>]79.4

      \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \color{blue}{\frac{\left(\frac{c0}{w} \cdot \frac{\frac{d}{D}}{h}\right) \cdot d}{D}}\right) \]

      div-inv [=>]79.4

      \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{\left(\frac{c0}{w} \cdot \color{blue}{\left(\frac{d}{D} \cdot \frac{1}{h}\right)}\right) \cdot d}{D}\right) \]

      frac-times [=>]81.7

      \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{\left(\frac{c0}{w} \cdot \color{blue}{\frac{d \cdot 1}{D \cdot h}}\right) \cdot d}{D}\right) \]

      *-commutative [<=]81.7

      \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{\left(\frac{c0}{w} \cdot \frac{\color{blue}{1 \cdot d}}{D \cdot h}\right) \cdot d}{D}\right) \]

      *-un-lft-identity [<=]81.7

      \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{\left(\frac{c0}{w} \cdot \frac{\color{blue}{d}}{D \cdot h}\right) \cdot d}{D}\right) \]

    if +inf.0 < (*.f64 (/.f64 c0 (*.f64 2 w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M)))))

    1. Initial program 0.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. Applied egg-rr0.6%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{c0 \cdot d}{1} \cdot \frac{d}{w \cdot \left(\left(h \cdot D\right) \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) \]
      Step-by-step derivation

      [Start]0.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) \]

      associate-*r* [=>]0.0

      \[ \frac{c0}{2 \cdot w} \cdot \left(\frac{\color{blue}{\left(c0 \cdot d\right) \cdot d}}{\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) \]

      *-un-lft-identity [=>]0.0

      \[ \frac{c0}{2 \cdot w} \cdot \left(\frac{\left(c0 \cdot d\right) \cdot d}{\color{blue}{1 \cdot \left(\left(w \cdot h\right) \cdot \left(D \cdot D\right)\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) \]

      times-frac [=>]0.0

      \[ \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{c0 \cdot d}{1} \cdot \frac{d}{\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) \]

      associate-*l* [=>]0.0

      \[ \frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot d}{1} \cdot \frac{d}{\color{blue}{w \cdot \left(h \cdot \left(D \cdot D\right)\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) \]

      associate-*r* [=>]0.6

      \[ \frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot d}{1} \cdot \frac{d}{w \cdot \color{blue}{\left(\left(h \cdot D\right) \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) \]
    3. Taylor expanded in c0 around -inf 0.6%

      \[\leadsto \color{blue}{-0.5 \cdot \frac{\left(\frac{{d}^{2}}{{D}^{2} \cdot \left(w \cdot h\right)} + -1 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(w \cdot h\right)}\right) \cdot {c0}^{2}}{w} + 0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}} \]
    4. Simplified36.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(0.25, \left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \left(h \cdot \left(M \cdot M\right)\right), \frac{0}{\frac{\frac{w}{c0}}{c0}}\right)} \]
      Step-by-step derivation

      [Start]0.6

      \[ -0.5 \cdot \frac{\left(\frac{{d}^{2}}{{D}^{2} \cdot \left(w \cdot h\right)} + -1 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(w \cdot h\right)}\right) \cdot {c0}^{2}}{w} + 0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}} \]

      +-commutative [=>]0.6

      \[ \color{blue}{0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}} + -0.5 \cdot \frac{\left(\frac{{d}^{2}}{{D}^{2} \cdot \left(w \cdot h\right)} + -1 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(w \cdot h\right)}\right) \cdot {c0}^{2}}{w}} \]

      fma-def [=>]0.6

      \[ \color{blue}{\mathsf{fma}\left(0.25, \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}, -0.5 \cdot \frac{\left(\frac{{d}^{2}}{{D}^{2} \cdot \left(w \cdot h\right)} + -1 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(w \cdot h\right)}\right) \cdot {c0}^{2}}{w}\right)} \]

      associate-/l* [=>]0.6

      \[ \mathsf{fma}\left(0.25, \color{blue}{\frac{{D}^{2}}{\frac{{d}^{2}}{{M}^{2} \cdot h}}}, -0.5 \cdot \frac{\left(\frac{{d}^{2}}{{D}^{2} \cdot \left(w \cdot h\right)} + -1 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(w \cdot h\right)}\right) \cdot {c0}^{2}}{w}\right) \]

      *-commutative [<=]0.6

      \[ \mathsf{fma}\left(0.25, \frac{{D}^{2}}{\frac{{d}^{2}}{\color{blue}{h \cdot {M}^{2}}}}, -0.5 \cdot \frac{\left(\frac{{d}^{2}}{{D}^{2} \cdot \left(w \cdot h\right)} + -1 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(w \cdot h\right)}\right) \cdot {c0}^{2}}{w}\right) \]

      associate-/r/ [=>]0.6

      \[ \mathsf{fma}\left(0.25, \color{blue}{\frac{{D}^{2}}{{d}^{2}} \cdot \left(h \cdot {M}^{2}\right)}, -0.5 \cdot \frac{\left(\frac{{d}^{2}}{{D}^{2} \cdot \left(w \cdot h\right)} + -1 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(w \cdot h\right)}\right) \cdot {c0}^{2}}{w}\right) \]

      unpow2 [=>]0.6

      \[ \mathsf{fma}\left(0.25, \frac{\color{blue}{D \cdot D}}{{d}^{2}} \cdot \left(h \cdot {M}^{2}\right), -0.5 \cdot \frac{\left(\frac{{d}^{2}}{{D}^{2} \cdot \left(w \cdot h\right)} + -1 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(w \cdot h\right)}\right) \cdot {c0}^{2}}{w}\right) \]

      unpow2 [=>]0.6

      \[ \mathsf{fma}\left(0.25, \frac{D \cdot D}{\color{blue}{d \cdot d}} \cdot \left(h \cdot {M}^{2}\right), -0.5 \cdot \frac{\left(\frac{{d}^{2}}{{D}^{2} \cdot \left(w \cdot h\right)} + -1 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(w \cdot h\right)}\right) \cdot {c0}^{2}}{w}\right) \]

      times-frac [=>]0.0

      \[ \mathsf{fma}\left(0.25, \color{blue}{\left(\frac{D}{d} \cdot \frac{D}{d}\right)} \cdot \left(h \cdot {M}^{2}\right), -0.5 \cdot \frac{\left(\frac{{d}^{2}}{{D}^{2} \cdot \left(w \cdot h\right)} + -1 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(w \cdot h\right)}\right) \cdot {c0}^{2}}{w}\right) \]

      unpow2 [=>]0.0

      \[ \mathsf{fma}\left(0.25, \left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \left(h \cdot \color{blue}{\left(M \cdot M\right)}\right), -0.5 \cdot \frac{\left(\frac{{d}^{2}}{{D}^{2} \cdot \left(w \cdot h\right)} + -1 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(w \cdot h\right)}\right) \cdot {c0}^{2}}{w}\right) \]

      associate-*r/ [=>]0.0

      \[ \mathsf{fma}\left(0.25, \left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \left(h \cdot \left(M \cdot M\right)\right), \color{blue}{\frac{-0.5 \cdot \left(\left(\frac{{d}^{2}}{{D}^{2} \cdot \left(w \cdot h\right)} + -1 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(w \cdot h\right)}\right) \cdot {c0}^{2}\right)}{w}}\right) \]
    5. Applied egg-rr37.8%

      \[\leadsto \mathsf{fma}\left(0.25, \color{blue}{\frac{\frac{D}{d} \cdot \left(h \cdot \left(M \cdot M\right)\right)}{\frac{d}{D}}}, \frac{0}{\frac{\frac{w}{c0}}{c0}}\right) \]
      Step-by-step derivation

      [Start]36.3

      \[ \mathsf{fma}\left(0.25, \left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \left(h \cdot \left(M \cdot M\right)\right), \frac{0}{\frac{\frac{w}{c0}}{c0}}\right) \]

      associate-*l* [=>]37.8

      \[ \mathsf{fma}\left(0.25, \color{blue}{\frac{D}{d} \cdot \left(\frac{D}{d} \cdot \left(h \cdot \left(M \cdot M\right)\right)\right)}, \frac{0}{\frac{\frac{w}{c0}}{c0}}\right) \]

      clear-num [=>]37.8

      \[ \mathsf{fma}\left(0.25, \color{blue}{\frac{1}{\frac{d}{D}}} \cdot \left(\frac{D}{d} \cdot \left(h \cdot \left(M \cdot M\right)\right)\right), \frac{0}{\frac{\frac{w}{c0}}{c0}}\right) \]

      associate-*l/ [=>]37.8

      \[ \mathsf{fma}\left(0.25, \color{blue}{\frac{1 \cdot \left(\frac{D}{d} \cdot \left(h \cdot \left(M \cdot M\right)\right)\right)}{\frac{d}{D}}}, \frac{0}{\frac{\frac{w}{c0}}{c0}}\right) \]

      *-un-lft-identity [<=]37.8

      \[ \mathsf{fma}\left(0.25, \frac{\color{blue}{\frac{D}{d} \cdot \left(h \cdot \left(M \cdot M\right)\right)}}{\frac{d}{D}}, \frac{0}{\frac{\frac{w}{c0}}{c0}}\right) \]
    6. Taylor expanded in w around 0 59.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\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) \leq \infty:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{d \cdot \left(\frac{c0}{w} \cdot \frac{d}{h \cdot D}\right)}{D}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(0.25, \frac{\frac{D}{d} \cdot \left(h \cdot \left(M \cdot M\right)\right)}{\frac{d}{D}}, 0\right)\\ \end{array} \]

Alternatives

Alternative 1
Accuracy45.9%
Cost8152
\[\begin{array}{l} t_0 := \mathsf{fma}\left(0.25, \left(h \cdot \left(M \cdot M\right)\right) \cdot \left(\frac{D}{d} \cdot \frac{D}{d}\right), 0\right)\\ \mathbf{if}\;c0 \leq -3.9 \cdot 10^{-33}:\\ \;\;\;\;\frac{c0}{\frac{2 \cdot w}{2 \cdot \left(\frac{d}{D} \cdot \frac{c0}{w \cdot \frac{D}{\frac{d}{h}}}\right)}}\\ \mathbf{elif}\;c0 \leq -8 \cdot 10^{-199}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c0 \leq 9.5 \cdot 10^{-279}:\\ \;\;\;\;\frac{{\left(\frac{d}{\frac{D}{c0}}\right)}^{2}}{h \cdot \left(w \cdot w\right)}\\ \mathbf{elif}\;c0 \leq 1.7 \cdot 10^{+16}:\\ \;\;\;\;0\\ \mathbf{elif}\;c0 \leq 1.7 \cdot 10^{+239}:\\ \;\;\;\;\frac{\frac{d}{D} \cdot \left(\frac{c0}{w} \cdot \frac{c0}{w \cdot h}\right)}{\frac{D}{d}}\\ \mathbf{elif}\;c0 \leq 2.6 \cdot 10^{+283}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{w} \cdot \left(\left(\frac{d}{D} \cdot \frac{d}{D}\right) \cdot \frac{\frac{c0}{w}}{h}\right)\\ \end{array} \]
Alternative 2
Accuracy46.6%
Cost1476
\[\begin{array}{l} \mathbf{if}\;c0 \leq -1.6 \cdot 10^{-31}:\\ \;\;\;\;\frac{c0}{\frac{2 \cdot w}{2 \cdot \left(\frac{d}{D} \cdot \frac{c0}{w \cdot \frac{D}{\frac{d}{h}}}\right)}}\\ \mathbf{elif}\;c0 \leq 3.3 \cdot 10^{+16}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{d}{D} \cdot \left(\frac{c0}{w} \cdot \frac{c0}{w \cdot h}\right)}{\frac{D}{d}}\\ \end{array} \]
Alternative 3
Accuracy46.3%
Cost1353
\[\begin{array}{l} \mathbf{if}\;c0 \leq -1.5 \cdot 10^{-102} \lor \neg \left(c0 \leq 2.1 \cdot 10^{+15}\right):\\ \;\;\;\;\frac{c0}{w} \cdot \left(\left(\frac{d}{D} \cdot \frac{d}{D}\right) \cdot \frac{\frac{c0}{w}}{h}\right)\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
Alternative 4
Accuracy45.5%
Cost1352
\[\begin{array}{l} t_0 := \frac{d}{D} \cdot \frac{d}{D}\\ \mathbf{if}\;c0 \leq -2.3 \cdot 10^{-103}:\\ \;\;\;\;\frac{c0}{w} \cdot \left(t_0 \cdot \frac{\frac{c0}{w}}{h}\right)\\ \mathbf{elif}\;c0 \leq 1.8 \cdot 10^{+16}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{c0}{w} \cdot \frac{c0}{w \cdot h}\right) \cdot t_0\\ \end{array} \]
Alternative 5
Accuracy45.1%
Cost1352
\[\begin{array}{l} \mathbf{if}\;c0 \leq -5.8 \cdot 10^{-34}:\\ \;\;\;\;d \cdot \frac{c0}{\frac{D}{\frac{\frac{c0}{w}}{\frac{w}{\frac{\frac{d}{h}}{D}}}}}\\ \mathbf{elif}\;c0 \leq 5.5 \cdot 10^{+15}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{c0}{w} \cdot \frac{c0}{w \cdot h}\right) \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right)\\ \end{array} \]
Alternative 6
Accuracy46.2%
Cost1352
\[\begin{array}{l} \mathbf{if}\;c0 \leq -2.75 \cdot 10^{-33}:\\ \;\;\;\;d \cdot \frac{c0}{\frac{D}{\frac{\frac{c0}{w}}{\frac{w}{\frac{\frac{d}{h}}{D}}}}}\\ \mathbf{elif}\;c0 \leq 1.68 \cdot 10^{+16}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{d}{D} \cdot \left(\frac{c0}{w} \cdot \frac{c0}{w \cdot h}\right)}{\frac{D}{d}}\\ \end{array} \]
Alternative 7
Accuracy33.2%
Cost64
\[0 \]

Reproduce?

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