Henrywood and Agarwal, Equation (13)

Percentage Accurate: 25.1% → 42.9%
Time: 30.9s
Alternatives: 6
Speedup: 21.6×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 6 alternatives:

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

Initial Program: 25.1% accurate, 1.0× speedup?

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

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

Alternative 1: 42.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := c0 \cdot \frac{0}{2 \cdot w}\\ \mathbf{if}\;M \cdot M \leq 10^{-320}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;M \cdot M \leq 6 \cdot 10^{-46}:\\ \;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(h \cdot \left(w \cdot D\right)\right)}, \left(c0 \cdot \frac{d}{\left(w \cdot h\right) \cdot D}\right) \cdot \frac{d}{D}\right)}{2 \cdot w}\\ \mathbf{elif}\;M \cdot M \leq 3.1 \cdot 10^{+113}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \frac{d}{D} \cdot \frac{d \cdot \frac{c0}{w}}{h \cdot D}\right)}{2 \cdot w}\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (let* ((t_0 (* c0 (/ 0.0 (* 2.0 w)))))
   (if (<= (* M M) 1e-320)
     t_0
     (if (<= (* M M) 6e-46)
       (*
        c0
        (/
         (fma
          c0
          (* d (/ d (* D (* h (* w D)))))
          (* (* c0 (/ d (* (* w h) D))) (/ d D)))
         (* 2.0 w)))
       (if (<= (* M M) 3.1e+113)
         t_0
         (*
          c0
          (/
           (fma
            c0
            (* d (/ d (* D (* w (* h D)))))
            (* (/ d D) (/ (* d (/ c0 w)) (* h D))))
           (* 2.0 w))))))))
double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = c0 * (0.0 / (2.0 * w));
	double tmp;
	if ((M * M) <= 1e-320) {
		tmp = t_0;
	} else if ((M * M) <= 6e-46) {
		tmp = c0 * (fma(c0, (d * (d / (D * (h * (w * D))))), ((c0 * (d / ((w * h) * D))) * (d / D))) / (2.0 * w));
	} else if ((M * M) <= 3.1e+113) {
		tmp = t_0;
	} else {
		tmp = c0 * (fma(c0, (d * (d / (D * (w * (h * D))))), ((d / D) * ((d * (c0 / w)) / (h * D)))) / (2.0 * w));
	}
	return tmp;
}
function code(c0, w, h, D, d, M)
	t_0 = Float64(c0 * Float64(0.0 / Float64(2.0 * w)))
	tmp = 0.0
	if (Float64(M * M) <= 1e-320)
		tmp = t_0;
	elseif (Float64(M * M) <= 6e-46)
		tmp = Float64(c0 * Float64(fma(c0, Float64(d * Float64(d / Float64(D * Float64(h * Float64(w * D))))), Float64(Float64(c0 * Float64(d / Float64(Float64(w * h) * D))) * Float64(d / D))) / Float64(2.0 * w)));
	elseif (Float64(M * M) <= 3.1e+113)
		tmp = t_0;
	else
		tmp = Float64(c0 * Float64(fma(c0, Float64(d * Float64(d / Float64(D * Float64(w * Float64(h * D))))), Float64(Float64(d / D) * Float64(Float64(d * Float64(c0 / w)) / Float64(h * D)))) / Float64(2.0 * w)));
	end
	return tmp
