Henrywood and Agarwal, Equation (13)

Percentage Accurate: 25.0% → 56.2%
Time: 32.8s
Alternatives: 6
Speedup: 151.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 6 alternatives:

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

Initial Program: 25.0% 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: 56.2% accurate, 0.5× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{c0 \cdot \mathsf{fma}\left(0.5, \left(w \cdot \left(h \cdot \left(M \cdot M\right)\right)\right) \cdot \left(\frac{D}{d} \cdot \frac{D}{c0 \cdot d}\right), c0 \cdot 0\right)}{2 \cdot w}\\


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

    1. Initial program 75.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-frac72.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) \]
      2. fma-def69.8%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(\frac{c0}{w \cdot h}, \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. times-frac70.3%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \color{blue}{\frac{d}{D} \cdot \frac{d}{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) \]
      4. difference-of-squares70.3%

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

      \[\leadsto \color{blue}{\frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\left(d \cdot d\right) \cdot \frac{c0}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M\right)}\right)} \]
    4. Step-by-step derivation
      1. associate-*r/69.9%

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\color{blue}{\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}} - M\right)}\right) \]
      4. associate-/l/72.2%

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\color{blue}{\frac{\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D}}{D}} - M\right)}\right) \]
      6. associate-/l*72.1%

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\frac{\frac{c0}{w \cdot h} \cdot \color{blue}{\left(d \cdot \frac{1}{\frac{D}{d}}\right)}}{D} - M\right)}\right) \]
      8. clear-num72.1%

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\color{blue}{\frac{\frac{c0}{w \cdot h} \cdot \left(d \cdot \frac{d}{D}\right)}{D}} - M\right)}\right) \]
    6. Step-by-step derivation
      1. associate-/l*72.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\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) \]
      3. frac-times73.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) \]
      4. associate-*r/78.4%

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \color{blue}{\frac{\frac{c0}{w} \cdot {\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. associate-*l/0.0%

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\left(d \cdot d\right) \cdot \frac{c0}{\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) \]
      3. fma-def0.0%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(d \cdot d, \frac{c0}{\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)} \]
      4. associate-*l*0.0%

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(d \cdot d, \frac{c0}{\color{blue}{\left(h \cdot \left(D \cdot D\right)\right) \cdot w}}, \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) \]
      6. associate-*r*0.0%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(d \cdot d, \frac{c0}{\color{blue}{\left(\left(h \cdot D\right) \cdot D\right)} \cdot w}, \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) \]
      7. associate-*l*0.0%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(d \cdot d, \frac{c0}{\color{blue}{\left(h \cdot D\right) \cdot \left(D \cdot w\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) \]
      8. *-commutative0.0%

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

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

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

        \[\leadsto \frac{c0 \cdot \mathsf{fma}\left(d \cdot d, \frac{c0}{\color{blue}{h \cdot \left(D \cdot \left(w \cdot D\right)\right)}}, \sqrt{\mathsf{fma}\left(\frac{\frac{c0}{h}}{w}, {\left(\frac{d}{D}\right)}^{4} \cdot \frac{\frac{c0}{h}}{w}, M \cdot \left(-M\right)\right)}\right)}{2 \cdot w} \]
      3. associate-/l/0.9%

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

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

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

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

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

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

        \[\leadsto \frac{c0 \cdot \color{blue}{\mathsf{fma}\left(0.5, \frac{{D}^{2} \cdot \left(w \cdot \left({M}^{2} \cdot h\right)\right)}{{d}^{2} \cdot c0}, -1 \cdot \left(\left(\frac{{d}^{2}}{{D}^{2} \cdot \left(w \cdot h\right)} + -1 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(w \cdot h\right)}\right) \cdot c0\right)\right)}}{w \cdot 2} \]
      2. associate-/l*1.8%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0 \cdot \mathsf{fma}\left(0.5, \frac{{D}^{2} \cdot \left(w \cdot \left(h \cdot \color{blue}{\left(M \cdot M\right)}\right)\right)}{{d}^{2} \cdot c0}, c0 \cdot 0\right)}{w \cdot 2} \]
      2. associate-*l/33.9%

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

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

        \[\leadsto \frac{c0 \cdot \mathsf{fma}\left(0.5, \frac{D \cdot D}{\color{blue}{\left(d \cdot d\right)} \cdot c0} \cdot \left(w \cdot \left(h \cdot \left(M \cdot M\right)\right)\right), c0 \cdot 0\right)}{w \cdot 2} \]
      5. associate-*r*34.7%

        \[\leadsto \frac{c0 \cdot \mathsf{fma}\left(0.5, \frac{D \cdot D}{\color{blue}{d \cdot \left(d \cdot c0\right)}} \cdot \left(w \cdot \left(h \cdot \left(M \cdot M\right)\right)\right), c0 \cdot 0\right)}{w \cdot 2} \]
      6. *-commutative34.7%

        \[\leadsto \frac{c0 \cdot \mathsf{fma}\left(0.5, \color{blue}{\left(w \cdot \left(h \cdot \left(M \cdot M\right)\right)\right) \cdot \frac{D \cdot D}{d \cdot \left(d \cdot c0\right)}}, c0 \cdot 0\right)}{w \cdot 2} \]
      7. times-frac41.5%

        \[\leadsto \frac{c0 \cdot \mathsf{fma}\left(0.5, \left(w \cdot \left(h \cdot \left(M \cdot M\right)\right)\right) \cdot \color{blue}{\left(\frac{D}{d} \cdot \frac{D}{d \cdot c0}\right)}, c0 \cdot 0\right)}{w \cdot 2} \]
    11. Simplified41.5%

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

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

