Henrywood and Agarwal, Equation (13)

Percentage Accurate: 25.1% → 54.5%
Time: 40.4s
Alternatives: 9
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 9 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.1% accurate, 1.0× speedup?

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

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

Alternative 1: 54.5% accurate, 0.3× speedup?

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

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

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


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

    1. Initial program 77.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. +-commutative77.0%

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\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)} \]
      3. times-frac74.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    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. +-commutative0.0%

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\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)} \]
      3. times-frac0.0%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification58.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 \cdot {\left(\left(\sqrt{\frac{c0}{w \cdot h}} \cdot \frac{d}{D}\right) \cdot \sqrt{2}\right)}^{2}}{2 \cdot w}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 53.7% accurate, 0.4× speedup?

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

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

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


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

    1. Initial program 77.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. +-commutative77.0%

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\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)} \]
      3. times-frac74.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0 \cdot \color{blue}{\frac{2 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2}}}{w \cdot h}}}{w \cdot 2} \]
      4. *-commutative84.0%

        \[\leadsto \frac{c0 \cdot \frac{2 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2}}}{\color{blue}{h \cdot w}}}{w \cdot 2} \]
    16. Simplified84.0%

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

    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. +-commutative0.0%

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\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)} \]
      3. times-frac0.0%

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

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

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

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

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

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

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

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

    \[\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 \cdot \frac{2 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2}}}{w \cdot h}}{2 \cdot w}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 54.9% accurate, 0.4× 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 {\left(\sqrt{\frac{c0}{w \cdot h}} \cdot \frac{d}{D}\right)}^{2}\right)\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (let* ((t_0 (/ c0 (* 2.0 w))) (t_1 (/ (* c0 (* d d)) (* (* w h) (* D D)))))
   (if (<= (* t_0 (+ t_1 (sqrt (- (* t_1 t_1) (* M M))))) INFINITY)
     (* t_0 (* 2.0 (pow (* (sqrt (/ c0 (* w h))) (/ d D)) 2.0)))
     0.0)))
double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = c0 / (2.0 * w);
	double t_1 = (c0 * (d * d)) / ((w * h) * (D * D));
	double tmp;
	if ((t_0 * (t_1 + sqrt(((t_1 * t_1) - (M * M))))) <= ((double) INFINITY)) {
		tmp = t_0 * (2.0 * pow((sqrt((c0 / (w * h))) * (d / D)), 2.0));
	} else {
		tmp = 0.0;
	}
	return tmp;
}
public static double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = c0 / (2.0 * w);
	double t_1 = (c0 * (d * d)) / ((w * h) * (D * D));
	double tmp;
	if ((t_0 * (t_1 + Math.sqrt(((t_1 * t_1) - (M * M))))) <= Double.POSITIVE_INFINITY) {
		tmp = t_0 * (2.0 * Math.pow((Math.sqrt((c0 / (w * h))) * (d / D)), 2.0));
	} else {
		tmp = 0.0;
	}
	return tmp;
}
def code(c0, w, h, D, d, M):
	t_0 = c0 / (2.0 * w)
	t_1 = (c0 * (d * d)) / ((w * h) * (D * D))
	tmp = 0
	if (t_0 * (t_1 + math.sqrt(((t_1 * t_1) - (M * M))))) <= math.inf:
		tmp = t_0 * (2.0 * math.pow((math.sqrt((c0 / (w * h))) * (d / D)), 2.0))
	else:
		tmp = 0.0
	return tmp
function code(c0, w, h, D, d, M)
	t_0 = Float64(c0 / Float64(2.0 * w))
	t_1 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D)))
	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(sqrt(Float64(c0 / Float64(w * h))) * Float64(d / D)) ^ 2.0)));
	else
		tmp = 0.0;
	end
	return tmp
