Henrywood and Agarwal, Equation (13)

Percentage Accurate: 23.9% → 56.7%
Time: 23.5s
Alternatives: 6
Speedup: 151.0×

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 6 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: 23.9% 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: 56.7% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \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({\left(\sqrt[3]{\frac{d}{D}}\right)}^{2} \cdot \frac{\sqrt[3]{c0}}{\sqrt[3]{w \cdot h}}\right)}^{3}\right)\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
(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
       (pow (* (pow (cbrt (/ d D)) 2.0) (/ (cbrt c0) (cbrt (* w h)))) 3.0)))
     0.0)))
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 * pow((pow(cbrt((d / D)), 2.0) * (cbrt(c0) / cbrt((w * h)))), 3.0));
	} else {
		tmp = 0.0;
	}
	return tmp;
}
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 * Math.pow((Math.pow(Math.cbrt((d / D)), 2.0) * (Math.cbrt(c0) / Math.cbrt((w * h)))), 3.0));
	} else {
		tmp = 0.0;
	}
	return tmp;
}
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((cbrt(Float64(d / D)) ^ 2.0) * Float64(cbrt(c0) / cbrt(Float64(w * h)))) ^ 3.0)));
	else
		tmp = 0.0;
	end
	return tmp
end
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[Power[N[(N[Power[N[Power[N[(d / D), $MachinePrecision], 1/3], $MachinePrecision], 2.0], $MachinePrecision] * N[(N[Power[c0, 1/3], $MachinePrecision] / N[Power[N[(w * h), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;0\\


\end{array}
\end{array}
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 68.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. Simplified68.5%

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(2 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)} \]
    4. Step-by-step derivation
      1. *-commutative68.6%

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

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

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

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

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(2 \cdot \frac{\frac{c0}{h \cdot w}}{\frac{{D}^{2}}{{d}^{2}}}\right)} \]
    6. Step-by-step derivation
      1. add-cube-cbrt69.8%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(2 \cdot {\left(\sqrt[3]{\frac{c0}{\color{blue}{{\left(\frac{d}{D}\right)}^{\left(-2\right)}} \cdot \left(h \cdot w\right)}}\right)}^{3}\right) \]
      10. metadata-eval69.9%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(2 \cdot {\left(\sqrt[3]{\frac{c0}{h \cdot w}} \cdot \sqrt[3]{\color{blue}{\frac{d}{D} \cdot \frac{d}{D}}}\right)}^{3}\right) \]
      8. cbrt-prod77.3%

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(2 \cdot {\left({\left(\sqrt[3]{\frac{d}{D}}\right)}^{2} \cdot \color{blue}{\frac{\sqrt[3]{c0}}{\sqrt[3]{h \cdot w}}}\right)}^{3}\right) \]
    13. Applied egg-rr82.4%

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

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(-1 \cdot \left(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)\right)\right)} \]
    4. Step-by-step derivation
      1. mul-1-neg0.7%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(-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)\right)} \]
      2. distribute-lft-in0.7%

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{0} \]
    6. Taylor expanded in c0 around 0 45.5%

      \[\leadsto \color{blue}{0} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification56.2%

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

Alternative 2: 56.1% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \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({\left(\sqrt[3]{\frac{d}{D}}\right)}^{2} \cdot \frac{1}{\sqrt[3]{\frac{w \cdot h}{c0}}}\right)}^{3}\right)\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
(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
       (pow (* (pow (cbrt (/ d D)) 2.0) (/ 1.0 (cbrt (/ (* w h) c0)))) 3.0)))
     0.0)))
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 * pow((pow(cbrt((d / D)), 2.0) * (1.0 / cbrt(((w * h) / c0)))), 3.0));
	} else {
		tmp = 0.0;
	}
	return tmp;
}
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 * Math.pow((Math.pow(Math.cbrt((d / D)), 2.0) * (1.0 / Math.cbrt(((w * h) / c0)))), 3.0));
	} else {
		tmp = 0.0;
	}
	return tmp;
}
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((cbrt(Float64(d / D)) ^ 2.0) * Float64(1.0 / cbrt(Float64(Float64(w * h) / c0)))) ^ 3.0)));
	else
		tmp = 0.0;
	end
	return tmp
