Henrywood and Agarwal, Equation (13)

Percentage Accurate: 24.1% → 63.9%
Time: 32.8s
Alternatives: 11
Speedup: 11.5×

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

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

Initial Program: 24.1% 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: 63.9% accurate, 0.2× speedup?

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

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

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

\mathbf{elif}\;t_2 \leq \infty:\\
\;\;\;\;d \cdot \left(d \cdot \left(t_0 \cdot t_0\right)\right)\\

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


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

    1. Initial program 67.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. Applied egg-rr73.4%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{\frac{w \cdot 2}{\color{blue}{M + \left({\left(\frac{d}{D}\right)}^{2} \cdot \frac{c0}{w \cdot h} + {\left(\frac{d}{D}\right)}^{2} \cdot \frac{c0}{w \cdot h}\right)}}} \]
      5. distribute-lft-out73.4%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{\frac{w \cdot 2}{M + \frac{\color{blue}{\frac{2 \cdot \frac{c0}{w}}{h}} \cdot \frac{d}{D}}{\frac{D}{d}}}} \]
      7. associate-*r/81.6%

        \[\leadsto \frac{c0}{\frac{w \cdot 2}{M + \frac{\frac{\color{blue}{\frac{2 \cdot c0}{w}}}{h} \cdot \frac{d}{D}}{\frac{D}{d}}}} \]
    8. Applied egg-rr81.6%

      \[\leadsto \frac{c0}{\frac{w \cdot 2}{M + \color{blue}{\frac{\frac{\frac{2 \cdot c0}{w}}{h} \cdot \frac{d}{D}}{\frac{D}{d}}}}} \]

    if -3.9999999999999998e-7 < (*.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

    1. Initial program 45.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. Simplified35.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)} \]
    3. Taylor expanded in c0 around -inf 72.3%

      \[\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)} \]
    4. Step-by-step derivation
      1. fma-def72.3%

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(-1, c0 \cdot \left(0 \cdot \frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w}\right), 0.5 \cdot \left(\frac{{D}^{2}}{c0 \cdot {d}^{2}} \cdot \left({M}^{2} \cdot \left(h \cdot w\right)\right)\right)\right)} \]
    6. Taylor expanded in c0 around 0 81.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(\frac{\frac{c0}{w}}{D \cdot \sqrt{h}} \cdot \frac{\frac{c0}{w}}{\color{blue}{\left(\sqrt{D} \cdot \sqrt{D}\right)} \cdot \sqrt{h}}\right) \cdot d\right) \cdot d \]
      13. add-sqr-sqrt94.2%

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

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

    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.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)} \]
    3. 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)} \]
    4. Step-by-step derivation
      1. fma-def3.0%

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(-1, c0 \cdot \left(0 \cdot \frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w}\right), 0.5 \cdot \left(\frac{{D}^{2}}{c0 \cdot {d}^{2}} \cdot \left({M}^{2} \cdot \left(h \cdot w\right)\right)\right)\right)} \]
    6. Taylor expanded in c0 around 0 39.3%

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

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

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

        \[\leadsto 0.25 \cdot \left(\left(-\color{blue}{\left({M}^{2} \cdot h\right) \cdot {D}^{2}}\right) \cdot \frac{1}{-{d}^{2}}\right) \]
      4. distribute-rgt-neg-in38.6%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.25 \cdot \color{blue}{\frac{-h}{\frac{-{d}^{2}}{{D}^{2} \cdot {M}^{2}}}} \]
      10. neg-mul-138.8%

        \[\leadsto 0.25 \cdot \frac{-h}{\frac{\color{blue}{-1 \cdot {d}^{2}}}{{D}^{2} \cdot {M}^{2}}} \]
      11. *-commutative38.8%

        \[\leadsto 0.25 \cdot \frac{-h}{\frac{-1 \cdot {d}^{2}}{\color{blue}{{M}^{2} \cdot {D}^{2}}}} \]
      12. times-frac39.5%

        \[\leadsto 0.25 \cdot \frac{-h}{\color{blue}{\frac{-1}{{M}^{2}} \cdot \frac{{d}^{2}}{{D}^{2}}}} \]
      13. unpow239.5%

        \[\leadsto 0.25 \cdot \frac{-h}{\frac{-1}{{M}^{2}} \cdot \frac{\color{blue}{d \cdot d}}{{D}^{2}}} \]
      14. unpow239.5%

        \[\leadsto 0.25 \cdot \frac{-h}{\frac{-1}{{M}^{2}} \cdot \frac{d \cdot d}{\color{blue}{D \cdot D}}} \]
      15. times-frac55.2%

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

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

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

