Henrywood and Agarwal, Equation (13)

?

Percentage Accurate: 24.3% → 68.5%
Time: 34.2s
Precision: binary64
Cost: 11076

?

\[\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(D \cdot D\right) \cdot \left(w \cdot h\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 \left(\frac{d}{D} \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d}{D}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.25 \cdot \left(D \cdot \frac{h}{\frac{\frac{d}{M} \cdot \frac{d}{M}}{D}}\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)) (* (* D D) (* w h)))))
   (if (<= (* t_0 (+ t_1 (sqrt (- (* t_1 t_1) (* M M))))) INFINITY)
     (* t_0 (* 2.0 (* (/ d D) (* (/ c0 (* w h)) (/ d D)))))
     (* 0.25 (* D (/ h (/ (* (/ d M) (/ d M)) 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 t_0 = c0 / (2.0 * w);
	double t_1 = (c0 * (d * d)) / ((D * D) * (w * h));
	double tmp;
	if ((t_0 * (t_1 + sqrt(((t_1 * t_1) - (M * M))))) <= ((double) INFINITY)) {
		tmp = t_0 * (2.0 * ((d / D) * ((c0 / (w * h)) * (d / D))));
	} else {
		tmp = 0.25 * (D * (h / (((d / M) * (d / M)) / D)));
	}
	return tmp;
}
public static 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))) + Math.sqrt(((((c0 * (d * d)) / ((w * h) * (D * D))) * ((c0 * (d * d)) / ((w * h) * (D * D)))) - (M * M))));
}
public static 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)) / ((D * D) * (w * h));
	double tmp;
	if ((t_0 * (t_1 + Math.sqrt(((t_1 * t_1) - (M * M))))) <= Double.POSITIVE_INFINITY) {
		tmp = t_0 * (2.0 * ((d / D) * ((c0 / (w * h)) * (d / D))));
	} else {
		tmp = 0.25 * (D * (h / (((d / M) * (d / M)) / D)));
	}
	return tmp;
}
def code(c0, w, h, D, d, M):
	return (c0 / (2.0 * w)) * (((c0 * (d * d)) / ((w * h) * (D * D))) + math.sqrt(((((c0 * (d * d)) / ((w * h) * (D * D))) * ((c0 * (d * d)) / ((w * h) * (D * D)))) - (M * M))))
def code(c0, w, h, D, d, M):
	t_0 = c0 / (2.0 * w)
	t_1 = (c0 * (d * d)) / ((D * D) * (w * h))
	tmp = 0
	if (t_0 * (t_1 + math.sqrt(((t_1 * t_1) - (M * M))))) <= math.inf:
		tmp = t_0 * (2.0 * ((d / D) * ((c0 / (w * h)) * (d / D))))
	else:
		tmp = 0.25 * (D * (h / (((d / M) * (d / M)) / D)))
	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(D * D) * Float64(w * h)))
	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 / D) * Float64(Float64(c0 / Float64(w * h)) * Float64(d / D)))));
	else
		tmp = Float64(0.25 * Float64(D * Float64(h / Float64(Float64(Float64(d / M) * Float64(d / M)) / D))));
	end
	return tmp
end
function tmp = code(c0, w, h, D, d, M)
	tmp = (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))));
