Henrywood and Agarwal, Equation (13)

Percentage Accurate: 23.8% → 62.8%
Time: 26.8s
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.8% 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: 62.8% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{w}{\frac{d}{D}}\\ t_1 := \frac{c0}{2 \cdot w}\\ t_2 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\ t_3 := t_1 \cdot \left(t_2 + \sqrt{t_2 \cdot t_2 - M \cdot M}\right)\\ \mathbf{if}\;t_3 \leq -4 \cdot 10^{-42}:\\ \;\;\;\;t_1 \cdot \left(2 \cdot \frac{c0}{\frac{h}{\frac{d}{D}} \cdot t_0}\right)\\ \mathbf{elif}\;t_3 \leq 0 \lor \neg \left(t_3 \leq \infty\right):\\ \;\;\;\;0.25 \cdot \frac{h \cdot \left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)}{{d}^{2}}\\ \mathbf{else}:\\ \;\;\;\;t_1 \cdot \left(2 \cdot \frac{c0}{t_0 \cdot \frac{h \cdot D}{d}}\right)\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (let* ((t_0 (/ w (/ d D)))
        (t_1 (/ c0 (* 2.0 w)))
        (t_2 (/ (* c0 (* d d)) (* (* w h) (* D D))))
        (t_3 (* t_1 (+ t_2 (sqrt (- (* t_2 t_2) (* M M)))))))
   (if (<= t_3 -4e-42)
     (* t_1 (* 2.0 (/ c0 (* (/ h (/ d D)) t_0))))
     (if (or (<= t_3 0.0) (not (<= t_3 INFINITY)))
       (* 0.25 (/ (* h (* (* D M) (* D M))) (pow d 2.0)))
       (* t_1 (* 2.0 (/ c0 (* t_0 (/ (* h D) d)))))))))
double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = w / (d / D);
	double t_1 = c0 / (2.0 * w);
	double t_2 = (c0 * (d * d)) / ((w * h) * (D * D));
	double t_3 = t_1 * (t_2 + sqrt(((t_2 * t_2) - (M * M))));
	double tmp;
	if (t_3 <= -4e-42) {
		tmp = t_1 * (2.0 * (c0 / ((h / (d / D)) * t_0)));
	} else if ((t_3 <= 0.0) || !(t_3 <= ((double) INFINITY))) {
		tmp = 0.25 * ((h * ((D * M) * (D * M))) / pow(d, 2.0));
	} else {
		tmp = t_1 * (2.0 * (c0 / (t_0 * ((h * D) / d))));
	}
	return tmp;
}
public static double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = w / (d / D);
	double t_1 = c0 / (2.0 * w);
	double t_2 = (c0 * (d * d)) / ((w * h) * (D * D));
	double t_3 = t_1 * (t_2 + Math.sqrt(((t_2 * t_2) - (M * M))));
	double tmp;
	if (t_3 <= -4e-42) {
		tmp = t_1 * (2.0 * (c0 / ((h / (d / D)) * t_0)));
	} else if ((t_3 <= 0.0) || !(t_3 <= Double.POSITIVE_INFINITY)) {
		tmp = 0.25 * ((h * ((D * M) * (D * M))) / Math.pow(d, 2.0));
	} else {
		tmp = t_1 * (2.0 * (c0 / (t_0 * ((h * D) / d))));
	}
	return tmp;
}
def code(c0, w, h, D, d, M):
	t_0 = w / (d / D)
	t_1 = c0 / (2.0 * w)
	t_2 = (c0 * (d * d)) / ((w * h) * (D * D))
	t_3 = t_1 * (t_2 + math.sqrt(((t_2 * t_2) - (M * M))))
	tmp = 0
	if t_3 <= -4e-42:
		tmp = t_1 * (2.0 * (c0 / ((h / (d / D)) * t_0)))
	elif (t_3 <= 0.0) or not (t_3 <= math.inf):
		tmp = 0.25 * ((h * ((D * M) * (D * M))) / math.pow(d, 2.0))
	else:
		tmp = t_1 * (2.0 * (c0 / (t_0 * ((h * D) / d))))
	return tmp
