Henrywood and Agarwal, Equation (13)

Percentage Accurate: 24.5% → 61.5%
Time: 32.7s
Alternatives: 11
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 11 alternatives:

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

Initial Program: 24.5% 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: 61.5% accurate, 0.6× 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(2 \cdot \left({\left(\frac{d}{D}\right)}^{2} \cdot \frac{c0}{w \cdot h}\right)\right)}{2 \cdot w}\\ \mathbf{else}:\\ \;\;\;\;0.25 \cdot \left(\left(M \cdot \left(h \cdot M\right)\right) \cdot \left(\frac{D}{d} \cdot \frac{D}{d}\right)\right)\\ \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))))) (* 2.0 w))
     (* 0.25 (* (* M (* h M)) (* (/ D d) (/ D d)))))))
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))))) / (2.0 * w);
	} else {
		tmp = 0.25 * ((M * (h * M)) * ((D / d) * (D / d)));
	}
	return tmp;
}
public static double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = (c0 * (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))))) / (2.0 * w);
	} else {
		tmp = 0.25 * ((M * (h * M)) * ((D / d) * (D / d)));
	}
	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))))) / (2.0 * w)
	else:
		tmp = 0.25 * ((M * (h * M)) * ((D / d) * (D / d)))
	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(2.0 * w));
	else
		tmp = Float64(0.25 * Float64(Float64(M * Float64(h * M)) * Float64(Float64(D / d) * Float64(D / d))));
	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))))) / (2.0 * w);
	else
		tmp = 0.25 * ((M * (h * M)) * ((D / d) * (D / d)));
	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[(2.0 * w), $MachinePrecision]), $MachinePrecision], N[(0.25 * N[(N[(M * N[(h * M), $MachinePrecision]), $MachinePrecision] * N[(N[(D / d), $MachinePrecision] * N[(D / d), $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)}\\
\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(2 \cdot \left({\left(\frac{d}{D}\right)}^{2} \cdot \frac{c0}{w \cdot h}\right)\right)}{2 \cdot w}\\

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


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

    1. Initial program 71.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(0.5, \frac{D \cdot D}{c0} \cdot \frac{\left(h \cdot w\right) \cdot \left(M \cdot M\right)}{\color{blue}{d \cdot d}}, -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) \]
      8. mul-1-neg3.5%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(0.5, \frac{D \cdot D}{c0} \cdot \frac{\left(h \cdot w\right) \cdot \left(M \cdot M\right)}{d \cdot d}, \color{blue}{-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) \]
      9. distribute-rgt-in1.8%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{h \cdot \left(M \cdot M\right)}}} \]
    9. Taylor expanded in D around 0 39.8%

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

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

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

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

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

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

        \[\leadsto 0.25 \cdot \color{blue}{\left(\left(h \cdot \left(M \cdot M\right)\right) \cdot \frac{D \cdot D}{d \cdot d}\right)} \]
      7. associate-*r*42.9%

        \[\leadsto 0.25 \cdot \left(\color{blue}{\left(\left(h \cdot M\right) \cdot M\right)} \cdot \frac{D \cdot D}{d \cdot d}\right) \]
      8. times-frac52.9%

        \[\leadsto 0.25 \cdot \left(\left(\left(h \cdot M\right) \cdot M\right) \cdot \color{blue}{\left(\frac{D}{d} \cdot \frac{D}{d}\right)}\right) \]
    11. Simplified52.9%

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

Alternative 2: 40.5% accurate, 4.1× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{d \cdot d}{w \cdot h} \cdot \frac{c0}{D \cdot D}\right)\right)\\
\mathbf{if}\;d \cdot d \leq 5 \cdot 10^{-187}:\\
\;\;\;\;0.25 \cdot \left(\left(M \cdot \left(h \cdot M\right)\right) \cdot \left(\frac{D}{d} \cdot \frac{D}{d}\right)\right)\\

\mathbf{elif}\;d \cdot d \leq 2 \cdot 10^{+108}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;d \cdot d \leq 10^{+221}:\\
\;\;\;\;0.25 \cdot \frac{D \cdot D}{\frac{d}{h \cdot M} \cdot \frac{d}{M}}\\

\mathbf{elif}\;d \cdot d \leq 10^{+233}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (*.f64 d d) < 4.9999999999999996e-187

    1. Initial program 9.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. Simplified9.3%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(0.5, \frac{D \cdot D}{c0} \cdot \frac{\left(h \cdot w\right) \cdot \left(M \cdot M\right)}{\color{blue}{d \cdot d}}, -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) \]
      8. mul-1-neg0.4%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(0.5, \frac{D \cdot D}{c0} \cdot \frac{\left(h \cdot w\right) \cdot \left(M \cdot M\right)}{d \cdot d}, \color{blue}{-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) \]
      9. distribute-rgt-in0.4%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{h \cdot \left(M \cdot M\right)}}} \]
    9. Taylor expanded in D around 0 23.3%

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

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

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

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

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

        \[\leadsto 0.25 \cdot \left(\frac{\color{blue}{D \cdot D}}{d \cdot d} \cdot \left(h \cdot \left(M \cdot M\right)\right)\right) \]
      6. *-commutative23.1%

        \[\leadsto 0.25 \cdot \color{blue}{\left(\left(h \cdot \left(M \cdot M\right)\right) \cdot \frac{D \cdot D}{d \cdot d}\right)} \]
      7. associate-*r*23.1%

        \[\leadsto 0.25 \cdot \left(\color{blue}{\left(\left(h \cdot M\right) \cdot M\right)} \cdot \frac{D \cdot D}{d \cdot d}\right) \]
      8. times-frac43.3%

        \[\leadsto 0.25 \cdot \left(\left(\left(h \cdot M\right) \cdot M\right) \cdot \color{blue}{\left(\frac{D}{d} \cdot \frac{D}{d}\right)}\right) \]
    11. Simplified43.3%

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

    if 4.9999999999999996e-187 < (*.f64 d d) < 2.0000000000000001e108 or 1e221 < (*.f64 d d) < 9.99999999999999974e232

    1. Initial program 41.9%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Simplified43.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{\mathsf{fma}\left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}, \frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}, -M \cdot M\right)}\right)} \]
    3. Taylor expanded in c0 around inf 50.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.0000000000000001e108 < (*.f64 d d) < 1e221

    1. Initial program 21.6%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(0.5, \frac{D \cdot D}{c0} \cdot \frac{\left(h \cdot w\right) \cdot \left(M \cdot M\right)}{\color{blue}{d \cdot d}}, -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) \]
      8. mul-1-neg3.5%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(0.5, \frac{D \cdot D}{c0} \cdot \frac{\left(h \cdot w\right) \cdot \left(M \cdot M\right)}{d \cdot d}, \color{blue}{-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) \]
      9. distribute-rgt-in0.1%

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

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

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

        \[\leadsto 0.25 \cdot \color{blue}{\frac{{D}^{2}}{\frac{{d}^{2}}{{M}^{2} \cdot h}}} \]
      2. unpow245.1%

        \[\leadsto 0.25 \cdot \frac{\color{blue}{D \cdot D}}{\frac{{d}^{2}}{{M}^{2} \cdot h}} \]
      3. unpow245.1%

        \[\leadsto 0.25 \cdot \frac{D \cdot D}{\frac{\color{blue}{d \cdot d}}{{M}^{2} \cdot h}} \]
      4. *-commutative45.1%

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

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

      \[\leadsto \color{blue}{0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{h \cdot \left(M \cdot M\right)}}} \]
    9. Taylor expanded in d around 0 45.1%

      \[\leadsto 0.25 \cdot \frac{D \cdot D}{\color{blue}{\frac{{d}^{2}}{{M}^{2} \cdot h}}} \]
    10. Step-by-step derivation
      1. unpow245.1%

        \[\leadsto 0.25 \cdot \frac{D \cdot D}{\frac{\color{blue}{d \cdot d}}{{M}^{2} \cdot h}} \]
      2. unpow245.1%

        \[\leadsto 0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{\color{blue}{\left(M \cdot M\right)} \cdot h}} \]
      3. *-commutative45.1%

        \[\leadsto 0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{\color{blue}{h \cdot \left(M \cdot M\right)}}} \]
      4. associate-*r*51.3%

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

        \[\leadsto 0.25 \cdot \frac{D \cdot D}{\color{blue}{\frac{d}{h \cdot M} \cdot \frac{d}{M}}} \]
    11. Simplified51.4%

      \[\leadsto 0.25 \cdot \frac{D \cdot D}{\color{blue}{\frac{d}{h \cdot M} \cdot \frac{d}{M}}} \]

    if 9.99999999999999974e232 < (*.f64 d d)

    1. Initial program 20.3%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \cdot d \leq 5 \cdot 10^{-187}:\\ \;\;\;\;0.25 \cdot \left(\left(M \cdot \left(h \cdot M\right)\right) \cdot \left(\frac{D}{d} \cdot \frac{D}{d}\right)\right)\\ \mathbf{elif}\;d \cdot d \leq 2 \cdot 10^{+108}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{d \cdot d}{w \cdot h} \cdot \frac{c0}{D \cdot D}\right)\right)\\ \mathbf{elif}\;d \cdot d \leq 10^{+221}:\\ \;\;\;\;0.25 \cdot \frac{D \cdot D}{\frac{d}{h \cdot M} \cdot \frac{d}{M}}\\ \mathbf{elif}\;d \cdot d \leq 10^{+233}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{d \cdot d}{w \cdot h} \cdot \frac{c0}{D \cdot D}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]

