Henrywood and Agarwal, Equation (13)

Percentage Accurate: 24.2% → 53.3%
Time: 33.5s
Alternatives: 4
Speedup: 30.2×

Specification

?
\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\ \frac{c0}{2 \cdot w} \cdot \left(t\_0 + \sqrt{t\_0 \cdot t\_0 - M \cdot M}\right) \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (let* ((t_0 (/ (* c0 (* d d)) (* (* w h) (* D D)))))
   (* (/ c0 (* 2.0 w)) (+ t_0 (sqrt (- (* t_0 t_0) (* M M)))))))
double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
	return (c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))));
}
real(8) function code(c0, w, h, d, d_1, m)
    real(8), intent (in) :: c0
    real(8), intent (in) :: w
    real(8), intent (in) :: h
    real(8), intent (in) :: d
    real(8), intent (in) :: d_1
    real(8), intent (in) :: m
    real(8) :: t_0
    t_0 = (c0 * (d_1 * d_1)) / ((w * h) * (d * d))
    code = (c0 / (2.0d0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (m * m))))
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
	return (c0 / (2.0 * w)) * (t_0 + Math.sqrt(((t_0 * t_0) - (M * M))));
}
def code(c0, w, h, D, d, M):
	t_0 = (c0 * (d * d)) / ((w * h) * (D * D))
	return (c0 / (2.0 * w)) * (t_0 + math.sqrt(((t_0 * t_0) - (M * M))))
function code(c0, w, h, D, d, M)
	t_0 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D)))
	return Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_0 + sqrt(Float64(Float64(t_0 * t_0) - Float64(M * M)))))
end
function tmp = code(c0, w, h, D, d, M)
	t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
	tmp = (c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))));
end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 + N[Sqrt[N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
\frac{c0}{2 \cdot w} \cdot \left(t\_0 + \sqrt{t\_0 \cdot t\_0 - M \cdot M}\right)
\end{array}
\end{array}

Sampling outcomes in binary64 precision:

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.

Accuracy vs Speed?

Herbie found 4 alternatives:

AlternativeAccuracySpeedup
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.

Initial Program: 24.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\ \frac{c0}{2 \cdot w} \cdot \left(t\_0 + \sqrt{t\_0 \cdot t\_0 - M \cdot M}\right) \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (let* ((t_0 (/ (* c0 (* d d)) (* (* w h) (* D D)))))
   (* (/ c0 (* 2.0 w)) (+ t_0 (sqrt (- (* t_0 t_0) (* M M)))))))
double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
	return (c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))));
}
real(8) function code(c0, w, h, d, d_1, m)
    real(8), intent (in) :: c0
    real(8), intent (in) :: w
    real(8), intent (in) :: h
    real(8), intent (in) :: d
    real(8), intent (in) :: d_1
    real(8), intent (in) :: m
    real(8) :: t_0
    t_0 = (c0 * (d_1 * d_1)) / ((w * h) * (d * d))
    code = (c0 / (2.0d0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (m * m))))
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
	return (c0 / (2.0 * w)) * (t_0 + Math.sqrt(((t_0 * t_0) - (M * M))));
}
def code(c0, w, h, D, d, M):
	t_0 = (c0 * (d * d)) / ((w * h) * (D * D))
	return (c0 / (2.0 * w)) * (t_0 + math.sqrt(((t_0 * t_0) - (M * M))))
function code(c0, w, h, D, d, M)
	t_0 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D)))
	return Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_0 + sqrt(Float64(Float64(t_0 * t_0) - Float64(M * M)))))
end
function tmp = code(c0, w, h, D, d, M)
	t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
	tmp = (c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))));
end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 + N[Sqrt[N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
\frac{c0}{2 \cdot w} \cdot \left(t\_0 + \sqrt{t\_0 \cdot t\_0 - M \cdot M}\right)
\end{array}
\end{array}

Alternative 1: 53.3% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\left(\frac{d}{D}\right)}^{2}\\ t_1 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(D \cdot D\right) \cdot \left(w \cdot h\right)}\\ \mathbf{if}\;\frac{c0}{2 \cdot w} \cdot \left(t\_1 + \sqrt{t\_1 \cdot t\_1 - M \cdot M}\right) \leq \infty:\\ \;\;\;\;c0 \cdot \left(\frac{-0.5}{h} \cdot \frac{c0 \cdot \left(\frac{t\_0}{w \cdot \sqrt[3]{-1}} - \frac{t\_0}{w}\right)}{w}\right)\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{0}{w}\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (let* ((t_0 (pow (/ d D) 2.0)) (t_1 (/ (* c0 (* d d)) (* (* D D) (* w h)))))
   (if (<=
        (* (/ c0 (* 2.0 w)) (+ t_1 (sqrt (- (* t_1 t_1) (* M M)))))
        INFINITY)
     (* c0 (* (/ -0.5 h) (/ (* c0 (- (/ t_0 (* w (cbrt -1.0))) (/ t_0 w))) w)))
     (* c0 (/ 0.0 w)))))