Alternative 2: 42.7% accurate, 1.2× speedup?

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

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

\mathbf{elif}\;d \leq 8 \cdot 10^{+213}:\\
\;\;\;\;0\\

\mathbf{elif}\;d \leq 2.65 \cdot 10^{+292}:\\
\;\;\;\;t_0 \cdot \left(2 \cdot \frac{c0}{\frac{w}{\frac{{\left(\frac{d}{D}\right)}^{2}}{h}}}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < 6.9999999999999998e153

    1. Initial program 26.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-frac25.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) \]
      2. fma-def23.8%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(\frac{c0}{w \cdot h}, \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. times-frac24.5%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \color{blue}{\frac{d}{D} \cdot \frac{d}{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) \]
      4. difference-of-squares31.0%

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

      \[\leadsto \color{blue}{\frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\left(d \cdot d\right) \cdot \frac{c0}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M\right)}\right)} \]
    4. Step-by-step derivation
      1. associate-*r/30.4%

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\color{blue}{\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}} - M\right)}\right) \]
      4. associate-/l/35.7%

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\color{blue}{\frac{\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D}}{D}} - M\right)}\right) \]
      6. associate-/l*40.7%

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\frac{\frac{c0}{w \cdot h} \cdot \color{blue}{\left(d \cdot \frac{1}{\frac{D}{d}}\right)}}{D} - M\right)}\right) \]
      8. clear-num40.7%

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\color{blue}{\frac{\frac{c0}{w \cdot h} \cdot \left(d \cdot \frac{d}{D}\right)}{D}} - M\right)}\right) \]
    6. Step-by-step derivation
      1. associate-/l*40.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.9999999999999998e153 < d < 7.99999999999999987e213 or 2.65e292 < d

    1. Initial program 17.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-frac17.6%

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(\frac{c0}{w \cdot h}, \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. associate-/r*17.6%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \color{blue}{\frac{\frac{d \cdot d}{D}}{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) \]
      4. difference-of-squares17.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 7.99999999999999987e213 < d < 2.65e292

    1. Initial program 31.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-frac31.6%

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(\frac{c0}{w \cdot h}, \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. times-frac31.6%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \color{blue}{\frac{d}{D} \cdot \frac{d}{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) \]
      4. difference-of-squares42.1%

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

      \[\leadsto \color{blue}{\frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\left(d \cdot d\right) \cdot \frac{c0}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M\right)}\right)} \]
    4. Step-by-step derivation
      1. associate-*r/42.1%

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\color{blue}{\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}} - M\right)}\right) \]
      4. associate-/l/42.8%

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\color{blue}{\frac{\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D}}{D}} - M\right)}\right) \]
      6. associate-/l*42.8%

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\frac{\frac{c0}{w \cdot h} \cdot \color{blue}{\left(d \cdot \frac{1}{\frac{D}{d}}\right)}}{D} - M\right)}\right) \]
      8. clear-num42.8%

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\color{blue}{\frac{\frac{c0}{w \cdot h} \cdot \left(d \cdot \frac{d}{D}\right)}{D}} - M\right)}\right) \]
    6. Step-by-step derivation
      1. associate-/l*42.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\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) \]
      3. frac-times54.2%

        \[\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) \]
      4. associate-*l/54.3%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq 7 \cdot 10^{+153}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\left(\frac{d}{D} \cdot \frac{d}{D}\right) \cdot \frac{c0}{w \cdot h}\right)\right)\\ \mathbf{elif}\;d \leq 8 \cdot 10^{+213}:\\ \;\;\;\;0\\ \mathbf{elif}\;d \leq 2.65 \cdot 10^{+292}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{c0}{\frac{w}{\frac{{\left(\frac{d}{D}\right)}^{2}}{h}}}\right)\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]