Alternative 3: 41.6% accurate, 4.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{d \cdot d}{w \cdot h}\\ t_1 := \frac{c0}{2 \cdot w}\\ \mathbf{if}\;d \cdot d \leq 5 \cdot 10^{-187}:\\ \;\;\;\;0.25 \cdot \left(\left(M \cdot \left(h \cdot M\right)\right) \cdot \left(\frac{D}{d} \cdot \frac{D}{d}\right)\right)\\ \mathbf{elif}\;d \cdot d \leq 2 \cdot 10^{+108}:\\ \;\;\;\;t_1 \cdot \left(2 \cdot \left(\frac{\frac{c0}{D}}{D} \cdot t_0\right)\right)\\ \mathbf{elif}\;d \cdot d \leq 10^{+221}:\\ \;\;\;\;0.25 \cdot \frac{D \cdot D}{\frac{d}{h \cdot M} \cdot \frac{d}{M}}\\ \mathbf{elif}\;d \cdot d \leq 10^{+233}:\\ \;\;\;\;t_1 \cdot \left(2 \cdot \left(t_0 \cdot \frac{c0}{D \cdot D}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (let* ((t_0 (/ (* d d) (* w h))) (t_1 (/ c0 (* 2.0 w))))
   (if (<= (* d d) 5e-187)
     (* 0.25 (* (* M (* h M)) (* (/ D d) (/ D d))))
     (if (<= (* d d) 2e+108)
       (* t_1 (* 2.0 (* (/ (/ c0 D) D) t_0)))
       (if (<= (* d d) 1e+221)
         (* 0.25 (/ (* D D) (* (/ d (* h M)) (/ d M))))
         (if (<= (* d d) 1e+233)
           (* t_1 (* 2.0 (* t_0 (/ c0 (* D D)))))
           0.0))))))
double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = (d * d) / (w * h);
	double t_1 = c0 / (2.0 * w);
	double tmp;
	if ((d * d) <= 5e-187) {
		tmp = 0.25 * ((M * (h * M)) * ((D / d) * (D / d)));
	} else if ((d * d) <= 2e+108) {
		tmp = t_1 * (2.0 * (((c0 / D) / D) * t_0));
	} else if ((d * d) <= 1e+221) {
		tmp = 0.25 * ((D * D) / ((d / (h * M)) * (d / M)));
	} else if ((d * d) <= 1e+233) {
		tmp = t_1 * (2.0 * (t_0 * (c0 / (D * D))));
	} else {
		tmp = 0.0;
	}
	return tmp;
}
real(8) function code(c0, w, h, d, d_1, m)
    real(8), intent (in) :: c0
    real(8), intent (in) :: w
    real(8), intent (in) :: h
    real(8), intent (in) :: d
    real(8), intent (in) :: d_1
    real(8), intent (in) :: m
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (d_1 * d_1) / (w * h)
    t_1 = c0 / (2.0d0 * w)
    if ((d_1 * d_1) <= 5d-187) then
        tmp = 0.25d0 * ((m * (h * m)) * ((d / d_1) * (d / d_1)))
    else if ((d_1 * d_1) <= 2d+108) then
        tmp = t_1 * (2.0d0 * (((c0 / d) / d) * t_0))
    else if ((d_1 * d_1) <= 1d+221) then
        tmp = 0.25d0 * ((d * d) / ((d_1 / (h * m)) * (d_1 / m)))
    else if ((d_1 * d_1) <= 1d+233) then
        tmp = t_1 * (2.0d0 * (t_0 * (c0 / (d * d))))
    else
        tmp = 0.0d0
    end if
    code = tmp
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = (d * d) / (w * h);
	double t_1 = c0 / (2.0 * w);
	double tmp;
	if ((d * d) <= 5e-187) {
		tmp = 0.25 * ((M * (h * M)) * ((D / d) * (D / d)));
	} else if ((d * d) <= 2e+108) {
		tmp = t_1 * (2.0 * (((c0 / D) / D) * t_0));
	} else if ((d * d) <= 1e+221) {
		tmp = 0.25 * ((D * D) / ((d / (h * M)) * (d / M)));
	} else if ((d * d) <= 1e+233) {
		tmp = t_1 * (2.0 * (t_0 * (c0 / (D * D))));
	} else {
		tmp = 0.0;
	}
	return tmp;
}
def code(c0, w, h, D, d, M):
	t_0 = (d * d) / (w * h)
	t_1 = c0 / (2.0 * w)
	tmp = 0
	if (d * d) <= 5e-187:
		tmp = 0.25 * ((M * (h * M)) * ((D / d) * (D / d)))
	elif (d * d) <= 2e+108:
		tmp = t_1 * (2.0 * (((c0 / D) / D) * t_0))
	elif (d * d) <= 1e+221:
		tmp = 0.25 * ((D * D) / ((d / (h * M)) * (d / M)))
	elif (d * d) <= 1e+233:
		tmp = t_1 * (2.0 * (t_0 * (c0 / (D * D))))
	else:
		tmp = 0.0
	return tmp
function code(c0, w, h, D, d, M)
	t_0 = Float64(Float64(d * d) / Float64(w * h))
	t_1 = Float64(c0 / Float64(2.0 * w))
	tmp = 0.0
	if (Float64(d * d) <= 5e-187)
		tmp = Float64(0.25 * Float64(Float64(M * Float64(h * M)) * Float64(Float64(D / d) * Float64(D / d))));
	elseif (Float64(d * d) <= 2e+108)
		tmp = Float64(t_1 * Float64(2.0 * Float64(Float64(Float64(c0 / D) / D) * t_0)));
	elseif (Float64(d * d) <= 1e+221)
		tmp = Float64(0.25 * Float64(Float64(D * D) / Float64(Float64(d / Float64(h * M)) * Float64(d / M))));
	elseif (Float64(d * d) <= 1e+233)
		tmp = Float64(t_1 * Float64(2.0 * Float64(t_0 * Float64(c0 / Float64(D * D)))));
	else
		tmp = 0.0;
	end
	return tmp
end
function tmp_2 = code(c0, w, h, D, d, M)
	t_0 = (d * d) / (w * h);
	t_1 = c0 / (2.0 * w);
	tmp = 0.0;
	if ((d * d) <= 5e-187)
		tmp = 0.25 * ((M * (h * M)) * ((D / d) * (D / d)));
	elseif ((d * d) <= 2e+108)
		tmp = t_1 * (2.0 * (((c0 / D) / D) * t_0));
	elseif ((d * d) <= 1e+221)
		tmp = 0.25 * ((D * D) / ((d / (h * M)) * (d / M)));
	elseif ((d * d) <= 1e+233)
		tmp = t_1 * (2.0 * (t_0 * (c0 / (D * D))));
	else
		tmp = 0.0;
	end
	tmp_2 = tmp;