end
function tmp_2 = code(c0, w, h, D, d, M)
	t_0 = c0 / (2.0 * w);
	t_1 = (c0 * (d * d)) / ((w * h) * (D * D));
	tmp = 0.0;
	if ((t_0 * (t_1 + sqrt(((t_1 * t_1) - (M * M))))) <= Inf)
		tmp = t_0 * (2.0 * ((sqrt((c0 / (w * h))) * (d / D)) ^ 2.0));
	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]}, 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[Power[N[(N[Sqrt[N[(c0 / N[(w * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]]]
\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 {\left(\sqrt{\frac{c0}{w \cdot h}} \cdot \frac{d}{D}\right)}^{2}\right)\\

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


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

    1. Initial program 77.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. +-commutative77.0%

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\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)} \]
      3. times-frac74.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\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)} \]
      3. times-frac0.0%

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

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

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

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

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

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

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

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

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

Alternative 4: 53.4% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 77.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. +-commutative77.0%

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\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)} \]
      3. times-frac74.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    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. +-commutative0.0%

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\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)} \]
      3. times-frac0.0%

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

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

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

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

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

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

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

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

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

Alternative 5: 44.1% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{1}{\frac{d}{D}}\\
\mathbf{if}\;w \leq -2.6 \cdot 10^{-52}:\\
\;\;\;\;0\\

\mathbf{elif}\;w \leq 1.6 \cdot 10^{-73}:\\
\;\;\;\;\frac{c0}{2 \cdot w} \cdot \frac{2}{\frac{t\_0 \cdot t\_0}{\frac{\frac{c0}{w}}{h}}}\\

\mathbf{elif}\;w \leq 5.8 \cdot 10^{-14}:\\
\;\;\;\;0\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if w < -2.5999999999999999e-52 or 1.59999999999999993e-73 < w < 5.8000000000000005e-14 or 2.9e65 < w

    1. Initial program 13.4%

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\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)} \]
      3. times-frac12.3%

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

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

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

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

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

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

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

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

    if -2.5999999999999999e-52 < w < 1.59999999999999993e-73

    1. Initial program 29.2%

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\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)} \]
      3. times-frac28.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) \]
      4. fma-neg28.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2}{\frac{\color{blue}{\frac{1}{\frac{d}{D}} \cdot \frac{1}{\frac{d}{D}}}}{\frac{c0}{h \cdot w}}} \]
    14. Step-by-step derivation
      1. associate-/l/52.3%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2}{\frac{\frac{1}{\frac{d}{D}} \cdot \frac{1}{\frac{d}{D}}}{\color{blue}{\frac{\frac{c0}{w}}{h}}}} \]
      2. div-inv52.3%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2}{\frac{\frac{1}{\frac{d}{D}} \cdot \frac{1}{\frac{d}{D}}}{\color{blue}{\frac{c0}{w} \cdot \frac{1}{h}}}} \]
    15. Applied egg-rr52.3%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2}{\frac{\frac{1}{\frac{d}{D}} \cdot \frac{1}{\frac{d}{D}}}{\color{blue}{\frac{c0}{w} \cdot \frac{1}{h}}}} \]
    16. Step-by-step derivation
      1. associate-*r/52.3%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2}{\frac{\frac{1}{\frac{d}{D}} \cdot \frac{1}{\frac{d}{D}}}{\color{blue}{\frac{\frac{c0}{w} \cdot 1}{h}}}} \]
      2. *-rgt-identity52.3%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2}{\frac{\frac{1}{\frac{d}{D}} \cdot \frac{1}{\frac{d}{D}}}{\frac{\color{blue}{\frac{c0}{w}}}{h}}} \]
    17. Simplified52.3%

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

    if 5.8000000000000005e-14 < w < 2.9e65

    1. Initial program 33.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. +-commutative33.8%

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\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)} \]
      3. times-frac33.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) \]
      4. fma-neg33.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2}{\frac{\frac{1}{\frac{d}{D}} \cdot \color{blue}{\frac{1}{\frac{d}{D}}}}{\frac{c0}{h \cdot w}}} \]
    13. Applied egg-rr62.2%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2}{\frac{\color{blue}{\frac{1}{\frac{d}{D}} \cdot \frac{1}{\frac{d}{D}}}}{\frac{c0}{h \cdot w}}} \]
    14. Step-by-step derivation
      1. associate-/r*62.2%

        \[\leadsto \color{blue}{\frac{\frac{c0}{2}}{w}} \cdot \frac{2}{\frac{\frac{1}{\frac{d}{D}} \cdot \frac{1}{\frac{d}{D}}}{\frac{c0}{h \cdot w}}} \]
      2. pow262.2%

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{c0}{2}}{w} \cdot \left(\frac{2}{e^{\color{blue}{\log \left(\frac{d}{D}\right) \cdot -2}}} \cdot \frac{c0}{h \cdot w}\right) \]
      10. pow-to-exp62.4%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;w \leq -2.6 \cdot 10^{-52}:\\ \;\;\;\;0\\ \mathbf{elif}\;w \leq 1.6 \cdot 10^{-73}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \frac{2}{\frac{\frac{1}{\frac{d}{D}} \cdot \frac{1}{\frac{d}{D}}}{\frac{\frac{c0}{w}}{h}}}\\ \mathbf{elif}\;w \leq 5.8 \cdot 10^{-14}:\\ \;\;\;\;0\\ \mathbf{elif}\;w \leq 2.9 \cdot 10^{+65}:\\ \;\;\;\;\frac{\frac{c0}{2} \cdot \left(\frac{c0}{w} \cdot \left(2 \cdot {\left(\frac{d}{D}\right)}^{2}\right)\right)}{w \cdot h}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 43.9% accurate, 3.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;w \leq -1.9 \cdot 10^{-52}:\\ \;\;\;\;0\\ \mathbf{elif}\;w \leq 3.1 \cdot 10^{-73} \lor \neg \left(w \leq 2.2 \cdot 10^{-16}\right) \land w \leq 6.5 \cdot 10^{+65}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{\frac{c0}{w \cdot h}}{\frac{D \cdot \frac{1}{d}}{\frac{d}{D}}}\right)\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (if (<= w -1.9e-52)
   0.0
   (if (or (<= w 3.1e-73) (and (not (<= w 2.2e-16)) (<= w 6.5e+65)))
     (*
      (/ c0 (* 2.0 w))
      (* 2.0 (/ (/ c0 (* w h)) (/ (* D (/ 1.0 d)) (/ d D)))))
     0.0)))