Alternative 3: 44.2% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\left(\frac{d}{D}\right)}^{2}\\ t_1 := \frac{c0}{2 \cdot w}\\ \mathbf{if}\;d \leq 7 \cdot 10^{+153}:\\ \;\;\;\;t_1 \cdot \left(2 \cdot \frac{\frac{c0}{w} \cdot t_0}{h}\right)\\ \mathbf{elif}\;d \leq 5.2 \cdot 10^{+213}:\\ \;\;\;\;0\\ \mathbf{elif}\;d \leq 1.32 \cdot 10^{+293}:\\ \;\;\;\;t_1 \cdot \left(2 \cdot \frac{c0}{\frac{w}{\frac{t_0}{h}}}\right)\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (let* ((t_0 (pow (/ d D) 2.0)) (t_1 (/ c0 (* 2.0 w))))
   (if (<= d 7e+153)
     (* t_1 (* 2.0 (/ (* (/ c0 w) t_0) h)))
     (if (<= d 5.2e+213)
       0.0
       (if (<= d 1.32e+293) (* 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 = pow((d / D), 2.0);
	double t_1 = c0 / (2.0 * w);
	double tmp;
	if (d <= 7e+153) {
		tmp = t_1 * (2.0 * (((c0 / w) * t_0) / h));
	} else if (d <= 5.2e+213) {
		tmp = 0.0;
	} else if (d <= 1.32e+293) {
		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) ** 2.0d0
    t_1 = c0 / (2.0d0 * w)
    if (d_1 <= 7d+153) then
        tmp = t_1 * (2.0d0 * (((c0 / w) * t_0) / h))
    else if (d_1 <= 5.2d+213) then
        tmp = 0.0d0
    else if (d_1 <= 1.32d+293) 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 = Math.pow((d / D), 2.0);
	double t_1 = c0 / (2.0 * w);
	double tmp;
	if (d <= 7e+153) {
		tmp = t_1 * (2.0 * (((c0 / w) * t_0) / h));
	} else if (d <= 5.2e+213) {
		tmp = 0.0;
	} else if (d <= 1.32e+293) {
		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 = math.pow((d / D), 2.0)
	t_1 = c0 / (2.0 * w)
	tmp = 0
	if d <= 7e+153:
		tmp = t_1 * (2.0 * (((c0 / w) * t_0) / h))
	elif d <= 5.2e+213:
		tmp = 0.0
	elif d <= 1.32e+293:
		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(d / D) ^ 2.0
	t_1 = Float64(c0 / Float64(2.0 * w))
	tmp = 0.0
	if (d <= 7e+153)
		tmp = Float64(t_1 * Float64(2.0 * Float64(Float64(Float64(c0 / w) * t_0) / h)));
	elseif (d <= 5.2e+213)
		tmp = 0.0;
	elseif (d <= 1.32e+293)
		tmp = Float64(t_1 * Float64(2.0 * Float64(c0 / Float64(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) ^ 2.0;
	t_1 = c0 / (2.0 * w);
	tmp = 0.0;
	if (d <= 7e+153)
		tmp = t_1 * (2.0 * (((c0 / w) * t_0) / h));
	elseif (d <= 5.2e+213)
		tmp = 0.0;
	elseif (d <= 1.32e+293)
		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[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, 7e+153], N[(t$95$1 * N[(2.0 * N[(N[(N[(c0 / w), $MachinePrecision] * t$95$0), $MachinePrecision] / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 5.2e+213], 0.0, If[LessEqual[d, 1.32e+293], N[(t$95$1 * N[(2.0 * N[(c0 / N[(w / N[(t$95$0 / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]]]]]
\begin{array}{l}

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

\mathbf{elif}\;d \leq 5.2 \cdot 10^{+213}:\\
\;\;\;\;0\\

\mathbf{elif}\;d \leq 1.32 \cdot 10^{+293}:\\
\;\;\;\;t_1 \cdot \left(2 \cdot \frac{c0}{\frac{w}{\frac{t_0}{h}}}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < 6.9999999999999998e153

    1. Initial program 26.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-frac25.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) \]
      2. fma-def23.8%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(\frac{c0}{w \cdot h}, \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. times-frac24.5%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \color{blue}{\frac{d}{D} \cdot \frac{d}{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) \]
      4. difference-of-squares31.0%

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

      \[\leadsto \color{blue}{\frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\left(d \cdot d\right) \cdot \frac{c0}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M\right)}\right)} \]
    4. Step-by-step derivation
      1. associate-*r/30.4%

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\color{blue}{\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}} - M\right)}\right) \]
      4. associate-/l/35.7%

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\color{blue}{\frac{\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D}}{D}} - M\right)}\right) \]
      6. associate-/l*40.7%

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\frac{\frac{c0}{w \cdot h} \cdot \color{blue}{\left(d \cdot \frac{1}{\frac{D}{d}}\right)}}{D} - M\right)}\right) \]
      8. clear-num40.7%

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\color{blue}{\frac{\frac{c0}{w \cdot h} \cdot \left(d \cdot \frac{d}{D}\right)}{D}} - M\right)}\right) \]
    6. Step-by-step derivation
      1. associate-/l*40.7%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \color{blue}{\left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2}\right)}\right) \]
      2. associate-*l/46.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) \]
      3. frac-times45.2%

        \[\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) \]
      4. associate-*r/48.4%

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

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

    if 6.9999999999999998e153 < d < 5.19999999999999998e213 or 1.32e293 < d

    1. Initial program 17.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-frac17.6%

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(\frac{c0}{w \cdot h}, \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. associate-/r*17.6%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \color{blue}{\frac{\frac{d \cdot d}{D}}{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) \]
      4. difference-of-squares17.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.19999999999999998e213 < d < 1.32e293

    1. Initial program 31.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-frac31.6%

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(\frac{c0}{w \cdot h}, \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. times-frac31.6%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \color{blue}{\frac{d}{D} \cdot \frac{d}{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) \]
      4. difference-of-squares42.1%

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

      \[\leadsto \color{blue}{\frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\left(d \cdot d\right) \cdot \frac{c0}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M\right)}\right)} \]
    4. Step-by-step derivation
      1. associate-*r/42.1%

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\color{blue}{\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}} - M\right)}\right) \]
      4. associate-/l/42.8%

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\color{blue}{\frac{\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D}}{D}} - M\right)}\right) \]
      6. associate-/l*42.8%

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\frac{\frac{c0}{w \cdot h} \cdot \color{blue}{\left(d \cdot \frac{1}{\frac{D}{d}}\right)}}{D} - M\right)}\right) \]
      8. clear-num42.8%

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\color{blue}{\frac{\frac{c0}{w \cdot h} \cdot \left(d \cdot \frac{d}{D}\right)}{D}} - M\right)}\right) \]
    6. Step-by-step derivation
      1. associate-/l*42.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\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) \]
      3. frac-times54.2%

        \[\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) \]
      4. associate-*l/54.3%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq 7 \cdot 10^{+153}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{\frac{c0}{w} \cdot {\left(\frac{d}{D}\right)}^{2}}{h}\right)\\ \mathbf{elif}\;d \leq 5.2 \cdot 10^{+213}:\\ \;\;\;\;0\\ \mathbf{elif}\;d \leq 1.32 \cdot 10^{+293}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{c0}{\frac{w}{\frac{{\left(\frac{d}{D}\right)}^{2}}{h}}}\right)\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]