end
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[Power[N[(N[Power[N[Power[N[(d / D), $MachinePrecision], 1/3], $MachinePrecision], 2.0], $MachinePrecision] * N[(1.0 / N[Power[N[(N[(w * h), $MachinePrecision] / c0), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;0\\


\end{array}
\end{array}
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 68.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. Simplified68.5%

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(2 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)} \]
    4. Step-by-step derivation
      1. *-commutative68.6%

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

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

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

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

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(2 \cdot \frac{\frac{c0}{h \cdot w}}{\frac{{D}^{2}}{{d}^{2}}}\right)} \]
    6. Step-by-step derivation
      1. add-cube-cbrt69.8%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(2 \cdot {\left(\sqrt[3]{\frac{c0}{\color{blue}{{\left(\frac{d}{D}\right)}^{\left(-2\right)}} \cdot \left(h \cdot w\right)}}\right)}^{3}\right) \]
      10. metadata-eval69.9%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(2 \cdot {\left(\sqrt[3]{\frac{c0}{h \cdot w}} \cdot \sqrt[3]{\color{blue}{\frac{d}{D} \cdot \frac{d}{D}}}\right)}^{3}\right) \]
      8. cbrt-prod77.3%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(-1 \cdot \left(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)\right)\right)} \]
    4. Step-by-step derivation
      1. mul-1-neg0.7%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(-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)\right)} \]
      2. distribute-lft-in0.7%

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{0} \]
    6. Taylor expanded in c0 around 0 45.5%

      \[\leadsto \color{blue}{0} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification55.1%

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

Alternative 3: 56.2% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \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({\left(\sqrt[3]{\frac{d}{D}}\right)}^{2} \cdot \sqrt[3]{\frac{c0}{w \cdot h}}\right)}^{3}\right)\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
(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 (pow (* (pow (cbrt (/ d D)) 2.0) (cbrt (/ c0 (* w h)))) 3.0)))
     0.0)))
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 * pow((pow(cbrt((d / D)), 2.0) * cbrt((c0 / (w * h)))), 3.0));
	} else {
		tmp = 0.0;
	}
	return tmp;
}
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 * Math.pow((Math.pow(Math.cbrt((d / D)), 2.0) * Math.cbrt((c0 / (w * h)))), 3.0));
	} else {
		tmp = 0.0;
	}
	return tmp;
}
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((cbrt(Float64(d / D)) ^ 2.0) * cbrt(Float64(c0 / Float64(w * h)))) ^ 3.0)));
	else
		tmp = 0.0;
	end
	return tmp
end
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[Power[N[(N[Power[N[Power[N[(d / D), $MachinePrecision], 1/3], $MachinePrecision], 2.0], $MachinePrecision] * N[Power[N[(c0 / N[(w * h), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;0\\


\end{array}
\end{array}
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 68.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. Simplified68.5%

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(2 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)} \]
    4. Step-by-step derivation
      1. *-commutative68.6%

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

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

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

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

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(2 \cdot \frac{\frac{c0}{h \cdot w}}{\frac{{D}^{2}}{{d}^{2}}}\right)} \]
    6. Step-by-step derivation
      1. add-cube-cbrt69.8%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(2 \cdot {\left(\sqrt[3]{\frac{c0}{\color{blue}{{\left(\frac{d}{D}\right)}^{\left(-2\right)}} \cdot \left(h \cdot w\right)}}\right)}^{3}\right) \]
      10. metadata-eval69.9%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(2 \cdot {\left(\sqrt[3]{\frac{c0}{h \cdot w}} \cdot \sqrt[3]{\color{blue}{\frac{d}{D} \cdot \frac{d}{D}}}\right)}^{3}\right) \]
      8. cbrt-prod77.3%

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

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

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

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

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

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(-1 \cdot \left(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)\right)\right)} \]
    4. Step-by-step derivation
      1. mul-1-neg0.7%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(-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)\right)} \]
      2. distribute-lft-in0.7%

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{0} \]
    6. Taylor expanded in c0 around 0 45.5%

      \[\leadsto \color{blue}{0} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification54.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:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot {\left({\left(\sqrt[3]{\frac{d}{D}}\right)}^{2} \cdot \sqrt[3]{\frac{c0}{w \cdot h}}\right)}^{3}\right)\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]