double code(double c0, double w, double h, double D, double d, double M) {
	double tmp;
	if (w <= -1.9e-52) {
		tmp = 0.0;
	} else if ((w <= 3.1e-73) || (!(w <= 2.2e-16) && (w <= 6.5e+65))) {
		tmp = (c0 / (2.0 * w)) * (2.0 * ((c0 / (w * h)) / ((D * (1.0 / d)) / (d / D))));
	} else {
		tmp = 0.0;
	}
	return tmp;
}
real(8) function code(c0, w, h, d, d_1, m)
    real(8), intent (in) :: c0
    real(8), intent (in) :: w
    real(8), intent (in) :: h
    real(8), intent (in) :: d
    real(8), intent (in) :: d_1
    real(8), intent (in) :: m
    real(8) :: tmp
    if (w <= (-1.9d-52)) then
        tmp = 0.0d0
    else if ((w <= 3.1d-73) .or. (.not. (w <= 2.2d-16)) .and. (w <= 6.5d+65)) then
        tmp = (c0 / (2.0d0 * w)) * (2.0d0 * ((c0 / (w * h)) / ((d * (1.0d0 / d_1)) / (d_1 / d))))
    else
        tmp = 0.0d0
    end if
    code = tmp
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
	double tmp;
	if (w <= -1.9e-52) {
		tmp = 0.0;
	} else if ((w <= 3.1e-73) || (!(w <= 2.2e-16) && (w <= 6.5e+65))) {
		tmp = (c0 / (2.0 * w)) * (2.0 * ((c0 / (w * h)) / ((D * (1.0 / d)) / (d / D))));
	} else {
		tmp = 0.0;
	}
	return tmp;
}
def code(c0, w, h, D, d, M):
	tmp = 0
	if w <= -1.9e-52:
		tmp = 0.0
	elif (w <= 3.1e-73) or (not (w <= 2.2e-16) and (w <= 6.5e+65)):
		tmp = (c0 / (2.0 * w)) * (2.0 * ((c0 / (w * h)) / ((D * (1.0 / d)) / (d / D))))
	else:
		tmp = 0.0
	return tmp
