Henrywood and Agarwal, Equation (13)

Percentage Accurate: 25.2% → 50.4%
Time: 26.7s
Alternatives: 7
Speedup: 21.6×

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 7 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: 25.2% accurate, 1.0× speedup?

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

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

Alternative 1: 50.4% accurate, 0.5× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (/.f64 c0 (*.f64 2 w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) < +inf.0

    1. Initial program 80.1%

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

    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. Simplified2.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 1.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*1.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-11.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-in1.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-eval1.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. mul0-lft42.4%

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(c0 \cdot \color{blue}{\left(-1 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)} + \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)}\right) \]
      12. distribute-lft-in0.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \leq \infty:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(\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)\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot 0\\ \end{array} \]

Alternative 2: 45.4% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{\frac{c0}{w}}{h} \cdot {\left(\frac{d}{D}\right)}^{2}\\
t_1 := \frac{c0}{2 \cdot w}\\
t_2 := t_1 \cdot \left(2 \cdot t_0\right)\\
t_3 := t_1 \cdot 0\\
\mathbf{if}\;c0 \leq -2.5 \cdot 10^{-154}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;c0 \leq 9 \cdot 10^{-38}:\\
\;\;\;\;t_3\\

\mathbf{elif}\;c0 \leq 5.6 \cdot 10^{+72}:\\
\;\;\;\;t_1 \cdot \left(t_0 + \frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right)\right)\\

\mathbf{elif}\;c0 \leq 4 \cdot 10^{+101}:\\
\;\;\;\;t_3\\

\mathbf{else}:\\
\;\;\;\;t_2\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c0 < -2.5000000000000001e-154 or 3.9999999999999999e101 < c0

    1. Initial program 27.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.5000000000000001e-154 < c0 < 9.00000000000000018e-38 or 5.5999999999999998e72 < c0 < 3.9999999999999999e101

    1. Initial program 18.1%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Simplified20.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 6.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*6.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-16.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-in6.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-eval6.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. mul0-lft53.2%

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

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

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

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

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

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

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

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

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

    if 9.00000000000000018e-38 < c0 < 5.5999999999999998e72

    1. Initial program 26.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. Simplified27.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 42.7%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D} + \frac{\frac{c0}{w}}{h} \cdot \color{blue}{\left(\frac{d}{D} \cdot \frac{d}{D}\right)}\right) \]
      13. unpow243.0%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c0 \leq -2.5 \cdot 10^{-154}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{\frac{c0}{w}}{h} \cdot {\left(\frac{d}{D}\right)}^{2}\right)\right)\\ \mathbf{elif}\;c0 \leq 9 \cdot 10^{-38}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot 0\\ \mathbf{elif}\;c0 \leq 5.6 \cdot 10^{+72}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(\frac{\frac{c0}{w}}{h} \cdot {\left(\frac{d}{D}\right)}^{2} + \frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right)\right)\\ \mathbf{elif}\;c0 \leq 4 \cdot 10^{+101}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot 0\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{\frac{c0}{w}}{h} \cdot {\left(\frac{d}{D}\right)}^{2}\right)\right)\\ \end{array} \]

Alternative 3: 44.7% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c0}{w \cdot h}\\ t_1 := \frac{\frac{c0}{w}}{h} \cdot {\left(\frac{d}{D}\right)}^{2}\\ t_2 := \frac{c0}{2 \cdot w}\\ t_3 := t_2 \cdot 0\\ \mathbf{if}\;c0 \leq -1.3 \cdot 10^{-154}:\\ \;\;\;\;t_2 \cdot \left(t_0 \cdot \frac{1}{\frac{D}{d} \cdot \frac{D}{d}} + t_1\right)\\ \mathbf{elif}\;c0 \leq 9.2 \cdot 10^{-38}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c0 \leq 5.6 \cdot 10^{+72}:\\ \;\;\;\;t_2 \cdot \left(t_1 + t_0 \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right)\right)\\ \mathbf{elif}\;c0 \leq 3.9 \cdot 10^{+101}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_2 \cdot \left(2 \cdot t_1\right)\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (let* ((t_0 (/ c0 (* w h)))
        (t_1 (* (/ (/ c0 w) h) (pow (/ d D) 2.0)))
        (t_2 (/ c0 (* 2.0 w)))
        (t_3 (* t_2 0.0)))
   (if (<= c0 -1.3e-154)
     (* t_2 (+ (* t_0 (/ 1.0 (* (/ D d) (/ D d)))) t_1))
     (if (<= c0 9.2e-38)
       t_3
       (if (<= c0 5.6e+72)
         (* t_2 (+ t_1 (* t_0 (* (/ d D) (/ d D)))))
         (if (<= c0 3.9e+101) t_3 (* t_2 (* 2.0 t_1))))))))