Alternative 2: 63.8% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c0 \cdot 2}{w}\\ t_1 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\ t_2 := \frac{c0}{2 \cdot w} \cdot \left(t_1 + \sqrt{t_1 \cdot t_1 - M \cdot M}\right)\\ \mathbf{if}\;t_2 \leq -4 \cdot 10^{-7}:\\ \;\;\;\;\frac{c0}{\frac{2 \cdot w}{M + \frac{\frac{t_0}{h} \cdot \frac{d}{D}}{\frac{D}{d}}}}\\ \mathbf{elif}\;t_2 \leq 0:\\ \;\;\;\;0.25 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{d} \cdot \frac{h}{d}\right)\\ \mathbf{elif}\;t_2 \leq \infty:\\ \;\;\;\;\frac{c0}{\frac{2 \cdot w}{M + \frac{t_0 \cdot \frac{d}{D}}{h \cdot \frac{D}{d}}}}\\ \mathbf{else}:\\ \;\;\;\;0.25 \cdot \frac{-h}{\frac{-1}{{M}^{2}} \cdot {\left(\frac{d}{D}\right)}^{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))))
        (t_2 (* (/ c0 (* 2.0 w)) (+ t_1 (sqrt (- (* t_1 t_1) (* M M)))))))
   (if (<= t_2 -4e-7)
     (/ c0 (/ (* 2.0 w) (+ M (/ (* (/ t_0 h) (/ d D)) (/ D d)))))
     (if (<= t_2 0.0)
       (* 0.25 (* (/ (* (pow D 2.0) (pow M 2.0)) d) (/ h d)))
       (if (<= t_2 INFINITY)
         (/ c0 (/ (* 2.0 w) (+ M (/ (* t_0 (/ d D)) (* h (/ D d))))))
         (* 0.25 (/ (- h) (* (/ -1.0 (pow M 2.0)) (pow (/ d 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 t_2 = (c0 / (2.0 * w)) * (t_1 + sqrt(((t_1 * t_1) - (M * M))));
	double tmp;
	if (t_2 <= -4e-7) {
		tmp = c0 / ((2.0 * w) / (M + (((t_0 / h) * (d / D)) / (D / d))));
	} else if (t_2 <= 0.0) {
		tmp = 0.25 * (((pow(D, 2.0) * pow(M, 2.0)) / d) * (h / d));
	} else if (t_2 <= ((double) INFINITY)) {
		tmp = c0 / ((2.0 * w) / (M + ((t_0 * (d / D)) / (h * (D / d)))));
	} else {
		tmp = 0.25 * (-h / ((-1.0 / pow(M, 2.0)) * pow((d / 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 t_2 = (c0 / (2.0 * w)) * (t_1 + Math.sqrt(((t_1 * t_1) - (M * M))));
	double tmp;
	if (t_2 <= -4e-7) {
		tmp = c0 / ((2.0 * w) / (M + (((t_0 / h) * (d / D)) / (D / d))));
	} else if (t_2 <= 0.0) {
		tmp = 0.25 * (((Math.pow(D, 2.0) * Math.pow(M, 2.0)) / d) * (h / d));
	} else if (t_2 <= Double.POSITIVE_INFINITY) {
		tmp = c0 / ((2.0 * w) / (M + ((t_0 * (d / D)) / (h * (D / d)))));
	} else {
		tmp = 0.25 * (-h / ((-1.0 / Math.pow(M, 2.0)) * Math.pow((d / 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))
	t_2 = (c0 / (2.0 * w)) * (t_1 + math.sqrt(((t_1 * t_1) - (M * M))))
	tmp = 0
	if t_2 <= -4e-7:
		tmp = c0 / ((2.0 * w) / (M + (((t_0 / h) * (d / D)) / (D / d))))
	elif t_2 <= 0.0:
		tmp = 0.25 * (((math.pow(D, 2.0) * math.pow(M, 2.0)) / d) * (h / d))
	elif t_2 <= math.inf:
		tmp = c0 / ((2.0 * w) / (M + ((t_0 * (d / D)) / (h * (D / d)))))
	else:
		tmp = 0.25 * (-h / ((-1.0 / math.pow(M, 2.0)) * math.pow((d / D), 2.0)))
	return tmp
function code(c0, w, h, D, d, M)
	t_0 = Float64(Float64(c0 * 2.0) / w)
	t_1 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D)))
	t_2 = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_1 + sqrt(Float64(Float64(t_1 * t_1) - Float64(M * M)))))
	tmp = 0.0
	if (t_2 <= -4e-7)
		tmp = Float64(c0 / Float64(Float64(2.0 * w) / Float64(M + Float64(Float64(Float64(t_0 / h) * Float64(d / D)) / Float64(D / d)))));
	elseif (t_2 <= 0.0)
		tmp = Float64(0.25 * Float64(Float64(Float64((D ^ 2.0) * (M ^ 2.0)) / d) * Float64(h / d)));
	elseif (t_2 <= Inf)
		tmp = Float64(c0 / Float64(Float64(2.0 * w) / Float64(M + Float64(Float64(t_0 * Float64(d / D)) / Float64(h * Float64(D / d))))));
	else
		tmp = Float64(0.25 * Float64(Float64(-h) / Float64(Float64(-1.0 / (M ^ 2.0)) * (Float64(d / 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));
	t_2 = (c0 / (2.0 * w)) * (t_1 + sqrt(((t_1 * t_1) - (M * M))));
	tmp = 0.0;
	if (t_2 <= -4e-7)
		tmp = c0 / ((2.0 * w) / (M + (((t_0 / h) * (d / D)) / (D / d))));
	elseif (t_2 <= 0.0)
		tmp = 0.25 * ((((D ^ 2.0) * (M ^ 2.0)) / d) * (h / d));
	elseif (t_2 <= Inf)
		tmp = c0 / ((2.0 * w) / (M + ((t_0 * (d / D)) / (h * (D / d)))));
	else
		tmp = 0.25 * (-h / ((-1.0 / (M ^ 2.0)) * ((d / D) ^ 2.0)));
	end
	tmp_2 = tmp;
end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(N[(c0 * 2.0), $MachinePrecision] / w), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(t$95$1 + N[Sqrt[N[(N[(t$95$1 * t$95$1), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -4e-7], N[(c0 / N[(N[(2.0 * w), $MachinePrecision] / N[(M + N[(N[(N[(t$95$0 / h), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision] / N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 0.0], N[(0.25 * N[(N[(N[(N[Power[D, 2.0], $MachinePrecision] * N[Power[M, 2.0], $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision] * N[(h / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, Infinity], N[(c0 / N[(N[(2.0 * w), $MachinePrecision] / N[(M + N[(N[(t$95$0 * N[(d / D), $MachinePrecision]), $MachinePrecision] / N[(h * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.25 * N[((-h) / N[(N[(-1.0 / N[Power[M, 2.0], $MachinePrecision]), $MachinePrecision] * N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;t_2 \leq \infty:\\
\;\;\;\;\frac{c0}{\frac{2 \cdot w}{M + \frac{t_0 \cdot \frac{d}{D}}{h \cdot \frac{D}{d}}}}\\

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


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

    1. Initial program 67.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. Applied egg-rr73.4%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{\frac{w \cdot 2}{\color{blue}{M + \left({\left(\frac{d}{D}\right)}^{2} \cdot \frac{c0}{w \cdot h} + {\left(\frac{d}{D}\right)}^{2} \cdot \frac{c0}{w \cdot h}\right)}}} \]
      5. distribute-lft-out73.4%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{\frac{w \cdot 2}{M + \frac{\color{blue}{\frac{2 \cdot \frac{c0}{w}}{h}} \cdot \frac{d}{D}}{\frac{D}{d}}}} \]
      7. associate-*r/81.6%

        \[\leadsto \frac{c0}{\frac{w \cdot 2}{M + \frac{\frac{\color{blue}{\frac{2 \cdot c0}{w}}}{h} \cdot \frac{d}{D}}{\frac{D}{d}}}} \]
    8. Applied egg-rr81.6%

      \[\leadsto \frac{c0}{\frac{w \cdot 2}{M + \color{blue}{\frac{\frac{\frac{2 \cdot c0}{w}}{h} \cdot \frac{d}{D}}{\frac{D}{d}}}}} \]

    if -3.9999999999999998e-7 < (*.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

    1. Initial program 45.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. Simplified35.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)} \]
    3. Taylor expanded in c0 around -inf 72.3%

      \[\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)} \]
    4. Step-by-step derivation
      1. fma-def72.3%

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(-1, c0 \cdot \left(0 \cdot \frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w}\right), 0.5 \cdot \left(\frac{{D}^{2}}{c0 \cdot {d}^{2}} \cdot \left({M}^{2} \cdot \left(h \cdot w\right)\right)\right)\right)} \]
    6. Taylor expanded in c0 around 0 81.5%

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

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

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

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

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

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

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Applied egg-rr84.4%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{\frac{w \cdot 2}{\color{blue}{M + \left({\left(\frac{d}{D}\right)}^{2} \cdot \frac{c0}{w \cdot h} + {\left(\frac{d}{D}\right)}^{2} \cdot \frac{c0}{w \cdot h}\right)}}} \]
      5. distribute-lft-out84.4%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{\frac{w \cdot 2}{M + \frac{2 \cdot \frac{c0}{w}}{h} \cdot \color{blue}{\frac{\frac{d}{D}}{\frac{D}{d}}}}} \]
      6. frac-times87.3%

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

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

      \[\leadsto \frac{c0}{\frac{w \cdot 2}{M + \color{blue}{\frac{\frac{2 \cdot c0}{w} \cdot \frac{d}{D}}{h \cdot \frac{D}{d}}}}} \]

    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.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)} \]
    3. 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)} \]
    4. Step-by-step derivation
      1. fma-def3.0%

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(-1, c0 \cdot \left(0 \cdot \frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w}\right), 0.5 \cdot \left(\frac{{D}^{2}}{c0 \cdot {d}^{2}} \cdot \left({M}^{2} \cdot \left(h \cdot w\right)\right)\right)\right)} \]
    6. Taylor expanded in c0 around 0 39.3%

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

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

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

        \[\leadsto 0.25 \cdot \left(\left(-\color{blue}{\left({M}^{2} \cdot h\right) \cdot {D}^{2}}\right) \cdot \frac{1}{-{d}^{2}}\right) \]
      4. distribute-rgt-neg-in38.6%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.25 \cdot \color{blue}{\frac{-h}{\frac{-{d}^{2}}{{D}^{2} \cdot {M}^{2}}}} \]
      10. neg-mul-138.8%

        \[\leadsto 0.25 \cdot \frac{-h}{\frac{\color{blue}{-1 \cdot {d}^{2}}}{{D}^{2} \cdot {M}^{2}}} \]
      11. *-commutative38.8%

        \[\leadsto 0.25 \cdot \frac{-h}{\frac{-1 \cdot {d}^{2}}{\color{blue}{{M}^{2} \cdot {D}^{2}}}} \]
      12. times-frac39.5%

        \[\leadsto 0.25 \cdot \frac{-h}{\color{blue}{\frac{-1}{{M}^{2}} \cdot \frac{{d}^{2}}{{D}^{2}}}} \]
      13. unpow239.5%

        \[\leadsto 0.25 \cdot \frac{-h}{\frac{-1}{{M}^{2}} \cdot \frac{\color{blue}{d \cdot d}}{{D}^{2}}} \]
      14. unpow239.5%

        \[\leadsto 0.25 \cdot \frac{-h}{\frac{-1}{{M}^{2}} \cdot \frac{d \cdot d}{\color{blue}{D \cdot D}}} \]
      15. times-frac55.2%

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

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

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

Alternative 3: 62.9% accurate, 0.2× speedup?

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

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

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

\mathbf{else}:\\
\;\;\;\;\frac{c0}{\frac{2 \cdot w}{M + \frac{t_0 \cdot \frac{d}{D}}{h \cdot \frac{D}{d}}}}\\


\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))))) < -3.9999999999999998e-7

    1. Initial program 67.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. Applied egg-rr73.4%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{\frac{w \cdot 2}{\color{blue}{M + \left({\left(\frac{d}{D}\right)}^{2} \cdot \frac{c0}{w \cdot h} + {\left(\frac{d}{D}\right)}^{2} \cdot \frac{c0}{w \cdot h}\right)}}} \]
      5. distribute-lft-out73.4%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{\frac{w \cdot 2}{M + \frac{\color{blue}{\frac{2 \cdot \frac{c0}{w}}{h}} \cdot \frac{d}{D}}{\frac{D}{d}}}} \]
      7. associate-*r/81.6%

        \[\leadsto \frac{c0}{\frac{w \cdot 2}{M + \frac{\frac{\color{blue}{\frac{2 \cdot c0}{w}}}{h} \cdot \frac{d}{D}}{\frac{D}{d}}}} \]
    8. Applied egg-rr81.6%

      \[\leadsto \frac{c0}{\frac{w \cdot 2}{M + \color{blue}{\frac{\frac{\frac{2 \cdot c0}{w}}{h} \cdot \frac{d}{D}}{\frac{D}{d}}}}} \]

    if -3.9999999999999998e-7 < (*.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.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. Simplified3.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 7.4%

      \[\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)} \]
    4. Step-by-step derivation
      1. fma-def7.4%

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(-1, c0 \cdot \left(0 \cdot \frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w}\right), 0.5 \cdot \left(\frac{{D}^{2}}{c0 \cdot {d}^{2}} \cdot \left({M}^{2} \cdot \left(h \cdot w\right)\right)\right)\right)} \]
    6. Taylor expanded in c0 around 0 42.0%

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

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

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

        \[\leadsto \frac{0.25}{\color{blue}{\frac{\frac{{d}^{2}}{{D}^{2}}}{{M}^{2} \cdot h}}} \]
      4. unpow240.2%

        \[\leadsto \frac{0.25}{\frac{\frac{\color{blue}{d \cdot d}}{{D}^{2}}}{{M}^{2} \cdot h}} \]
      5. unpow240.2%

        \[\leadsto \frac{0.25}{\frac{\frac{d \cdot d}{\color{blue}{D \cdot D}}}{{M}^{2} \cdot h}} \]
      6. frac-times54.6%

        \[\leadsto \frac{0.25}{\frac{\color{blue}{\frac{d}{D} \cdot \frac{d}{D}}}{{M}^{2} \cdot h}} \]
      7. unpow254.6%

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

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

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

        \[\leadsto \frac{0.25}{\color{blue}{\frac{\frac{{\left(\frac{d}{D}\right)}^{2}}{h}}{{M}^{2}}}} \]
      2. associate-/r/53.8%

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

      \[\leadsto \color{blue}{\frac{0.25}{\frac{{\left(\frac{d}{D}\right)}^{2}}{h}} \cdot {M}^{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 84.7%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Applied egg-rr84.4%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{\frac{w \cdot 2}{\color{blue}{M + \left({\left(\frac{d}{D}\right)}^{2} \cdot \frac{c0}{w \cdot h} + {\left(\frac{d}{D}\right)}^{2} \cdot \frac{c0}{w \cdot h}\right)}}} \]
      5. distribute-lft-out84.4%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{\frac{w \cdot 2}{M + \frac{2 \cdot \frac{c0}{w}}{h} \cdot \color{blue}{\frac{\frac{d}{D}}{\frac{D}{d}}}}} \]
      6. frac-times87.3%

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

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

      \[\leadsto \frac{c0}{\frac{w \cdot 2}{M + \color{blue}{\frac{\frac{2 \cdot c0}{w} \cdot \frac{d}{D}}{h \cdot \frac{D}{d}}}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification63.7%

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

Alternative 4: 63.2% accurate, 0.2× speedup?

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

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

\mathbf{elif}\;t_3 \leq 0:\\
\;\;\;\;{M}^{2} \cdot \frac{0.25}{\frac{t_0}{h}}\\

\mathbf{elif}\;t_3 \leq \infty:\\
\;\;\;\;\frac{c0}{\frac{2 \cdot w}{M + \frac{t_1 \cdot \frac{d}{D}}{h \cdot \frac{D}{d}}}}\\

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


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

    1. Initial program 67.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. Applied egg-rr73.4%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{\frac{w \cdot 2}{\color{blue}{M + \left({\left(\frac{d}{D}\right)}^{2} \cdot \frac{c0}{w \cdot h} + {\left(\frac{d}{D}\right)}^{2} \cdot \frac{c0}{w \cdot h}\right)}}} \]
      5. distribute-lft-out73.4%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{\frac{w \cdot 2}{M + \frac{\color{blue}{\frac{2 \cdot \frac{c0}{w}}{h}} \cdot \frac{d}{D}}{\frac{D}{d}}}} \]
      7. associate-*r/81.6%

        \[\leadsto \frac{c0}{\frac{w \cdot 2}{M + \frac{\frac{\color{blue}{\frac{2 \cdot c0}{w}}}{h} \cdot \frac{d}{D}}{\frac{D}{d}}}} \]
    8. Applied egg-rr81.6%

      \[\leadsto \frac{c0}{\frac{w \cdot 2}{M + \color{blue}{\frac{\frac{\frac{2 \cdot c0}{w}}{h} \cdot \frac{d}{D}}{\frac{D}{d}}}}} \]

    if -3.9999999999999998e-7 < (*.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

    1. Initial program 45.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. Simplified35.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)} \]
    3. Taylor expanded in c0 around -inf 72.3%

      \[\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)} \]
    4. Step-by-step derivation
      1. fma-def72.3%

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(-1, c0 \cdot \left(0 \cdot \frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w}\right), 0.5 \cdot \left(\frac{{D}^{2}}{c0 \cdot {d}^{2}} \cdot \left({M}^{2} \cdot \left(h \cdot w\right)\right)\right)\right)} \]
    6. Taylor expanded in c0 around 0 81.5%

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

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

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

        \[\leadsto \frac{0.25}{\color{blue}{\frac{\frac{{d}^{2}}{{D}^{2}}}{{M}^{2} \cdot h}}} \]
      4. unpow272.9%

        \[\leadsto \frac{0.25}{\frac{\frac{\color{blue}{d \cdot d}}{{D}^{2}}}{{M}^{2} \cdot h}} \]
      5. unpow272.9%

        \[\leadsto \frac{0.25}{\frac{\frac{d \cdot d}{\color{blue}{D \cdot D}}}{{M}^{2} \cdot h}} \]
      6. frac-times72.9%

        \[\leadsto \frac{0.25}{\frac{\color{blue}{\frac{d}{D} \cdot \frac{d}{D}}}{{M}^{2} \cdot h}} \]
      7. unpow272.9%

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

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

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

        \[\leadsto \frac{0.25}{\color{blue}{\frac{\frac{{\left(\frac{d}{D}\right)}^{2}}{h}}{{M}^{2}}}} \]
      2. associate-/r/75.0%

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

      \[\leadsto \color{blue}{\frac{0.25}{\frac{{\left(\frac{d}{D}\right)}^{2}}{h}} \cdot {M}^{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 84.7%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Applied egg-rr84.4%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{\frac{w \cdot 2}{\color{blue}{M + \left({\left(\frac{d}{D}\right)}^{2} \cdot \frac{c0}{w \cdot h} + {\left(\frac{d}{D}\right)}^{2} \cdot \frac{c0}{w \cdot h}\right)}}} \]
      5. distribute-lft-out84.4%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{\frac{w \cdot 2}{M + \frac{2 \cdot \frac{c0}{w}}{h} \cdot \color{blue}{\frac{\frac{d}{D}}{\frac{D}{d}}}}} \]
      6. frac-times87.3%

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

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

      \[\leadsto \frac{c0}{\frac{w \cdot 2}{M + \color{blue}{\frac{\frac{2 \cdot c0}{w} \cdot \frac{d}{D}}{h \cdot \frac{D}{d}}}}} \]

    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.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)} \]
    3. 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)} \]
    4. Step-by-step derivation
      1. fma-def3.0%

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(-1, c0 \cdot \left(0 \cdot \frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w}\right), 0.5 \cdot \left(\frac{{D}^{2}}{c0 \cdot {d}^{2}} \cdot \left({M}^{2} \cdot \left(h \cdot w\right)\right)\right)\right)} \]
    6. Taylor expanded in c0 around 0 39.3%

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

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

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

        \[\leadsto \frac{0.25}{\color{blue}{\frac{\frac{{d}^{2}}{{D}^{2}}}{{M}^{2} \cdot h}}} \]
      4. unpow238.0%

        \[\leadsto \frac{0.25}{\frac{\frac{\color{blue}{d \cdot d}}{{D}^{2}}}{{M}^{2} \cdot h}} \]
      5. unpow238.0%

        \[\leadsto \frac{0.25}{\frac{\frac{d \cdot d}{\color{blue}{D \cdot D}}}{{M}^{2} \cdot h}} \]
      6. frac-times53.4%

        \[\leadsto \frac{0.25}{\frac{\color{blue}{\frac{d}{D} \cdot \frac{d}{D}}}{{M}^{2} \cdot h}} \]
      7. unpow253.4%

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

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

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

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

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

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

Alternative 5: 63.0% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c0 \cdot 2}{w}\\ t_1 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\ t_2 := \frac{c0}{2 \cdot w} \cdot \left(t_1 + \sqrt{t_1 \cdot t_1 - M \cdot M}\right)\\ \mathbf{if}\;t_2 \leq -4 \cdot 10^{-7}:\\ \;\;\;\;\frac{c0}{\frac{2 \cdot w}{M + \frac{\frac{t_0}{h} \cdot \frac{d}{D}}{\frac{D}{d}}}}\\ \mathbf{elif}\;t_2 \leq 0:\\ \;\;\;\;0.25 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{d} \cdot \frac{h}{d}\right)\\ \mathbf{elif}\;t_2 \leq \infty:\\ \;\;\;\;\frac{c0}{\frac{2 \cdot w}{M + \frac{t_0 \cdot \frac{d}{D}}{h \cdot \frac{D}{d}}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.25}{{\left(\frac{d}{D}\right)}^{2}} \cdot \left(h \cdot {M}^{2}\right)\\ \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))))
        (t_2 (* (/ c0 (* 2.0 w)) (+ t_1 (sqrt (- (* t_1 t_1) (* M M)))))))
   (if (<= t_2 -4e-7)
     (/ c0 (/ (* 2.0 w) (+ M (/ (* (/ t_0 h) (/ d D)) (/ D d)))))
     (if (<= t_2 0.0)
       (* 0.25 (* (/ (* (pow D 2.0) (pow M 2.0)) d) (/ h d)))
       (if (<= t_2 INFINITY)
         (/ c0 (/ (* 2.0 w) (+ M (/ (* t_0 (/ d D)) (* h (/ D d))))))
         (* (/ 0.25 (pow (/ d D) 2.0)) (* h (pow M 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 t_2 = (c0 / (2.0 * w)) * (t_1 + sqrt(((t_1 * t_1) - (M * M))));
	double tmp;
	if (t_2 <= -4e-7) {
		tmp = c0 / ((2.0 * w) / (M + (((t_0 / h) * (d / D)) / (D / d))));
	} else if (t_2 <= 0.0) {
		tmp = 0.25 * (((pow(D, 2.0) * pow(M, 2.0)) / d) * (h / d));
	} else if (t_2 <= ((double) INFINITY)) {
		tmp = c0 / ((2.0 * w) / (M + ((t_0 * (d / D)) / (h * (D / d)))));
	} else {
		tmp = (0.25 / pow((d / D), 2.0)) * (h * pow(M, 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 t_2 = (c0 / (2.0 * w)) * (t_1 + Math.sqrt(((t_1 * t_1) - (M * M))));
	double tmp;
	if (t_2 <= -4e-7) {
		tmp = c0 / ((2.0 * w) / (M + (((t_0 / h) * (d / D)) / (D / d))));
	} else if (t_2 <= 0.0) {
		tmp = 0.25 * (((Math.pow(D, 2.0) * Math.pow(M, 2.0)) / d) * (h / d));
	} else if (t_2 <= Double.POSITIVE_INFINITY) {
		tmp = c0 / ((2.0 * w) / (M + ((t_0 * (d / D)) / (h * (D / d)))));
	} else {
		tmp = (0.25 / Math.pow((d / D), 2.0)) * (h * Math.pow(M, 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))
	t_2 = (c0 / (2.0 * w)) * (t_1 + math.sqrt(((t_1 * t_1) - (M * M))))
	tmp = 0
	if t_2 <= -4e-7:
		tmp = c0 / ((2.0 * w) / (M + (((t_0 / h) * (d / D)) / (D / d))))
	elif t_2 <= 0.0:
		tmp = 0.25 * (((math.pow(D, 2.0) * math.pow(M, 2.0)) / d) * (h / d))
	elif t_2 <= math.inf:
		tmp = c0 / ((2.0 * w) / (M + ((t_0 * (d / D)) / (h * (D / d)))))
	else:
		tmp = (0.25 / math.pow((d / D), 2.0)) * (h * math.pow(M, 2.0))
	return tmp
function code(c0, w, h, D, d, M)
	t_0 = Float64(Float64(c0 * 2.0) / w)
	t_1 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D)))
	t_2 = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_1 + sqrt(Float64(Float64(t_1 * t_1) - Float64(M * M)))))
	tmp = 0.0
	if (t_2 <= -4e-7)
		tmp = Float64(c0 / Float64(Float64(2.0 * w) / Float64(M + Float64(Float64(Float64(t_0 / h) * Float64(d / D)) / Float64(D / d)))));
	elseif (t_2 <= 0.0)
		tmp = Float64(0.25 * Float64(Float64(Float64((D ^ 2.0) * (M ^ 2.0)) / d) * Float64(h / d)));
	elseif (t_2 <= Inf)
		tmp = Float64(c0 / Float64(Float64(2.0 * w) / Float64(M + Float64(Float64(t_0 * Float64(d / D)) / Float64(h * Float64(D / d))))));
	else
		tmp = Float64(Float64(0.25 / (Float64(d / D) ^ 2.0)) * Float64(h * (M ^ 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));
	t_2 = (c0 / (2.0 * w)) * (t_1 + sqrt(((t_1 * t_1) - (M * M))));
	tmp = 0.0;
	if (t_2 <= -4e-7)
		tmp = c0 / ((2.0 * w) / (M + (((t_0 / h) * (d / D)) / (D / d))));
	elseif (t_2 <= 0.0)
		tmp = 0.25 * ((((D ^ 2.0) * (M ^ 2.0)) / d) * (h / d));
	elseif (t_2 <= Inf)
		tmp = c0 / ((2.0 * w) / (M + ((t_0 * (d / D)) / (h * (D / d)))));
	else
		tmp = (0.25 / ((d / D) ^ 2.0)) * (h * (M ^ 2.0));
	end
	tmp_2 = tmp;
end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(N[(c0 * 2.0), $MachinePrecision] / w), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(t$95$1 + N[Sqrt[N[(N[(t$95$1 * t$95$1), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -4e-7], N[(c0 / N[(N[(2.0 * w), $MachinePrecision] / N[(M + N[(N[(N[(t$95$0 / h), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision] / N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 0.0], N[(0.25 * N[(N[(N[(N[Power[D, 2.0], $MachinePrecision] * N[Power[M, 2.0], $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision] * N[(h / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, Infinity], N[(c0 / N[(N[(2.0 * w), $MachinePrecision] / N[(M + N[(N[(t$95$0 * N[(d / D), $MachinePrecision]), $MachinePrecision] / N[(h * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.25 / N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h * N[Power[M, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;t_2 \leq \infty:\\
\;\;\;\;\frac{c0}{\frac{2 \cdot w}{M + \frac{t_0 \cdot \frac{d}{D}}{h \cdot \frac{D}{d}}}}\\

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


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

    1. Initial program 67.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. Applied egg-rr73.4%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{\frac{w \cdot 2}{\color{blue}{M + \left({\left(\frac{d}{D}\right)}^{2} \cdot \frac{c0}{w \cdot h} + {\left(\frac{d}{D}\right)}^{2} \cdot \frac{c0}{w \cdot h}\right)}}} \]
      5. distribute-lft-out73.4%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{\frac{w \cdot 2}{M + \frac{\color{blue}{\frac{2 \cdot \frac{c0}{w}}{h}} \cdot \frac{d}{D}}{\frac{D}{d}}}} \]
      7. associate-*r/81.6%

        \[\leadsto \frac{c0}{\frac{w \cdot 2}{M + \frac{\frac{\color{blue}{\frac{2 \cdot c0}{w}}}{h} \cdot \frac{d}{D}}{\frac{D}{d}}}} \]
    8. Applied egg-rr81.6%

      \[\leadsto \frac{c0}{\frac{w \cdot 2}{M + \color{blue}{\frac{\frac{\frac{2 \cdot c0}{w}}{h} \cdot \frac{d}{D}}{\frac{D}{d}}}}} \]

    if -3.9999999999999998e-7 < (*.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

    1. Initial program 45.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. Simplified35.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)} \]
    3. Taylor expanded in c0 around -inf 72.3%

      \[\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)} \]
    4. Step-by-step derivation
      1. fma-def72.3%

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(-1, c0 \cdot \left(0 \cdot \frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w}\right), 0.5 \cdot \left(\frac{{D}^{2}}{c0 \cdot {d}^{2}} \cdot \left({M}^{2} \cdot \left(h \cdot w\right)\right)\right)\right)} \]
    6. Taylor expanded in c0 around 0 81.5%

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

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

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

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

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

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

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Applied egg-rr84.4%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{\frac{w \cdot 2}{\color{blue}{M + \left({\left(\frac{d}{D}\right)}^{2} \cdot \frac{c0}{w \cdot h} + {\left(\frac{d}{D}\right)}^{2} \cdot \frac{c0}{w \cdot h}\right)}}} \]
      5. distribute-lft-out84.4%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{\frac{w \cdot 2}{M + \frac{2 \cdot \frac{c0}{w}}{h} \cdot \color{blue}{\frac{\frac{d}{D}}{\frac{D}{d}}}}} \]
      6. frac-times87.3%

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

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

      \[\leadsto \frac{c0}{\frac{w \cdot 2}{M + \color{blue}{\frac{\frac{2 \cdot c0}{w} \cdot \frac{d}{D}}{h \cdot \frac{D}{d}}}}} \]

    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.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)} \]
    3. 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)} \]
    4. Step-by-step derivation
      1. fma-def3.0%

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(-1, c0 \cdot \left(0 \cdot \frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w}\right), 0.5 \cdot \left(\frac{{D}^{2}}{c0 \cdot {d}^{2}} \cdot \left({M}^{2} \cdot \left(h \cdot w\right)\right)\right)\right)} \]
    6. Taylor expanded in c0 around 0 39.3%

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

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

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

        \[\leadsto \frac{0.25}{\color{blue}{\frac{\frac{{d}^{2}}{{D}^{2}}}{{M}^{2} \cdot h}}} \]
      4. unpow238.0%

        \[\leadsto \frac{0.25}{\frac{\frac{\color{blue}{d \cdot d}}{{D}^{2}}}{{M}^{2} \cdot h}} \]
      5. unpow238.0%

        \[\leadsto \frac{0.25}{\frac{\frac{d \cdot d}{\color{blue}{D \cdot D}}}{{M}^{2} \cdot h}} \]
      6. frac-times53.4%

        \[\leadsto \frac{0.25}{\frac{\color{blue}{\frac{d}{D} \cdot \frac{d}{D}}}{{M}^{2} \cdot h}} \]
      7. unpow253.4%

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

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

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

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

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

Alternative 6: 49.5% accurate, 0.4× 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)}\\ \mathbf{if}\;\frac{c0}{2 \cdot w} \cdot \left(t_0 + \sqrt{t_0 \cdot t_0 - M \cdot M}\right) \leq \infty:\\ \;\;\;\;\frac{c0}{\frac{2 \cdot w}{M + \frac{\frac{\frac{c0 \cdot 2}{w}}{h} \cdot \frac{d}{D}}{\frac{D}{d}}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{w}{\frac{M}{2}}\right)\right)}\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (let* ((t_0 (/ (* c0 (* d d)) (* (* w h) (* D D)))))
   (if (<=
        (* (/ c0 (* 2.0 w)) (+ t_0 (sqrt (- (* t_0 t_0) (* M M)))))
        INFINITY)
     (/ c0 (/ (* 2.0 w) (+ M (/ (* (/ (/ (* c0 2.0) w) h) (/ d D)) (/ D d)))))
     (/ c0 (log1p (expm1 (/ w (/ M 2.0))))))))
double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
	double tmp;
	if (((c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))))) <= ((double) INFINITY)) {
		tmp = c0 / ((2.0 * w) / (M + (((((c0 * 2.0) / w) / h) * (d / D)) / (D / d))));
	} else {
		tmp = c0 / log1p(expm1((w / (M / 2.0))));
	}
	return tmp;
}
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));
	double tmp;
	if (((c0 / (2.0 * w)) * (t_0 + Math.sqrt(((t_0 * t_0) - (M * M))))) <= Double.POSITIVE_INFINITY) {
		tmp = c0 / ((2.0 * w) / (M + (((((c0 * 2.0) / w) / h) * (d / D)) / (D / d))));
	} else {
		tmp = c0 / Math.log1p(Math.expm1((w / (M / 2.0))));
	}
	return tmp;
}
def code(c0, w, h, D, d, M):
	t_0 = (c0 * (d * d)) / ((w * h) * (D * D))
	tmp = 0
	if ((c0 / (2.0 * w)) * (t_0 + math.sqrt(((t_0 * t_0) - (M * M))))) <= math.inf:
		tmp = c0 / ((2.0 * w) / (M + (((((c0 * 2.0) / w) / h) * (d / D)) / (D / d))))
	else:
		tmp = c0 / math.log1p(math.expm1((w / (M / 2.0))))
	return tmp
function code(c0, w, h, D, d, M)
	t_0 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D)))
	tmp = 0.0
	if (Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_0 + sqrt(Float64(Float64(t_0 * t_0) - Float64(M * M))))) <= Inf)
		tmp = Float64(c0 / Float64(Float64(2.0 * w) / Float64(M + Float64(Float64(Float64(Float64(Float64(c0 * 2.0) / w) / h) * Float64(d / D)) / Float64(D / d)))));
	else
		tmp = Float64(c0 / log1p(expm1(Float64(w / Float64(M / 2.0)))));
	end
	return tmp
end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 + N[Sqrt[N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(c0 / N[(N[(2.0 * w), $MachinePrecision] / N[(M + N[(N[(N[(N[(N[(c0 * 2.0), $MachinePrecision] / w), $MachinePrecision] / h), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision] / N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 / N[Log[1 + N[(Exp[N[(w / N[(M / 2.0), $MachinePrecision]), $MachinePrecision]] - 1), $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)}\\
\mathbf{if}\;\frac{c0}{2 \cdot w} \cdot \left(t_0 + \sqrt{t_0 \cdot t_0 - M \cdot M}\right) \leq \infty:\\
\;\;\;\;\frac{c0}{\frac{2 \cdot w}{M + \frac{\frac{\frac{c0 \cdot 2}{w}}{h} \cdot \frac{d}{D}}{\frac{D}{d}}}}\\

\mathbf{else}:\\
\;\;\;\;\frac{c0}{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{w}{\frac{M}{2}}\right)\right)}\\


\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 71.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. Applied egg-rr70.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{\frac{w \cdot 2}{M + \left(2 \cdot \frac{\frac{c0}{w}}{h}\right) \cdot \left(\frac{d}{D} \cdot \color{blue}{\frac{1}{\frac{D}{d}}}\right)}} \]
      4. div-inv72.6%

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

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

        \[\leadsto \frac{c0}{\frac{w \cdot 2}{M + \frac{\color{blue}{\frac{2 \cdot \frac{c0}{w}}{h}} \cdot \frac{d}{D}}{\frac{D}{d}}}} \]
      7. associate-*r/76.7%

        \[\leadsto \frac{c0}{\frac{w \cdot 2}{M + \frac{\frac{\color{blue}{\frac{2 \cdot c0}{w}}}{h} \cdot \frac{d}{D}}{\frac{D}{d}}}} \]
    8. Applied egg-rr76.7%

      \[\leadsto \frac{c0}{\frac{w \cdot 2}{M + \color{blue}{\frac{\frac{\frac{2 \cdot c0}{w}}{h} \cdot \frac{d}{D}}{\frac{D}{d}}}}} \]

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

    1. Initial program 0.0%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Applied egg-rr26.3%

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

      \[\leadsto \frac{c0}{\color{blue}{2 \cdot \frac{w}{M}}} \]
    4. Step-by-step derivation
      1. log1p-expm1-u36.8%

        \[\leadsto \frac{c0}{\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(2 \cdot \frac{w}{M}\right)\right)}} \]
      2. associate-*r/36.8%

        \[\leadsto \frac{c0}{\mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\frac{2 \cdot w}{M}}\right)\right)} \]
      3. *-commutative36.8%

        \[\leadsto \frac{c0}{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\color{blue}{w \cdot 2}}{M}\right)\right)} \]
      4. associate-/l*36.8%

        \[\leadsto \frac{c0}{\mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\frac{w}{\frac{M}{2}}}\right)\right)} \]
    5. Applied egg-rr36.8%

      \[\leadsto \frac{c0}{\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{w}{\frac{M}{2}}\right)\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification51.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 \infty:\\ \;\;\;\;\frac{c0}{\frac{2 \cdot w}{M + \frac{\frac{\frac{c0 \cdot 2}{w}}{h} \cdot \frac{d}{D}}{\frac{D}{d}}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{w}{\frac{M}{2}}\right)\right)}\\ \end{array} \]

Alternative 7: 47.5% accurate, 5.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;w \leq -1.9 \cdot 10^{+20} \lor \neg \left(w \leq 1.65 \cdot 10^{+115}\right):\\
\;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(c0 \cdot 0\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{c0}{\frac{2 \cdot w}{M + \frac{\frac{c0 \cdot 2}{w} \cdot \frac{d}{D}}{h \cdot \frac{D}{d}}}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if w < -1.9e20 or 1.65000000000000003e115 < w

    1. Initial program 14.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. Simplified16.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)} \]
    3. Taylor expanded in c0 around -inf 11.2%

      \[\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. associate-*r*11.2%

        \[\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-111.2%

        \[\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-in11.2%

        \[\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-eval11.2%

        \[\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. *-commutative11.2%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\left(-c0\right) \cdot \left(0 \cdot \frac{\color{blue}{\frac{\frac{d}{1} \cdot \frac{d}{D}}{D}}}{w \cdot h}\right)\right) \]
      14. /-rgt-identity19.7%

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

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

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

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

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\left(-c0\right) \cdot \color{blue}{0}\right) \]

    if -1.9e20 < w < 1.65000000000000003e115

    1. Initial program 31.3%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Applied egg-rr48.3%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{\frac{w \cdot 2}{\color{blue}{M + \left({\left(\frac{d}{D}\right)}^{2} \cdot \frac{c0}{w \cdot h} + {\left(\frac{d}{D}\right)}^{2} \cdot \frac{c0}{w \cdot h}\right)}}} \]
      5. distribute-lft-out48.3%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{\frac{w \cdot 2}{M + \frac{2 \cdot \frac{c0}{w}}{h} \cdot \color{blue}{\frac{\frac{d}{D}}{\frac{D}{d}}}}} \]
      6. frac-times52.6%

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

        \[\leadsto \frac{c0}{\frac{w \cdot 2}{M + \frac{\color{blue}{\frac{2 \cdot c0}{w}} \cdot \frac{d}{D}}{h \cdot \frac{D}{d}}}} \]
    8. Applied egg-rr52.6%

      \[\leadsto \frac{c0}{\frac{w \cdot 2}{M + \color{blue}{\frac{\frac{2 \cdot c0}{w} \cdot \frac{d}{D}}{h \cdot \frac{D}{d}}}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification51.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;w \leq -1.9 \cdot 10^{+20} \lor \neg \left(w \leq 1.65 \cdot 10^{+115}\right):\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(c0 \cdot 0\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{\frac{2 \cdot w}{M + \frac{\frac{c0 \cdot 2}{w} \cdot \frac{d}{D}}{h \cdot \frac{D}{d}}}}\\ \end{array} \]

Alternative 8: 47.6% accurate, 6.6× speedup?

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

\\
\frac{c0}{\frac{2 \cdot w}{M + \frac{\frac{\frac{c0 \cdot 2}{w}}{h} \cdot \frac{d}{D}}{\frac{D}{d}}}}
\end{array}
Derivation
  1. Initial program 26.7%

    \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
  2. Applied egg-rr42.7%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{c0}{\frac{w \cdot 2}{\color{blue}{M + \left({\left(\frac{d}{D}\right)}^{2} \cdot \frac{c0}{w \cdot h} + {\left(\frac{d}{D}\right)}^{2} \cdot \frac{c0}{w \cdot h}\right)}}} \]
    5. distribute-lft-out42.7%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{c0}{\frac{w \cdot 2}{M + \frac{\color{blue}{\frac{2 \cdot \frac{c0}{w}}{h}} \cdot \frac{d}{D}}{\frac{D}{d}}}} \]
    7. associate-*r/49.1%

      \[\leadsto \frac{c0}{\frac{w \cdot 2}{M + \frac{\frac{\color{blue}{\frac{2 \cdot c0}{w}}}{h} \cdot \frac{d}{D}}{\frac{D}{d}}}} \]
  8. Applied egg-rr49.1%

    \[\leadsto \frac{c0}{\frac{w \cdot 2}{M + \color{blue}{\frac{\frac{\frac{2 \cdot c0}{w}}{h} \cdot \frac{d}{D}}{\frac{D}{d}}}}} \]
  9. Final simplification49.1%

    \[\leadsto \frac{c0}{\frac{2 \cdot w}{M + \frac{\frac{\frac{c0 \cdot 2}{w}}{h} \cdot \frac{d}{D}}{\frac{D}{d}}}} \]

Alternative 9: 28.6% accurate, 11.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;w \leq -4.6 \cdot 10^{-206} \lor \neg \left(w \leq 1.25 \cdot 10^{-50}\right):\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(c0 \cdot 0\right)\\ \mathbf{else}:\\ \;\;\;\;M \cdot \left(\frac{c0}{w} \cdot 0.5\right)\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (if (or (<= w -4.6e-206) (not (<= w 1.25e-50)))
   (* (/ c0 (* 2.0 w)) (* c0 0.0))
   (* M (* (/ c0 w) 0.5))))