function code(c0, w, h, D, d, M)
	tmp = 0.0
	if (w <= -1.9e-52)
		tmp = 0.0;
	elseif ((w <= 3.1e-73) || (!(w <= 2.2e-16) && (w <= 6.5e+65)))
		tmp = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(2.0 * Float64(Float64(c0 / Float64(w * h)) / Float64(Float64(D * Float64(1.0 / d)) / Float64(d / D)))));
	else
		tmp = 0.0;
	end
	return tmp
end
function tmp_2 = code(c0, w, h, D, d, M)
	tmp = 0.0;
	if (w <= -1.9e-52)
		tmp = 0.0;
	elseif ((w <= 3.1e-73) || (~((w <= 2.2e-16)) && (w <= 6.5e+65)))
		tmp = (c0 / (2.0 * w)) * (2.0 * ((c0 / (w * h)) / ((D * (1.0 / d)) / (d / D))));
	else
		tmp = 0.0;
	end
	tmp_2 = tmp;
end
code[c0_, w_, h_, D_, d_, M_] := If[LessEqual[w, -1.9e-52], 0.0, If[Or[LessEqual[w, 3.1e-73], And[N[Not[LessEqual[w, 2.2e-16]], $MachinePrecision], LessEqual[w, 6.5e+65]]], N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(2.0 * N[(N[(c0 / N[(w * h), $MachinePrecision]), $MachinePrecision] / N[(N[(D * N[(1.0 / d), $MachinePrecision]), $MachinePrecision] / N[(d / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;w \leq -1.9 \cdot 10^{-52}:\\
\;\;\;\;0\\

\mathbf{elif}\;w \leq 3.1 \cdot 10^{-73} \lor \neg \left(w \leq 2.2 \cdot 10^{-16}\right) \land w \leq 6.5 \cdot 10^{+65}:\\
\;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{\frac{c0}{w \cdot h}}{\frac{D \cdot \frac{1}{d}}{\frac{d}{D}}}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if w < -1.9000000000000002e-52 or 3.09999999999999969e-73 < w < 2.2e-16 or 6.5000000000000003e65 < w

    1. Initial program 13.4%

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\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)} \]
      3. times-frac12.3%

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

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

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

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

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

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

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

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

    if -1.9000000000000002e-52 < w < 3.09999999999999969e-73 or 2.2e-16 < w < 6.5000000000000003e65

    1. Initial program 29.7%

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\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)} \]
      3. times-frac29.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) \]
      4. fma-neg29.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{\frac{c0}{h \cdot w}}{\color{blue}{{\left({\left({\left(\frac{d}{D}\right)}^{-2}\right)}^{3}\right)}^{0.3333333333333333}}}\right) \]
    10. Step-by-step derivation
      1. unpow1/346.7%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;w \leq -1.9 \cdot 10^{-52}:\\ \;\;\;\;0\\ \mathbf{elif}\;w \leq 3.1 \cdot 10^{-73} \lor \neg \left(w \leq 2.2 \cdot 10^{-16}\right) \land w \leq 6.5 \cdot 10^{+65}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{\frac{c0}{w \cdot h}}{\frac{D \cdot \frac{1}{d}}{\frac{d}{D}}}\right)\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 43.8% accurate, 3.5× speedup?

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

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

\mathbf{elif}\;w \leq 2.1 \cdot 10^{-73}:\\
\;\;\;\;t\_1 \cdot \left(2 \cdot \frac{t\_0}{\frac{D \cdot \frac{1}{d}}{\frac{d}{D}}}\right)\\

\mathbf{elif}\;w \leq 1.2 \cdot 10^{-9}:\\
\;\;\;\;0\\