end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(N[(d * d), $MachinePrecision] / N[(w * h), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(d * d), $MachinePrecision], 5e-187], N[(0.25 * N[(N[(M * N[(h * M), $MachinePrecision]), $MachinePrecision] * N[(N[(D / d), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(d * d), $MachinePrecision], 2e+108], N[(t$95$1 * N[(2.0 * N[(N[(N[(c0 / D), $MachinePrecision] / D), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(d * d), $MachinePrecision], 1e+221], N[(0.25 * N[(N[(D * D), $MachinePrecision] / N[(N[(d / N[(h * M), $MachinePrecision]), $MachinePrecision] * N[(d / M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(d * d), $MachinePrecision], 1e+233], N[(t$95$1 * N[(2.0 * N[(t$95$0 * N[(c0 / N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;d \cdot d \leq 10^{+221}:\\
\;\;\;\;0.25 \cdot \frac{D \cdot D}{\frac{d}{h \cdot M} \cdot \frac{d}{M}}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if (*.f64 d d) < 4.9999999999999996e-187

    1. Initial program 9.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. Simplified9.3%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(0.5, \frac{D \cdot D}{c0} \cdot \frac{\left(h \cdot w\right) \cdot \left(M \cdot M\right)}{\color{blue}{d \cdot d}}, -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) \]
      8. mul-1-neg0.4%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(0.5, \frac{D \cdot D}{c0} \cdot \frac{\left(h \cdot w\right) \cdot \left(M \cdot M\right)}{d \cdot d}, \color{blue}{-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) \]
      9. distribute-rgt-in0.4%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{h \cdot \left(M \cdot M\right)}}} \]
    9. Taylor expanded in D around 0 23.3%

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

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

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

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

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

        \[\leadsto 0.25 \cdot \left(\frac{\color{blue}{D \cdot D}}{d \cdot d} \cdot \left(h \cdot \left(M \cdot M\right)\right)\right) \]
      6. *-commutative23.1%

        \[\leadsto 0.25 \cdot \color{blue}{\left(\left(h \cdot \left(M \cdot M\right)\right) \cdot \frac{D \cdot D}{d \cdot d}\right)} \]
      7. associate-*r*23.1%

        \[\leadsto 0.25 \cdot \left(\color{blue}{\left(\left(h \cdot M\right) \cdot M\right)} \cdot \frac{D \cdot D}{d \cdot d}\right) \]
      8. times-frac43.3%

        \[\leadsto 0.25 \cdot \left(\left(\left(h \cdot M\right) \cdot M\right) \cdot \color{blue}{\left(\frac{D}{d} \cdot \frac{D}{d}\right)}\right) \]
    11. Simplified43.3%

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

    if 4.9999999999999996e-187 < (*.f64 d d) < 2.0000000000000001e108

    1. Initial program 38.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. Simplified39.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{\mathsf{fma}\left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}, \frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}, -M \cdot M\right)}\right)} \]
    3. Taylor expanded in c0 around inf 48.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)} \]
    4. Step-by-step derivation
      1. associate-*r*44.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.0000000000000001e108 < (*.f64 d d) < 1e221

    1. Initial program 21.6%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(0.5, \frac{D \cdot D}{c0} \cdot \frac{\left(h \cdot w\right) \cdot \left(M \cdot M\right)}{\color{blue}{d \cdot d}}, -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) \]
      8. mul-1-neg3.5%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(0.5, \frac{D \cdot D}{c0} \cdot \frac{\left(h \cdot w\right) \cdot \left(M \cdot M\right)}{d \cdot d}, \color{blue}{-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) \]
      9. distribute-rgt-in0.1%

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

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

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

        \[\leadsto 0.25 \cdot \color{blue}{\frac{{D}^{2}}{\frac{{d}^{2}}{{M}^{2} \cdot h}}} \]
      2. unpow245.1%

        \[\leadsto 0.25 \cdot \frac{\color{blue}{D \cdot D}}{\frac{{d}^{2}}{{M}^{2} \cdot h}} \]
      3. unpow245.1%

        \[\leadsto 0.25 \cdot \frac{D \cdot D}{\frac{\color{blue}{d \cdot d}}{{M}^{2} \cdot h}} \]
      4. *-commutative45.1%

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

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

      \[\leadsto \color{blue}{0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{h \cdot \left(M \cdot M\right)}}} \]
    9. Taylor expanded in d around 0 45.1%

      \[\leadsto 0.25 \cdot \frac{D \cdot D}{\color{blue}{\frac{{d}^{2}}{{M}^{2} \cdot h}}} \]
    10. Step-by-step derivation
      1. unpow245.1%

        \[\leadsto 0.25 \cdot \frac{D \cdot D}{\frac{\color{blue}{d \cdot d}}{{M}^{2} \cdot h}} \]
      2. unpow245.1%

        \[\leadsto 0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{\color{blue}{\left(M \cdot M\right)} \cdot h}} \]
      3. *-commutative45.1%

        \[\leadsto 0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{\color{blue}{h \cdot \left(M \cdot M\right)}}} \]
      4. associate-*r*51.3%

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

        \[\leadsto 0.25 \cdot \frac{D \cdot D}{\color{blue}{\frac{d}{h \cdot M} \cdot \frac{d}{M}}} \]
    11. Simplified51.4%

      \[\leadsto 0.25 \cdot \frac{D \cdot D}{\color{blue}{\frac{d}{h \cdot M} \cdot \frac{d}{M}}} \]

    if 1e221 < (*.f64 d d) < 9.99999999999999974e232

    1. Initial program 71.8%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Simplified71.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{\mathsf{fma}\left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}, \frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}, -M \cdot M\right)}\right)} \]
    3. Taylor expanded in c0 around inf 72.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.99999999999999974e232 < (*.f64 d d)

    1. Initial program 20.3%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \cdot d \leq 5 \cdot 10^{-187}:\\ \;\;\;\;0.25 \cdot \left(\left(M \cdot \left(h \cdot M\right)\right) \cdot \left(\frac{D}{d} \cdot \frac{D}{d}\right)\right)\\ \mathbf{elif}\;d \cdot d \leq 2 \cdot 10^{+108}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{\frac{c0}{D}}{D} \cdot \frac{d \cdot d}{w \cdot h}\right)\right)\\ \mathbf{elif}\;d \cdot d \leq 10^{+221}:\\ \;\;\;\;0.25 \cdot \frac{D \cdot D}{\frac{d}{h \cdot M} \cdot \frac{d}{M}}\\ \mathbf{elif}\;d \cdot d \leq 10^{+233}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{d \cdot d}{w \cdot h} \cdot \frac{c0}{D \cdot D}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]

Alternative 4: 43.2% accurate, 4.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\left(\frac{d}{D} \cdot \frac{d}{D}\right) \cdot \frac{\frac{c0}{w}}{h}\right)\right)\\ \mathbf{if}\;M \cdot M \leq 2 \cdot 10^{-295}:\\ \;\;\;\;0\\ \mathbf{elif}\;M \cdot M \leq 2 \cdot 10^{-212}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;M \cdot M \leq 5 \cdot 10^{-186}:\\ \;\;\;\;0\\ \mathbf{elif}\;M \cdot M \leq 4 \cdot 10^{+294}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;0.25 \cdot \frac{D \cdot D}{\frac{d}{h \cdot M} \cdot \frac{d}{M}}\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (let* ((t_0
         (* (/ c0 (* 2.0 w)) (* 2.0 (* (* (/ d D) (/ d D)) (/ (/ c0 w) h))))))
   (if (<= (* M M) 2e-295)
     0.0
     (if (<= (* M M) 2e-212)
       t_0
       (if (<= (* M M) 5e-186)
         0.0
         (if (<= (* M M) 4e+294)
           t_0
           (* 0.25 (/ (* D D) (* (/ d (* h M)) (/ d M))))))))))