double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = c0 / (w * h);
	double t_1 = ((c0 / w) / h) * pow((d / D), 2.0);
	double t_2 = c0 / (2.0 * w);
	double t_3 = t_2 * 0.0;
	double tmp;
	if (c0 <= -1.3e-154) {
		tmp = t_2 * ((t_0 * (1.0 / ((D / d) * (D / d)))) + t_1);
	} else if (c0 <= 9.2e-38) {
		tmp = t_3;
	} else if (c0 <= 5.6e+72) {
		tmp = t_2 * (t_1 + (t_0 * ((d / D) * (d / D))));
	} else if (c0 <= 3.9e+101) {
		tmp = t_3;
	} else {
		tmp = t_2 * (2.0 * t_1);
	}
	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) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: t_3
    real(8) :: tmp
    t_0 = c0 / (w * h)
    t_1 = ((c0 / w) / h) * ((d_1 / d) ** 2.0d0)
    t_2 = c0 / (2.0d0 * w)
    t_3 = t_2 * 0.0d0
    if (c0 <= (-1.3d-154)) then
        tmp = t_2 * ((t_0 * (1.0d0 / ((d / d_1) * (d / d_1)))) + t_1)
    else if (c0 <= 9.2d-38) then
        tmp = t_3
    else if (c0 <= 5.6d+72) then
        tmp = t_2 * (t_1 + (t_0 * ((d_1 / d) * (d_1 / d))))
    else if (c0 <= 3.9d+101) then
        tmp = t_3
    else
        tmp = t_2 * (2.0d0 * t_1)
    end if
    code = tmp
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = c0 / (w * h);
	double t_1 = ((c0 / w) / h) * Math.pow((d / D), 2.0);
	double t_2 = c0 / (2.0 * w);
	double t_3 = t_2 * 0.0;
	double tmp;
	if (c0 <= -1.3e-154) {
		tmp = t_2 * ((t_0 * (1.0 / ((D / d) * (D / d)))) + t_1);
	} else if (c0 <= 9.2e-38) {
		tmp = t_3;
	} else if (c0 <= 5.6e+72) {
		tmp = t_2 * (t_1 + (t_0 * ((d / D) * (d / D))));
	} else if (c0 <= 3.9e+101) {
		tmp = t_3;
	} else {
		tmp = t_2 * (2.0 * t_1);
	}
	return tmp;
}
def code(c0, w, h, D, d, M):
	t_0 = c0 / (w * h)
	t_1 = ((c0 / w) / h) * math.pow((d / D), 2.0)
	t_2 = c0 / (2.0 * w)
	t_3 = t_2 * 0.0
	tmp = 0
	if c0 <= -1.3e-154:
		tmp = t_2 * ((t_0 * (1.0 / ((D / d) * (D / d)))) + t_1)
	elif c0 <= 9.2e-38:
		tmp = t_3
	elif c0 <= 5.6e+72:
		tmp = t_2 * (t_1 + (t_0 * ((d / D) * (d / D))))
	elif c0 <= 3.9e+101:
		tmp = t_3
	else:
		tmp = t_2 * (2.0 * t_1)
	return tmp