end
function tmp_2 = code(c0, w, h, D, d, M)
	t_0 = c0 / (2.0 * w);
	t_1 = (c0 * (d * d)) / ((D * D) * (w * h));
	tmp = 0.0;
	if ((t_0 * (t_1 + sqrt(((t_1 * t_1) - (M * M))))) <= Inf)
		tmp = t_0 * (2.0 * ((d / D) * ((c0 / (w * h)) * (d / D))));
	else
		tmp = 0.25 * (D * (h / (((d / M) * (d / M)) / D)));
	end
	tmp_2 = 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[(D * D), $MachinePrecision] * N[(w * h), $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 / D), $MachinePrecision] * N[(N[(c0 / N[(w * h), $MachinePrecision]), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.25 * N[(D * N[(h / N[(N[(N[(d / M), $MachinePrecision] * N[(d / M), $MachinePrecision]), $MachinePrecision] / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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(D \cdot D\right) \cdot \left(w \cdot h\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 \left(\frac{d}{D} \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d}{D}\right)\right)\right)\\

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


\end{array}

Local Percentage Accuracy vs ?

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 3 alternatives:

AlternativeAccuracySpeedup

Accuracy vs Speed

The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Bogosity?

Bogosity

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

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 75.8%

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

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

      [Start]75.8%

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

      times-frac [=>]70.1%

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

      fma-def [=>]68.9%

      \[ \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d \cdot d}{D \cdot D}, \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* [=>]69.3%

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

      difference-of-squares [=>]69.3%

      \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{\frac{d \cdot d}{D}}{D}, \sqrt{\color{blue}{\left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + M\right) \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M\right)}}\right) \]
    3. Taylor expanded in c0 around inf 69.3%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{\frac{d \cdot d}{D}}{D}, \sqrt{\color{blue}{\frac{{d}^{2} \cdot c0}{{D}^{2} \cdot \left(w \cdot h\right)}} \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{\frac{d \cdot d}{D}}{D} - M\right)}\right) \]
    4. Simplified71.4%

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

      [Start]69.3%

      \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{\frac{d \cdot d}{D}}{D}, \sqrt{\frac{{d}^{2} \cdot c0}{{D}^{2} \cdot \left(w \cdot h\right)} \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{\frac{d \cdot d}{D}}{D} - M\right)}\right) \]

      *-commutative [=>]69.3%

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

      unpow2 [=>]69.3%

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

      associate-/l/ [<=]68.9%

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

      associate-/r* [=>]68.9%

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

      associate-/r* [<=]69.3%

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

      unpow2 [=>]69.3%

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

      associate-/l/ [=>]69.2%

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

      unpow2 [<=]69.2%

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

      *-commutative [<=]69.2%

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

      unpow2 [=>]69.2%

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

      associate-*r* [=>]71.4%

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

      *-commutative [=>]71.4%

      \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{\frac{d \cdot d}{D}}{D}, \sqrt{\frac{\left(d \cdot d\right) \cdot c0}{\left(\color{blue}{\left(D \cdot h\right)} \cdot D\right) \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{\frac{d \cdot d}{D}}{D} - M\right)}\right) \]
    5. Taylor expanded in c0 around inf 73.6%

      \[\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)} \]
    6. Simplified76.8%

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

      [Start]73.6%

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

      times-frac [=>]72.2%

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

      unpow2 [=>]72.2%

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

      unpow2 [=>]72.2%

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

      times-frac [=>]76.8%

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

      unpow2 [<=]76.8%

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

      *-commutative [<=]76.8%

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

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

      [Start]76.8%

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

      associate-*l/ [=>]77.9%

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

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

      [Start]77.9%

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

      pow2 [<=]77.9%

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

      associate-*l/ [<=]76.8%

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

      associate-*r* [=>]86.2%

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

      *-commutative [=>]86.2%

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(0.5 \cdot \frac{{D}^{2} \cdot \left(w \cdot \left({M}^{2} \cdot h\right)\right)}{{d}^{2} \cdot c0} + -1 \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\right)\right)} \]
    3. Simplified34.4%

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

      [Start]1.8%

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

      fma-def [=>]1.8%

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

      associate-/l* [=>]1.8%

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

      *-commutative [=>]1.8%

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

      unpow2 [=>]1.8%

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

      unpow2 [=>]1.8%

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

      unpow2 [=>]1.8%

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

      associate-*r* [=>]1.8%

      \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(0.5, \frac{D \cdot D}{\frac{\left(d \cdot d\right) \cdot c0}{w \cdot \left(h \cdot \left(M \cdot M\right)\right)}}, \color{blue}{\left(-1 \cdot \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)\right) \cdot c0}\right) \]
    4. Taylor expanded in c0 around 0 46.6%

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

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

      [Start]46.6%

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

      associate-/l* [=>]46.6%

      \[ 0.25 \cdot \color{blue}{\frac{{D}^{2}}{\frac{{d}^{2}}{h \cdot {M}^{2}}}} \]

      unpow2 [=>]46.6%

      \[ 0.25 \cdot \frac{\color{blue}{D \cdot D}}{\frac{{d}^{2}}{h \cdot {M}^{2}}} \]

      unpow2 [=>]46.6%

      \[ 0.25 \cdot \frac{D \cdot D}{\frac{\color{blue}{d \cdot d}}{h \cdot {M}^{2}}} \]

      unpow2 [=>]46.6%

      \[ 0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{h \cdot \color{blue}{\left(M \cdot M\right)}}} \]
    6. Applied egg-rr54.2%

      \[\leadsto 0.25 \cdot \color{blue}{\left(\left(D \cdot D\right) \cdot \frac{1}{\frac{d}{\frac{h \cdot \left(M \cdot M\right)}{d}}}\right)} \]
      Step-by-step derivation

      [Start]46.6%

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

      div-inv [=>]46.7%

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

      associate-/l* [=>]54.2%

      \[ 0.25 \cdot \left(\left(D \cdot D\right) \cdot \frac{1}{\color{blue}{\frac{d}{\frac{h \cdot \left(M \cdot M\right)}{d}}}}\right) \]
    7. Simplified69.5%

      \[\leadsto 0.25 \cdot \color{blue}{\left(D \cdot \left(D \cdot \left(\frac{1}{d} \cdot \frac{h}{\frac{d}{M \cdot M}}\right)\right)\right)} \]
      Step-by-step derivation

      [Start]54.2%

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

      associate-*l* [=>]68.3%

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

      associate-/r/ [=>]68.3%

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

      unpow2 [<=]68.3%

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

      associate-/l* [=>]69.5%

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

      unpow2 [=>]69.5%

      \[ 0.25 \cdot \left(D \cdot \left(D \cdot \left(\frac{1}{d} \cdot \frac{h}{\frac{d}{\color{blue}{M \cdot M}}}\right)\right)\right) \]
    8. Taylor expanded in D around 0 57.2%

      \[\leadsto 0.25 \cdot \left(D \cdot \color{blue}{\frac{D \cdot \left(h \cdot {M}^{2}\right)}{{d}^{2}}}\right) \]
    9. Simplified71.8%

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

      [Start]57.2%

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

      *-commutative [=>]57.2%

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

      unpow2 [=>]57.2%

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

      unpow2 [=>]57.2%

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

      times-frac [=>]65.3%

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

      associate-/l* [=>]68.2%

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

      times-frac [<=]63.6%

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

      *-commutative [<=]63.6%

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

      associate-/l* [=>]69.6%

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

      associate-*r/ [=>]59.1%

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

      times-frac [=>]71.8%

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

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

Alternatives

Alternative 1
Accuracy68.5%
Cost11076
\[\begin{array}{l} t_0 := \frac{c0}{2 \cdot w}\\ t_1 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(D \cdot D\right) \cdot \left(w \cdot h\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 \left(\frac{d}{D} \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d}{D}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.25 \cdot \left(D \cdot \frac{h}{\frac{\frac{d}{M} \cdot \frac{d}{M}}{D}}\right)\\ \end{array} \]
Alternative 2
Accuracy48.7%
Cost960
\[0.25 \cdot \left(D \cdot \frac{h}{\frac{\frac{d}{M} \cdot \frac{d}{M}}{D}}\right) \]
Alternative 3
Accuracy33.5%
Cost64
\[0 \]

Reproduce?

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