double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = pow((d / D), 2.0);
	double t_1 = (c0 * (d * d)) / ((D * D) * (w * h));
	double tmp;
	if (((c0 / (2.0 * w)) * (t_1 + sqrt(((t_1 * t_1) - (M * M))))) <= ((double) INFINITY)) {
		tmp = c0 * ((-0.5 / h) * ((c0 * ((t_0 / (w * cbrt(-1.0))) - (t_0 / w))) / w));
	} else {
		tmp = c0 * (0.0 / w);
	}
	return tmp;
}
public static double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = Math.pow((d / D), 2.0);
	double t_1 = (c0 * (d * d)) / ((D * D) * (w * h));
	double tmp;
	if (((c0 / (2.0 * w)) * (t_1 + Math.sqrt(((t_1 * t_1) - (M * M))))) <= Double.POSITIVE_INFINITY) {
		tmp = c0 * ((-0.5 / h) * ((c0 * ((t_0 / (w * Math.cbrt(-1.0))) - (t_0 / w))) / w));
	} else {
		tmp = c0 * (0.0 / w);
	}
	return tmp;
}
function code(c0, w, h, D, d, M)
	t_0 = Float64(d / D) ^ 2.0
	t_1 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(D * D) * Float64(w * h)))
	tmp = 0.0
	if (Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_1 + sqrt(Float64(Float64(t_1 * t_1) - Float64(M * M))))) <= Inf)
		tmp = Float64(c0 * Float64(Float64(-0.5 / h) * Float64(Float64(c0 * Float64(Float64(t_0 / Float64(w * cbrt(-1.0))) - Float64(t_0 / w))) / w)));
	else
		tmp = Float64(c0 * Float64(0.0 / w));
	end
	return tmp