\mathbf{elif}\;w \leq 1.1 \cdot 10^{+65}:\\
\;\;\;\;t\_1 \cdot \frac{2}{\frac{\frac{1}{\frac{d}{D}} \cdot \frac{D}{d}}{t\_0}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if w < -4.80000000000000015e-53 or 2.0999999999999999e-73 < w < 1.2e-9 or 1.0999999999999999e65 < w

    1. Initial program 13.4%

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\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)} \]
      3. times-frac12.3%

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

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

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

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

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

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

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

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

    if -4.80000000000000015e-53 < w < 2.0999999999999999e-73

    1. Initial program 29.2%

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\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)} \]
      3. times-frac28.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) \]
      4. fma-neg28.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{\frac{c0}{h \cdot w}}{\color{blue}{{\left({\left({\left(\frac{d}{D}\right)}^{-2}\right)}^{3}\right)}^{0.3333333333333333}}}\right) \]
    10. Step-by-step derivation
      1. unpow1/345.4%

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

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

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

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

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

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

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

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

    if 1.2e-9 < w < 1.0999999999999999e65

    1. Initial program 33.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. +-commutative33.8%

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\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)} \]
      3. times-frac33.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) \]
      4. fma-neg33.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2}{\frac{\frac{1}{\frac{d}{D}} \cdot \color{blue}{\frac{1}{\frac{d}{D}}}}{\frac{c0}{h \cdot w}}} \]
    13. Applied egg-rr62.2%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2}{\frac{\color{blue}{\frac{1}{\frac{d}{D}} \cdot \frac{1}{\frac{d}{D}}}}{\frac{c0}{h \cdot w}}} \]
    14. Taylor expanded in d around 0 62.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;w \leq -4.8 \cdot 10^{-53}:\\ \;\;\;\;0\\ \mathbf{elif}\;w \leq 2.1 \cdot 10^{-73}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{\frac{c0}{w \cdot h}}{\frac{D \cdot \frac{1}{d}}{\frac{d}{D}}}\right)\\ \mathbf{elif}\;w \leq 1.2 \cdot 10^{-9}:\\ \;\;\;\;0\\ \mathbf{elif}\;w \leq 1.1 \cdot 10^{+65}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \frac{2}{\frac{\frac{1}{\frac{d}{D}} \cdot \frac{D}{d}}{\frac{c0}{w \cdot h}}}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 44.2% accurate, 3.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{1}{\frac{d}{D}}\\ t_1 := \frac{c0}{2 \cdot w}\\ \mathbf{if}\;w \leq -2.1 \cdot 10^{-53}:\\ \;\;\;\;0\\ \mathbf{elif}\;w \leq 2.9 \cdot 10^{-73}:\\ \;\;\;\;t\_1 \cdot \frac{2}{\frac{t\_0 \cdot t\_0}{\frac{\frac{c0}{w}}{h}}}\\ \mathbf{elif}\;w \leq 6.2 \cdot 10^{-12}:\\ \;\;\;\;0\\ \mathbf{elif}\;w \leq 2.6 \cdot 10^{+64}:\\ \;\;\;\;t\_1 \cdot \frac{2}{\frac{t\_0 \cdot \frac{D}{d}}{\frac{c0}{w \cdot h}}}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (let* ((t_0 (/ 1.0 (/ d D))) (t_1 (/ c0 (* 2.0 w))))
   (if (<= w -2.1e-53)
     0.0
     (if (<= w 2.9e-73)
       (* t_1 (/ 2.0 (/ (* t_0 t_0) (/ (/ c0 w) h))))
       (if (<= w 6.2e-12)
         0.0
         (if (<= w 2.6e+64)
           (* t_1 (/ 2.0 (/ (* t_0 (/ D d)) (/ c0 (* w h)))))
           0.0))))))