function code(c0, w, h, D, d, M)
	t_0 = Float64(w / Float64(d / D))
	t_1 = Float64(c0 / Float64(2.0 * w))
	t_2 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D)))
	t_3 = Float64(t_1 * Float64(t_2 + sqrt(Float64(Float64(t_2 * t_2) - Float64(M * M)))))
	tmp = 0.0
	if (t_3 <= -4e-42)
		tmp = Float64(t_1 * Float64(2.0 * Float64(c0 / Float64(Float64(h / Float64(d / D)) * t_0))));
	elseif ((t_3 <= 0.0) || !(t_3 <= Inf))
		tmp = Float64(0.25 * Float64(Float64(h * Float64(Float64(D * M) * Float64(D * M))) / (d ^ 2.0)));
	else
		tmp = Float64(t_1 * Float64(2.0 * Float64(c0 / Float64(t_0 * Float64(Float64(h * D) / d)))));
	end
	return tmp
end
function tmp_2 = code(c0, w, h, D, d, M)
	t_0 = w / (d / D);
	t_1 = c0 / (2.0 * w);
	t_2 = (c0 * (d * d)) / ((w * h) * (D * D));
	t_3 = t_1 * (t_2 + sqrt(((t_2 * t_2) - (M * M))));
	tmp = 0.0;
	if (t_3 <= -4e-42)
		tmp = t_1 * (2.0 * (c0 / ((h / (d / D)) * t_0)));
	elseif ((t_3 <= 0.0) || ~((t_3 <= Inf)))
		tmp = 0.25 * ((h * ((D * M) * (D * M))) / (d ^ 2.0));
	else
		tmp = t_1 * (2.0 * (c0 / (t_0 * ((h * D) / d))));
	end
	tmp_2 = tmp;