function code(c0, w, h, D, d, M)
	t_0 = Float64(c0 / Float64(w * h))
	t_1 = Float64(Float64(Float64(c0 / w) / h) * (Float64(d / D) ^ 2.0))
	t_2 = Float64(c0 / Float64(2.0 * w))
	t_3 = Float64(t_2 * 0.0)
	tmp = 0.0
	if (c0 <= -1.3e-154)
		tmp = Float64(t_2 * Float64(Float64(t_0 * Float64(1.0 / Float64(Float64(D / d) * Float64(D / d)))) + t_1));
	elseif (c0 <= 9.2e-38)
		tmp = t_3;
	elseif (c0 <= 5.6e+72)
		tmp = Float64(t_2 * Float64(t_1 + Float64(t_0 * Float64(Float64(d / D) * Float64(d / D)))));
	elseif (c0 <= 3.9e+101)
		tmp = t_3;
	else
		tmp = Float64(t_2 * Float64(2.0 * t_1));
	end
	return tmp
end
function tmp_2 = code(c0, w, h, D, d, M)
	t_0 = c0 / (w * h);
	t_1 = ((c0 / w) / h) * ((d / D) ^ 2.0);
	t_2 = c0 / (2.0 * w);
	t_3 = t_2 * 0.0;
	tmp = 0.0;
	if (c0 <= -1.3e-154)
		tmp = t_2 * ((t_0 * (1.0 / ((D / d) * (D / d)))) + t_1);
	elseif (c0 <= 9.2e-38)
		tmp = t_3;
	elseif (c0 <= 5.6e+72)
		tmp = t_2 * (t_1 + (t_0 * ((d / D) * (d / D))));
	elseif (c0 <= 3.9e+101)
		tmp = t_3;
	else
		tmp = t_2 * (2.0 * t_1);
	end
	tmp_2 = tmp;