double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = (c0 / (2.0 * w)) * (2.0 * (((d / D) * (d / D)) * ((c0 / w) / h)));
	double tmp;
	if ((M * M) <= 2e-295) {
		tmp = 0.0;
	} else if ((M * M) <= 2e-212) {
		tmp = t_0;
	} else if ((M * M) <= 5e-186) {
		tmp = 0.0;
	} else if ((M * M) <= 4e+294) {
		tmp = t_0;
	} else {
		tmp = 0.25 * ((D * D) / ((d / (h * M)) * (d / M)));
	}
	return tmp;
}
real(8) function code(c0, w, h, d, d_1, m)
    real(8), intent (in) :: c0
    real(8), intent (in) :: w
    real(8), intent (in) :: h
    real(8), intent (in) :: d
    real(8), intent (in) :: d_1
    real(8), intent (in) :: m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (c0 / (2.0d0 * w)) * (2.0d0 * (((d_1 / d) * (d_1 / d)) * ((c0 / w) / h)))
    if ((m * m) <= 2d-295) then
        tmp = 0.0d0
    else if ((m * m) <= 2d-212) then
        tmp = t_0
    else if ((m * m) <= 5d-186) then
        tmp = 0.0d0
    else if ((m * m) <= 4d+294) then
        tmp = t_0
    else
        tmp = 0.25d0 * ((d * d) / ((d_1 / (h * m)) * (d_1 / m)))
    end if
    code = tmp
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = (c0 / (2.0 * w)) * (2.0 * (((d / D) * (d / D)) * ((c0 / w) / h)));
	double tmp;
	if ((M * M) <= 2e-295) {
		tmp = 0.0;
	} else if ((M * M) <= 2e-212) {
		tmp = t_0;
	} else if ((M * M) <= 5e-186) {
		tmp = 0.0;
	} else if ((M * M) <= 4e+294) {
		tmp = t_0;
	} else {
		tmp = 0.25 * ((D * D) / ((d / (h * M)) * (d / M)));
	}
	return tmp;
}
def code(c0, w, h, D, d, M):
	t_0 = (c0 / (2.0 * w)) * (2.0 * (((d / D) * (d / D)) * ((c0 / w) / h)))
	tmp = 0
	if (M * M) <= 2e-295:
		tmp = 0.0
	elif (M * M) <= 2e-212:
		tmp = t_0
	elif (M * M) <= 5e-186:
		tmp = 0.0
	elif (M * M) <= 4e+294:
		tmp = t_0
	else:
		tmp = 0.25 * ((D * D) / ((d / (h * M)) * (d / M)))
	return tmp
function code(c0, w, h, D, d, M)
	t_0 = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(2.0 * Float64(Float64(Float64(d / D) * Float64(d / D)) * Float64(Float64(c0 / w) / h))))
	tmp = 0.0
	if (Float64(M * M) <= 2e-295)
		tmp = 0.0;
	elseif (Float64(M * M) <= 2e-212)
		tmp = t_0;
	elseif (Float64(M * M) <= 5e-186)
		tmp = 0.0;
	elseif (Float64(M * M) <= 4e+294)
		tmp = t_0;
	else
		tmp = Float64(0.25 * Float64(Float64(D * D) / Float64(Float64(d / Float64(h * M)) * Float64(d / M))));
	end
	return tmp
end
function tmp_2 = code(c0, w, h, D, d, M)
	t_0 = (c0 / (2.0 * w)) * (2.0 * (((d / D) * (d / D)) * ((c0 / w) / h)));
	tmp = 0.0;
	if ((M * M) <= 2e-295)
		tmp = 0.0;
	elseif ((M * M) <= 2e-212)
		tmp = t_0;
	elseif ((M * M) <= 5e-186)
		tmp = 0.0;
	elseif ((M * M) <= 4e+294)
		tmp = t_0;
	else
		tmp = 0.25 * ((D * D) / ((d / (h * M)) * (d / M)));
	end
	tmp_2 = tmp;