double code(double c0, double w, double h, double D, double d, double M) {
	double tmp;
	if ((w <= -4.6e-206) || !(w <= 1.25e-50)) {
		tmp = (c0 / (2.0 * w)) * (c0 * 0.0);
	} else {
		tmp = M * ((c0 / w) * 0.5);
	}
	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 ((w <= (-4.6d-206)) .or. (.not. (w <= 1.25d-50))) then
        tmp = (c0 / (2.0d0 * w)) * (c0 * 0.0d0)
    else
        tmp = m * ((c0 / w) * 0.5d0)
    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 ((w <= -4.6e-206) || !(w <= 1.25e-50)) {
		tmp = (c0 / (2.0 * w)) * (c0 * 0.0);
	} else {
		tmp = M * ((c0 / w) * 0.5);
	}
	return tmp;
}
def code(c0, w, h, D, d, M):
	tmp = 0
	if (w <= -4.6e-206) or not (w <= 1.25e-50):
		tmp = (c0 / (2.0 * w)) * (c0 * 0.0)
	else:
		tmp = M * ((c0 / w) * 0.5)
	return tmp
function code(c0, w, h, D, d, M)
	tmp = 0.0
	if ((w <= -4.6e-206) || !(w <= 1.25e-50))
		tmp = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(c0 * 0.0));
	else
		tmp = Float64(M * Float64(Float64(c0 / w) * 0.5));
	end
	return tmp