Alternative 4: 42.7% accurate, 5.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq 6 \cdot 10^{+153} \lor \neg \left(d \leq 6 \cdot 10^{+213}\right) \land d \leq 3.05 \cdot 10^{+292}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\left(\frac{d}{D} \cdot \frac{d}{D}\right) \cdot \frac{c0}{w \cdot h}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (if (or (<= d 6e+153) (and (not (<= d 6e+213)) (<= d 3.05e+292)))
   (* (/ 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 <= 6e+153) || (!(d <= 6e+213) && (d <= 3.05e+292))) {
		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 <= 6d+153) .or. (.not. (d_1 <= 6d+213)) .and. (d_1 <= 3.05d+292)) 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 <= 6e+153) || (!(d <= 6e+213) && (d <= 3.05e+292))) {
		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 <= 6e+153) or (not (d <= 6e+213) and (d <= 3.05e+292)):
		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 <= 6e+153) || (!(d <= 6e+213) && (d <= 3.05e+292)))
		tmp = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(2.0 * Float64(Float64(Float64(d / D) * 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 <= 6e+153) || (~((d <= 6e+213)) && (d <= 3.05e+292)))
		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[Or[LessEqual[d, 6e+153], And[N[Not[LessEqual[d, 6e+213]], $MachinePrecision], LessEqual[d, 3.05e+292]]], N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(2.0 * N[(N[(N[(d / D), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision] * N[(c0 / N[(w * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;d \leq 6 \cdot 10^{+153} \lor \neg \left(d \leq 6 \cdot 10^{+213}\right) \land d \leq 3.05 \cdot 10^{+292}:\\
\;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\left(\frac{d}{D} \cdot \frac{d}{D}\right) \cdot \frac{c0}{w \cdot h}\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < 6.00000000000000037e153 or 6.0000000000000002e213 < d < 3.05000000000000011e292

    1. Initial program 26.5%

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(\frac{c0}{w \cdot h}, \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. times-frac25.1%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \color{blue}{\frac{d}{D} \cdot \frac{d}{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) \]
      4. difference-of-squares31.8%

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

      \[\leadsto \color{blue}{\frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\left(d \cdot d\right) \cdot \frac{c0}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M\right)}\right)} \]
    4. Step-by-step derivation
      1. associate-*r/31.4%

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\color{blue}{\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}} - M\right)}\right) \]
      4. associate-/l/36.3%

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\color{blue}{\frac{\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D}}{D}} - M\right)}\right) \]
      6. associate-/l*40.8%

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\frac{\frac{c0}{w \cdot h} \cdot \color{blue}{\left(d \cdot \frac{1}{\frac{D}{d}}\right)}}{D} - M\right)}\right) \]
      8. clear-num40.8%

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\color{blue}{\frac{\frac{c0}{w \cdot h} \cdot \left(d \cdot \frac{d}{D}\right)}{D}} - M\right)}\right) \]
    6. Step-by-step derivation
      1. associate-/l*40.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.00000000000000037e153 < d < 6.0000000000000002e213 or 3.05000000000000011e292 < d

    1. Initial program 17.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-frac17.6%

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(\frac{c0}{w \cdot h}, \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. associate-/r*17.6%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \color{blue}{\frac{\frac{d \cdot d}{D}}{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) \]
      4. difference-of-squares17.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq 6 \cdot 10^{+153} \lor \neg \left(d \leq 6 \cdot 10^{+213}\right) \land d \leq 3.05 \cdot 10^{+292}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\left(\frac{d}{D} \cdot \frac{d}{D}\right) \cdot \frac{c0}{w \cdot h}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]