end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(w / N[(d / D), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$1 * N[(t$95$2 + N[Sqrt[N[(N[(t$95$2 * t$95$2), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$3, -4e-42], N[(t$95$1 * N[(2.0 * N[(c0 / N[(N[(h / N[(d / D), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[t$95$3, 0.0], N[Not[LessEqual[t$95$3, Infinity]], $MachinePrecision]], N[(0.25 * N[(N[(h * N[(N[(D * M), $MachinePrecision] * N[(D * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Power[d, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(2.0 * N[(c0 / N[(t$95$0 * N[(N[(h * D), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{w}{\frac{d}{D}}\\
t_1 := \frac{c0}{2 \cdot w}\\
t_2 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
t_3 := t_1 \cdot \left(t_2 + \sqrt{t_2 \cdot t_2 - M \cdot M}\right)\\
\mathbf{if}\;t_3 \leq -4 \cdot 10^{-42}:\\
\;\;\;\;t_1 \cdot \left(2 \cdot \frac{c0}{\frac{h}{\frac{d}{D}} \cdot t_0}\right)\\

\mathbf{elif}\;t_3 \leq 0 \lor \neg \left(t_3 \leq \infty\right):\\
\;\;\;\;0.25 \cdot \frac{h \cdot \left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)}{{d}^{2}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 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))))) < -4.00000000000000015e-42

    1. Initial program 82.5%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Step-by-step derivation
      1. times-frac82.5%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    3. Simplified82.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)} \]
    4. Taylor expanded in c0 around inf 82.5%

      \[\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)} \]
    5. Step-by-step derivation
      1. *-commutative82.5%

        \[\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. *-commutative82.5%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{\frac{c0}{w}}{h} \cdot \left(d \cdot \color{blue}{\frac{\frac{d}{D}}{D}}\right)\right)\right) \]
      11. associate-*r/86.3%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{\frac{c0}{w}}{h} \cdot \color{blue}{\frac{d \cdot \frac{d}{D}}{D}}\right)\right) \]
      12. associate-/r*84.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{c0}{\color{blue}{\frac{h}{\frac{d}{D}} \cdot \frac{w}{\frac{d}{D}}}}\right) \]
    10. Applied egg-rr88.6%

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

    if -4.00000000000000015e-42 < (*.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))))) < 0.0 or +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 2.4%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Step-by-step derivation
      1. times-frac0.3%

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

      \[\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)} \]
    4. Taylor expanded in c0 around -inf 5.5%

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(0.5 \cdot \frac{\left({D}^{2} \cdot {M}^{2}\right) \cdot \left(h \cdot w\right)}{c0 \cdot {d}^{2}} + 0\right)} \]
    6. Taylor expanded in c0 around 0 35.7%

      \[\leadsto \color{blue}{0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}} \]
    7. Step-by-step derivation
      1. *-commutative35.7%

        \[\leadsto 0.25 \cdot \frac{\color{blue}{\left({M}^{2} \cdot h\right) \cdot {D}^{2}}}{{d}^{2}} \]
      2. *-commutative35.7%

        \[\leadsto 0.25 \cdot \frac{\color{blue}{\left(h \cdot {M}^{2}\right)} \cdot {D}^{2}}{{d}^{2}} \]
      3. associate-*l*37.9%

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

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

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

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

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

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

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

        \[\leadsto 0.25 \cdot \frac{h \cdot \color{blue}{\left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)}}{{d}^{2}} \]
    10. Applied egg-rr49.9%

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

    if 0.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))))) < +inf.0

    1. Initial program 82.1%

      \[\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. Step-by-step derivation
      1. times-frac78.4%

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

      \[\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)} \]
    4. Taylor expanded in c0 around inf 84.1%

      \[\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)} \]
    5. Step-by-step derivation
      1. *-commutative84.1%

        \[\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. *-commutative84.1%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{\frac{c0}{w}}{h} \cdot \left(d \cdot \color{blue}{\frac{\frac{d}{D}}{D}}\right)\right)\right) \]
      11. associate-*r/80.4%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{\frac{c0}{w}}{h} \cdot \color{blue}{\frac{d \cdot \frac{d}{D}}{D}}\right)\right) \]
      12. associate-/r*80.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 62.3% accurate, 0.4× 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(w \cdot h\right) \cdot \left(D \cdot D\right)}\\ \mathbf{if}\;t_0 \cdot \left(t_1 + \sqrt{t_1 \cdot t_1 - M \cdot M}\right) \leq \infty:\\ \;\;\;\;t_0 \cdot \left(2 \cdot {\left(\frac{d}{D} \cdot \sqrt{\frac{1}{\frac{h}{\frac{c0}{w}}}}\right)}^{2}\right)\\ \mathbf{else}:\\ \;\;\;\;0.25 \cdot \frac{h \cdot \left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)}{{d}^{2}}\\ \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)) (* (* w h) (* D D)))))
   (if (<= (* t_0 (+ t_1 (sqrt (- (* t_1 t_1) (* M M))))) INFINITY)
     (* t_0 (* 2.0 (pow (* (/ d D) (sqrt (/ 1.0 (/ h (/ c0 w))))) 2.0)))
     (* 0.25 (/ (* h (* (* D M) (* D M))) (pow d 2.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)) / ((w * h) * (D * D));
	double tmp;
	if ((t_0 * (t_1 + sqrt(((t_1 * t_1) - (M * M))))) <= ((double) INFINITY)) {
		tmp = t_0 * (2.0 * pow(((d / D) * sqrt((1.0 / (h / (c0 / w))))), 2.0));
	} else {
		tmp = 0.25 * ((h * ((D * M) * (D * M))) / pow(d, 2.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)) / ((w * h) * (D * D));
	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(((d / D) * Math.sqrt((1.0 / (h / (c0 / w))))), 2.0));
	} else {
		tmp = 0.25 * ((h * ((D * M) * (D * M))) / Math.pow(d, 2.0));
	}
	return tmp;
}
def code(c0, w, h, D, d, M):
	t_0 = c0 / (2.0 * w)
	t_1 = (c0 * (d * d)) / ((w * h) * (D * D))
	tmp = 0
	if (t_0 * (t_1 + math.sqrt(((t_1 * t_1) - (M * M))))) <= math.inf:
		tmp = t_0 * (2.0 * math.pow(((d / D) * math.sqrt((1.0 / (h / (c0 / w))))), 2.0))
	else:
		tmp = 0.25 * ((h * ((D * M) * (D * M))) / math.pow(d, 2.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(w * h) * Float64(D * D)))
	tmp = 0.0
	if (Float64(t_0 * Float64(t_1 + sqrt(Float64(Float64(t_1 * t_1) - Float64(M * M))))) <= Inf)
		tmp = Float64(t_0 * Float64(2.0 * (Float64(Float64(d / D) * sqrt(Float64(1.0 / Float64(h / Float64(c0 / w))))) ^ 2.0)));
	else
		tmp = Float64(0.25 * Float64(Float64(h * Float64(Float64(D * M) * Float64(D * M))) / (d ^ 2.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)) / ((w * h) * (D * D));
	tmp = 0.0;
	if ((t_0 * (t_1 + sqrt(((t_1 * t_1) - (M * M))))) <= Inf)
		tmp = t_0 * (2.0 * (((d / D) * sqrt((1.0 / (h / (c0 / w))))) ^ 2.0));
	else
		tmp = 0.25 * ((h * ((D * M) * (D * M))) / (d ^ 2.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[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 * N[(t$95$1 + N[Sqrt[N[(N[(t$95$1 * t$95$1), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(t$95$0 * N[(2.0 * N[Power[N[(N[(d / D), $MachinePrecision] * N[Sqrt[N[(1.0 / N[(h / N[(c0 / w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.25 * N[(N[(h * N[(N[(D * M), $MachinePrecision] * N[(D * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Power[d, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

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


\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 75.6%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Step-by-step derivation
      1. times-frac69.6%

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

      \[\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)} \]
    4. Taylor expanded in c0 around inf 74.0%

      \[\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)} \]
    5. Step-by-step derivation
      1. *-commutative74.0%

        \[\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. *-commutative74.0%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{\frac{c0}{w}}{h} \cdot \left(d \cdot \color{blue}{\frac{\frac{d}{D}}{D}}\right)\right)\right) \]
      11. associate-*r/74.4%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{\frac{c0}{w}}{h} \cdot \color{blue}{\frac{d \cdot \frac{d}{D}}{D}}\right)\right) \]
      12. associate-/r*73.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    3. Simplified1.3%

      \[\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)} \]
    4. Taylor expanded in c0 around -inf 3.0%

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(0.5 \cdot \frac{\left({D}^{2} \cdot {M}^{2}\right) \cdot \left(h \cdot w\right)}{c0 \cdot {d}^{2}} + 0\right)} \]
    6. Taylor expanded in c0 around 0 34.7%

      \[\leadsto \color{blue}{0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}} \]
    7. Step-by-step derivation
      1. *-commutative34.7%

        \[\leadsto 0.25 \cdot \frac{\color{blue}{\left({M}^{2} \cdot h\right) \cdot {D}^{2}}}{{d}^{2}} \]
      2. *-commutative34.7%

        \[\leadsto 0.25 \cdot \frac{\color{blue}{\left(h \cdot {M}^{2}\right)} \cdot {D}^{2}}{{d}^{2}} \]
      3. associate-*l*37.0%

        \[\leadsto 0.25 \cdot \frac{\color{blue}{h \cdot \left({M}^{2} \cdot {D}^{2}\right)}}{{d}^{2}} \]
      4. unpow237.0%

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

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

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

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

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

      \[\leadsto \color{blue}{0.25 \cdot \frac{h \cdot {\left(D \cdot M\right)}^{2}}{{d}^{2}}} \]
    9. Step-by-step derivation
      1. unpow248.7%

        \[\leadsto 0.25 \cdot \frac{h \cdot \color{blue}{\left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)}}{{d}^{2}} \]
    10. Applied egg-rr48.7%

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

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

Alternative 3: 62.0% accurate, 0.4× 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(w \cdot h\right) \cdot \left(D \cdot D\right)}\\ \mathbf{if}\;t_0 \cdot \left(t_1 + \sqrt{t_1 \cdot t_1 - M \cdot M}\right) \leq \infty:\\ \;\;\;\;t_0 \cdot \left(2 \cdot {\left(\frac{d}{D} \cdot \sqrt{\frac{c0}{w \cdot h}}\right)}^{2}\right)\\ \mathbf{else}:\\ \;\;\;\;0.25 \cdot \frac{h \cdot \left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)}{{d}^{2}}\\ \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)) (* (* w h) (* D D)))))
   (if (<= (* t_0 (+ t_1 (sqrt (- (* t_1 t_1) (* M M))))) INFINITY)
     (* t_0 (* 2.0 (pow (* (/ d D) (sqrt (/ c0 (* w h)))) 2.0)))
     (* 0.25 (/ (* h (* (* D M) (* D M))) (pow d 2.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)) / ((w * h) * (D * D));
	double tmp;
	if ((t_0 * (t_1 + sqrt(((t_1 * t_1) - (M * M))))) <= ((double) INFINITY)) {
		tmp = t_0 * (2.0 * pow(((d / D) * sqrt((c0 / (w * h)))), 2.0));
	} else {
		tmp = 0.25 * ((h * ((D * M) * (D * M))) / pow(d, 2.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)) / ((w * h) * (D * D));
	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(((d / D) * Math.sqrt((c0 / (w * h)))), 2.0));
	} else {
		tmp = 0.25 * ((h * ((D * M) * (D * M))) / Math.pow(d, 2.0));
	}
	return tmp;
}
def code(c0, w, h, D, d, M):
	t_0 = c0 / (2.0 * w)
	t_1 = (c0 * (d * d)) / ((w * h) * (D * D))
	tmp = 0
	if (t_0 * (t_1 + math.sqrt(((t_1 * t_1) - (M * M))))) <= math.inf:
		tmp = t_0 * (2.0 * math.pow(((d / D) * math.sqrt((c0 / (w * h)))), 2.0))
	else:
		tmp = 0.25 * ((h * ((D * M) * (D * M))) / math.pow(d, 2.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(w * h) * Float64(D * D)))
	tmp = 0.0
	if (Float64(t_0 * Float64(t_1 + sqrt(Float64(Float64(t_1 * t_1) - Float64(M * M))))) <= Inf)
		tmp = Float64(t_0 * Float64(2.0 * (Float64(Float64(d / D) * sqrt(Float64(c0 / Float64(w * h)))) ^ 2.0)));
	else
		tmp = Float64(0.25 * Float64(Float64(h * Float64(Float64(D * M) * Float64(D * M))) / (d ^ 2.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)) / ((w * h) * (D * D));
	tmp = 0.0;
	if ((t_0 * (t_1 + sqrt(((t_1 * t_1) - (M * M))))) <= Inf)
		tmp = t_0 * (2.0 * (((d / D) * sqrt((c0 / (w * h)))) ^ 2.0));
	else
		tmp = 0.25 * ((h * ((D * M) * (D * M))) / (d ^ 2.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[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 * N[(t$95$1 + N[Sqrt[N[(N[(t$95$1 * t$95$1), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(t$95$0 * N[(2.0 * N[Power[N[(N[(d / D), $MachinePrecision] * N[Sqrt[N[(c0 / N[(w * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.25 * N[(N[(h * N[(N[(D * M), $MachinePrecision] * N[(D * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Power[d, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

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


\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 75.6%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Step-by-step derivation
      1. times-frac69.6%

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

      \[\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)} \]
    4. Taylor expanded in c0 around inf 74.0%

      \[\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)} \]
    5. Step-by-step derivation
      1. *-commutative74.0%

        \[\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. *-commutative74.0%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{\frac{c0}{w}}{h} \cdot \left(d \cdot \color{blue}{\frac{\frac{d}{D}}{D}}\right)\right)\right) \]
      11. associate-*r/74.4%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{\frac{c0}{w}}{h} \cdot \color{blue}{\frac{d \cdot \frac{d}{D}}{D}}\right)\right) \]
      12. associate-/r*73.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    3. Simplified1.3%

      \[\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)} \]
    4. Taylor expanded in c0 around -inf 3.0%

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(0.5 \cdot \frac{\left({D}^{2} \cdot {M}^{2}\right) \cdot \left(h \cdot w\right)}{c0 \cdot {d}^{2}} + 0\right)} \]
    6. Taylor expanded in c0 around 0 34.7%

      \[\leadsto \color{blue}{0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}} \]
    7. Step-by-step derivation
      1. *-commutative34.7%

        \[\leadsto 0.25 \cdot \frac{\color{blue}{\left({M}^{2} \cdot h\right) \cdot {D}^{2}}}{{d}^{2}} \]
      2. *-commutative34.7%

        \[\leadsto 0.25 \cdot \frac{\color{blue}{\left(h \cdot {M}^{2}\right)} \cdot {D}^{2}}{{d}^{2}} \]
      3. associate-*l*37.0%

        \[\leadsto 0.25 \cdot \frac{\color{blue}{h \cdot \left({M}^{2} \cdot {D}^{2}\right)}}{{d}^{2}} \]
      4. unpow237.0%

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

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

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

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

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

      \[\leadsto \color{blue}{0.25 \cdot \frac{h \cdot {\left(D \cdot M\right)}^{2}}{{d}^{2}}} \]
    9. Step-by-step derivation
      1. unpow248.7%

        \[\leadsto 0.25 \cdot \frac{h \cdot \color{blue}{\left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)}}{{d}^{2}} \]
    10. Applied egg-rr48.7%

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

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

Alternative 4: 39.3% accurate, 6.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;M \leq 2.25 \cdot 10^{-123}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{c0}{\frac{h}{d} \cdot \left(D \cdot \left(D \cdot \frac{w}{d}\right)\right)}\right)\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (if (<= M 2.25e-123)
   0.0
   (* (/ c0 (* 2.0 w)) (* 2.0 (/ c0 (* (/ h d) (* D (* D (/ w d)))))))))
double code(double c0, double w, double h, double D, double d, double M) {
	double tmp;
	if (M <= 2.25e-123) {
		tmp = 0.0;
	} else {
		tmp = (c0 / (2.0 * w)) * (2.0 * (c0 / ((h / d) * (D * (D * (w / d))))));
	}
	return tmp;
}
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) :: tmp
    if (m <= 2.25d-123) then
        tmp = 0.0d0
    else
        tmp = (c0 / (2.0d0 * w)) * (2.0d0 * (c0 / ((h / d_1) * (d * (d * (w / d_1))))))
    end if
    code = tmp
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
	double tmp;
	if (M <= 2.25e-123) {
		tmp = 0.0;
	} else {
		tmp = (c0 / (2.0 * w)) * (2.0 * (c0 / ((h / d) * (D * (D * (w / d))))));
	}
	return tmp;
}
def code(c0, w, h, D, d, M):
	tmp = 0
	if M <= 2.25e-123:
		tmp = 0.0
	else:
		tmp = (c0 / (2.0 * w)) * (2.0 * (c0 / ((h / d) * (D * (D * (w / d))))))
	return tmp
function code(c0, w, h, D, d, M)
	tmp = 0.0
	if (M <= 2.25e-123)
		tmp = 0.0;
	else
		tmp = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(2.0 * Float64(c0 / Float64(Float64(h / d) * Float64(D * Float64(D * Float64(w / d)))))));
	end
	return tmp
end
function tmp_2 = code(c0, w, h, D, d, M)
	tmp = 0.0;
	if (M <= 2.25e-123)
		tmp = 0.0;
	else
		tmp = (c0 / (2.0 * w)) * (2.0 * (c0 / ((h / d) * (D * (D * (w / d))))));
	end
	tmp_2 = tmp;
end
code[c0_, w_, h_, D_, d_, M_] := If[LessEqual[M, 2.25e-123], 0.0, N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(2.0 * N[(c0 / N[(N[(h / d), $MachinePrecision] * N[(D * N[(D * N[(w / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;M \leq 2.25 \cdot 10^{-123}:\\
\;\;\;\;0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if M < 2.24999999999999997e-123

    1. Initial program 25.6%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Step-by-step derivation
      1. times-frac23.3%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    3. Simplified25.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)} \]
    4. Taylor expanded in c0 around -inf 5.1%

      \[\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)} \]
    5. Step-by-step derivation
      1. associate-*r*5.1%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(\left(-1 \cdot c0\right) \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. neg-mul-15.1%

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\left(-c0\right) \cdot \color{blue}{0}\right) \]
      6. distribute-lft-neg-in31.2%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(-c0 \cdot 0\right)} \]
      7. distribute-rgt-neg-in31.2%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(c0 \cdot \left(-0\right)\right)} \]
      8. metadata-eval31.2%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(c0 \cdot \color{blue}{0}\right) \]
      9. mul0-lft5.1%

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

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

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

        \[\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)}\right) + c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)} \]
    6. Simplified31.2%

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

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

    if 2.24999999999999997e-123 < M

    1. Initial program 20.5%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Step-by-step derivation
      1. times-frac19.4%

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

      \[\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)} \]
    4. Taylor expanded in c0 around inf 42.1%

      \[\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)} \]
    5. Step-by-step derivation
      1. *-commutative42.1%

        \[\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. *-commutative42.1%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{\frac{c0}{w}}{h} \cdot \left(d \cdot \color{blue}{\frac{\frac{d}{D}}{D}}\right)\right)\right) \]
      11. associate-*r/50.7%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{\frac{c0}{w}}{h} \cdot \color{blue}{\frac{d \cdot \frac{d}{D}}{D}}\right)\right) \]
      12. associate-/r*50.7%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{c0}{\color{blue}{\frac{h}{\frac{d}{D}} \cdot \frac{w}{\frac{d}{D}}}}\right) \]
    11. Step-by-step derivation
      1. associate-/r/54.3%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 2.25 \cdot 10^{-123}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{c0}{\frac{h}{d} \cdot \left(D \cdot \left(D \cdot \frac{w}{d}\right)\right)}\right)\\ \end{array} \]

Alternative 5: 40.3% accurate, 6.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;M \leq 1.95 \cdot 10^{-100}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{c0}{\frac{h}{\frac{d}{D}} \cdot \frac{w}{\frac{d}{D}}}\right)\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (if (<= M 1.95e-100)
   0.0
   (* (/ c0 (* 2.0 w)) (* 2.0 (/ c0 (* (/ h (/ d D)) (/ w (/ d D))))))))
double code(double c0, double w, double h, double D, double d, double M) {
	double tmp;
	if (M <= 1.95e-100) {
		tmp = 0.0;
	} else {
		tmp = (c0 / (2.0 * w)) * (2.0 * (c0 / ((h / (d / D)) * (w / (d / D)))));
	}
	return tmp;
}
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) :: tmp
    if (m <= 1.95d-100) then
        tmp = 0.0d0
    else
        tmp = (c0 / (2.0d0 * w)) * (2.0d0 * (c0 / ((h / (d_1 / d)) * (w / (d_1 / d)))))
    end if
    code = tmp
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
	double tmp;
	if (M <= 1.95e-100) {
		tmp = 0.0;
	} else {
		tmp = (c0 / (2.0 * w)) * (2.0 * (c0 / ((h / (d / D)) * (w / (d / D)))));
	}
	return tmp;
}
def code(c0, w, h, D, d, M):
	tmp = 0
	if M <= 1.95e-100:
		tmp = 0.0
	else:
		tmp = (c0 / (2.0 * w)) * (2.0 * (c0 / ((h / (d / D)) * (w / (d / D)))))
	return tmp
function code(c0, w, h, D, d, M)
	tmp = 0.0
	if (M <= 1.95e-100)
		tmp = 0.0;
	else
		tmp = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(2.0 * Float64(c0 / Float64(Float64(h / Float64(d / D)) * Float64(w / Float64(d / D))))));
	end
	return tmp
end
function tmp_2 = code(c0, w, h, D, d, M)
	tmp = 0.0;
	if (M <= 1.95e-100)
		tmp = 0.0;
	else
		tmp = (c0 / (2.0 * w)) * (2.0 * (c0 / ((h / (d / D)) * (w / (d / D)))));
	end
	tmp_2 = tmp;
end
code[c0_, w_, h_, D_, d_, M_] := If[LessEqual[M, 1.95e-100], 0.0, N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(2.0 * N[(c0 / N[(N[(h / N[(d / D), $MachinePrecision]), $MachinePrecision] * N[(w / N[(d / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;M \leq 1.95 \cdot 10^{-100}:\\
\;\;\;\;0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if M < 1.94999999999999989e-100

    1. Initial program 26.1%

      \[\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. Step-by-step derivation
      1. times-frac24.0%

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

      \[\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)} \]
    4. Taylor expanded in c0 around -inf 4.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)} \]
    5. Step-by-step derivation
      1. associate-*r*4.9%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(\left(-1 \cdot c0\right) \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. neg-mul-14.9%

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\left(-c0\right) \cdot \left(\color{blue}{0} \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)\right) \]
      5. mul0-lft31.6%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\left(-c0\right) \cdot \color{blue}{0}\right) \]
      6. distribute-lft-neg-in31.6%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(-c0 \cdot 0\right)} \]
      7. distribute-rgt-neg-in31.6%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(c0 \cdot \left(-0\right)\right)} \]
      8. metadata-eval31.6%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(c0 \cdot \color{blue}{0}\right) \]
      9. mul0-lft4.9%

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(c0 \cdot \left(\color{blue}{\left(-1 + 1\right)} \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)\right) \]
      11. distribute-lft1-in4.9%

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

        \[\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)}\right) + c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)} \]
    6. Simplified31.6%

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

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

    if 1.94999999999999989e-100 < M

    1. Initial program 18.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. Step-by-step derivation
      1. times-frac17.5%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    3. Simplified17.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)} \]
    4. Taylor expanded in c0 around inf 42.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)} \]
    5. Step-by-step derivation
      1. *-commutative42.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. *-commutative42.6%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{\frac{c0}{w}}{h} \cdot \left(d \cdot \color{blue}{\frac{\frac{d}{D}}{D}}\right)\right)\right) \]
      11. associate-*r/50.8%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{\frac{c0}{w}}{h} \cdot \color{blue}{\frac{d \cdot \frac{d}{D}}{D}}\right)\right) \]
      12. associate-/r*50.7%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 1.95 \cdot 10^{-100}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{c0}{\frac{h}{\frac{d}{D}} \cdot \frac{w}{\frac{d}{D}}}\right)\\ \end{array} \]