double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = 1.0 / (d / D);
	double t_1 = c0 / (2.0 * w);
	double tmp;
	if (w <= -2.1e-53) {
		tmp = 0.0;
	} else if (w <= 2.9e-73) {
		tmp = t_1 * (2.0 / ((t_0 * t_0) / ((c0 / w) / h)));
	} else if (w <= 6.2e-12) {
		tmp = 0.0;
	} else if (w <= 2.6e+64) {
		tmp = t_1 * (2.0 / ((t_0 * (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) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = 1.0d0 / (d_1 / d)
    t_1 = c0 / (2.0d0 * w)
    if (w <= (-2.1d-53)) then
        tmp = 0.0d0
    else if (w <= 2.9d-73) then
        tmp = t_1 * (2.0d0 / ((t_0 * t_0) / ((c0 / w) / h)))
    else if (w <= 6.2d-12) then
        tmp = 0.0d0
    else if (w <= 2.6d+64) then
        tmp = t_1 * (2.0d0 / ((t_0 * (d / d_1)) / (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 t_0 = 1.0 / (d / D);
	double t_1 = c0 / (2.0 * w);
	double tmp;
	if (w <= -2.1e-53) {
		tmp = 0.0;
	} else if (w <= 2.9e-73) {
		tmp = t_1 * (2.0 / ((t_0 * t_0) / ((c0 / w) / h)));
	} else if (w <= 6.2e-12) {
		tmp = 0.0;
	} else if (w <= 2.6e+64) {
		tmp = t_1 * (2.0 / ((t_0 * (D / d)) / (c0 / (w * h))));
	} else {
		tmp = 0.0;
	}
	return tmp;
}
def code(c0, w, h, D, d, M):
	t_0 = 1.0 / (d / D)
	t_1 = c0 / (2.0 * w)
	tmp = 0
	if w <= -2.1e-53:
		tmp = 0.0
	elif w <= 2.9e-73:
		tmp = t_1 * (2.0 / ((t_0 * t_0) / ((c0 / w) / h)))
	elif w <= 6.2e-12:
		tmp = 0.0
	elif w <= 2.6e+64:
		tmp = t_1 * (2.0 / ((t_0 * (D / d)) / (c0 / (w * h))))
	else:
		tmp = 0.0
	return tmp
function code(c0, w, h, D, d, M)
	t_0 = Float64(1.0 / Float64(d / D))
	t_1 = Float64(c0 / Float64(2.0 * w))
	tmp = 0.0
	if (w <= -2.1e-53)
		tmp = 0.0;
	elseif (w <= 2.9e-73)
		tmp = Float64(t_1 * Float64(2.0 / Float64(Float64(t_0 * t_0) / Float64(Float64(c0 / w) / h))));
	elseif (w <= 6.2e-12)
		tmp = 0.0;
	elseif (w <= 2.6e+64)
		tmp = Float64(t_1 * Float64(2.0 / Float64(Float64(t_0 * 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)
	t_0 = 1.0 / (d / D);
	t_1 = c0 / (2.0 * w);
	tmp = 0.0;
	if (w <= -2.1e-53)
		tmp = 0.0;
	elseif (w <= 2.9e-73)
		tmp = t_1 * (2.0 / ((t_0 * t_0) / ((c0 / w) / h)));
	elseif (w <= 6.2e-12)
		tmp = 0.0;
	elseif (w <= 2.6e+64)
		tmp = t_1 * (2.0 / ((t_0 * (D / d)) / (c0 / (w * h))));
	else
		tmp = 0.0;
	end
	tmp_2 = tmp;
end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(1.0 / N[(d / D), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[w, -2.1e-53], 0.0, If[LessEqual[w, 2.9e-73], N[(t$95$1 * N[(2.0 / N[(N[(t$95$0 * t$95$0), $MachinePrecision] / N[(N[(c0 / w), $MachinePrecision] / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[w, 6.2e-12], 0.0, If[LessEqual[w, 2.6e+64], N[(t$95$1 * N[(2.0 / N[(N[(t$95$0 * N[(D / d), $MachinePrecision]), $MachinePrecision] / N[(c0 / N[(w * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;w \leq 2.9 \cdot 10^{-73}:\\
\;\;\;\;t\_1 \cdot \frac{2}{\frac{t\_0 \cdot t\_0}{\frac{\frac{c0}{w}}{h}}}\\

\mathbf{elif}\;w \leq 6.2 \cdot 10^{-12}:\\
\;\;\;\;0\\

\mathbf{elif}\;w \leq 2.6 \cdot 10^{+64}:\\
\;\;\;\;t\_1 \cdot \frac{2}{\frac{t\_0 \cdot \frac{D}{d}}{\frac{c0}{w \cdot h}}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if w < -2.09999999999999977e-53 or 2.9e-73 < w < 6.2000000000000002e-12 or 2.59999999999999997e64 < w

    1. Initial program 13.4%

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\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)} \]
      3. times-frac12.3%

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

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

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

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

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

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

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

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

    if -2.09999999999999977e-53 < w < 2.9e-73

    1. Initial program 29.2%

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\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)} \]
      3. times-frac28.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) \]
      4. fma-neg28.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2}{\frac{\color{blue}{\frac{1}{\frac{d}{D}} \cdot \frac{1}{\frac{d}{D}}}}{\frac{c0}{h \cdot w}}} \]
    14. Step-by-step derivation
      1. associate-/l/52.3%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2}{\frac{\frac{1}{\frac{d}{D}} \cdot \frac{1}{\frac{d}{D}}}{\color{blue}{\frac{\frac{c0}{w}}{h}}}} \]
      2. div-inv52.3%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2}{\frac{\frac{1}{\frac{d}{D}} \cdot \frac{1}{\frac{d}{D}}}{\color{blue}{\frac{c0}{w} \cdot \frac{1}{h}}}} \]
    15. Applied egg-rr52.3%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2}{\frac{\frac{1}{\frac{d}{D}} \cdot \frac{1}{\frac{d}{D}}}{\color{blue}{\frac{c0}{w} \cdot \frac{1}{h}}}} \]
    16. Step-by-step derivation
      1. associate-*r/52.3%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2}{\frac{\frac{1}{\frac{d}{D}} \cdot \frac{1}{\frac{d}{D}}}{\color{blue}{\frac{\frac{c0}{w} \cdot 1}{h}}}} \]
      2. *-rgt-identity52.3%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2}{\frac{\frac{1}{\frac{d}{D}} \cdot \frac{1}{\frac{d}{D}}}{\frac{\color{blue}{\frac{c0}{w}}}{h}}} \]
    17. Simplified52.3%

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

    if 6.2000000000000002e-12 < w < 2.59999999999999997e64

    1. Initial program 33.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. +-commutative33.8%

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\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)} \]
      3. times-frac33.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) \]
      4. fma-neg33.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2}{\frac{\frac{1}{\frac{d}{D}} \cdot \color{blue}{\frac{1}{\frac{d}{D}}}}{\frac{c0}{h \cdot w}}} \]
    13. Applied egg-rr62.2%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2}{\frac{\color{blue}{\frac{1}{\frac{d}{D}} \cdot \frac{1}{\frac{d}{D}}}}{\frac{c0}{h \cdot w}}} \]
    14. Taylor expanded in d around 0 62.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;w \leq -2.1 \cdot 10^{-53}:\\ \;\;\;\;0\\ \mathbf{elif}\;w \leq 2.9 \cdot 10^{-73}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \frac{2}{\frac{\frac{1}{\frac{d}{D}} \cdot \frac{1}{\frac{d}{D}}}{\frac{\frac{c0}{w}}{h}}}\\ \mathbf{elif}\;w \leq 6.2 \cdot 10^{-12}:\\ \;\;\;\;0\\ \mathbf{elif}\;w \leq 2.6 \cdot 10^{+64}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \frac{2}{\frac{\frac{1}{\frac{d}{D}} \cdot \frac{D}{d}}{\frac{c0}{w \cdot h}}}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 33.2% 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 23.1%

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

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\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)} \]
    3. times-frac22.3%

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

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

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

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

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

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

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

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

    \[\leadsto 0 \]
  10. Add Preprocessing

Reproduce

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