Henrywood and Agarwal, Equation (13)

Percentage Accurate: 24.1% → 63.2%
Time: 23.1s
Alternatives: 5
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 5 alternatives:

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

Initial Program: 24.1% accurate, 1.0× speedup?

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

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

Alternative 1: 63.2% accurate, 0.6× speedup?

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

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

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


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

    1. Initial program 76.8%

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

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

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

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

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

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

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

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

        \[\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) \]
      8. associate-*r*81.0%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(0.5 \cdot \color{blue}{\left(\frac{{D}^{2}}{c0} \cdot \frac{{M}^{2} \cdot \left(h \cdot w\right)}{{d}^{2}}\right)} + -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) \]
      3. associate-*r*1.3%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(0.5 \cdot \left(\frac{{D}^{2}}{c0} \cdot \frac{{M}^{2} \cdot \left(h \cdot w\right)}{{d}^{2}}\right) + \color{blue}{\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) \]
      4. neg-mul-11.3%

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(0.5 \cdot \left(\frac{{D}^{2}}{c0} \cdot \frac{{M}^{2} \cdot \left(h \cdot w\right)}{{d}^{2}}\right) + \color{blue}{\left(-c0 \cdot 0\right)}\right) \]
      9. distribute-rgt-neg-in28.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.25 \cdot \left({M}^{2} \cdot \left(h \cdot \color{blue}{\frac{{D}^{2}}{{d}^{2}}}\right)\right) \]
      8. add-sqr-sqrt44.5%

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

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

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

        \[\leadsto 0.25 \cdot \left({M}^{2} \cdot \left(h \cdot \left(\frac{\color{blue}{\sqrt{D} \cdot \sqrt{D}}}{\sqrt{{d}^{2}}} \cdot \sqrt{\frac{{D}^{2}}{{d}^{2}}}\right)\right)\right) \]
      12. add-sqr-sqrt37.6%

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

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

        \[\leadsto 0.25 \cdot \left({M}^{2} \cdot \left(h \cdot \left(\frac{D}{\color{blue}{\sqrt{d} \cdot \sqrt{d}}} \cdot \sqrt{\frac{{D}^{2}}{{d}^{2}}}\right)\right)\right) \]
      15. add-sqr-sqrt41.0%

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

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

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

        \[\leadsto 0.25 \cdot \left({M}^{2} \cdot \left(h \cdot \left(\frac{D}{d} \cdot \frac{\color{blue}{\sqrt{D} \cdot \sqrt{D}}}{\sqrt{{d}^{2}}}\right)\right)\right) \]
      19. add-sqr-sqrt46.5%

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

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

        \[\leadsto 0.25 \cdot \left({M}^{2} \cdot \left(h \cdot \left(\frac{D}{d} \cdot \frac{D}{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}\right)\right)\right) \]
      22. add-sqr-sqrt56.4%

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

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

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

Alternative 2: 43.9% accurate, 5.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq 1.5 \cdot 10^{+46} \lor \neg \left(d \leq 5.4 \cdot 10^{+82}\right) \land d \leq 1.02 \cdot 10^{+165}:\\
\;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{d}{D} \cdot \left(\frac{c0}{D} \cdot \frac{d}{w \cdot h}\right)\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < 1.50000000000000012e46 or 5.3999999999999999e82 < d < 1.02000000000000003e165

    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. Simplified25.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 35.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. *-commutative35.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. *-commutative35.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. frac-times33.8%

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

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

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

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

        \[\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) \]
      8. associate-*r*51.2%

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

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

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

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

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

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

    if 1.50000000000000012e46 < d < 5.3999999999999999e82 or 1.02000000000000003e165 < d

    1. Initial program 16.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq 1.5 \cdot 10^{+46} \lor \neg \left(d \leq 5.4 \cdot 10^{+82}\right) \land d \leq 1.02 \cdot 10^{+165}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{d}{D} \cdot \left(\frac{c0}{D} \cdot \frac{d}{w \cdot h}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]

Alternative 3: 45.8% accurate, 6.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq 1.1 \cdot 10^{+165}:\\
\;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{d}{D} \cdot \left(\frac{d}{D} \cdot \frac{c0}{w \cdot h}\right)\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < 1.1e165

    1. Initial program 26.8%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. 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)} \]
    3. Taylor expanded in c0 around inf 34.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. *-commutative34.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. *-commutative34.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. frac-times33.1%

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

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

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

        \[\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) \]
      8. associate-*r*50.3%

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

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

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

    if 1.1e165 < d

    1. Initial program 17.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. Simplified17.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 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 45.8% accurate, 6.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq 1.02 \cdot 10^{+165}:\\
\;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{\frac{d}{D} \cdot \frac{c0}{w \cdot h}}{\frac{D}{d}}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < 1.02000000000000003e165

    1. Initial program 26.8%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. 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)} \]
    3. Taylor expanded in c0 around inf 34.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. *-commutative34.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. *-commutative34.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. frac-times33.1%

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

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

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

        \[\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) \]
      8. associate-*r*50.3%

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

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

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

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

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

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

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

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

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

    if 1.02000000000000003e165 < d

    1. Initial program 17.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. Simplified17.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 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 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 24.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. Simplified23.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{0} \]
  7. Final simplification33.5%

    \[\leadsto 0 \]

Reproduce

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