Alternative 6: 34.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 23.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. Step-by-step derivation
    1. times-frac22.0%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
  3. Simplified23.3%

    \[\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)} \]
  4. Taylor expanded in c0 around -inf 3.5%

    \[\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)} \]
  5. Step-by-step derivation
    1. associate-*r*3.5%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(\left(-1 \cdot c0\right) \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. neg-mul-13.5%

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

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\left(-c0\right) \cdot \left(\color{blue}{0} \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)\right) \]
    5. mul0-lft28.4%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\left(-c0\right) \cdot \color{blue}{0}\right) \]
    6. distribute-lft-neg-in28.4%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(-c0 \cdot 0\right)} \]
    7. distribute-rgt-neg-in28.4%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(c0 \cdot \left(-0\right)\right)} \]
    8. metadata-eval28.4%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(c0 \cdot \color{blue}{0}\right) \]
    9. mul0-lft3.5%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(c0 \cdot \color{blue}{\left(0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)}\right) \]
    10. metadata-eval3.5%

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(c0 \cdot \color{blue}{\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) \]
    12. distribute-lft-in2.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)}\right) + c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)} \]
  6. Simplified28.4%

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

    \[\leadsto \color{blue}{0} \]
  8. Final simplification32.3%

    \[\leadsto 0 \]

Reproduce

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