Alternative 4: 56.4% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \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({\left(\sqrt[3]{\frac{d}{D}}\right)}^{2} \cdot \sqrt[3]{\frac{\frac{c0}{w}}{h}}\right)}^{3}\right)\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
(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 (pow (* (pow (cbrt (/ d D)) 2.0) (cbrt (/ (/ c0 w) h))) 3.0)))
     0.0)))
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 * pow((pow(cbrt((d / D)), 2.0) * cbrt(((c0 / w) / h))), 3.0));
	} else {
		tmp = 0.0;
	}
	return tmp;
}
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 * Math.pow((Math.pow(Math.cbrt((d / D)), 2.0) * Math.cbrt(((c0 / w) / h))), 3.0));
	} else {
		tmp = 0.0;
	}
	return tmp;
}
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((cbrt(Float64(d / D)) ^ 2.0) * cbrt(Float64(Float64(c0 / w) / h))) ^ 3.0)));
	else
		tmp = 0.0;
	end
	return tmp
end
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[Power[N[(N[Power[N[Power[N[(d / D), $MachinePrecision], 1/3], $MachinePrecision], 2.0], $MachinePrecision] * N[Power[N[(N[(c0 / w), $MachinePrecision] / h), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;0\\


\end{array}
\end{array}
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 68.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. Simplified68.5%

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(2 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)} \]
    4. Step-by-step derivation
      1. *-commutative68.6%

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

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

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

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

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(2 \cdot \frac{\frac{c0}{h \cdot w}}{\frac{{D}^{2}}{{d}^{2}}}\right)} \]
    6. Step-by-step derivation
      1. add-cube-cbrt69.8%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(2 \cdot {\left(\sqrt[3]{\frac{c0}{\color{blue}{{\left(\frac{d}{D}\right)}^{\left(-2\right)}} \cdot \left(h \cdot w\right)}}\right)}^{3}\right) \]
      10. metadata-eval69.9%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(2 \cdot {\left(\sqrt[3]{\frac{c0}{h \cdot w}} \cdot \sqrt[3]{\color{blue}{\frac{d}{D} \cdot \frac{d}{D}}}\right)}^{3}\right) \]
      8. cbrt-prod77.3%

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

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

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

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

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

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

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(2 \cdot {\left({\left(\sqrt[3]{\frac{d}{D}}\right)}^{2} \cdot \sqrt[3]{\color{blue}{\frac{c0}{w} \cdot \frac{1}{h}}}\right)}^{3}\right) \]
    14. Step-by-step derivation
      1. associate-*r/77.4%

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

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

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

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(-1 \cdot \left(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)\right)\right)} \]
    4. Step-by-step derivation
      1. mul-1-neg0.7%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(-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)\right)} \]
      2. distribute-lft-in0.7%

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{0} \]
    6. Taylor expanded in c0 around 0 45.5%

      \[\leadsto \color{blue}{0} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification54.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:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot {\left({\left(\sqrt[3]{\frac{d}{D}}\right)}^{2} \cdot \sqrt[3]{\frac{\frac{c0}{w}}{h}}\right)}^{3}\right)\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]

Alternative 5: 54.6% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \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 \frac{\frac{c0}{w \cdot h}}{\frac{D}{d} \cdot \frac{1}{\frac{d}{D}}}\right)\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
(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 (/ (/ c0 (* w h)) (* (/ D d) (/ 1.0 (/ d D))))))
     0.0)))
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 * ((c0 / (w * h)) / ((D / d) * (1.0 / (d / D)))));
	} else {
		tmp = 0.0;
	}
	return tmp;
}
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 * ((c0 / (w * h)) / ((D / d) * (1.0 / (d / D)))));
	} else {
		tmp = 0.0;
	}
	return tmp;
}
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 * ((c0 / (w * h)) / ((D / d) * (1.0 / (d / D)))))
	else:
		tmp = 0.0
	return tmp
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(c0 / Float64(w * h)) / Float64(Float64(D / d) * Float64(1.0 / Float64(d / D))))));
	else
		tmp = 0.0;
	end
	return tmp
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 * ((c0 / (w * h)) / ((D / d) * (1.0 / (d / D)))));
	else
		tmp = 0.0;
	end
	tmp_2 = tmp;