end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[Power[N[(d / D), $MachinePrecision], 2.0], $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[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * 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[(c0 * N[(N[(-0.5 / h), $MachinePrecision] * N[(N[(c0 * N[(N[(t$95$0 / N[(w * N[Power[-1.0, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(t$95$0 / w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(0.0 / w), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\left(\frac{d}{D}\right)}^{2}\\
t_1 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(D \cdot D\right) \cdot \left(w \cdot h\right)}\\
\mathbf{if}\;\frac{c0}{2 \cdot w} \cdot \left(t\_1 + \sqrt{t\_1 \cdot t\_1 - M \cdot M}\right) \leq \infty:\\
\;\;\;\;c0 \cdot \left(\frac{-0.5}{h} \cdot \frac{c0 \cdot \left(\frac{t\_0}{w \cdot \sqrt[3]{-1}} - \frac{t\_0}{w}\right)}{w}\right)\\

\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{0}{w}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (/.f64 c0 (*.f64 #s(literal 2 binary64) 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 73.9%

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

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

      \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \color{blue}{\frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
    5. Step-by-step derivation
      1. *-commutative74.9%

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \color{blue}{\left(w \cdot h\right)}}\right)}{2 \cdot w} \]
      2. add-cbrt-cube64.1%

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \color{blue}{\sqrt[3]{\left(\left(w \cdot h\right) \cdot \left(w \cdot h\right)\right) \cdot \left(w \cdot h\right)}}}\right)}{2 \cdot w} \]
      3. pow1/337.7%

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \color{blue}{{\left(\left(\left(w \cdot h\right) \cdot \left(w \cdot h\right)\right) \cdot \left(w \cdot h\right)\right)}^{0.3333333333333333}}}\right)}{2 \cdot w} \]
      4. pow337.7%

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot {\color{blue}{\left({\left(w \cdot h\right)}^{3}\right)}}^{0.3333333333333333}}\right)}{2 \cdot w} \]
      5. *-commutative37.7%

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot {\left({\color{blue}{\left(h \cdot w\right)}}^{3}\right)}^{0.3333333333333333}}\right)}{2 \cdot w} \]
    6. Applied egg-rr37.7%

      \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \color{blue}{{\left({\left(h \cdot w\right)}^{3}\right)}^{0.3333333333333333}}}\right)}{2 \cdot w} \]
    7. Taylor expanded in h around -inf 75.7%

      \[\leadsto c0 \cdot \color{blue}{\left(-0.5 \cdot \frac{-1 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot w} + \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(w \cdot \sqrt[3]{-1}\right)}}{h \cdot w}\right)} \]
    8. Step-by-step derivation
      1. +-commutative75.7%

        \[\leadsto c0 \cdot \left(-0.5 \cdot \frac{\color{blue}{\frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(w \cdot \sqrt[3]{-1}\right)} + -1 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot w}}}{h \cdot w}\right) \]
      2. mul-1-neg75.7%

        \[\leadsto c0 \cdot \left(-0.5 \cdot \frac{\frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(w \cdot \sqrt[3]{-1}\right)} + \color{blue}{\left(-\frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot w}\right)}}{h \cdot w}\right) \]
      3. unsub-neg75.7%

        \[\leadsto c0 \cdot \left(-0.5 \cdot \frac{\color{blue}{\frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(w \cdot \sqrt[3]{-1}\right)} - \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot w}}}{h \cdot w}\right) \]
      4. associate-/l*74.2%

        \[\leadsto c0 \cdot \left(-0.5 \cdot \frac{\color{blue}{c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(w \cdot \sqrt[3]{-1}\right)}} - \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot w}}{h \cdot w}\right) \]
      5. associate-/l*76.4%

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

      \[\leadsto c0 \cdot \color{blue}{\left(-0.5 \cdot \frac{c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(w \cdot \sqrt[3]{-1}\right)} - c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot w}}{h \cdot w}\right)} \]
    10. Step-by-step derivation
      1. pow176.4%

        \[\leadsto \color{blue}{{\left(c0 \cdot \left(-0.5 \cdot \frac{c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(w \cdot \sqrt[3]{-1}\right)} - c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot w}}{h \cdot w}\right)\right)}^{1}} \]
    11. Applied egg-rr80.0%

      \[\leadsto \color{blue}{{\left(c0 \cdot \frac{-0.5 \cdot \left(c0 \cdot \left(\frac{{\left(\frac{d}{D}\right)}^{2}}{w \cdot \sqrt[3]{-1}} - \frac{{\left(\frac{d}{D}\right)}^{2}}{w}\right)\right)}{h \cdot w}\right)}^{1}} \]
    12. Step-by-step derivation
      1. unpow180.0%

        \[\leadsto \color{blue}{c0 \cdot \frac{-0.5 \cdot \left(c0 \cdot \left(\frac{{\left(\frac{d}{D}\right)}^{2}}{w \cdot \sqrt[3]{-1}} - \frac{{\left(\frac{d}{D}\right)}^{2}}{w}\right)\right)}{h \cdot w}} \]
      2. times-frac80.1%

        \[\leadsto c0 \cdot \color{blue}{\left(\frac{-0.5}{h} \cdot \frac{c0 \cdot \left(\frac{{\left(\frac{d}{D}\right)}^{2}}{w \cdot \sqrt[3]{-1}} - \frac{{\left(\frac{d}{D}\right)}^{2}}{w}\right)}{w}\right)} \]
    13. Simplified80.1%

      \[\leadsto \color{blue}{c0 \cdot \left(\frac{-0.5}{h} \cdot \frac{c0 \cdot \left(\frac{{\left(\frac{d}{D}\right)}^{2}}{w \cdot \sqrt[3]{-1}} - \frac{{\left(\frac{d}{D}\right)}^{2}}{w}\right)}{w}\right)} \]

    if +inf.0 < (*.f64 (/.f64 c0 (*.f64 #s(literal 2 binary64) 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. Simplified11.1%

      \[\leadsto \color{blue}{c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right) \cdot \mathsf{fma}\left(\frac{c0}{w \cdot \left(h \cdot D\right)}, \frac{d \cdot d}{D}, -M\right)}\right)}{2 \cdot w}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. associate-*r/11.1%

        \[\leadsto \color{blue}{\frac{c0 \cdot \mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right) \cdot \mathsf{fma}\left(\frac{c0}{w \cdot \left(h \cdot D\right)}, \frac{d \cdot d}{D}, -M\right)}\right)}{2 \cdot w}} \]
    5. Applied egg-rr11.6%

      \[\leadsto \color{blue}{\frac{c0 \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, {\left(\frac{d}{D}\right)}^{2}, \sqrt{\mathsf{fma}\left(\frac{c0}{w \cdot h}, {\left(\frac{d}{D}\right)}^{2}, M\right) \cdot \mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{{d}^{2}}{D}, -M\right)}\right)}{w \cdot 2}} \]
    6. Step-by-step derivation
      1. associate-/l*11.6%

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

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

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

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

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

      \[\leadsto c0 \cdot \color{blue}{\left(-0.5 \cdot \frac{c0 \cdot \left(-1 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)} + \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)}{w}\right)} \]
    9. Step-by-step derivation
      1. Simplified49.1%

        \[\leadsto c0 \cdot \color{blue}{\frac{0}{w}} \]
    10. Recombined 2 regimes into one program.
    11. Final simplification58.4%

      \[\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:\\ \;\;\;\;c0 \cdot \left(\frac{-0.5}{h} \cdot \frac{c0 \cdot \left(\frac{{\left(\frac{d}{D}\right)}^{2}}{w \cdot \sqrt[3]{-1}} - \frac{{\left(\frac{d}{D}\right)}^{2}}{w}\right)}{w}\right)\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{0}{w}\\ \end{array} \]
    12. Add Preprocessing

    Alternative 2: 53.5% accurate, 0.4× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(D \cdot D\right) \cdot \left(w \cdot h\right)}\\ \mathbf{if}\;\frac{c0}{2 \cdot w} \cdot \left(t\_0 + \sqrt{t\_0 \cdot t\_0 - M \cdot M}\right) \leq \infty:\\ \;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, c0 \cdot \left(d \cdot \frac{d}{\left(w \cdot h\right) \cdot {D}^{2}}\right)\right)}{2 \cdot w}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{0}{w}\\ \end{array} \end{array} \]
    (FPCore (c0 w h D d M)
     :precision binary64
     (let* ((t_0 (/ (* c0 (* d d)) (* (* D D) (* w h)))))
       (if (<=
            (* (/ c0 (* 2.0 w)) (+ t_0 (sqrt (- (* t_0 t_0) (* M M)))))
            INFINITY)
         (*
          c0
          (/
           (fma
            c0
            (* d (/ d (* D (* w (* h D)))))
            (* c0 (* d (/ d (* (* w h) (pow D 2.0))))))
           (* 2.0 w)))
         (* c0 (/ 0.0 w)))))
    double code(double c0, double w, double h, double D, double d, double M) {
    	double t_0 = (c0 * (d * d)) / ((D * D) * (w * h));
    	double tmp;
    	if (((c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))))) <= ((double) INFINITY)) {
    		tmp = c0 * (fma(c0, (d * (d / (D * (w * (h * D))))), (c0 * (d * (d / ((w * h) * pow(D, 2.0)))))) / (2.0 * w));
    	} else {
    		tmp = c0 * (0.0 / w);
    	}
    	return tmp;
    }
    
    function code(c0, w, h, D, d, M)
    	t_0 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(D * D) * Float64(w * h)))
    	tmp = 0.0
    	if (Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_0 + sqrt(Float64(Float64(t_0 * t_0) - Float64(M * M))))) <= Inf)
    		tmp = Float64(c0 * Float64(fma(c0, Float64(d * Float64(d / Float64(D * Float64(w * Float64(h * D))))), Float64(c0 * Float64(d * Float64(d / Float64(Float64(w * h) * (D ^ 2.0)))))) / Float64(2.0 * w)));
    	else
    		tmp = Float64(c0 * Float64(0.0 / w));
    	end
    	return tmp
    end
    
    code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(D * D), $MachinePrecision] * N[(w * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 + N[Sqrt[N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(c0 * N[(N[(c0 * N[(d * N[(d / N[(D * N[(w * N[(h * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(c0 * N[(d * N[(d / N[(N[(w * h), $MachinePrecision] * N[Power[D, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(0.0 / w), $MachinePrecision]), $MachinePrecision]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(D \cdot D\right) \cdot \left(w \cdot h\right)}\\
    \mathbf{if}\;\frac{c0}{2 \cdot w} \cdot \left(t\_0 + \sqrt{t\_0 \cdot t\_0 - M \cdot M}\right) \leq \infty:\\
    \;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, c0 \cdot \left(d \cdot \frac{d}{\left(w \cdot h\right) \cdot {D}^{2}}\right)\right)}{2 \cdot w}\\
    
    \mathbf{else}:\\
    \;\;\;\;c0 \cdot \frac{0}{w}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (*.f64 (/.f64 c0 (*.f64 #s(literal 2 binary64) 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 73.9%

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

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

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \color{blue}{\frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
      5. Step-by-step derivation
        1. associate-/l*75.9%

          \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \color{blue}{c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
        2. associate-/r*72.1%

          \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, c0 \cdot \color{blue}{\frac{\frac{{d}^{2}}{{D}^{2}}}{h \cdot w}}\right)}{2 \cdot w} \]
      6. Simplified72.1%

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \color{blue}{c0 \cdot \frac{\frac{{d}^{2}}{{D}^{2}}}{h \cdot w}}\right)}{2 \cdot w} \]
      7. Step-by-step derivation
        1. associate-/l/75.9%

          \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, c0 \cdot \color{blue}{\frac{{d}^{2}}{\left(h \cdot w\right) \cdot {D}^{2}}}\right)}{2 \cdot w} \]
        2. unpow275.9%

          \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, c0 \cdot \frac{\color{blue}{d \cdot d}}{\left(h \cdot w\right) \cdot {D}^{2}}\right)}{2 \cdot w} \]
        3. *-commutative75.9%

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

          \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, c0 \cdot \frac{d \cdot d}{\color{blue}{\left(D \cdot D\right)} \cdot \left(h \cdot w\right)}\right)}{2 \cdot w} \]
        5. associate-*r*77.0%

          \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, c0 \cdot \frac{d \cdot d}{\color{blue}{D \cdot \left(D \cdot \left(h \cdot w\right)\right)}}\right)}{2 \cdot w} \]
        6. associate-*r*77.0%

          \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, c0 \cdot \frac{d \cdot d}{D \cdot \color{blue}{\left(\left(D \cdot h\right) \cdot w\right)}}\right)}{2 \cdot w} \]
        7. *-commutative77.0%

          \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, c0 \cdot \frac{d \cdot d}{D \cdot \color{blue}{\left(w \cdot \left(D \cdot h\right)\right)}}\right)}{2 \cdot w} \]
        8. rem-cube-cbrt76.9%

          \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, c0 \cdot \frac{d \cdot d}{D \cdot \left(w \cdot \color{blue}{{\left(\sqrt[3]{D \cdot h}\right)}^{3}}\right)}\right)}{2 \cdot w} \]
        9. associate-*r/79.4%

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

          \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, c0 \cdot \color{blue}{\left(\frac{d}{D \cdot \left(w \cdot {\left(\sqrt[3]{D \cdot h}\right)}^{3}\right)} \cdot d\right)}\right)}{2 \cdot w} \]
        11. associate-/r*79.6%

          \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, c0 \cdot \left(\color{blue}{\frac{\frac{d}{D}}{w \cdot {\left(\sqrt[3]{D \cdot h}\right)}^{3}}} \cdot d\right)\right)}{2 \cdot w} \]
        12. rem-cube-cbrt79.7%

          \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, c0 \cdot \left(\frac{\frac{d}{D}}{w \cdot \color{blue}{\left(D \cdot h\right)}} \cdot d\right)\right)}{2 \cdot w} \]
        13. *-commutative79.7%

          \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, c0 \cdot \left(\frac{\frac{d}{D}}{\color{blue}{\left(D \cdot h\right) \cdot w}} \cdot d\right)\right)}{2 \cdot w} \]
        14. associate-*r*79.7%

          \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, c0 \cdot \left(\frac{\frac{d}{D}}{\color{blue}{D \cdot \left(h \cdot w\right)}} \cdot d\right)\right)}{2 \cdot w} \]
        15. associate-/r*79.5%

          \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, c0 \cdot \left(\color{blue}{\frac{d}{D \cdot \left(D \cdot \left(h \cdot w\right)\right)}} \cdot d\right)\right)}{2 \cdot w} \]
        16. associate-*r*78.5%

          \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, c0 \cdot \left(\frac{d}{\color{blue}{\left(D \cdot D\right) \cdot \left(h \cdot w\right)}} \cdot d\right)\right)}{2 \cdot w} \]
        17. unpow278.5%

          \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, c0 \cdot \left(\frac{d}{\color{blue}{{D}^{2}} \cdot \left(h \cdot w\right)} \cdot d\right)\right)}{2 \cdot w} \]
        18. *-commutative78.5%

          \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, c0 \cdot \left(\frac{d}{\color{blue}{\left(h \cdot w\right) \cdot {D}^{2}}} \cdot d\right)\right)}{2 \cdot w} \]
      8. Applied egg-rr78.5%

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

      if +inf.0 < (*.f64 (/.f64 c0 (*.f64 #s(literal 2 binary64) 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. Simplified11.1%

        \[\leadsto \color{blue}{c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right) \cdot \mathsf{fma}\left(\frac{c0}{w \cdot \left(h \cdot D\right)}, \frac{d \cdot d}{D}, -M\right)}\right)}{2 \cdot w}} \]
      3. Add Preprocessing
      4. Step-by-step derivation
        1. associate-*r/11.1%

          \[\leadsto \color{blue}{\frac{c0 \cdot \mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right) \cdot \mathsf{fma}\left(\frac{c0}{w \cdot \left(h \cdot D\right)}, \frac{d \cdot d}{D}, -M\right)}\right)}{2 \cdot w}} \]
      5. Applied egg-rr11.6%

        \[\leadsto \color{blue}{\frac{c0 \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, {\left(\frac{d}{D}\right)}^{2}, \sqrt{\mathsf{fma}\left(\frac{c0}{w \cdot h}, {\left(\frac{d}{D}\right)}^{2}, M\right) \cdot \mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{{d}^{2}}{D}, -M\right)}\right)}{w \cdot 2}} \]
      6. Step-by-step derivation
        1. associate-/l*11.6%

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

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

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

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

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

        \[\leadsto c0 \cdot \color{blue}{\left(-0.5 \cdot \frac{c0 \cdot \left(-1 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)} + \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)}{w}\right)} \]
      9. Step-by-step derivation
        1. Simplified49.1%

          \[\leadsto c0 \cdot \color{blue}{\frac{0}{w}} \]
      10. Recombined 2 regimes into one program.
      11. Final simplification57.9%

        \[\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:\\ \;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, c0 \cdot \left(d \cdot \frac{d}{\left(w \cdot h\right) \cdot {D}^{2}}\right)\right)}{2 \cdot w}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{0}{w}\\ \end{array} \]
      12. Add Preprocessing

      Alternative 3: 53.6% accurate, 0.6× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(D \cdot D\right) \cdot \left(w \cdot h\right)}\\ \mathbf{if}\;\frac{c0}{2 \cdot w} \cdot \left(t\_0 + \sqrt{t\_0 \cdot t\_0 - M \cdot M}\right) \leq \infty:\\ \;\;\;\;c0 \cdot \frac{2 \cdot \left({\left(\frac{d}{D}\right)}^{2} \cdot \frac{c0}{w \cdot h}\right)}{2 \cdot w}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{0}{w}\\ \end{array} \end{array} \]
      (FPCore (c0 w h D d M)
       :precision binary64
       (let* ((t_0 (/ (* c0 (* d d)) (* (* D D) (* w h)))))
         (if (<=
              (* (/ c0 (* 2.0 w)) (+ t_0 (sqrt (- (* t_0 t_0) (* M M)))))
              INFINITY)
           (* c0 (/ (* 2.0 (* (pow (/ d D) 2.0) (/ c0 (* w h)))) (* 2.0 w)))
           (* c0 (/ 0.0 w)))))
      double code(double c0, double w, double h, double D, double d, double M) {
      	double t_0 = (c0 * (d * d)) / ((D * D) * (w * h));
      	double tmp;
      	if (((c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))))) <= ((double) INFINITY)) {
      		tmp = c0 * ((2.0 * (pow((d / D), 2.0) * (c0 / (w * h)))) / (2.0 * w));
      	} else {
      		tmp = c0 * (0.0 / w);
      	}
      	return tmp;
      }
      
      public static double code(double c0, double w, double h, double D, double d, double M) {
      	double t_0 = (c0 * (d * d)) / ((D * D) * (w * h));
      	double tmp;
      	if (((c0 / (2.0 * w)) * (t_0 + Math.sqrt(((t_0 * t_0) - (M * M))))) <= Double.POSITIVE_INFINITY) {
      		tmp = c0 * ((2.0 * (Math.pow((d / D), 2.0) * (c0 / (w * h)))) / (2.0 * w));
      	} else {
      		tmp = c0 * (0.0 / w);
      	}
      	return tmp;
      }
      
      def code(c0, w, h, D, d, M):
      	t_0 = (c0 * (d * d)) / ((D * D) * (w * h))
      	tmp = 0
      	if ((c0 / (2.0 * w)) * (t_0 + math.sqrt(((t_0 * t_0) - (M * M))))) <= math.inf:
      		tmp = c0 * ((2.0 * (math.pow((d / D), 2.0) * (c0 / (w * h)))) / (2.0 * w))
      	else:
      		tmp = c0 * (0.0 / w)
      	return tmp
      
      function code(c0, w, h, D, d, M)
      	t_0 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(D * D) * Float64(w * h)))
      	tmp = 0.0
      	if (Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_0 + sqrt(Float64(Float64(t_0 * t_0) - Float64(M * M))))) <= Inf)
      		tmp = Float64(c0 * Float64(Float64(2.0 * Float64((Float64(d / D) ^ 2.0) * Float64(c0 / Float64(w * h)))) / Float64(2.0 * w)));
      	else
      		tmp = Float64(c0 * Float64(0.0 / w));
      	end
      	return tmp
      end
      
      function tmp_2 = code(c0, w, h, D, d, M)
      	t_0 = (c0 * (d * d)) / ((D * D) * (w * h));
      	tmp = 0.0;
      	if (((c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))))) <= Inf)
      		tmp = c0 * ((2.0 * (((d / D) ^ 2.0) * (c0 / (w * h)))) / (2.0 * w));
      	else
      		tmp = c0 * (0.0 / w);
      	end
      	tmp_2 = tmp;
      end
      
      code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(D * D), $MachinePrecision] * N[(w * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 + N[Sqrt[N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(c0 * N[(N[(2.0 * N[(N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision] * N[(c0 / N[(w * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(0.0 / w), $MachinePrecision]), $MachinePrecision]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(D \cdot D\right) \cdot \left(w \cdot h\right)}\\
      \mathbf{if}\;\frac{c0}{2 \cdot w} \cdot \left(t\_0 + \sqrt{t\_0 \cdot t\_0 - M \cdot M}\right) \leq \infty:\\
      \;\;\;\;c0 \cdot \frac{2 \cdot \left({\left(\frac{d}{D}\right)}^{2} \cdot \frac{c0}{w \cdot h}\right)}{2 \cdot w}\\
      
      \mathbf{else}:\\
      \;\;\;\;c0 \cdot \frac{0}{w}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if (*.f64 (/.f64 c0 (*.f64 #s(literal 2 binary64) 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 73.9%

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

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

          \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \color{blue}{\frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
        5. Step-by-step derivation
          1. associate-/l*75.9%

            \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \color{blue}{c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
          2. associate-/r*72.1%

            \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, c0 \cdot \color{blue}{\frac{\frac{{d}^{2}}{{D}^{2}}}{h \cdot w}}\right)}{2 \cdot w} \]
        6. Simplified72.1%

          \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \color{blue}{c0 \cdot \frac{\frac{{d}^{2}}{{D}^{2}}}{h \cdot w}}\right)}{2 \cdot w} \]
        7. Applied egg-rr44.0%

          \[\leadsto \color{blue}{e^{\log \left(c0 \cdot \frac{\mathsf{fma}\left(\frac{c0}{{D}^{2}}, \frac{{d}^{2}}{h \cdot w}, \frac{c0}{{D}^{2}} \cdot \frac{{d}^{2}}{h \cdot w}\right)}{w \cdot 2}\right)}} \]
        8. Step-by-step derivation
          1. rem-exp-log75.3%

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

          \[\leadsto \color{blue}{c0 \cdot \frac{\mathsf{fma}\left(\frac{\frac{c0}{w}}{h}, {\left(\frac{d}{D}\right)}^{2}, \frac{\frac{c0}{w}}{h} \cdot {\left(\frac{d}{D}\right)}^{2}\right)}{w \cdot 2}} \]
        10. Step-by-step derivation
          1. fma-define77.4%

            \[\leadsto c0 \cdot \frac{\color{blue}{\frac{\frac{c0}{w}}{h} \cdot {\left(\frac{d}{D}\right)}^{2} + \frac{\frac{c0}{w}}{h} \cdot {\left(\frac{d}{D}\right)}^{2}}}{w \cdot 2} \]
          2. count-277.4%

            \[\leadsto c0 \cdot \frac{\color{blue}{2 \cdot \left(\frac{\frac{c0}{w}}{h} \cdot {\left(\frac{d}{D}\right)}^{2}\right)}}{w \cdot 2} \]
          3. associate-/l/77.9%

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

            \[\leadsto c0 \cdot \frac{2 \cdot \left(\frac{c0}{h \cdot w} \cdot {\left(\frac{d}{D}\right)}^{2}\right)}{\color{blue}{2 \cdot w}} \]
        11. Simplified77.9%

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

        if +inf.0 < (*.f64 (/.f64 c0 (*.f64 #s(literal 2 binary64) 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. Simplified11.1%

          \[\leadsto \color{blue}{c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right) \cdot \mathsf{fma}\left(\frac{c0}{w \cdot \left(h \cdot D\right)}, \frac{d \cdot d}{D}, -M\right)}\right)}{2 \cdot w}} \]
        3. Add Preprocessing
        4. Step-by-step derivation
          1. associate-*r/11.1%

            \[\leadsto \color{blue}{\frac{c0 \cdot \mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right) \cdot \mathsf{fma}\left(\frac{c0}{w \cdot \left(h \cdot D\right)}, \frac{d \cdot d}{D}, -M\right)}\right)}{2 \cdot w}} \]
        5. Applied egg-rr11.6%

          \[\leadsto \color{blue}{\frac{c0 \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, {\left(\frac{d}{D}\right)}^{2}, \sqrt{\mathsf{fma}\left(\frac{c0}{w \cdot h}, {\left(\frac{d}{D}\right)}^{2}, M\right) \cdot \mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{{d}^{2}}{D}, -M\right)}\right)}{w \cdot 2}} \]
        6. Step-by-step derivation
          1. associate-/l*11.6%

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

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

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

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

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

          \[\leadsto c0 \cdot \color{blue}{\left(-0.5 \cdot \frac{c0 \cdot \left(-1 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)} + \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)}{w}\right)} \]
        9. Step-by-step derivation
          1. Simplified49.1%

            \[\leadsto c0 \cdot \color{blue}{\frac{0}{w}} \]
        10. Recombined 2 regimes into one program.
        11. Final simplification57.7%

          \[\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:\\ \;\;\;\;c0 \cdot \frac{2 \cdot \left({\left(\frac{d}{D}\right)}^{2} \cdot \frac{c0}{w \cdot h}\right)}{2 \cdot w}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{0}{w}\\ \end{array} \]
        12. Add Preprocessing

        Alternative 4: 33.6% accurate, 30.2× speedup?

        \[\begin{array}{l} \\ c0 \cdot \frac{0}{w} \end{array} \]
        (FPCore (c0 w h D d M) :precision binary64 (* c0 (/ 0.0 w)))
        double code(double c0, double w, double h, double D, double d, double M) {
        	return c0 * (0.0 / w);
        }
        
        real(8) function code(c0, w, h, d, d_1, m)
            real(8), intent (in) :: c0
            real(8), intent (in) :: w
            real(8), intent (in) :: h
            real(8), intent (in) :: d
            real(8), intent (in) :: d_1
            real(8), intent (in) :: m
            code = c0 * (0.0d0 / w)
        end function
        
        public static double code(double c0, double w, double h, double D, double d, double M) {
        	return c0 * (0.0 / w);
        }
        
        def code(c0, w, h, D, d, M):
        	return c0 * (0.0 / w)
        
        function code(c0, w, h, D, d, M)
        	return Float64(c0 * Float64(0.0 / w))
        end
        
        function tmp = code(c0, w, h, D, d, M)
        	tmp = c0 * (0.0 / w);
        end
        
        code[c0_, w_, h_, D_, d_, M_] := N[(c0 * N[(0.0 / w), $MachinePrecision]), $MachinePrecision]
        
        \begin{array}{l}
        
        \\
        c0 \cdot \frac{0}{w}
        \end{array}
        
        Derivation
        1. Initial program 22.2%

          \[\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. Simplified30.3%

          \[\leadsto \color{blue}{c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right) \cdot \mathsf{fma}\left(\frac{c0}{w \cdot \left(h \cdot D\right)}, \frac{d \cdot d}{D}, -M\right)}\right)}{2 \cdot w}} \]
        3. Add Preprocessing
        4. Step-by-step derivation
          1. associate-*r/29.6%

            \[\leadsto \color{blue}{\frac{c0 \cdot \mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right) \cdot \mathsf{fma}\left(\frac{c0}{w \cdot \left(h \cdot D\right)}, \frac{d \cdot d}{D}, -M\right)}\right)}{2 \cdot w}} \]
        5. Applied egg-rr30.3%

          \[\leadsto \color{blue}{\frac{c0 \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, {\left(\frac{d}{D}\right)}^{2}, \sqrt{\mathsf{fma}\left(\frac{c0}{w \cdot h}, {\left(\frac{d}{D}\right)}^{2}, M\right) \cdot \mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{{d}^{2}}{D}, -M\right)}\right)}{w \cdot 2}} \]
        6. Step-by-step derivation
          1. associate-/l*31.1%

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

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

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

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

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

          \[\leadsto c0 \cdot \color{blue}{\left(-0.5 \cdot \frac{c0 \cdot \left(-1 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)} + \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)}{w}\right)} \]
        9. Step-by-step derivation
          1. Simplified35.7%

            \[\leadsto c0 \cdot \color{blue}{\frac{0}{w}} \]
          2. Add Preprocessing

          Reproduce

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