Alternative 5: 40.0% accurate, 6.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq 5.8 \cdot 10^{+153} \lor \neg \left(d \leq 5.1 \cdot 10^{+213}\right) \land d \leq 5.5 \cdot 10^{+292}:\\
\;\;\;\;\left(\frac{d}{D} \cdot \frac{c0 \cdot d}{D}\right) \cdot \frac{\frac{c0}{h}}{w \cdot w}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < 5.80000000000000004e153 or 5.1000000000000002e213 < d < 5.5000000000000003e292

    1. Initial program 26.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-frac25.5%

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(\frac{c0}{w \cdot h}, \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. associate-/r*24.6%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \color{blue}{\frac{\frac{d \cdot d}{D}}{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) \]
      4. difference-of-squares31.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{1 \cdot \left(\frac{d \cdot \left(d \cdot c0\right)}{D \cdot D} \cdot \frac{c0}{h \cdot \left(w \cdot w\right)}\right)} \]
    12. Step-by-step derivation
      1. *-lft-identity38.0%

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

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

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

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

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

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

    if 5.80000000000000004e153 < d < 5.1000000000000002e213 or 5.5000000000000003e292 < d

    1. Initial program 18.8%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Step-by-step derivation
      1. times-frac18.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) \]
      2. fma-def18.8%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(\frac{c0}{w \cdot h}, \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. associate-/r*18.8%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \color{blue}{\frac{\frac{d \cdot d}{D}}{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) \]
      4. difference-of-squares18.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq 5.8 \cdot 10^{+153} \lor \neg \left(d \leq 5.1 \cdot 10^{+213}\right) \land d \leq 5.5 \cdot 10^{+292}:\\ \;\;\;\;\left(\frac{d}{D} \cdot \frac{c0 \cdot d}{D}\right) \cdot \frac{\frac{c0}{h}}{w \cdot w}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]

Alternative 6: 33.9% 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 25.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-frac25.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) \]
    2. fma-def24.0%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(\frac{c0}{w \cdot h}, \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. associate-/r*24.2%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \color{blue}{\frac{\frac{d \cdot d}{D}}{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) \]
    4. difference-of-squares30.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto 0 \]

Reproduce

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