end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(2.0 * N[(N[(N[(d / D), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision] * N[(N[(c0 / w), $MachinePrecision] / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(M * M), $MachinePrecision], 2e-295], 0.0, If[LessEqual[N[(M * M), $MachinePrecision], 2e-212], t$95$0, If[LessEqual[N[(M * M), $MachinePrecision], 5e-186], 0.0, If[LessEqual[N[(M * M), $MachinePrecision], 4e+294], t$95$0, N[(0.25 * N[(N[(D * D), $MachinePrecision] / N[(N[(d / N[(h * M), $MachinePrecision]), $MachinePrecision] * N[(d / M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;M \cdot M \leq 2 \cdot 10^{-212}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;M \cdot M \leq 5 \cdot 10^{-186}:\\
\;\;\;\;0\\

\mathbf{elif}\;M \cdot M \leq 4 \cdot 10^{+294}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;0.25 \cdot \frac{D \cdot D}{\frac{d}{h \cdot M} \cdot \frac{d}{M}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 M M) < 2.00000000000000012e-295 or 1.99999999999999991e-212 < (*.f64 M M) < 5e-186

    1. Initial program 23.9%

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

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

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

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

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

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

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

    if 2.00000000000000012e-295 < (*.f64 M M) < 1.99999999999999991e-212 or 5e-186 < (*.f64 M M) < 4.00000000000000027e294

    1. Initial program 34.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. Simplified34.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.00000000000000027e294 < (*.f64 M M)

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(0.5, \frac{D \cdot D}{c0} \cdot \frac{\left(h \cdot w\right) \cdot \left(M \cdot M\right)}{\color{blue}{d \cdot d}}, -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) \]
      8. mul-1-neg1.9%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{h \cdot \left(M \cdot M\right)}}} \]
    9. Taylor expanded in d around 0 10.3%

      \[\leadsto 0.25 \cdot \frac{D \cdot D}{\color{blue}{\frac{{d}^{2}}{{M}^{2} \cdot h}}} \]
    10. Step-by-step derivation
      1. unpow210.3%

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

        \[\leadsto 0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{\color{blue}{\left(M \cdot M\right)} \cdot h}} \]
      3. *-commutative10.3%

        \[\leadsto 0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{\color{blue}{h \cdot \left(M \cdot M\right)}}} \]
      4. associate-*r*25.7%

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

        \[\leadsto 0.25 \cdot \frac{D \cdot D}{\color{blue}{\frac{d}{h \cdot M} \cdot \frac{d}{M}}} \]
    11. Simplified46.4%

      \[\leadsto 0.25 \cdot \frac{D \cdot D}{\color{blue}{\frac{d}{h \cdot M} \cdot \frac{d}{M}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification49.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \cdot M \leq 2 \cdot 10^{-295}:\\ \;\;\;\;0\\ \mathbf{elif}\;M \cdot M \leq 2 \cdot 10^{-212}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\left(\frac{d}{D} \cdot \frac{d}{D}\right) \cdot \frac{\frac{c0}{w}}{h}\right)\right)\\ \mathbf{elif}\;M \cdot M \leq 5 \cdot 10^{-186}:\\ \;\;\;\;0\\ \mathbf{elif}\;M \cdot M \leq 4 \cdot 10^{+294}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\left(\frac{d}{D} \cdot \frac{d}{D}\right) \cdot \frac{\frac{c0}{w}}{h}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.25 \cdot \frac{D \cdot D}{\frac{d}{h \cdot M} \cdot \frac{d}{M}}\\ \end{array} \]

Alternative 5: 44.7% accurate, 5.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;w \leq -4.3 \cdot 10^{-60}:\\ \;\;\;\;0.25 \cdot \left(\left(M \cdot \left(h \cdot M\right)\right) \cdot \left(\frac{D}{d} \cdot \frac{D}{d}\right)\right)\\ \mathbf{elif}\;w \leq 1.3 \cdot 10^{-305} \lor \neg \left(w \leq 1.25 \cdot 10^{-251}\right):\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{\frac{c0}{w} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right)}{h}\right)\\ \mathbf{else}:\\ \;\;\;\;0.25 \cdot \frac{D \cdot D}{\frac{d}{h \cdot M} \cdot \frac{d}{M}}\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (if (<= w -4.3e-60)
   (* 0.25 (* (* M (* h M)) (* (/ D d) (/ D d))))
   (if (or (<= w 1.3e-305) (not (<= w 1.25e-251)))
     (* (/ c0 (* 2.0 w)) (* 2.0 (/ (* (/ c0 w) (* (/ d D) (/ d D))) h)))
     (* 0.25 (/ (* D D) (* (/ d (* h M)) (/ d M)))))))
double code(double c0, double w, double h, double D, double d, double M) {
	double tmp;
	if (w <= -4.3e-60) {
		tmp = 0.25 * ((M * (h * M)) * ((D / d) * (D / d)));
	} else if ((w <= 1.3e-305) || !(w <= 1.25e-251)) {
		tmp = (c0 / (2.0 * w)) * (2.0 * (((c0 / w) * ((d / D) * (d / D))) / h));
	} else {
		tmp = 0.25 * ((D * D) / ((d / (h * M)) * (d / M)));
	}
	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 <= (-4.3d-60)) then
        tmp = 0.25d0 * ((m * (h * m)) * ((d / d_1) * (d / d_1)))
    else if ((w <= 1.3d-305) .or. (.not. (w <= 1.25d-251))) then
        tmp = (c0 / (2.0d0 * w)) * (2.0d0 * (((c0 / w) * ((d_1 / d) * (d_1 / d))) / h))
    else
        tmp = 0.25d0 * ((d * d) / ((d_1 / (h * m)) * (d_1 / m)))
    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 <= -4.3e-60) {
		tmp = 0.25 * ((M * (h * M)) * ((D / d) * (D / d)));
	} else if ((w <= 1.3e-305) || !(w <= 1.25e-251)) {
		tmp = (c0 / (2.0 * w)) * (2.0 * (((c0 / w) * ((d / D) * (d / D))) / h));
	} else {
		tmp = 0.25 * ((D * D) / ((d / (h * M)) * (d / M)));
	}
	return tmp;
}
def code(c0, w, h, D, d, M):
	tmp = 0
	if w <= -4.3e-60:
		tmp = 0.25 * ((M * (h * M)) * ((D / d) * (D / d)))
	elif (w <= 1.3e-305) or not (w <= 1.25e-251):
		tmp = (c0 / (2.0 * w)) * (2.0 * (((c0 / w) * ((d / D) * (d / D))) / h))
	else:
		tmp = 0.25 * ((D * D) / ((d / (h * M)) * (d / M)))
	return tmp
function code(c0, w, h, D, d, M)
	tmp = 0.0
	if (w <= -4.3e-60)
		tmp = Float64(0.25 * Float64(Float64(M * Float64(h * M)) * Float64(Float64(D / d) * Float64(D / d))));
	elseif ((w <= 1.3e-305) || !(w <= 1.25e-251))
		tmp = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(2.0 * Float64(Float64(Float64(c0 / w) * Float64(Float64(d / D) * Float64(d / D))) / h)));
	else
		tmp = Float64(0.25 * Float64(Float64(D * D) / Float64(Float64(d / Float64(h * M)) * Float64(d / M))));
	end
	return tmp
end
function tmp_2 = code(c0, w, h, D, d, M)
	tmp = 0.0;
	if (w <= -4.3e-60)
		tmp = 0.25 * ((M * (h * M)) * ((D / d) * (D / d)));
	elseif ((w <= 1.3e-305) || ~((w <= 1.25e-251)))
		tmp = (c0 / (2.0 * w)) * (2.0 * (((c0 / w) * ((d / D) * (d / D))) / h));
	else
		tmp = 0.25 * ((D * D) / ((d / (h * M)) * (d / M)));
	end
	tmp_2 = tmp;
end
code[c0_, w_, h_, D_, d_, M_] := If[LessEqual[w, -4.3e-60], N[(0.25 * N[(N[(M * N[(h * M), $MachinePrecision]), $MachinePrecision] * N[(N[(D / d), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[w, 1.3e-305], N[Not[LessEqual[w, 1.25e-251]], $MachinePrecision]], N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(2.0 * N[(N[(N[(c0 / w), $MachinePrecision] * N[(N[(d / D), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.25 * N[(N[(D * D), $MachinePrecision] / N[(N[(d / N[(h * M), $MachinePrecision]), $MachinePrecision] * N[(d / M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;w \leq -4.3 \cdot 10^{-60}:\\
\;\;\;\;0.25 \cdot \left(\left(M \cdot \left(h \cdot M\right)\right) \cdot \left(\frac{D}{d} \cdot \frac{D}{d}\right)\right)\\

\mathbf{elif}\;w \leq 1.3 \cdot 10^{-305} \lor \neg \left(w \leq 1.25 \cdot 10^{-251}\right):\\
\;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{\frac{c0}{w} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right)}{h}\right)\\

\mathbf{else}:\\
\;\;\;\;0.25 \cdot \frac{D \cdot D}{\frac{d}{h \cdot M} \cdot \frac{d}{M}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if w < -4.3000000000000001e-60

    1. Initial program 21.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. Simplified20.9%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(0.5, \frac{D \cdot D}{c0} \cdot \frac{\left(h \cdot w\right) \cdot \left(M \cdot M\right)}{d \cdot d}, \color{blue}{-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) \]
      9. distribute-rgt-in5.4%

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

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

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

        \[\leadsto 0.25 \cdot \color{blue}{\frac{{D}^{2}}{\frac{{d}^{2}}{{M}^{2} \cdot h}}} \]
      2. unpow235.9%

        \[\leadsto 0.25 \cdot \frac{\color{blue}{D \cdot D}}{\frac{{d}^{2}}{{M}^{2} \cdot h}} \]
      3. unpow235.9%

        \[\leadsto 0.25 \cdot \frac{D \cdot D}{\frac{\color{blue}{d \cdot d}}{{M}^{2} \cdot h}} \]
      4. *-commutative35.9%

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

        \[\leadsto 0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{h \cdot \color{blue}{\left(M \cdot M\right)}}} \]
    8. Simplified35.9%

      \[\leadsto \color{blue}{0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{h \cdot \left(M \cdot M\right)}}} \]
    9. Taylor expanded in D around 0 36.0%

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

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

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

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

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

        \[\leadsto 0.25 \cdot \left(\frac{\color{blue}{D \cdot D}}{d \cdot d} \cdot \left(h \cdot \left(M \cdot M\right)\right)\right) \]
      6. *-commutative35.8%

        \[\leadsto 0.25 \cdot \color{blue}{\left(\left(h \cdot \left(M \cdot M\right)\right) \cdot \frac{D \cdot D}{d \cdot d}\right)} \]
      7. associate-*r*37.7%

        \[\leadsto 0.25 \cdot \left(\color{blue}{\left(\left(h \cdot M\right) \cdot M\right)} \cdot \frac{D \cdot D}{d \cdot d}\right) \]
      8. times-frac41.7%

        \[\leadsto 0.25 \cdot \left(\left(\left(h \cdot M\right) \cdot M\right) \cdot \color{blue}{\left(\frac{D}{d} \cdot \frac{D}{d}\right)}\right) \]
    11. Simplified41.7%

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

    if -4.3000000000000001e-60 < w < 1.3000000000000001e-305 or 1.2500000000000001e-251 < w

    1. Initial program 26.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. Simplified26.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.3000000000000001e-305 < w < 1.2500000000000001e-251

    1. Initial program 10.5%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Simplified10.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{\mathsf{fma}\left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}, \frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}, -M \cdot M\right)}\right)} \]
    3. Taylor expanded in c0 around -inf 0.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) + 0.5 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(h \cdot w\right)\right)}{c0 \cdot {d}^{2}}\right)} \]
    4. Step-by-step derivation
      1. +-commutative0.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.25 \cdot \frac{D \cdot D}{\frac{\color{blue}{d \cdot d}}{{M}^{2} \cdot h}} \]
      4. *-commutative58.5%

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

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

      \[\leadsto \color{blue}{0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{h \cdot \left(M \cdot M\right)}}} \]
    9. Taylor expanded in d around 0 58.5%

      \[\leadsto 0.25 \cdot \frac{D \cdot D}{\color{blue}{\frac{{d}^{2}}{{M}^{2} \cdot h}}} \]
    10. Step-by-step derivation
      1. unpow258.5%

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

        \[\leadsto 0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{\color{blue}{\left(M \cdot M\right)} \cdot h}} \]
      3. *-commutative58.5%

        \[\leadsto 0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{\color{blue}{h \cdot \left(M \cdot M\right)}}} \]
      4. associate-*r*63.8%

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

        \[\leadsto 0.25 \cdot \frac{D \cdot D}{\color{blue}{\frac{d}{h \cdot M} \cdot \frac{d}{M}}} \]
    11. Simplified74.2%

      \[\leadsto 0.25 \cdot \frac{D \cdot D}{\color{blue}{\frac{d}{h \cdot M} \cdot \frac{d}{M}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification50.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;w \leq -4.3 \cdot 10^{-60}:\\ \;\;\;\;0.25 \cdot \left(\left(M \cdot \left(h \cdot M\right)\right) \cdot \left(\frac{D}{d} \cdot \frac{D}{d}\right)\right)\\ \mathbf{elif}\;w \leq 1.3 \cdot 10^{-305} \lor \neg \left(w \leq 1.25 \cdot 10^{-251}\right):\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{\frac{c0}{w} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right)}{h}\right)\\ \mathbf{else}:\\ \;\;\;\;0.25 \cdot \frac{D \cdot D}{\frac{d}{h \cdot M} \cdot \frac{d}{M}}\\ \end{array} \]

Alternative 6: 36.3% accurate, 7.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;M \leq 5.5 \cdot 10^{-93}:\\
\;\;\;\;0\\

\mathbf{elif}\;M \leq 3 \cdot 10^{-12}:\\
\;\;\;\;\frac{c0 \cdot c0}{\frac{\left(D \cdot D\right) \cdot \left(h \cdot \left(w \cdot w\right)\right)}{d \cdot d}}\\

\mathbf{elif}\;M \leq 2.25 \cdot 10^{+157}:\\
\;\;\;\;0.25 \cdot \left(\left(M \cdot \left(h \cdot M\right)\right) \cdot \left(\frac{D}{d} \cdot \frac{D}{d}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;0.25 \cdot \frac{D \cdot D}{\frac{d}{h \cdot M} \cdot \frac{d}{M}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if M < 5.49999999999999968e-93

    1. Initial program 25.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. Simplified25.5%

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

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

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

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

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

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

    if 5.49999999999999968e-93 < M < 3.0000000000000001e-12

    1. Initial program 44.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.0000000000000001e-12 < M < 2.24999999999999992e157

    1. Initial program 21.5%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Simplified21.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{\mathsf{fma}\left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}, \frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}, -M \cdot M\right)}\right)} \]
    3. Taylor expanded in c0 around -inf 0.5%

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(0.5, \frac{D \cdot D}{c0} \cdot \frac{\left(h \cdot w\right) \cdot \left(M \cdot M\right)}{\color{blue}{d \cdot d}}, -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) \]
      8. mul-1-neg3.6%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(0.5, \frac{D \cdot D}{c0} \cdot \frac{\left(h \cdot w\right) \cdot \left(M \cdot M\right)}{d \cdot d}, \color{blue}{-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) \]
      9. distribute-rgt-in0.1%

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

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

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

        \[\leadsto 0.25 \cdot \color{blue}{\frac{{D}^{2}}{\frac{{d}^{2}}{{M}^{2} \cdot h}}} \]
      2. unpow220.0%

        \[\leadsto 0.25 \cdot \frac{\color{blue}{D \cdot D}}{\frac{{d}^{2}}{{M}^{2} \cdot h}} \]
      3. unpow220.0%

        \[\leadsto 0.25 \cdot \frac{D \cdot D}{\frac{\color{blue}{d \cdot d}}{{M}^{2} \cdot h}} \]
      4. *-commutative20.0%

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

        \[\leadsto 0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{h \cdot \color{blue}{\left(M \cdot M\right)}}} \]
    8. Simplified20.0%

      \[\leadsto \color{blue}{0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{h \cdot \left(M \cdot M\right)}}} \]
    9. Taylor expanded in D around 0 23.0%

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

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

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

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

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

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

        \[\leadsto 0.25 \cdot \color{blue}{\left(\left(h \cdot \left(M \cdot M\right)\right) \cdot \frac{D \cdot D}{d \cdot d}\right)} \]
      7. associate-*r*20.2%

        \[\leadsto 0.25 \cdot \left(\color{blue}{\left(\left(h \cdot M\right) \cdot M\right)} \cdot \frac{D \cdot D}{d \cdot d}\right) \]
      8. times-frac33.9%

        \[\leadsto 0.25 \cdot \left(\left(\left(h \cdot M\right) \cdot M\right) \cdot \color{blue}{\left(\frac{D}{d} \cdot \frac{D}{d}\right)}\right) \]
    11. Simplified33.9%

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

    if 2.24999999999999992e157 < M

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(0.5, \frac{D \cdot D}{c0} \cdot \frac{\left(h \cdot w\right) \cdot \left(M \cdot M\right)}{d \cdot d}, \color{blue}{-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) \]
      9. distribute-rgt-in0.0%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{h \cdot \left(M \cdot M\right)}}} \]
    9. Taylor expanded in d around 0 8.3%

      \[\leadsto 0.25 \cdot \frac{D \cdot D}{\color{blue}{\frac{{d}^{2}}{{M}^{2} \cdot h}}} \]
    10. Step-by-step derivation
      1. unpow28.3%

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

        \[\leadsto 0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{\color{blue}{\left(M \cdot M\right)} \cdot h}} \]
      3. *-commutative8.3%

        \[\leadsto 0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{\color{blue}{h \cdot \left(M \cdot M\right)}}} \]
      4. associate-*r*21.1%

        \[\leadsto 0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{\color{blue}{\left(h \cdot M\right) \cdot M}}} \]
      5. times-frac32.6%

        \[\leadsto 0.25 \cdot \frac{D \cdot D}{\color{blue}{\frac{d}{h \cdot M} \cdot \frac{d}{M}}} \]
    11. Simplified32.6%

      \[\leadsto 0.25 \cdot \frac{D \cdot D}{\color{blue}{\frac{d}{h \cdot M} \cdot \frac{d}{M}}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification38.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 5.5 \cdot 10^{-93}:\\ \;\;\;\;0\\ \mathbf{elif}\;M \leq 3 \cdot 10^{-12}:\\ \;\;\;\;\frac{c0 \cdot c0}{\frac{\left(D \cdot D\right) \cdot \left(h \cdot \left(w \cdot w\right)\right)}{d \cdot d}}\\ \mathbf{elif}\;M \leq 2.25 \cdot 10^{+157}:\\ \;\;\;\;0.25 \cdot \left(\left(M \cdot \left(h \cdot M\right)\right) \cdot \left(\frac{D}{d} \cdot \frac{D}{d}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.25 \cdot \frac{D \cdot D}{\frac{d}{h \cdot M} \cdot \frac{d}{M}}\\ \end{array} \]

Alternative 7: 36.4% accurate, 7.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;M \leq 1.32 \cdot 10^{-92}:\\
\;\;\;\;0\\

\mathbf{elif}\;M \leq 3 \cdot 10^{-12}:\\
\;\;\;\;\frac{c0 \cdot c0}{\frac{\left(D \cdot \left(h \cdot D\right)\right) \cdot \left(w \cdot w\right)}{d \cdot d}}\\

\mathbf{elif}\;M \leq 7.5 \cdot 10^{+156}:\\
\;\;\;\;0.25 \cdot \left(\left(M \cdot \left(h \cdot M\right)\right) \cdot \left(\frac{D}{d} \cdot \frac{D}{d}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;0.25 \cdot \frac{D \cdot D}{\frac{d}{h \cdot M} \cdot \frac{d}{M}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if M < 1.3200000000000001e-92

    1. Initial program 25.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. Simplified25.5%

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

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

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

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

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

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

    if 1.3200000000000001e-92 < M < 3.0000000000000001e-12

    1. Initial program 44.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.0000000000000001e-12 < M < 7.50000000000000026e156

    1. Initial program 21.5%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Simplified21.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{\mathsf{fma}\left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}, \frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}, -M \cdot M\right)}\right)} \]
    3. Taylor expanded in c0 around -inf 0.5%

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(0.5, \frac{D \cdot D}{c0} \cdot \frac{\left(h \cdot w\right) \cdot \left(M \cdot M\right)}{\color{blue}{d \cdot d}}, -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) \]
      8. mul-1-neg3.6%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(0.5, \frac{D \cdot D}{c0} \cdot \frac{\left(h \cdot w\right) \cdot \left(M \cdot M\right)}{d \cdot d}, \color{blue}{-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) \]
      9. distribute-rgt-in0.1%

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

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

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

        \[\leadsto 0.25 \cdot \color{blue}{\frac{{D}^{2}}{\frac{{d}^{2}}{{M}^{2} \cdot h}}} \]
      2. unpow220.0%

        \[\leadsto 0.25 \cdot \frac{\color{blue}{D \cdot D}}{\frac{{d}^{2}}{{M}^{2} \cdot h}} \]
      3. unpow220.0%

        \[\leadsto 0.25 \cdot \frac{D \cdot D}{\frac{\color{blue}{d \cdot d}}{{M}^{2} \cdot h}} \]
      4. *-commutative20.0%

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

        \[\leadsto 0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{h \cdot \color{blue}{\left(M \cdot M\right)}}} \]
    8. Simplified20.0%

      \[\leadsto \color{blue}{0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{h \cdot \left(M \cdot M\right)}}} \]
    9. Taylor expanded in D around 0 23.0%

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

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

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

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

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

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

        \[\leadsto 0.25 \cdot \color{blue}{\left(\left(h \cdot \left(M \cdot M\right)\right) \cdot \frac{D \cdot D}{d \cdot d}\right)} \]
      7. associate-*r*20.2%

        \[\leadsto 0.25 \cdot \left(\color{blue}{\left(\left(h \cdot M\right) \cdot M\right)} \cdot \frac{D \cdot D}{d \cdot d}\right) \]
      8. times-frac33.9%

        \[\leadsto 0.25 \cdot \left(\left(\left(h \cdot M\right) \cdot M\right) \cdot \color{blue}{\left(\frac{D}{d} \cdot \frac{D}{d}\right)}\right) \]
    11. Simplified33.9%

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

    if 7.50000000000000026e156 < M

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(0.5, \frac{D \cdot D}{c0} \cdot \frac{\left(h \cdot w\right) \cdot \left(M \cdot M\right)}{d \cdot d}, \color{blue}{-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) \]
      9. distribute-rgt-in0.0%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{h \cdot \left(M \cdot M\right)}}} \]
    9. Taylor expanded in d around 0 8.3%

      \[\leadsto 0.25 \cdot \frac{D \cdot D}{\color{blue}{\frac{{d}^{2}}{{M}^{2} \cdot h}}} \]
    10. Step-by-step derivation
      1. unpow28.3%

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

        \[\leadsto 0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{\color{blue}{\left(M \cdot M\right)} \cdot h}} \]
      3. *-commutative8.3%

        \[\leadsto 0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{\color{blue}{h \cdot \left(M \cdot M\right)}}} \]
      4. associate-*r*21.1%

        \[\leadsto 0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{\color{blue}{\left(h \cdot M\right) \cdot M}}} \]
      5. times-frac32.6%

        \[\leadsto 0.25 \cdot \frac{D \cdot D}{\color{blue}{\frac{d}{h \cdot M} \cdot \frac{d}{M}}} \]
    11. Simplified32.6%

      \[\leadsto 0.25 \cdot \frac{D \cdot D}{\color{blue}{\frac{d}{h \cdot M} \cdot \frac{d}{M}}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification38.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 1.32 \cdot 10^{-92}:\\ \;\;\;\;0\\ \mathbf{elif}\;M \leq 3 \cdot 10^{-12}:\\ \;\;\;\;\frac{c0 \cdot c0}{\frac{\left(D \cdot \left(h \cdot D\right)\right) \cdot \left(w \cdot w\right)}{d \cdot d}}\\ \mathbf{elif}\;M \leq 7.5 \cdot 10^{+156}:\\ \;\;\;\;0.25 \cdot \left(\left(M \cdot \left(h \cdot M\right)\right) \cdot \left(\frac{D}{d} \cdot \frac{D}{d}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.25 \cdot \frac{D \cdot D}{\frac{d}{h \cdot M} \cdot \frac{d}{M}}\\ \end{array} \]

Alternative 8: 41.4% accurate, 8.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq 8.2 \cdot 10^{+105}:\\ \;\;\;\;0.25 \cdot \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \left(h \cdot \left(M \cdot M\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (if (<= d 8.2e+105) (* 0.25 (* (* (/ D d) (/ D d)) (* h (* M M)))) 0.0))
double code(double c0, double w, double h, double D, double d, double M) {
	double tmp;
	if (d <= 8.2e+105) {
		tmp = 0.25 * (((D / d) * (D / d)) * (h * (M * M)));
	} else {
		tmp = 0.0;
	}
	return tmp;
}
real(8) function code(c0, w, h, d, d_1, m)
    real(8), intent (in) :: c0
    real(8), intent (in) :: w
    real(8), intent (in) :: h
    real(8), intent (in) :: d
    real(8), intent (in) :: d_1
    real(8), intent (in) :: m
    real(8) :: tmp
    if (d_1 <= 8.2d+105) then
        tmp = 0.25d0 * (((d / d_1) * (d / d_1)) * (h * (m * m)))
    else
        tmp = 0.0d0
    end if
    code = tmp
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
	double tmp;
	if (d <= 8.2e+105) {
		tmp = 0.25 * (((D / d) * (D / d)) * (h * (M * M)));
	} else {
		tmp = 0.0;
	}
	return tmp;
}
def code(c0, w, h, D, d, M):
	tmp = 0
	if d <= 8.2e+105:
		tmp = 0.25 * (((D / d) * (D / d)) * (h * (M * M)))
	else:
		tmp = 0.0
	return tmp
function code(c0, w, h, D, d, M)
	tmp = 0.0
	if (d <= 8.2e+105)
		tmp = Float64(0.25 * Float64(Float64(Float64(D / d) * Float64(D / d)) * Float64(h * Float64(M * M))));
	else
		tmp = 0.0;
	end
	return tmp
end
function tmp_2 = code(c0, w, h, D, d, M)
	tmp = 0.0;
	if (d <= 8.2e+105)
		tmp = 0.25 * (((D / d) * (D / d)) * (h * (M * M)));
	else
		tmp = 0.0;
	end
	tmp_2 = tmp;
end
code[c0_, w_, h_, D_, d_, M_] := If[LessEqual[d, 8.2e+105], N[(0.25 * N[(N[(N[(D / d), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision] * N[(h * N[(M * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;d \leq 8.2 \cdot 10^{+105}:\\
\;\;\;\;0.25 \cdot \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \left(h \cdot \left(M \cdot M\right)\right)\right)\\

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


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

    1. Initial program 24.9%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Simplified25.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{\mathsf{fma}\left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}, \frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}, -M \cdot M\right)}\right)} \]
    3. Taylor expanded in c0 around -inf 1.5%

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(0.5, \frac{D \cdot D}{c0} \cdot \frac{\left(h \cdot w\right) \cdot \left(M \cdot M\right)}{\color{blue}{d \cdot d}}, -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) \]
      8. mul-1-neg2.4%

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

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

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

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

        \[\leadsto 0.25 \cdot \color{blue}{\frac{{D}^{2}}{\frac{{d}^{2}}{{M}^{2} \cdot h}}} \]
      2. unpow227.8%

        \[\leadsto 0.25 \cdot \frac{\color{blue}{D \cdot D}}{\frac{{d}^{2}}{{M}^{2} \cdot h}} \]
      3. unpow227.8%

        \[\leadsto 0.25 \cdot \frac{D \cdot D}{\frac{\color{blue}{d \cdot d}}{{M}^{2} \cdot h}} \]
      4. *-commutative27.8%

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

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

      \[\leadsto \color{blue}{0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{h \cdot \left(M \cdot M\right)}}} \]
    9. Taylor expanded in D around 0 28.3%

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

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

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

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

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

        \[\leadsto 0.25 \cdot \left(\frac{\color{blue}{D \cdot D}}{d \cdot d} \cdot \left(h \cdot \left(M \cdot M\right)\right)\right) \]
      6. *-commutative27.7%

        \[\leadsto 0.25 \cdot \color{blue}{\left(\left(h \cdot \left(M \cdot M\right)\right) \cdot \frac{D \cdot D}{d \cdot d}\right)} \]
      7. associate-*r*29.9%

        \[\leadsto 0.25 \cdot \left(\color{blue}{\left(\left(h \cdot M\right) \cdot M\right)} \cdot \frac{D \cdot D}{d \cdot d}\right) \]
      8. times-frac36.7%

        \[\leadsto 0.25 \cdot \left(\left(\left(h \cdot M\right) \cdot M\right) \cdot \color{blue}{\left(\frac{D}{d} \cdot \frac{D}{d}\right)}\right) \]
    11. Simplified36.7%

      \[\leadsto 0.25 \cdot \color{blue}{\left(\left(\left(h \cdot M\right) \cdot M\right) \cdot \left(\frac{D}{d} \cdot \frac{D}{d}\right)\right)} \]
    12. Taylor expanded in h around 0 34.0%

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

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

        \[\leadsto 0.25 \cdot \left(\left(h \cdot \color{blue}{\left(M \cdot M\right)}\right) \cdot \left(\frac{D}{d} \cdot \frac{D}{d}\right)\right) \]
    14. Simplified34.0%

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

    if 8.2000000000000005e105 < d

    1. Initial program 19.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. Simplified19.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{\mathsf{fma}\left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}, \frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}, -M \cdot M\right)}\right)} \]
    3. Taylor expanded in c0 around -inf 5.0%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(-1 \cdot \left(c0 \cdot \left(-1 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)} + \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)\right)\right)} \]
    4. Step-by-step derivation
      1. mul-1-neg5.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-rgt-in3.3%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq 8.2 \cdot 10^{+105}:\\ \;\;\;\;0.25 \cdot \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \left(h \cdot \left(M \cdot M\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]

Alternative 9: 44.5% accurate, 8.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;M \leq 6.4 \cdot 10^{+156}:\\
\;\;\;\;0.25 \cdot \left(\left(M \cdot \left(h \cdot M\right)\right) \cdot \left(\frac{D}{d} \cdot \frac{D}{d}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;0.25 \cdot \frac{D \cdot D}{\frac{d}{h \cdot M} \cdot \frac{d}{M}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if M < 6.40000000000000005e156

    1. Initial program 26.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. Simplified26.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{\mathsf{fma}\left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}, \frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}, -M \cdot M\right)}\right)} \]
    3. Taylor expanded in c0 around -inf 2.5%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(0.5, \frac{D \cdot D}{c0} \cdot \frac{\left(h \cdot w\right) \cdot \left(M \cdot M\right)}{d \cdot d}, \color{blue}{-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) \]
      9. distribute-rgt-in2.0%

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

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

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

        \[\leadsto 0.25 \cdot \color{blue}{\frac{{D}^{2}}{\frac{{d}^{2}}{{M}^{2} \cdot h}}} \]
      2. unpow230.0%

        \[\leadsto 0.25 \cdot \frac{\color{blue}{D \cdot D}}{\frac{{d}^{2}}{{M}^{2} \cdot h}} \]
      3. unpow230.0%

        \[\leadsto 0.25 \cdot \frac{D \cdot D}{\frac{\color{blue}{d \cdot d}}{{M}^{2} \cdot h}} \]
      4. *-commutative30.0%

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

        \[\leadsto 0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{h \cdot \color{blue}{\left(M \cdot M\right)}}} \]
    8. Simplified30.0%

      \[\leadsto \color{blue}{0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{h \cdot \left(M \cdot M\right)}}} \]
    9. Taylor expanded in D around 0 30.4%

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

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

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

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

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

        \[\leadsto 0.25 \cdot \left(\frac{\color{blue}{D \cdot D}}{d \cdot d} \cdot \left(h \cdot \left(M \cdot M\right)\right)\right) \]
      6. *-commutative29.9%

        \[\leadsto 0.25 \cdot \color{blue}{\left(\left(h \cdot \left(M \cdot M\right)\right) \cdot \frac{D \cdot D}{d \cdot d}\right)} \]
      7. associate-*r*31.3%

        \[\leadsto 0.25 \cdot \left(\color{blue}{\left(\left(h \cdot M\right) \cdot M\right)} \cdot \frac{D \cdot D}{d \cdot d}\right) \]
      8. times-frac38.7%

        \[\leadsto 0.25 \cdot \left(\left(\left(h \cdot M\right) \cdot M\right) \cdot \color{blue}{\left(\frac{D}{d} \cdot \frac{D}{d}\right)}\right) \]
    11. Simplified38.7%

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

    if 6.40000000000000005e156 < M

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(0.5, \frac{D \cdot D}{c0} \cdot \frac{\left(h \cdot w\right) \cdot \left(M \cdot M\right)}{d \cdot d}, \color{blue}{-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) \]
      9. distribute-rgt-in0.0%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{h \cdot \left(M \cdot M\right)}}} \]
    9. Taylor expanded in d around 0 8.3%

      \[\leadsto 0.25 \cdot \frac{D \cdot D}{\color{blue}{\frac{{d}^{2}}{{M}^{2} \cdot h}}} \]
    10. Step-by-step derivation
      1. unpow28.3%

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

        \[\leadsto 0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{\color{blue}{\left(M \cdot M\right)} \cdot h}} \]
      3. *-commutative8.3%

        \[\leadsto 0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{\color{blue}{h \cdot \left(M \cdot M\right)}}} \]
      4. associate-*r*21.1%

        \[\leadsto 0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{\color{blue}{\left(h \cdot M\right) \cdot M}}} \]
      5. times-frac32.6%

        \[\leadsto 0.25 \cdot \frac{D \cdot D}{\color{blue}{\frac{d}{h \cdot M} \cdot \frac{d}{M}}} \]
    11. Simplified32.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 6.4 \cdot 10^{+156}:\\ \;\;\;\;0.25 \cdot \left(\left(M \cdot \left(h \cdot M\right)\right) \cdot \left(\frac{D}{d} \cdot \frac{D}{d}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.25 \cdot \frac{D \cdot D}{\frac{d}{h \cdot M} \cdot \frac{d}{M}}\\ \end{array} \]

Alternative 10: 43.6% accurate, 10.1× speedup?

\[\begin{array}{l} \\ 0.25 \cdot \left(\left(M \cdot \left(h \cdot M\right)\right) \cdot \left(\frac{D}{d} \cdot \frac{D}{d}\right)\right) \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (* 0.25 (* (* M (* h M)) (* (/ D d) (/ D d)))))
double code(double c0, double w, double h, double D, double d, double M) {
	return 0.25 * ((M * (h * M)) * ((D / d) * (D / d)));
}
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.25d0 * ((m * (h * m)) * ((d / d_1) * (d / d_1)))
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
	return 0.25 * ((M * (h * M)) * ((D / d) * (D / d)));
}
def code(c0, w, h, D, d, M):
	return 0.25 * ((M * (h * M)) * ((D / d) * (D / d)))