end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(c0 * N[(0.0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(M * M), $MachinePrecision], 1e-320], t$95$0, If[LessEqual[N[(M * M), $MachinePrecision], 6e-46], N[(c0 * N[(N[(c0 * N[(d * N[(d / N[(D * N[(h * N[(w * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(c0 * N[(d / N[(N[(w * h), $MachinePrecision] * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(M * M), $MachinePrecision], 3.1e+113], t$95$0, N[(c0 * N[(N[(c0 * N[(d * N[(d / N[(D * N[(w * N[(h * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(d / D), $MachinePrecision] * N[(N[(d * N[(c0 / w), $MachinePrecision]), $MachinePrecision] / N[(h * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := c0 \cdot \frac{0}{2 \cdot w}\\
\mathbf{if}\;M \cdot M \leq 10^{-320}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;M \cdot M \leq 6 \cdot 10^{-46}:\\
\;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(h \cdot \left(w \cdot D\right)\right)}, \left(c0 \cdot \frac{d}{\left(w \cdot h\right) \cdot D}\right) \cdot \frac{d}{D}\right)}{2 \cdot w}\\

\mathbf{elif}\;M \cdot M \leq 3.1 \cdot 10^{+113}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 M M) < 9.99989e-321 or 5.99999999999999975e-46 < (*.f64 M M) < 3.09999999999999991e113

    1. Initial program 19.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. Simplified23.7%

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

      \[\leadsto c0 \cdot \frac{\color{blue}{-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)}}{2 \cdot w} \]
    5. Step-by-step derivation
      1. distribute-lft-in10.7%

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

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

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

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

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

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

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

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

        \[\leadsto c0 \cdot \frac{-1 \cdot \color{blue}{0}}{2 \cdot w} \]
      10. metadata-eval54.7%

        \[\leadsto c0 \cdot \frac{\color{blue}{0}}{2 \cdot w} \]
    6. Simplified54.7%

      \[\leadsto c0 \cdot \frac{\color{blue}{0}}{2 \cdot w} \]

    if 9.99989e-321 < (*.f64 M M) < 5.99999999999999975e-46

    1. Initial program 39.4%

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

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

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

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

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \frac{\color{blue}{-c0 \cdot {d}^{2}}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)}{2 \cdot w} \]
      3. distribute-lft-neg-in9.6%

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

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

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \frac{\color{blue}{{d}^{2} \cdot \left(-c0\right)}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)}{2 \cdot w} \]
      2. add-sqr-sqrt4.7%

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

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

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

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \frac{{d}^{2} \cdot \color{blue}{\left(\sqrt{c0} \cdot \sqrt{c0}\right)}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)}{2 \cdot w} \]
      6. add-sqr-sqrt38.5%

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

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

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

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

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \color{blue}{\left(\frac{d}{D} \cdot \frac{d}{D}\right)} \cdot \frac{c0}{h \cdot w}\right)}{2 \cdot w} \]
      11. pow246.1%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \color{blue}{\left(c0 \cdot \frac{d}{D \cdot \left(h \cdot w\right)}\right)} \cdot \frac{d}{D}\right)}{2 \cdot w} \]
    11. Simplified58.1%

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

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

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, \color{blue}{\frac{d}{\frac{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}{d}}}, \left(c0 \cdot \frac{d}{D \cdot \left(h \cdot w\right)}\right) \cdot \frac{d}{D}\right)}{2 \cdot w} \]
    13. Applied egg-rr58.0%

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

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

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

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

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, \frac{d}{D \cdot \color{blue}{\left(\left(D \cdot w\right) \cdot h\right)}} \cdot d, \left(c0 \cdot \frac{d}{D \cdot \left(h \cdot w\right)}\right) \cdot \frac{d}{D}\right)}{2 \cdot w} \]
    15. Simplified59.6%

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

    if 3.09999999999999991e113 < (*.f64 M M)

    1. Initial program 11.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. Simplified43.7%

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

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

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

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \frac{\color{blue}{-c0 \cdot {d}^{2}}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)}{2 \cdot w} \]
      3. distribute-lft-neg-in1.3%

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

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

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \frac{\color{blue}{{d}^{2} \cdot \left(-c0\right)}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)}{2 \cdot w} \]
      2. add-sqr-sqrt0.0%

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

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

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

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

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

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

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

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

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \color{blue}{\left(\frac{d}{D} \cdot \frac{d}{D}\right)} \cdot \frac{c0}{h \cdot w}\right)}{2 \cdot w} \]
      11. pow248.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \cdot M \leq 10^{-320}:\\ \;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\ \mathbf{elif}\;M \cdot M \leq 6 \cdot 10^{-46}:\\ \;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(h \cdot \left(w \cdot D\right)\right)}, \left(c0 \cdot \frac{d}{\left(w \cdot h\right) \cdot D}\right) \cdot \frac{d}{D}\right)}{2 \cdot w}\\ \mathbf{elif}\;M \cdot M \leq 3.1 \cdot 10^{+113}:\\ \;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \frac{d}{D} \cdot \frac{d \cdot \frac{c0}{w}}{h \cdot D}\right)}{2 \cdot w}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 54.6% accurate, 0.5× speedup?

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

\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\


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

    1. Initial program 74.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. Add Preprocessing

    if +inf.0 < (*.f64 (/.f64 c0 (*.f64 #s(literal 2 binary64) 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. Simplified26.0%

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

      \[\leadsto c0 \cdot \frac{\color{blue}{-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)}}{2 \cdot w} \]
    5. Step-by-step derivation
      1. distribute-lft-in1.2%

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

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

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

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

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

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

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

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

        \[\leadsto c0 \cdot \frac{-1 \cdot \color{blue}{0}}{2 \cdot w} \]
      10. metadata-eval44.6%

        \[\leadsto c0 \cdot \frac{\color{blue}{0}}{2 \cdot w} \]
    6. Simplified44.6%

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

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

Alternative 3: 38.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;M \leq 2.3 \cdot 10^{-159} \lor \neg \left(M \leq 6 \cdot 10^{-23}\right) \land M \leq 6.5 \cdot 10^{+56}:\\ \;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \left(c0 \cdot \frac{d}{\left(w \cdot h\right) \cdot D}\right) \cdot \frac{d}{D}\right)}{2 \cdot w}\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (if (or (<= M 2.3e-159) (and (not (<= M 6e-23)) (<= M 6.5e+56)))
   (* c0 (/ 0.0 (* 2.0 w)))
   (*
    c0
    (/
     (fma
      c0
      (* d (/ d (* D (* w (* h D)))))
      (* (* c0 (/ d (* (* w h) D))) (/ d D)))
     (* 2.0 w)))))
double code(double c0, double w, double h, double D, double d, double M) {
	double tmp;
	if ((M <= 2.3e-159) || (!(M <= 6e-23) && (M <= 6.5e+56))) {
		tmp = c0 * (0.0 / (2.0 * w));
	} else {
		tmp = c0 * (fma(c0, (d * (d / (D * (w * (h * D))))), ((c0 * (d / ((w * h) * D))) * (d / D))) / (2.0 * w));
	}
	return tmp;
}
function code(c0, w, h, D, d, M)
	tmp = 0.0
	if ((M <= 2.3e-159) || (!(M <= 6e-23) && (M <= 6.5e+56)))
		tmp = Float64(c0 * Float64(0.0 / Float64(2.0 * w)));
	else
		tmp = Float64(c0 * Float64(fma(c0, Float64(d * Float64(d / Float64(D * Float64(w * Float64(h * D))))), Float64(Float64(c0 * Float64(d / Float64(Float64(w * h) * D))) * Float64(d / D))) / Float64(2.0 * w)));
	end
	return tmp
end
code[c0_, w_, h_, D_, d_, M_] := If[Or[LessEqual[M, 2.3e-159], And[N[Not[LessEqual[M, 6e-23]], $MachinePrecision], LessEqual[M, 6.5e+56]]], N[(c0 * N[(0.0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(N[(c0 * N[(d * N[(d / N[(D * N[(w * N[(h * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(c0 * N[(d / N[(N[(w * h), $MachinePrecision] * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;M \leq 2.3 \cdot 10^{-159} \lor \neg \left(M \leq 6 \cdot 10^{-23}\right) \land M \leq 6.5 \cdot 10^{+56}:\\
\;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if M < 2.29999999999999978e-159 or 6.00000000000000006e-23 < M < 6.5000000000000001e56

    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. Simplified32.5%

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

      \[\leadsto c0 \cdot \frac{\color{blue}{-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)}}{2 \cdot w} \]
    5. Step-by-step derivation
      1. distribute-lft-in7.3%

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

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

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

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

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

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

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

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

        \[\leadsto c0 \cdot \frac{-1 \cdot \color{blue}{0}}{2 \cdot w} \]
      10. metadata-eval41.7%

        \[\leadsto c0 \cdot \frac{\color{blue}{0}}{2 \cdot w} \]
    6. Simplified41.7%

      \[\leadsto c0 \cdot \frac{\color{blue}{0}}{2 \cdot w} \]

    if 2.29999999999999978e-159 < M < 6.00000000000000006e-23 or 6.5000000000000001e56 < M

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

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

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

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

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \frac{\color{blue}{-c0 \cdot {d}^{2}}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)}{2 \cdot w} \]
      3. distribute-lft-neg-in6.1%

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

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

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \frac{\color{blue}{{d}^{2} \cdot \left(-c0\right)}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)}{2 \cdot w} \]
      2. add-sqr-sqrt2.3%

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

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

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

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

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

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

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

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

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \color{blue}{\left(\frac{d}{D} \cdot \frac{d}{D}\right)} \cdot \frac{c0}{h \cdot w}\right)}{2 \cdot w} \]
      11. pow248.4%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \color{blue}{\left(c0 \cdot \frac{d}{D \cdot \left(h \cdot w\right)}\right)} \cdot \frac{d}{D}\right)}{2 \cdot w} \]
    11. Simplified55.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 2.3 \cdot 10^{-159} \lor \neg \left(M \leq 6 \cdot 10^{-23}\right) \land M \leq 6.5 \cdot 10^{+56}:\\ \;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \left(c0 \cdot \frac{d}{\left(w \cdot h\right) \cdot D}\right) \cdot \frac{d}{D}\right)}{2 \cdot w}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 38.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := c0 \cdot \frac{0}{2 \cdot w}\\ t_1 := w \cdot \left(h \cdot D\right)\\ t_2 := d \cdot \frac{d}{D \cdot t\_1}\\ \mathbf{if}\;M \leq 3.5 \cdot 10^{-159}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;M \leq 7.6 \cdot 10^{-23}:\\ \;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, t\_2, \left(c0 \cdot \frac{d}{\left(w \cdot h\right) \cdot D}\right) \cdot \frac{d}{D}\right)}{2 \cdot w}\\ \mathbf{elif}\;M \leq 5.5 \cdot 10^{+56}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, t\_2, \frac{d}{D} \cdot \frac{c0 \cdot d}{t\_1}\right)}{2 \cdot w}\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (let* ((t_0 (* c0 (/ 0.0 (* 2.0 w))))
        (t_1 (* w (* h D)))
        (t_2 (* d (/ d (* D t_1)))))
   (if (<= M 3.5e-159)
     t_0
     (if (<= M 7.6e-23)
       (* c0 (/ (fma c0 t_2 (* (* c0 (/ d (* (* w h) D))) (/ d D))) (* 2.0 w)))
       (if (<= M 5.5e+56)
         t_0
         (* c0 (/ (fma c0 t_2 (* (/ d D) (/ (* c0 d) t_1))) (* 2.0 w))))))))
double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = c0 * (0.0 / (2.0 * w));
	double t_1 = w * (h * D);
	double t_2 = d * (d / (D * t_1));
	double tmp;
	if (M <= 3.5e-159) {
		tmp = t_0;
	} else if (M <= 7.6e-23) {
		tmp = c0 * (fma(c0, t_2, ((c0 * (d / ((w * h) * D))) * (d / D))) / (2.0 * w));
	} else if (M <= 5.5e+56) {
		tmp = t_0;
	} else {
		tmp = c0 * (fma(c0, t_2, ((d / D) * ((c0 * d) / t_1))) / (2.0 * w));
	}
	return tmp;
}
function code(c0, w, h, D, d, M)
	t_0 = Float64(c0 * Float64(0.0 / Float64(2.0 * w)))
	t_1 = Float64(w * Float64(h * D))
	t_2 = Float64(d * Float64(d / Float64(D * t_1)))
	tmp = 0.0
	if (M <= 3.5e-159)
		tmp = t_0;
	elseif (M <= 7.6e-23)
		tmp = Float64(c0 * Float64(fma(c0, t_2, Float64(Float64(c0 * Float64(d / Float64(Float64(w * h) * D))) * Float64(d / D))) / Float64(2.0 * w)));
	elseif (M <= 5.5e+56)
		tmp = t_0;
	else
		tmp = Float64(c0 * Float64(fma(c0, t_2, Float64(Float64(d / D) * Float64(Float64(c0 * d) / t_1))) / Float64(2.0 * w)));
	end
	return tmp
end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(c0 * N[(0.0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(w * N[(h * D), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(d * N[(d / N[(D * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[M, 3.5e-159], t$95$0, If[LessEqual[M, 7.6e-23], N[(c0 * N[(N[(c0 * t$95$2 + N[(N[(c0 * N[(d / N[(N[(w * h), $MachinePrecision] * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[M, 5.5e+56], t$95$0, N[(c0 * N[(N[(c0 * t$95$2 + N[(N[(d / D), $MachinePrecision] * N[(N[(c0 * d), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := c0 \cdot \frac{0}{2 \cdot w}\\
t_1 := w \cdot \left(h \cdot D\right)\\
t_2 := d \cdot \frac{d}{D \cdot t\_1}\\
\mathbf{if}\;M \leq 3.5 \cdot 10^{-159}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;M \leq 7.6 \cdot 10^{-23}:\\
\;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, t\_2, \left(c0 \cdot \frac{d}{\left(w \cdot h\right) \cdot D}\right) \cdot \frac{d}{D}\right)}{2 \cdot w}\\

\mathbf{elif}\;M \leq 5.5 \cdot 10^{+56}:\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, t\_2, \frac{d}{D} \cdot \frac{c0 \cdot d}{t\_1}\right)}{2 \cdot w}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if M < 3.50000000000000002e-159 or 7.60000000000000023e-23 < M < 5.5000000000000002e56

    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. Simplified32.5%

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

      \[\leadsto c0 \cdot \frac{\color{blue}{-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)}}{2 \cdot w} \]
    5. Step-by-step derivation
      1. distribute-lft-in7.3%

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

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

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

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

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

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

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

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

        \[\leadsto c0 \cdot \frac{-1 \cdot \color{blue}{0}}{2 \cdot w} \]
      10. metadata-eval41.7%

        \[\leadsto c0 \cdot \frac{\color{blue}{0}}{2 \cdot w} \]
    6. Simplified41.7%

      \[\leadsto c0 \cdot \frac{\color{blue}{0}}{2 \cdot w} \]

    if 3.50000000000000002e-159 < M < 7.60000000000000023e-23

    1. Initial program 30.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. Simplified53.6%

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

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

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

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \frac{\color{blue}{-c0 \cdot {d}^{2}}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)}{2 \cdot w} \]
      3. distribute-lft-neg-in12.3%

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

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

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \frac{\color{blue}{{d}^{2} \cdot \left(-c0\right)}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)}{2 \cdot w} \]
      2. add-sqr-sqrt5.9%

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

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

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

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

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

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

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

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

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \color{blue}{\left(\frac{d}{D} \cdot \frac{d}{D}\right)} \cdot \frac{c0}{h \cdot w}\right)}{2 \cdot w} \]
      11. pow245.3%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \color{blue}{\left(c0 \cdot \frac{d}{D \cdot \left(h \cdot w\right)}\right)} \cdot \frac{d}{D}\right)}{2 \cdot w} \]
    11. Simplified60.3%

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

    if 5.5000000000000002e56 < M

    1. Initial program 9.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. Simplified43.8%

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

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

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

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

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

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

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \frac{\color{blue}{{d}^{2} \cdot \left(-c0\right)}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)}{2 \cdot w} \]
      2. add-sqr-sqrt0.0%

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

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

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

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

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

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

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

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

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \color{blue}{\left(\frac{d}{D} \cdot \frac{d}{D}\right)} \cdot \frac{c0}{h \cdot w}\right)}{2 \cdot w} \]
      11. pow250.4%

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

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

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

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

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \color{blue}{\left(\frac{c0}{w \cdot h} \cdot \frac{d}{D}\right) \cdot \frac{d}{D}}\right)}{2 \cdot w} \]
      16. *-commutative52.3%

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

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \color{blue}{\frac{c0 \cdot d}{\left(h \cdot w\right) \cdot D}} \cdot \frac{d}{D}\right)}{2 \cdot w} \]
      18. *-commutative52.3%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 3.5 \cdot 10^{-159}:\\ \;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\ \mathbf{elif}\;M \leq 7.6 \cdot 10^{-23}:\\ \;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \left(c0 \cdot \frac{d}{\left(w \cdot h\right) \cdot D}\right) \cdot \frac{d}{D}\right)}{2 \cdot w}\\ \mathbf{elif}\;M \leq 5.5 \cdot 10^{+56}:\\ \;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \frac{d}{D} \cdot \frac{c0 \cdot d}{w \cdot \left(h \cdot D\right)}\right)}{2 \cdot w}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 39.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\\ t_1 := c0 \cdot \frac{0}{2 \cdot w}\\ \mathbf{if}\;M \leq 4.5 \cdot 10^{-159}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;M \leq 1.28 \cdot 10^{-23}:\\ \;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, t\_0, \left(c0 \cdot \frac{d}{\left(w \cdot h\right) \cdot D}\right) \cdot \frac{d}{D}\right)}{2 \cdot w}\\ \mathbf{elif}\;M \leq 6.6 \cdot 10^{+56}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, t\_0, \frac{d}{D} \cdot \frac{d \cdot \frac{c0}{w}}{h \cdot D}\right)}{2 \cdot w}\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (let* ((t_0 (* d (/ d (* D (* w (* h D)))))) (t_1 (* c0 (/ 0.0 (* 2.0 w)))))
   (if (<= M 4.5e-159)
     t_1
     (if (<= M 1.28e-23)
       (* c0 (/ (fma c0 t_0 (* (* c0 (/ d (* (* w h) D))) (/ d D))) (* 2.0 w)))
       (if (<= M 6.6e+56)
         t_1
         (*
          c0
          (/
           (fma c0 t_0 (* (/ d D) (/ (* d (/ c0 w)) (* h D))))
           (* 2.0 w))))))))
double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = d * (d / (D * (w * (h * D))));
	double t_1 = c0 * (0.0 / (2.0 * w));
	double tmp;
	if (M <= 4.5e-159) {
		tmp = t_1;
	} else if (M <= 1.28e-23) {
		tmp = c0 * (fma(c0, t_0, ((c0 * (d / ((w * h) * D))) * (d / D))) / (2.0 * w));
	} else if (M <= 6.6e+56) {
		tmp = t_1;
	} else {
		tmp = c0 * (fma(c0, t_0, ((d / D) * ((d * (c0 / w)) / (h * D)))) / (2.0 * w));
	}
	return tmp;
}
function code(c0, w, h, D, d, M)
	t_0 = Float64(d * Float64(d / Float64(D * Float64(w * Float64(h * D)))))
	t_1 = Float64(c0 * Float64(0.0 / Float64(2.0 * w)))
	tmp = 0.0
	if (M <= 4.5e-159)
		tmp = t_1;
	elseif (M <= 1.28e-23)
		tmp = Float64(c0 * Float64(fma(c0, t_0, Float64(Float64(c0 * Float64(d / Float64(Float64(w * h) * D))) * Float64(d / D))) / Float64(2.0 * w)));
	elseif (M <= 6.6e+56)
		tmp = t_1;
	else
		tmp = Float64(c0 * Float64(fma(c0, t_0, Float64(Float64(d / D) * Float64(Float64(d * Float64(c0 / w)) / Float64(h * D)))) / Float64(2.0 * w)));
	end
	return tmp
end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(d * N[(d / N[(D * N[(w * N[(h * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(c0 * N[(0.0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[M, 4.5e-159], t$95$1, If[LessEqual[M, 1.28e-23], N[(c0 * N[(N[(c0 * t$95$0 + N[(N[(c0 * N[(d / N[(N[(w * h), $MachinePrecision] * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[M, 6.6e+56], t$95$1, N[(c0 * N[(N[(c0 * t$95$0 + N[(N[(d / D), $MachinePrecision] * N[(N[(d * N[(c0 / w), $MachinePrecision]), $MachinePrecision] / N[(h * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;M \leq 1.28 \cdot 10^{-23}:\\
\;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, t\_0, \left(c0 \cdot \frac{d}{\left(w \cdot h\right) \cdot D}\right) \cdot \frac{d}{D}\right)}{2 \cdot w}\\

\mathbf{elif}\;M \leq 6.6 \cdot 10^{+56}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if M < 4.49999999999999989e-159 or 1.28000000000000005e-23 < M < 6.60000000000000004e56

    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. Simplified32.5%

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

      \[\leadsto c0 \cdot \frac{\color{blue}{-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)}}{2 \cdot w} \]
    5. Step-by-step derivation
      1. distribute-lft-in7.3%

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

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

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

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

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

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

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

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

        \[\leadsto c0 \cdot \frac{-1 \cdot \color{blue}{0}}{2 \cdot w} \]
      10. metadata-eval41.7%

        \[\leadsto c0 \cdot \frac{\color{blue}{0}}{2 \cdot w} \]
    6. Simplified41.7%

      \[\leadsto c0 \cdot \frac{\color{blue}{0}}{2 \cdot w} \]

    if 4.49999999999999989e-159 < M < 1.28000000000000005e-23

    1. Initial program 30.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. Simplified53.6%

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

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

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

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \frac{\color{blue}{-c0 \cdot {d}^{2}}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)}{2 \cdot w} \]
      3. distribute-lft-neg-in12.3%

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

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

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \frac{\color{blue}{{d}^{2} \cdot \left(-c0\right)}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)}{2 \cdot w} \]
      2. add-sqr-sqrt5.9%

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

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

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

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

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

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

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

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

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \color{blue}{\left(\frac{d}{D} \cdot \frac{d}{D}\right)} \cdot \frac{c0}{h \cdot w}\right)}{2 \cdot w} \]
      11. pow245.3%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \color{blue}{\left(c0 \cdot \frac{d}{D \cdot \left(h \cdot w\right)}\right)} \cdot \frac{d}{D}\right)}{2 \cdot w} \]
    11. Simplified60.3%

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

    if 6.60000000000000004e56 < M

    1. Initial program 9.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. Simplified43.8%

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

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

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

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

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

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

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \frac{\color{blue}{{d}^{2} \cdot \left(-c0\right)}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)}{2 \cdot w} \]
      2. add-sqr-sqrt0.0%

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

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

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

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

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

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

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

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

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \color{blue}{\left(\frac{d}{D} \cdot \frac{d}{D}\right)} \cdot \frac{c0}{h \cdot w}\right)}{2 \cdot w} \]
      11. pow250.4%

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

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

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

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

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \color{blue}{\left(\frac{c0}{w \cdot h} \cdot \frac{d}{D}\right) \cdot \frac{d}{D}}\right)}{2 \cdot w} \]
      16. *-commutative52.3%

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

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \color{blue}{\frac{c0 \cdot d}{\left(h \cdot w\right) \cdot D}} \cdot \frac{d}{D}\right)}{2 \cdot w} \]
      18. *-commutative52.3%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 4.5 \cdot 10^{-159}:\\ \;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\ \mathbf{elif}\;M \leq 1.28 \cdot 10^{-23}:\\ \;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \left(c0 \cdot \frac{d}{\left(w \cdot h\right) \cdot D}\right) \cdot \frac{d}{D}\right)}{2 \cdot w}\\ \mathbf{elif}\;M \leq 6.6 \cdot 10^{+56}:\\ \;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \frac{d}{D} \cdot \frac{d \cdot \frac{c0}{w}}{h \cdot D}\right)}{2 \cdot w}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 33.5% accurate, 21.6× speedup?

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

\\
c0 \cdot \frac{0}{2 \cdot w}
\end{array}
Derivation
  1. Initial program 21.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. Simplified37.6%

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

    \[\leadsto c0 \cdot \frac{\color{blue}{-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)}}{2 \cdot w} \]
  5. Step-by-step derivation
    1. distribute-lft-in6.1%

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

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

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

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

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

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

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

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

      \[\leadsto c0 \cdot \frac{-1 \cdot \color{blue}{0}}{2 \cdot w} \]
    10. metadata-eval37.1%

      \[\leadsto c0 \cdot \frac{\color{blue}{0}}{2 \cdot w} \]
  6. Simplified37.1%

    \[\leadsto c0 \cdot \frac{\color{blue}{0}}{2 \cdot w} \]
  7. Final simplification37.1%

    \[\leadsto c0 \cdot \frac{0}{2 \cdot w} \]
  8. Add Preprocessing

Reproduce

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