end
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[(c0 / N[(w * h), $MachinePrecision]), $MachinePrecision] / N[(N[(D / d), $MachinePrecision] * N[(1.0 / N[(d / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]]]
\begin{array}{l}

\\
\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 \frac{\frac{c0}{w \cdot h}}{\frac{D}{d} \cdot \frac{1}{\frac{d}{D}}}\right)\\

\mathbf{else}:\\
\;\;\;\;0\\


\end{array}
\end{array}
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 68.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. Simplified68.5%

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(2 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)} \]
    4. Step-by-step derivation
      1. *-commutative68.6%

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

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

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

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

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(2 \cdot \frac{\frac{c0}{h \cdot w}}{\frac{{D}^{2}}{{d}^{2}}}\right)} \]
    6. Step-by-step derivation
      1. clear-num69.8%

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{\frac{c0}{h \cdot w}}{\frac{1}{\color{blue}{\frac{d}{D} \cdot \frac{d}{D}}}}\right) \]
      5. pow272.3%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{\frac{c0}{h \cdot w}}{\frac{1}{\color{blue}{{\left(\frac{d}{D}\right)}^{2}}}}\right) \]
      6. inv-pow72.3%

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{\frac{c0}{h \cdot w}}{{\color{blue}{\left(\frac{d}{D} \cdot \frac{d}{D}\right)}}^{-1}}\right) \]
      3. pow-prod-down72.3%

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{\frac{c0}{h \cdot w}}{\color{blue}{\frac{1}{\frac{d}{D}}} \cdot {\left(\frac{d}{D}\right)}^{-1}}\right) \]
      5. unpow-172.3%

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{\frac{c0}{h \cdot w}}{\color{blue}{\frac{1}{\frac{d}{D}} \cdot \frac{1}{\frac{d}{D}}}}\right) \]
    12. Taylor expanded in d around 0 72.3%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{\frac{c0}{h \cdot w}}{\color{blue}{\frac{D}{d}} \cdot \frac{1}{\frac{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. Simplified1.2%

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(-1 \cdot \left(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)\right)\right)} \]
    4. Step-by-step derivation
      1. mul-1-neg0.7%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(-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)\right)} \]
      2. distribute-lft-in0.7%

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{0} \]
    6. Taylor expanded in c0 around 0 45.5%

      \[\leadsto \color{blue}{0} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification53.3%

    \[\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 \frac{\frac{c0}{w \cdot h}}{\frac{D}{d} \cdot \frac{1}{\frac{d}{D}}}\right)\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]

Alternative 6: 35.0% accurate, 151.0× speedup?

\[\begin{array}{l} \\ 0 \end{array} \]
(FPCore (c0 w h D d M) :precision binary64 0.0)
double code(double c0, double w, double h, double D, double d, double M) {
	return 0.0;
}
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 = 0.0d0
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
	return 0.0;
}
def code(c0, w, h, D, d, M):
	return 0.0
function code(c0, w, h, D, d, M)
	return 0.0
end
function tmp = code(c0, w, h, D, d, M)
	tmp = 0.0;
end
code[c0_, w_, h_, D_, d_, M_] := 0.0
\begin{array}{l}

\\
0
\end{array}
Derivation
  1. Initial program 19.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. Simplified20.6%

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

    \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(-1 \cdot \left(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)\right)\right)} \]
  4. Step-by-step derivation
    1. mul-1-neg3.9%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(-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)\right)} \]
    2. distribute-lft-in3.8%

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

    \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{0} \]
  6. Taylor expanded in c0 around 0 36.1%

    \[\leadsto \color{blue}{0} \]
  7. Final simplification36.1%

    \[\leadsto 0 \]

Reproduce

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