function code(c0, w, h, D, d, M)
	return Float64(0.25 * Float64(Float64(M * Float64(h * M)) * Float64(Float64(D / d) * Float64(D / d))))
end
function tmp = code(c0, w, h, D, d, M)
	tmp = 0.25 * ((M * (h * M)) * ((D / d) * (D / d)));
end
code[c0_, w_, h_, D_, d_, M_] := N[(0.25 * N[(N[(M * N[(h * M), $MachinePrecision]), $MachinePrecision] * N[(N[(D / d), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
0.25 \cdot \left(\left(M \cdot \left(h \cdot M\right)\right) \cdot \left(\frac{D}{d} \cdot \frac{D}{d}\right)\right)
\end{array}
Derivation
  1. Initial program 23.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. Simplified24.0%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(0.5, \frac{D \cdot D}{c0} \cdot \frac{\left(h \cdot w\right) \cdot \left(M \cdot M\right)}{d \cdot d}, \color{blue}{-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) \]
    9. distribute-rgt-in1.8%

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

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

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

      \[\leadsto 0.25 \cdot \color{blue}{\frac{{D}^{2}}{\frac{{d}^{2}}{{M}^{2} \cdot h}}} \]
    2. unpow227.9%

      \[\leadsto 0.25 \cdot \frac{\color{blue}{D \cdot D}}{\frac{{d}^{2}}{{M}^{2} \cdot h}} \]
    3. unpow227.9%

      \[\leadsto 0.25 \cdot \frac{D \cdot D}{\frac{\color{blue}{d \cdot d}}{{M}^{2} \cdot h}} \]
    4. *-commutative27.9%

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

      \[\leadsto 0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{h \cdot \color{blue}{\left(M \cdot M\right)}}} \]
  8. Simplified27.9%

    \[\leadsto \color{blue}{0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{h \cdot \left(M \cdot M\right)}}} \]
  9. Taylor expanded in D around 0 28.3%

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

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

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

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

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

      \[\leadsto 0.25 \cdot \left(\frac{\color{blue}{D \cdot D}}{d \cdot d} \cdot \left(h \cdot \left(M \cdot M\right)\right)\right) \]
    6. *-commutative27.9%

      \[\leadsto 0.25 \cdot \color{blue}{\left(\left(h \cdot \left(M \cdot M\right)\right) \cdot \frac{D \cdot D}{d \cdot d}\right)} \]
    7. associate-*r*30.3%

      \[\leadsto 0.25 \cdot \left(\color{blue}{\left(\left(h \cdot M\right) \cdot M\right)} \cdot \frac{D \cdot D}{d \cdot d}\right) \]
    8. times-frac37.5%

      \[\leadsto 0.25 \cdot \left(\left(\left(h \cdot M\right) \cdot M\right) \cdot \color{blue}{\left(\frac{D}{d} \cdot \frac{D}{d}\right)}\right) \]
  11. Simplified37.5%

    \[\leadsto 0.25 \cdot \color{blue}{\left(\left(\left(h \cdot M\right) \cdot M\right) \cdot \left(\frac{D}{d} \cdot \frac{D}{d}\right)\right)} \]
  12. Final simplification37.5%

    \[\leadsto 0.25 \cdot \left(\left(M \cdot \left(h \cdot M\right)\right) \cdot \left(\frac{D}{d} \cdot \frac{D}{d}\right)\right) \]

Alternative 11: 33.4% 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.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. Simplified24.0%

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

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

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

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

    \[\leadsto 0 \]

Reproduce

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