Henrywood and Agarwal, Equation (13)

Percentage Accurate: 24.4% → 54.0%
Time: 30.5s
Alternatives: 7
Speedup: 151.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 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: 24.4% 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: 54.0% accurate, 0.2× speedup?

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

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

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


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

    1. Initial program 74.9%

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(\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} + \frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}\right)} \]
      2. add-sqr-sqrt73.5%

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(\sqrt{\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}}, \sqrt{\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}}, \frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}\right)} \]
    5. Applied egg-rr60.9%

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

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

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(c0 \cdot \color{blue}{0}\right) \]
    6. Simplified35.4%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(c0 \cdot 0\right)} \]
    7. Taylor expanded in c0 around 0 45.2%

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

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

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

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


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

    1. Initial program 74.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) \]

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(c0 \cdot \color{blue}{0}\right) \]
    6. Simplified35.4%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(c0 \cdot 0\right)} \]
    7. Taylor expanded in c0 around 0 45.2%

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

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

Alternative 3: 41.5% accurate, 5.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;D \leq 3.1 \cdot 10^{-298} \lor \neg \left(D \leq 8.6 \cdot 10^{-147} \lor \neg \left(D \leq 1.56 \cdot 10^{-97}\right) \land D \leq 3.1 \cdot 10^{-34}\right):\\
\;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{c0}{w} \cdot \frac{\frac{d}{D} \cdot \frac{d}{D}}{h}\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if D < 3.1000000000000002e-298 or 8.6000000000000002e-147 < D < 1.55999999999999989e-97 or 3.0999999999999998e-34 < D

    1. Initial program 24.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.1000000000000002e-298 < D < 8.6000000000000002e-147 or 1.55999999999999989e-97 < D < 3.0999999999999998e-34

    1. Initial program 13.4%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(c0 \cdot \color{blue}{0}\right) \]
    6. Simplified44.5%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(c0 \cdot 0\right)} \]
    7. Taylor expanded in c0 around 0 55.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;D \leq 3.1 \cdot 10^{-298} \lor \neg \left(D \leq 8.6 \cdot 10^{-147} \lor \neg \left(D \leq 1.56 \cdot 10^{-97}\right) \land D \leq 3.1 \cdot 10^{-34}\right):\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{c0}{w} \cdot \frac{\frac{d}{D} \cdot \frac{d}{D}}{h}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]

Alternative 4: 41.2% accurate, 5.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;w \leq -2.5 \cdot 10^{+83}:\\
\;\;\;\;0\\

\mathbf{elif}\;w \leq -2.4 \cdot 10^{-288} \lor \neg \left(w \leq 1.02 \cdot 10^{-286}\right) \land w \leq 1.8 \cdot 10^{-180}:\\
\;\;\;\;\left(\left(\frac{d}{D} \cdot \frac{d}{D}\right) \cdot \frac{c0 \cdot 2}{2 \cdot w}\right) \cdot \frac{c0}{w \cdot h}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if w < -2.50000000000000014e83 or -2.3999999999999998e-288 < w < 1.01999999999999996e-286 or 1.8e-180 < w

    1. Initial program 13.6%

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(c0 \cdot \color{blue}{0}\right) \]
    6. Simplified40.7%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(c0 \cdot 0\right)} \]
    7. Taylor expanded in c0 around 0 49.1%

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

    if -2.50000000000000014e83 < w < -2.3999999999999998e-288 or 1.01999999999999996e-286 < w < 1.8e-180

    1. Initial program 30.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. Step-by-step derivation
      1. times-frac29.3%

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

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

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

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

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)\right)} - 1} \]
    6. Applied egg-rr21.5%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;w \leq -2.5 \cdot 10^{+83}:\\ \;\;\;\;0\\ \mathbf{elif}\;w \leq -2.4 \cdot 10^{-288} \lor \neg \left(w \leq 1.02 \cdot 10^{-286}\right) \land w \leq 1.8 \cdot 10^{-180}:\\ \;\;\;\;\left(\left(\frac{d}{D} \cdot \frac{d}{D}\right) \cdot \frac{c0 \cdot 2}{2 \cdot w}\right) \cdot \frac{c0}{w \cdot h}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]