end
function tmp_2 = code(c0, w, h, D, d, M)
	tmp = 0.0;
	if ((w <= -4.6e-206) || ~((w <= 1.25e-50)))
		tmp = (c0 / (2.0 * w)) * (c0 * 0.0);
	else
		tmp = M * ((c0 / w) * 0.5);
	end
	tmp_2 = tmp;
end
code[c0_, w_, h_, D_, d_, M_] := If[Or[LessEqual[w, -4.6e-206], N[Not[LessEqual[w, 1.25e-50]], $MachinePrecision]], N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(c0 * 0.0), $MachinePrecision]), $MachinePrecision], N[(M * N[(N[(c0 / w), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;w \leq -4.6 \cdot 10^{-206} \lor \neg \left(w \leq 1.25 \cdot 10^{-50}\right):\\
\;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(c0 \cdot 0\right)\\

\mathbf{else}:\\
\;\;\;\;M \cdot \left(\frac{c0}{w} \cdot 0.5\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if w < -4.6e-206 or 1.24999999999999992e-50 < w

    1. Initial program 21.3%

      \[\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. Simplified22.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)} \]
    3. Taylor expanded in c0 around -inf 6.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. associate-*r*6.7%

        \[\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-16.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\left(-c0\right) \cdot \color{blue}{0}\right) \]

    if -4.6e-206 < w < 1.24999999999999992e-50

    1. Initial program 34.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. Applied egg-rr50.5%

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

      \[\leadsto \frac{c0}{\color{blue}{2 \cdot \frac{w}{M}}} \]
    4. Step-by-step derivation
      1. associate-*r/20.3%

        \[\leadsto \frac{c0}{\color{blue}{\frac{2 \cdot w}{M}}} \]
      2. *-commutative20.3%

        \[\leadsto \frac{c0}{\frac{\color{blue}{w \cdot 2}}{M}} \]
      3. associate-/r/21.2%

        \[\leadsto \color{blue}{\frac{c0}{w \cdot 2} \cdot M} \]
      4. *-un-lft-identity21.2%

        \[\leadsto \frac{\color{blue}{1 \cdot c0}}{w \cdot 2} \cdot M \]
      5. metadata-eval21.2%

        \[\leadsto \frac{\color{blue}{\frac{2}{2}} \cdot c0}{w \cdot 2} \cdot M \]
      6. *-commutative21.2%

        \[\leadsto \frac{\frac{2}{2} \cdot c0}{\color{blue}{2 \cdot w}} \cdot M \]
      7. times-frac21.2%

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

        \[\leadsto \left(\frac{\color{blue}{1}}{2} \cdot \frac{c0}{w}\right) \cdot M \]
      9. metadata-eval21.2%

        \[\leadsto \left(\color{blue}{0.5} \cdot \frac{c0}{w}\right) \cdot M \]
    5. Applied egg-rr21.2%

      \[\leadsto \color{blue}{\left(0.5 \cdot \frac{c0}{w}\right) \cdot M} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification30.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;w \leq -4.6 \cdot 10^{-206} \lor \neg \left(w \leq 1.25 \cdot 10^{-50}\right):\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(c0 \cdot 0\right)\\ \mathbf{else}:\\ \;\;\;\;M \cdot \left(\frac{c0}{w} \cdot 0.5\right)\\ \end{array} \]

Alternative 10: 18.0% accurate, 21.6× speedup?

\[\begin{array}{l} \\ 0.5 \cdot \frac{M}{\frac{w}{c0}} \end{array} \]
(FPCore (c0 w h D d M) :precision binary64 (* 0.5 (/ M (/ w c0))))
double code(double c0, double w, double h, double D, double d, double M) {
	return 0.5 * (M / (w / c0));
}
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.5d0 * (m / (w / c0))
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
	return 0.5 * (M / (w / c0));
}
def code(c0, w, h, D, d, M):
	return 0.5 * (M / (w / c0))
function code(c0, w, h, D, d, M)
	return Float64(0.5 * Float64(M / Float64(w / c0)))
end
function tmp = code(c0, w, h, D, d, M)
	tmp = 0.5 * (M / (w / c0));
end
code[c0_, w_, h_, D_, d_, M_] := N[(0.5 * N[(M / N[(w / c0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
0.5 \cdot \frac{M}{\frac{w}{c0}}
\end{array}
Derivation
  1. Initial program 26.7%

    \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
  2. Applied egg-rr42.7%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{c0}{\frac{w \cdot 2}{\color{blue}{M + \left({\left(\frac{d}{D}\right)}^{2} \cdot \frac{c0}{w \cdot h} + {\left(\frac{d}{D}\right)}^{2} \cdot \frac{c0}{w \cdot h}\right)}}} \]
    5. distribute-lft-out42.7%

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

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

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

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

    \[\leadsto \color{blue}{0.5 \cdot \frac{M \cdot c0}{w}} \]
  8. Step-by-step derivation
    1. associate-/l*17.2%

      \[\leadsto 0.5 \cdot \color{blue}{\frac{M}{\frac{w}{c0}}} \]
  9. Simplified17.2%

    \[\leadsto \color{blue}{0.5 \cdot \frac{M}{\frac{w}{c0}}} \]
  10. Final simplification17.2%

    \[\leadsto 0.5 \cdot \frac{M}{\frac{w}{c0}} \]

Alternative 11: 18.1% accurate, 21.6× speedup?

\[\begin{array}{l} \\ M \cdot \left(\frac{c0}{w} \cdot 0.5\right) \end{array} \]
(FPCore (c0 w h D d M) :precision binary64 (* M (* (/ c0 w) 0.5)))
double code(double c0, double w, double h, double D, double d, double M) {
	return M * ((c0 / w) * 0.5);
}
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 = m * ((c0 / w) * 0.5d0)
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
	return M * ((c0 / w) * 0.5);
}
def code(c0, w, h, D, d, M):
	return M * ((c0 / w) * 0.5)
function code(c0, w, h, D, d, M)
	return Float64(M * Float64(Float64(c0 / w) * 0.5))
end
function tmp = code(c0, w, h, D, d, M)
	tmp = M * ((c0 / w) * 0.5);
end
code[c0_, w_, h_, D_, d_, M_] := N[(M * N[(N[(c0 / w), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
M \cdot \left(\frac{c0}{w} \cdot 0.5\right)
\end{array}
Derivation
  1. Initial program 26.7%

    \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
  2. Applied egg-rr42.7%

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

    \[\leadsto \frac{c0}{\color{blue}{2 \cdot \frac{w}{M}}} \]
  4. Step-by-step derivation
    1. associate-*r/18.3%

      \[\leadsto \frac{c0}{\color{blue}{\frac{2 \cdot w}{M}}} \]
    2. *-commutative18.3%

      \[\leadsto \frac{c0}{\frac{\color{blue}{w \cdot 2}}{M}} \]
    3. associate-/r/17.2%

      \[\leadsto \color{blue}{\frac{c0}{w \cdot 2} \cdot M} \]
    4. *-un-lft-identity17.2%

      \[\leadsto \frac{\color{blue}{1 \cdot c0}}{w \cdot 2} \cdot M \]
    5. metadata-eval17.2%

      \[\leadsto \frac{\color{blue}{\frac{2}{2}} \cdot c0}{w \cdot 2} \cdot M \]
    6. *-commutative17.2%

      \[\leadsto \frac{\frac{2}{2} \cdot c0}{\color{blue}{2 \cdot w}} \cdot M \]
    7. times-frac17.2%

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

      \[\leadsto \left(\frac{\color{blue}{1}}{2} \cdot \frac{c0}{w}\right) \cdot M \]
    9. metadata-eval17.2%

      \[\leadsto \left(\color{blue}{0.5} \cdot \frac{c0}{w}\right) \cdot M \]
  5. Applied egg-rr17.2%

    \[\leadsto \color{blue}{\left(0.5 \cdot \frac{c0}{w}\right) \cdot M} \]
  6. Final simplification17.2%

    \[\leadsto M \cdot \left(\frac{c0}{w} \cdot 0.5\right) \]

Reproduce

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