end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(c0 / N[(w * h), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(c0 / w), $MachinePrecision] / h), $MachinePrecision] * N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 * 0.0), $MachinePrecision]}, If[LessEqual[c0, -1.3e-154], N[(t$95$2 * N[(N[(t$95$0 * N[(1.0 / N[(N[(D / d), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[c0, 9.2e-38], t$95$3, If[LessEqual[c0, 5.6e+72], N[(t$95$2 * N[(t$95$1 + N[(t$95$0 * N[(N[(d / D), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c0, 3.9e+101], t$95$3, N[(t$95$2 * N[(2.0 * t$95$1), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;c0 \leq 9.2 \cdot 10^{-38}:\\
\;\;\;\;t_3\\

\mathbf{elif}\;c0 \leq 5.6 \cdot 10^{+72}:\\
\;\;\;\;t_2 \cdot \left(t_1 + t_0 \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right)\right)\\

\mathbf{elif}\;c0 \leq 3.9 \cdot 10^{+101}:\\
\;\;\;\;t_3\\

\mathbf{else}:\\
\;\;\;\;t_2 \cdot \left(2 \cdot t_1\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if c0 < -1.3e-154

    1. Initial program 31.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D} + \frac{\frac{c0}{w}}{h} \cdot \color{blue}{\left(\frac{d}{D} \cdot \frac{d}{D}\right)}\right) \]
      13. unpow239.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.3e-154 < c0 < 9.20000000000000007e-38 or 5.5999999999999998e72 < c0 < 3.9e101

    1. Initial program 18.1%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Simplified20.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 6.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*6.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-16.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-in6.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-eval6.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. mul0-lft53.2%

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

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

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

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

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

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

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

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

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

    if 9.20000000000000007e-38 < c0 < 5.5999999999999998e72

    1. Initial program 26.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. Simplified27.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 42.7%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D} + \frac{\frac{c0}{w}}{h} \cdot \color{blue}{\left(\frac{d}{D} \cdot \frac{d}{D}\right)}\right) \]
      13. unpow243.0%

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

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

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

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

    if 3.9e101 < c0

    1. Initial program 21.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c0 \leq -1.3 \cdot 10^{-154}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{1}{\frac{D}{d} \cdot \frac{D}{d}} + \frac{\frac{c0}{w}}{h} \cdot {\left(\frac{d}{D}\right)}^{2}\right)\\ \mathbf{elif}\;c0 \leq 9.2 \cdot 10^{-38}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot 0\\ \mathbf{elif}\;c0 \leq 5.6 \cdot 10^{+72}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(\frac{\frac{c0}{w}}{h} \cdot {\left(\frac{d}{D}\right)}^{2} + \frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right)\right)\\ \mathbf{elif}\;c0 \leq 3.9 \cdot 10^{+101}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot 0\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{\frac{c0}{w}}{h} \cdot {\left(\frac{d}{D}\right)}^{2}\right)\right)\\ \end{array} \]

Alternative 4: 45.5% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c0}{2 \cdot w}\\ \mathbf{if}\;c0 \leq -1.6 \cdot 10^{-154} \lor \neg \left(c0 \leq 5.8 \cdot 10^{-38} \lor \neg \left(c0 \leq 5.4 \cdot 10^{+72}\right) \land c0 \leq 3.4 \cdot 10^{+101}\right):\\ \;\;\;\;t_0 \cdot \left(2 \cdot \left(\frac{\frac{c0}{w}}{h} \cdot {\left(\frac{d}{D}\right)}^{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot 0\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (let* ((t_0 (/ c0 (* 2.0 w))))
   (if (or (<= c0 -1.6e-154)
           (not
            (or (<= c0 5.8e-38) (and (not (<= c0 5.4e+72)) (<= c0 3.4e+101)))))
     (* t_0 (* 2.0 (* (/ (/ c0 w) h) (pow (/ d D) 2.0))))
     (* t_0 0.0))))
double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = c0 / (2.0 * w);
	double tmp;
	if ((c0 <= -1.6e-154) || !((c0 <= 5.8e-38) || (!(c0 <= 5.4e+72) && (c0 <= 3.4e+101)))) {
		tmp = t_0 * (2.0 * (((c0 / w) / h) * pow((d / D), 2.0)));
	} else {
		tmp = t_0 * 0.0;
	}
	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) :: t_0
    real(8) :: tmp
    t_0 = c0 / (2.0d0 * w)
    if ((c0 <= (-1.6d-154)) .or. (.not. (c0 <= 5.8d-38) .or. (.not. (c0 <= 5.4d+72)) .and. (c0 <= 3.4d+101))) then
        tmp = t_0 * (2.0d0 * (((c0 / w) / h) * ((d_1 / d) ** 2.0d0)))
    else
        tmp = t_0 * 0.0d0
    end if
    code = tmp
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = c0 / (2.0 * w);
	double tmp;
	if ((c0 <= -1.6e-154) || !((c0 <= 5.8e-38) || (!(c0 <= 5.4e+72) && (c0 <= 3.4e+101)))) {
		tmp = t_0 * (2.0 * (((c0 / w) / h) * Math.pow((d / D), 2.0)));
	} else {
		tmp = t_0 * 0.0;
	}
	return tmp;
}
def code(c0, w, h, D, d, M):
	t_0 = c0 / (2.0 * w)
	tmp = 0
	if (c0 <= -1.6e-154) or not ((c0 <= 5.8e-38) or (not (c0 <= 5.4e+72) and (c0 <= 3.4e+101))):
		tmp = t_0 * (2.0 * (((c0 / w) / h) * math.pow((d / D), 2.0)))
	else:
		tmp = t_0 * 0.0
	return tmp
function code(c0, w, h, D, d, M)
	t_0 = Float64(c0 / Float64(2.0 * w))
	tmp = 0.0
	if ((c0 <= -1.6e-154) || !((c0 <= 5.8e-38) || (!(c0 <= 5.4e+72) && (c0 <= 3.4e+101))))
		tmp = Float64(t_0 * Float64(2.0 * Float64(Float64(Float64(c0 / w) / h) * (Float64(d / D) ^ 2.0))));
	else
		tmp = Float64(t_0 * 0.0);
	end
	return tmp
end
function tmp_2 = code(c0, w, h, D, d, M)
	t_0 = c0 / (2.0 * w);
	tmp = 0.0;
	if ((c0 <= -1.6e-154) || ~(((c0 <= 5.8e-38) || (~((c0 <= 5.4e+72)) && (c0 <= 3.4e+101)))))
		tmp = t_0 * (2.0 * (((c0 / w) / h) * ((d / D) ^ 2.0)));
	else
		tmp = t_0 * 0.0;
	end
	tmp_2 = tmp;
end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[c0, -1.6e-154], N[Not[Or[LessEqual[c0, 5.8e-38], And[N[Not[LessEqual[c0, 5.4e+72]], $MachinePrecision], LessEqual[c0, 3.4e+101]]]], $MachinePrecision]], N[(t$95$0 * N[(2.0 * N[(N[(N[(c0 / w), $MachinePrecision] / h), $MachinePrecision] * N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * 0.0), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{c0}{2 \cdot w}\\
\mathbf{if}\;c0 \leq -1.6 \cdot 10^{-154} \lor \neg \left(c0 \leq 5.8 \cdot 10^{-38} \lor \neg \left(c0 \leq 5.4 \cdot 10^{+72}\right) \land c0 \leq 3.4 \cdot 10^{+101}\right):\\
\;\;\;\;t_0 \cdot \left(2 \cdot \left(\frac{\frac{c0}{w}}{h} \cdot {\left(\frac{d}{D}\right)}^{2}\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c0 < -1.60000000000000002e-154 or 5.79999999999999988e-38 < c0 < 5.4000000000000001e72 or 3.40000000000000017e101 < c0

    1. Initial program 27.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.60000000000000002e-154 < c0 < 5.79999999999999988e-38 or 5.4000000000000001e72 < c0 < 3.40000000000000017e101

    1. Initial program 18.1%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Simplified20.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 6.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*6.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-16.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-in6.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-eval6.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. mul0-lft53.2%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{0} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification48.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;c0 \leq -1.6 \cdot 10^{-154} \lor \neg \left(c0 \leq 5.8 \cdot 10^{-38} \lor \neg \left(c0 \leq 5.4 \cdot 10^{+72}\right) \land c0 \leq 3.4 \cdot 10^{+101}\right):\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{\frac{c0}{w}}{h} \cdot {\left(\frac{d}{D}\right)}^{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot 0\\ \end{array} \]

Alternative 5: 42.8% accurate, 3.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c0}{2 \cdot w}\\ \mathbf{if}\;c0 \leq -1 \cdot 10^{-153} \lor \neg \left(c0 \leq 8.6 \cdot 10^{-38}\right) \land \left(c0 \leq 4.9 \cdot 10^{+72} \lor \neg \left(c0 \leq 3.5 \cdot 10^{+101}\right)\right):\\ \;\;\;\;t_0 \cdot \left(\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right) + \frac{d \cdot \left(c0 \cdot \frac{d}{D}\right)}{\left(w \cdot h\right) \cdot D}\right)\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot 0\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (let* ((t_0 (/ c0 (* 2.0 w))))
   (if (or (<= c0 -1e-153)
           (and (not (<= c0 8.6e-38))
                (or (<= c0 4.9e+72) (not (<= c0 3.5e+101)))))
     (*
      t_0
      (+
       (* (/ c0 (* w h)) (* (/ d D) (/ d D)))
       (/ (* d (* c0 (/ d D))) (* (* w h) D))))
     (* t_0 0.0))))
double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = c0 / (2.0 * w);
	double tmp;
	if ((c0 <= -1e-153) || (!(c0 <= 8.6e-38) && ((c0 <= 4.9e+72) || !(c0 <= 3.5e+101)))) {
		tmp = t_0 * (((c0 / (w * h)) * ((d / D) * (d / D))) + ((d * (c0 * (d / D))) / ((w * h) * D)));
	} else {
		tmp = t_0 * 0.0;
	}
	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) :: t_0
    real(8) :: tmp
    t_0 = c0 / (2.0d0 * w)
    if ((c0 <= (-1d-153)) .or. (.not. (c0 <= 8.6d-38)) .and. (c0 <= 4.9d+72) .or. (.not. (c0 <= 3.5d+101))) then
        tmp = t_0 * (((c0 / (w * h)) * ((d_1 / d) * (d_1 / d))) + ((d_1 * (c0 * (d_1 / d))) / ((w * h) * d)))
    else
        tmp = t_0 * 0.0d0
    end if
    code = tmp
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = c0 / (2.0 * w);
	double tmp;
	if ((c0 <= -1e-153) || (!(c0 <= 8.6e-38) && ((c0 <= 4.9e+72) || !(c0 <= 3.5e+101)))) {
		tmp = t_0 * (((c0 / (w * h)) * ((d / D) * (d / D))) + ((d * (c0 * (d / D))) / ((w * h) * D)));
	} else {
		tmp = t_0 * 0.0;
	}
	return tmp;
}
def code(c0, w, h, D, d, M):
	t_0 = c0 / (2.0 * w)
	tmp = 0
	if (c0 <= -1e-153) or (not (c0 <= 8.6e-38) and ((c0 <= 4.9e+72) or not (c0 <= 3.5e+101))):
		tmp = t_0 * (((c0 / (w * h)) * ((d / D) * (d / D))) + ((d * (c0 * (d / D))) / ((w * h) * D)))
	else:
		tmp = t_0 * 0.0
	return tmp
function code(c0, w, h, D, d, M)
	t_0 = Float64(c0 / Float64(2.0 * w))
	tmp = 0.0
	if ((c0 <= -1e-153) || (!(c0 <= 8.6e-38) && ((c0 <= 4.9e+72) || !(c0 <= 3.5e+101))))
		tmp = Float64(t_0 * Float64(Float64(Float64(c0 / Float64(w * h)) * Float64(Float64(d / D) * Float64(d / D))) + Float64(Float64(d * Float64(c0 * Float64(d / D))) / Float64(Float64(w * h) * D))));
	else
		tmp = Float64(t_0 * 0.0);
	end
	return tmp
end
function tmp_2 = code(c0, w, h, D, d, M)
	t_0 = c0 / (2.0 * w);
	tmp = 0.0;
	if ((c0 <= -1e-153) || (~((c0 <= 8.6e-38)) && ((c0 <= 4.9e+72) || ~((c0 <= 3.5e+101)))))
		tmp = t_0 * (((c0 / (w * h)) * ((d / D) * (d / D))) + ((d * (c0 * (d / D))) / ((w * h) * D)));
	else
		tmp = t_0 * 0.0;
	end
	tmp_2 = tmp;
end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[c0, -1e-153], And[N[Not[LessEqual[c0, 8.6e-38]], $MachinePrecision], Or[LessEqual[c0, 4.9e+72], N[Not[LessEqual[c0, 3.5e+101]], $MachinePrecision]]]], N[(t$95$0 * N[(N[(N[(c0 / N[(w * h), $MachinePrecision]), $MachinePrecision] * N[(N[(d / D), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(d * N[(c0 * N[(d / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * 0.0), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{c0}{2 \cdot w}\\
\mathbf{if}\;c0 \leq -1 \cdot 10^{-153} \lor \neg \left(c0 \leq 8.6 \cdot 10^{-38}\right) \land \left(c0 \leq 4.9 \cdot 10^{+72} \lor \neg \left(c0 \leq 3.5 \cdot 10^{+101}\right)\right):\\
\;\;\;\;t_0 \cdot \left(\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right) + \frac{d \cdot \left(c0 \cdot \frac{d}{D}\right)}{\left(w \cdot h\right) \cdot D}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c0 < -1.00000000000000004e-153 or 8.6000000000000004e-38 < c0 < 4.90000000000000006e72 or 3.50000000000000023e101 < c0

    1. Initial program 27.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.00000000000000004e-153 < c0 < 8.6000000000000004e-38 or 4.90000000000000006e72 < c0 < 3.50000000000000023e101

    1. Initial program 18.1%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Simplified20.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 6.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*6.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-16.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-in6.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-eval6.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. mul0-lft53.2%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{0} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification47.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;c0 \leq -1 \cdot 10^{-153} \lor \neg \left(c0 \leq 8.6 \cdot 10^{-38}\right) \land \left(c0 \leq 4.9 \cdot 10^{+72} \lor \neg \left(c0 \leq 3.5 \cdot 10^{+101}\right)\right):\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right) + \frac{d \cdot \left(c0 \cdot \frac{d}{D}\right)}{\left(w \cdot h\right) \cdot D}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot 0\\ \end{array} \]

Alternative 6: 43.0% accurate, 3.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right)\\ t_1 := \frac{c0}{2 \cdot w}\\ \mathbf{if}\;c0 \leq -9.2 \cdot 10^{-153}:\\ \;\;\;\;t_1 \cdot \left(t_0 + \frac{d \cdot \frac{d}{D}}{D \cdot \frac{h}{\frac{c0}{w}}}\right)\\ \mathbf{elif}\;c0 \leq 8.8 \cdot 10^{-38} \lor \neg \left(c0 \leq 6.1 \cdot 10^{+72}\right) \land c0 \leq 4.6 \cdot 10^{+101}:\\ \;\;\;\;t_1 \cdot 0\\ \mathbf{else}:\\ \;\;\;\;t_1 \cdot \left(t_0 + \frac{d \cdot \left(c0 \cdot \frac{d}{D}\right)}{\left(w \cdot h\right) \cdot D}\right)\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (let* ((t_0 (* (/ c0 (* w h)) (* (/ d D) (/ d D)))) (t_1 (/ c0 (* 2.0 w))))
   (if (<= c0 -9.2e-153)
     (* t_1 (+ t_0 (/ (* d (/ d D)) (* D (/ h (/ c0 w))))))
     (if (or (<= c0 8.8e-38) (and (not (<= c0 6.1e+72)) (<= c0 4.6e+101)))
       (* t_1 0.0)
       (* t_1 (+ t_0 (/ (* d (* c0 (/ d D))) (* (* w h) D))))))))
double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = (c0 / (w * h)) * ((d / D) * (d / D));
	double t_1 = c0 / (2.0 * w);
	double tmp;
	if (c0 <= -9.2e-153) {
		tmp = t_1 * (t_0 + ((d * (d / D)) / (D * (h / (c0 / w)))));
	} else if ((c0 <= 8.8e-38) || (!(c0 <= 6.1e+72) && (c0 <= 4.6e+101))) {
		tmp = t_1 * 0.0;
	} else {
		tmp = t_1 * (t_0 + ((d * (c0 * (d / D))) / ((w * h) * 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) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (c0 / (w * h)) * ((d_1 / d) * (d_1 / d))
    t_1 = c0 / (2.0d0 * w)
    if (c0 <= (-9.2d-153)) then
        tmp = t_1 * (t_0 + ((d_1 * (d_1 / d)) / (d * (h / (c0 / w)))))
    else if ((c0 <= 8.8d-38) .or. (.not. (c0 <= 6.1d+72)) .and. (c0 <= 4.6d+101)) then
        tmp = t_1 * 0.0d0
    else
        tmp = t_1 * (t_0 + ((d_1 * (c0 * (d_1 / d))) / ((w * h) * d)))
    end if
    code = tmp
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = (c0 / (w * h)) * ((d / D) * (d / D));
	double t_1 = c0 / (2.0 * w);
	double tmp;
	if (c0 <= -9.2e-153) {
		tmp = t_1 * (t_0 + ((d * (d / D)) / (D * (h / (c0 / w)))));
	} else if ((c0 <= 8.8e-38) || (!(c0 <= 6.1e+72) && (c0 <= 4.6e+101))) {
		tmp = t_1 * 0.0;
	} else {
		tmp = t_1 * (t_0 + ((d * (c0 * (d / D))) / ((w * h) * D)));
	}
	return tmp;
}
def code(c0, w, h, D, d, M):
	t_0 = (c0 / (w * h)) * ((d / D) * (d / D))
	t_1 = c0 / (2.0 * w)
	tmp = 0
	if c0 <= -9.2e-153:
		tmp = t_1 * (t_0 + ((d * (d / D)) / (D * (h / (c0 / w)))))
	elif (c0 <= 8.8e-38) or (not (c0 <= 6.1e+72) and (c0 <= 4.6e+101)):
		tmp = t_1 * 0.0
	else:
		tmp = t_1 * (t_0 + ((d * (c0 * (d / D))) / ((w * h) * D)))
	return tmp
function code(c0, w, h, D, d, M)
	t_0 = Float64(Float64(c0 / Float64(w * h)) * Float64(Float64(d / D) * Float64(d / D)))
	t_1 = Float64(c0 / Float64(2.0 * w))
	tmp = 0.0
	if (c0 <= -9.2e-153)
		tmp = Float64(t_1 * Float64(t_0 + Float64(Float64(d * Float64(d / D)) / Float64(D * Float64(h / Float64(c0 / w))))));
	elseif ((c0 <= 8.8e-38) || (!(c0 <= 6.1e+72) && (c0 <= 4.6e+101)))
		tmp = Float64(t_1 * 0.0);
	else
		tmp = Float64(t_1 * Float64(t_0 + Float64(Float64(d * Float64(c0 * Float64(d / D))) / Float64(Float64(w * h) * D))));
	end
	return tmp
end
function tmp_2 = code(c0, w, h, D, d, M)
	t_0 = (c0 / (w * h)) * ((d / D) * (d / D));
	t_1 = c0 / (2.0 * w);
	tmp = 0.0;
	if (c0 <= -9.2e-153)
		tmp = t_1 * (t_0 + ((d * (d / D)) / (D * (h / (c0 / w)))));
	elseif ((c0 <= 8.8e-38) || (~((c0 <= 6.1e+72)) && (c0 <= 4.6e+101)))
		tmp = t_1 * 0.0;
	else
		tmp = t_1 * (t_0 + ((d * (c0 * (d / D))) / ((w * h) * D)));
	end
	tmp_2 = tmp;
end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(N[(c0 / N[(w * h), $MachinePrecision]), $MachinePrecision] * N[(N[(d / D), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c0, -9.2e-153], N[(t$95$1 * N[(t$95$0 + N[(N[(d * N[(d / D), $MachinePrecision]), $MachinePrecision] / N[(D * N[(h / N[(c0 / w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[c0, 8.8e-38], And[N[Not[LessEqual[c0, 6.1e+72]], $MachinePrecision], LessEqual[c0, 4.6e+101]]], N[(t$95$1 * 0.0), $MachinePrecision], N[(t$95$1 * N[(t$95$0 + N[(N[(d * N[(c0 * N[(d / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

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

\mathbf{elif}\;c0 \leq 8.8 \cdot 10^{-38} \lor \neg \left(c0 \leq 6.1 \cdot 10^{+72}\right) \land c0 \leq 4.6 \cdot 10^{+101}:\\
\;\;\;\;t_1 \cdot 0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c0 < -9.19999999999999988e-153

    1. Initial program 31.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D} + \frac{\frac{c0}{w}}{h} \cdot \color{blue}{\left(\frac{d}{D} \cdot \frac{d}{D}\right)}\right) \]
      13. unpow239.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.19999999999999988e-153 < c0 < 8.80000000000000029e-38 or 6.09999999999999991e72 < c0 < 4.6000000000000003e101

    1. Initial program 18.1%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Simplified20.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 6.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*6.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-16.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-in6.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-eval6.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. mul0-lft53.2%

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

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

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

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

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

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

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

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

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

    if 8.80000000000000029e-38 < c0 < 6.09999999999999991e72 or 4.6000000000000003e101 < c0

    1. Initial program 23.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. Simplified23.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 35.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c0 \leq -9.2 \cdot 10^{-153}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right) + \frac{d \cdot \frac{d}{D}}{D \cdot \frac{h}{\frac{c0}{w}}}\right)\\ \mathbf{elif}\;c0 \leq 8.8 \cdot 10^{-38} \lor \neg \left(c0 \leq 6.1 \cdot 10^{+72}\right) \land c0 \leq 4.6 \cdot 10^{+101}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot 0\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right) + \frac{d \cdot \left(c0 \cdot \frac{d}{D}\right)}{\left(w \cdot h\right) \cdot D}\right)\\ \end{array} \]

Alternative 7: 28.5% accurate, 21.6× speedup?

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

\\
\frac{c0}{2 \cdot w} \cdot 0
\end{array}
Derivation
  1. Initial program 24.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{0} \]
  6. Final simplification33.6%

    \[\leadsto \frac{c0}{2 \cdot w} \cdot 0 \]

Reproduce

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