Alternative 5: 41.2% accurate, 5.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c0 \cdot 2}{2 \cdot w}\\ t_1 := \frac{c0}{w \cdot h}\\ \mathbf{if}\;w \leq -3.1 \cdot 10^{+87}:\\ \;\;\;\;0\\ \mathbf{elif}\;w \leq -1.35 \cdot 10^{-289}:\\ \;\;\;\;\left(\left(\frac{d}{D} \cdot \frac{d}{D}\right) \cdot t_0\right) \cdot t_1\\ \mathbf{elif}\;w \leq 1.1 \cdot 10^{-286}:\\ \;\;\;\;0\\ \mathbf{elif}\;w \leq 1.06 \cdot 10^{-180}:\\ \;\;\;\;t_1 \cdot \left(t_0 \cdot \frac{d \cdot \frac{d}{D}}{D}\right)\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (let* ((t_0 (/ (* c0 2.0) (* 2.0 w))) (t_1 (/ c0 (* w h))))
   (if (<= w -3.1e+87)
     0.0
     (if (<= w -1.35e-289)
       (* (* (* (/ d D) (/ d D)) t_0) t_1)
       (if (<= w 1.1e-286)
         0.0
         (if (<= w 1.06e-180) (* t_1 (* t_0 (/ (* d (/ d D)) D))) 0.0))))))
double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = (c0 * 2.0) / (2.0 * w);
	double t_1 = c0 / (w * h);
	double tmp;
	if (w <= -3.1e+87) {
		tmp = 0.0;
	} else if (w <= -1.35e-289) {
		tmp = (((d / D) * (d / D)) * t_0) * t_1;
	} else if (w <= 1.1e-286) {
		tmp = 0.0;
	} else if (w <= 1.06e-180) {
		tmp = t_1 * (t_0 * ((d * (d / D)) / D));
	} else {
		tmp = 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) :: t_1
    real(8) :: tmp
    t_0 = (c0 * 2.0d0) / (2.0d0 * w)
    t_1 = c0 / (w * h)
    if (w <= (-3.1d+87)) then
        tmp = 0.0d0
    else if (w <= (-1.35d-289)) then
        tmp = (((d_1 / d) * (d_1 / d)) * t_0) * t_1
    else if (w <= 1.1d-286) then
        tmp = 0.0d0
    else if (w <= 1.06d-180) then
        tmp = t_1 * (t_0 * ((d_1 * (d_1 / d)) / d))
    else
        tmp = 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) / (2.0 * w);
	double t_1 = c0 / (w * h);
	double tmp;
	if (w <= -3.1e+87) {
		tmp = 0.0;
	} else if (w <= -1.35e-289) {
		tmp = (((d / D) * (d / D)) * t_0) * t_1;
	} else if (w <= 1.1e-286) {
		tmp = 0.0;
	} else if (w <= 1.06e-180) {
		tmp = t_1 * (t_0 * ((d * (d / D)) / D));
	} else {
		tmp = 0.0;
	}
	return tmp;
}
def code(c0, w, h, D, d, M):
	t_0 = (c0 * 2.0) / (2.0 * w)
	t_1 = c0 / (w * h)
	tmp = 0
	if w <= -3.1e+87:
		tmp = 0.0
	elif w <= -1.35e-289:
		tmp = (((d / D) * (d / D)) * t_0) * t_1
	elif w <= 1.1e-286:
		tmp = 0.0
	elif w <= 1.06e-180:
		tmp = t_1 * (t_0 * ((d * (d / D)) / D))
	else:
		tmp = 0.0
	return tmp
function code(c0, w, h, D, d, M)
	t_0 = Float64(Float64(c0 * 2.0) / Float64(2.0 * w))
	t_1 = Float64(c0 / Float64(w * h))
	tmp = 0.0
	if (w <= -3.1e+87)
		tmp = 0.0;
	elseif (w <= -1.35e-289)
		tmp = Float64(Float64(Float64(Float64(d / D) * Float64(d / D)) * t_0) * t_1);
	elseif (w <= 1.1e-286)
		tmp = 0.0;
	elseif (w <= 1.06e-180)
		tmp = Float64(t_1 * Float64(t_0 * Float64(Float64(d * Float64(d / D)) / D)));
	else
		tmp = 0.0;
	end
	return tmp
end
function tmp_2 = code(c0, w, h, D, d, M)
	t_0 = (c0 * 2.0) / (2.0 * w);
	t_1 = c0 / (w * h);
	tmp = 0.0;
	if (w <= -3.1e+87)
		tmp = 0.0;
	elseif (w <= -1.35e-289)
		tmp = (((d / D) * (d / D)) * t_0) * t_1;
	elseif (w <= 1.1e-286)
		tmp = 0.0;
	elseif (w <= 1.06e-180)
		tmp = t_1 * (t_0 * ((d * (d / D)) / D));
	else
		tmp = 0.0;
	end
	tmp_2 = tmp;
end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(N[(c0 * 2.0), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(c0 / N[(w * h), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[w, -3.1e+87], 0.0, If[LessEqual[w, -1.35e-289], N[(N[(N[(N[(d / D), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[w, 1.1e-286], 0.0, If[LessEqual[w, 1.06e-180], N[(t$95$1 * N[(t$95$0 * N[(N[(d * N[(d / D), $MachinePrecision]), $MachinePrecision] / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{c0 \cdot 2}{2 \cdot w}\\
t_1 := \frac{c0}{w \cdot h}\\
\mathbf{if}\;w \leq -3.1 \cdot 10^{+87}:\\
\;\;\;\;0\\

\mathbf{elif}\;w \leq -1.35 \cdot 10^{-289}:\\
\;\;\;\;\left(\left(\frac{d}{D} \cdot \frac{d}{D}\right) \cdot t_0\right) \cdot t_1\\

\mathbf{elif}\;w \leq 1.1 \cdot 10^{-286}:\\
\;\;\;\;0\\

\mathbf{elif}\;w \leq 1.06 \cdot 10^{-180}:\\
\;\;\;\;t_1 \cdot \left(t_0 \cdot \frac{d \cdot \frac{d}{D}}{D}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if w < -3.1e87 or -1.35e-289 < w < 1.1e-286 or 1.0600000000000001e-180 < w

    1. Initial program 13.6%

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(c0 \cdot \color{blue}{0}\right) \]
    6. Simplified40.7%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(c0 \cdot 0\right)} \]
    7. Taylor expanded in c0 around 0 49.1%

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

    if -3.1e87 < w < -1.35e-289

    1. Initial program 27.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.1e-286 < w < 1.0600000000000001e-180

    1. Initial program 39.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;w \leq -3.1 \cdot 10^{+87}:\\ \;\;\;\;0\\ \mathbf{elif}\;w \leq -1.35 \cdot 10^{-289}:\\ \;\;\;\;\left(\left(\frac{d}{D} \cdot \frac{d}{D}\right) \cdot \frac{c0 \cdot 2}{2 \cdot w}\right) \cdot \frac{c0}{w \cdot h}\\ \mathbf{elif}\;w \leq 1.1 \cdot 10^{-286}:\\ \;\;\;\;0\\ \mathbf{elif}\;w \leq 1.06 \cdot 10^{-180}:\\ \;\;\;\;\frac{c0}{w \cdot h} \cdot \left(\frac{c0 \cdot 2}{2 \cdot w} \cdot \frac{d \cdot \frac{d}{D}}{D}\right)\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]

Alternative 6: 42.0% accurate, 5.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{d}{D} \cdot \frac{d}{D}\\ t_1 := \frac{c0}{2 \cdot w}\\ \mathbf{if}\;w \leq -1.35 \cdot 10^{+82}:\\ \;\;\;\;0\\ \mathbf{elif}\;w \leq -1.28 \cdot 10^{-289}:\\ \;\;\;\;\frac{c0}{w} \cdot \frac{t_0 \cdot \left(2 \cdot t_1\right)}{h}\\ \mathbf{elif}\;w \leq 3.9 \cdot 10^{-286}:\\ \;\;\;\;0\\ \mathbf{elif}\;w \leq 1.65 \cdot 10^{-180}:\\ \;\;\;\;t_1 \cdot \left(2 \cdot \left(\frac{c0}{w} \cdot \frac{t_0}{h}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (let* ((t_0 (* (/ d D) (/ d D))) (t_1 (/ c0 (* 2.0 w))))
   (if (<= w -1.35e+82)
     0.0
     (if (<= w -1.28e-289)
       (* (/ c0 w) (/ (* t_0 (* 2.0 t_1)) h))
       (if (<= w 3.9e-286)
         0.0
         (if (<= w 1.65e-180) (* t_1 (* 2.0 (* (/ c0 w) (/ t_0 h)))) 0.0))))))
double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = (d / D) * (d / D);
	double t_1 = c0 / (2.0 * w);
	double tmp;
	if (w <= -1.35e+82) {
		tmp = 0.0;
	} else if (w <= -1.28e-289) {
		tmp = (c0 / w) * ((t_0 * (2.0 * t_1)) / h);
	} else if (w <= 3.9e-286) {
		tmp = 0.0;
	} else if (w <= 1.65e-180) {
		tmp = t_1 * (2.0 * ((c0 / w) * (t_0 / h)));
	} else {
		tmp = 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) :: t_1
    real(8) :: tmp
    t_0 = (d_1 / d) * (d_1 / d)
    t_1 = c0 / (2.0d0 * w)
    if (w <= (-1.35d+82)) then
        tmp = 0.0d0
    else if (w <= (-1.28d-289)) then
        tmp = (c0 / w) * ((t_0 * (2.0d0 * t_1)) / h)
    else if (w <= 3.9d-286) then
        tmp = 0.0d0
    else if (w <= 1.65d-180) then
        tmp = t_1 * (2.0d0 * ((c0 / w) * (t_0 / h)))
    else
        tmp = 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 = (d / D) * (d / D);
	double t_1 = c0 / (2.0 * w);
	double tmp;
	if (w <= -1.35e+82) {
		tmp = 0.0;
	} else if (w <= -1.28e-289) {
		tmp = (c0 / w) * ((t_0 * (2.0 * t_1)) / h);
	} else if (w <= 3.9e-286) {
		tmp = 0.0;
	} else if (w <= 1.65e-180) {
		tmp = t_1 * (2.0 * ((c0 / w) * (t_0 / h)));
	} else {
		tmp = 0.0;
	}
	return tmp;
}
def code(c0, w, h, D, d, M):
	t_0 = (d / D) * (d / D)
	t_1 = c0 / (2.0 * w)
	tmp = 0
	if w <= -1.35e+82:
		tmp = 0.0
	elif w <= -1.28e-289:
		tmp = (c0 / w) * ((t_0 * (2.0 * t_1)) / h)
	elif w <= 3.9e-286:
		tmp = 0.0
	elif w <= 1.65e-180:
		tmp = t_1 * (2.0 * ((c0 / w) * (t_0 / h)))
	else:
		tmp = 0.0
	return tmp
function code(c0, w, h, D, d, M)
	t_0 = Float64(Float64(d / D) * Float64(d / D))
	t_1 = Float64(c0 / Float64(2.0 * w))
	tmp = 0.0
	if (w <= -1.35e+82)
		tmp = 0.0;
	elseif (w <= -1.28e-289)
		tmp = Float64(Float64(c0 / w) * Float64(Float64(t_0 * Float64(2.0 * t_1)) / h));
	elseif (w <= 3.9e-286)
		tmp = 0.0;
	elseif (w <= 1.65e-180)
		tmp = Float64(t_1 * Float64(2.0 * Float64(Float64(c0 / w) * Float64(t_0 / h))));
	else
		tmp = 0.0;
	end
	return tmp
end
function tmp_2 = code(c0, w, h, D, d, M)
	t_0 = (d / D) * (d / D);
	t_1 = c0 / (2.0 * w);
	tmp = 0.0;
	if (w <= -1.35e+82)
		tmp = 0.0;
	elseif (w <= -1.28e-289)
		tmp = (c0 / w) * ((t_0 * (2.0 * t_1)) / h);
	elseif (w <= 3.9e-286)
		tmp = 0.0;
	elseif (w <= 1.65e-180)
		tmp = t_1 * (2.0 * ((c0 / w) * (t_0 / h)));
	else
		tmp = 0.0;
	end
	tmp_2 = tmp;
end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(N[(d / D), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[w, -1.35e+82], 0.0, If[LessEqual[w, -1.28e-289], N[(N[(c0 / w), $MachinePrecision] * N[(N[(t$95$0 * N[(2.0 * t$95$1), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision]), $MachinePrecision], If[LessEqual[w, 3.9e-286], 0.0, If[LessEqual[w, 1.65e-180], N[(t$95$1 * N[(2.0 * N[(N[(c0 / w), $MachinePrecision] * N[(t$95$0 / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{d}{D} \cdot \frac{d}{D}\\
t_1 := \frac{c0}{2 \cdot w}\\
\mathbf{if}\;w \leq -1.35 \cdot 10^{+82}:\\
\;\;\;\;0\\

\mathbf{elif}\;w \leq -1.28 \cdot 10^{-289}:\\
\;\;\;\;\frac{c0}{w} \cdot \frac{t_0 \cdot \left(2 \cdot t_1\right)}{h}\\

\mathbf{elif}\;w \leq 3.9 \cdot 10^{-286}:\\
\;\;\;\;0\\

\mathbf{elif}\;w \leq 1.65 \cdot 10^{-180}:\\
\;\;\;\;t_1 \cdot \left(2 \cdot \left(\frac{c0}{w} \cdot \frac{t_0}{h}\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if w < -1.35e82 or -1.27999999999999995e-289 < w < 3.89999999999999995e-286 or 1.64999999999999999e-180 < w

    1. Initial program 13.6%

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(c0 \cdot \color{blue}{0}\right) \]
    6. Simplified40.7%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(c0 \cdot 0\right)} \]
    7. Taylor expanded in c0 around 0 49.1%

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

    if -1.35e82 < w < -1.27999999999999995e-289

    1. Initial program 27.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.89999999999999995e-286 < w < 1.64999999999999999e-180

    1. Initial program 39.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;w \leq -1.35 \cdot 10^{+82}:\\ \;\;\;\;0\\ \mathbf{elif}\;w \leq -1.28 \cdot 10^{-289}:\\ \;\;\;\;\frac{c0}{w} \cdot \frac{\left(\frac{d}{D} \cdot \frac{d}{D}\right) \cdot \left(2 \cdot \frac{c0}{2 \cdot w}\right)}{h}\\ \mathbf{elif}\;w \leq 3.9 \cdot 10^{-286}:\\ \;\;\;\;0\\ \mathbf{elif}\;w \leq 1.65 \cdot 10^{-180}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{c0}{w} \cdot \frac{\frac{d}{D} \cdot \frac{d}{D}}{h}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]

Alternative 7: 33.8% accurate, 151.0× speedup?

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

\\
0
\end{array}
Derivation
  1. Initial program 21.3%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(c0 \cdot \color{blue}{0}\right) \]
  6. Simplified28.5%

    \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(c0 \cdot 0\right)} \]
  7. Taylor expanded in c0 around 0 35.6%

    \[\leadsto \color{blue}{0} \]
  8. Final simplification35.6%

    \[\leadsto 0 \]

Reproduce

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