Henrywood and Agarwal, Equation (13)

Percentage Accurate: 23.8% → 54.6%
Time: 35.3s
Alternatives: 5
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 5 alternatives:

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

Initial Program: 23.8% accurate, 1.0× speedup?

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

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

Alternative 1: 54.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)}\\ \mathbf{if}\;\frac{c0}{2 \cdot w} \cdot \left(t\_0 + \sqrt{t\_0 \cdot t\_0 - M \cdot M}\right) \leq \infty:\\ \;\;\;\;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{\frac{c0}{w} \cdot \frac{d}{D}}{h}\right)}{2 \cdot w}\\ \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)))))
   (if (<=
        (* (/ c0 (* 2.0 w)) (+ t_0 (sqrt (- (* t_0 t_0) (* M M)))))
        INFINITY)
     (*
      c0
      (/
       (fma
        c0
        (* d (/ d (* D (* w (* h D)))))
        (* (/ d D) (/ (* (/ c0 w) (/ d D)) h)))
       (* 2.0 w)))
     (* 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 tmp;
	if (((c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))))) <= ((double) INFINITY)) {
		tmp = c0 * (fma(c0, (d * (d / (D * (w * (h * D))))), ((d / D) * (((c0 / w) * (d / D)) / h))) / (2.0 * w));
	} 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)))
	tmp = 0.0
	if (Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_0 + sqrt(Float64(Float64(t_0 * t_0) - Float64(M * M))))) <= Inf)
		tmp = Float64(c0 * Float64(fma(c0, Float64(d * Float64(d / Float64(D * Float64(w * Float64(h * D))))), Float64(Float64(d / D) * Float64(Float64(Float64(c0 / w) * Float64(d / D)) / h))) / Float64(2.0 * w)));
	else
		tmp = Float64(c0 * Float64(0.0 / Float64(2.0 * w)));
	end
	return tmp
end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 + N[Sqrt[N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(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[(N[(c0 / w), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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)}\\
\mathbf{if}\;\frac{c0}{2 \cdot w} \cdot \left(t\_0 + \sqrt{t\_0 \cdot t\_0 - M \cdot M}\right) \leq \infty:\\
\;\;\;\;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{\frac{c0}{w} \cdot \frac{d}{D}}{h}\right)}{2 \cdot w}\\

\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 77.0%

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

      \[\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 77.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}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
    5. Step-by-step derivation
      1. pow277.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 \color{blue}{\left(d \cdot d\right)}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)}{2 \cdot w} \]
      2. pow277.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 \left(d \cdot d\right)}{\color{blue}{\left(D \cdot D\right)} \cdot \left(h \cdot w\right)}\right)}{2 \cdot w} \]
      3. *-commutative77.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 \left(d \cdot d\right)}{\left(D \cdot D\right) \cdot \color{blue}{\left(w \cdot h\right)}}\right)}{2 \cdot w} \]
      4. *-commutative77.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 \left(d \cdot d\right)}{\color{blue}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}}\right)}{2 \cdot w} \]
      5. frac-times76.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{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}}\right)}{2 \cdot w} \]
      6. frac-times79.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{c0}{w \cdot h} \cdot \color{blue}{\left(\frac{d}{D} \cdot \frac{d}{D}\right)}\right)}{2 \cdot w} \]
      7. associate-*r*80.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}{\left(\frac{c0}{w \cdot h} \cdot \frac{d}{D}\right) \cdot \frac{d}{D}}\right)}{2 \cdot w} \]
      8. associate-/r*80.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(\color{blue}{\frac{\frac{c0}{w}}{h}} \cdot \frac{d}{D}\right) \cdot \frac{d}{D}\right)}{2 \cdot w} \]
    6. Applied egg-rr80.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{\frac{c0}{w}}{h} \cdot \frac{d}{D}\right) \cdot \frac{d}{D}}\right)}{2 \cdot w} \]
    7. Step-by-step derivation
      1. associate-*l/81.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{\frac{c0}{w} \cdot \frac{d}{D}}{h}} \cdot \frac{d}{D}\right)}{2 \cdot w} \]
    8. Applied egg-rr81.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{\frac{c0}{w} \cdot \frac{d}{D}}{h}} \cdot \frac{d}{D}\right)}{2 \cdot w} \]

    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. Simplified16.2%

      \[\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. Step-by-step derivation
      1. pow1/216.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}{{\left(\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)}^{0.5}}\right)}{2 \cdot w} \]
      2. *-commutative16.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}{\left(\left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right) - M\right) \cdot \mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right)\right)}}^{0.5}\right)}{2 \cdot w} \]
      3. unpow-prod-down15.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 \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right) - M\right)}^{0.5} \cdot {\left(\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right)\right)}^{0.5}}\right)}{2 \cdot w} \]
      4. pow1/215.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}{\sqrt{c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right) - M}} \cdot {\left(\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right)\right)}^{0.5}\right)}{2 \cdot w} \]
      5. pow1/215.3%

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right) - M} \cdot \color{blue}{\sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right)}}\right)}{2 \cdot w} \]
    5. Applied egg-rr14.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}{\sqrt{\mathsf{fma}\left(\frac{c0}{w \cdot h}, {\left(\frac{d}{D}\right)}^{2}, -M\right)} \cdot \sqrt{\mathsf{fma}\left(\frac{c0}{w \cdot h}, {\left(\frac{d}{D}\right)}^{2}, M\right)}}\right)}{2 \cdot w} \]
    6. Taylor expanded in c0 around -inf 1.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} \]
    7. Step-by-step derivation
      1. mul-1-neg1.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 38.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 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 \left(\frac{d}{D} \cdot \frac{\frac{c0}{w}}{h}\right)\right)}{2 \cdot w}\\ t_1 := c0 \cdot \frac{0}{2 \cdot w}\\ \mathbf{if}\;M \leq 6.5 \cdot 10^{-221}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;M \leq 5.2 \cdot 10^{-173}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;M \leq 2.4 \cdot 10^{-154}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;M \leq 8 \cdot 10^{+91}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;M \leq 2.45 \cdot 10^{+150}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{2 \cdot \frac{\frac{c0 \cdot {\left(\frac{d}{D}\right)}^{2}}{h}}{w}}{2 \cdot w}\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (let* ((t_0
         (*
          c0
          (/
           (fma
            c0
            (* d (/ d (* D (* w (* h D)))))
            (* (/ d D) (* (/ d D) (/ (/ c0 w) h))))
           (* 2.0 w))))
        (t_1 (* c0 (/ 0.0 (* 2.0 w)))))
   (if (<= M 6.5e-221)
     t_1
     (if (<= M 5.2e-173)
       t_0
       (if (<= M 2.4e-154)
         t_1
         (if (<= M 8e+91)
           t_0
           (if (<= M 2.45e+150)
             t_1
             (*
              c0
              (/
               (* 2.0 (/ (/ (* c0 (pow (/ d D) 2.0)) h) w))
               (* 2.0 w))))))))))
double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = c0 * (fma(c0, (d * (d / (D * (w * (h * D))))), ((d / D) * ((d / D) * ((c0 / w) / h)))) / (2.0 * w));
	double t_1 = c0 * (0.0 / (2.0 * w));
	double tmp;
	if (M <= 6.5e-221) {
		tmp = t_1;
	} else if (M <= 5.2e-173) {
		tmp = t_0;
	} else if (M <= 2.4e-154) {
		tmp = t_1;
	} else if (M <= 8e+91) {
		tmp = t_0;
	} else if (M <= 2.45e+150) {
		tmp = t_1;
	} else {
		tmp = c0 * ((2.0 * (((c0 * pow((d / D), 2.0)) / h) / w)) / (2.0 * w));
	}
	return tmp;
}
function code(c0, w, h, D, d, M)
	t_0 = Float64(c0 * Float64(fma(c0, Float64(d * Float64(d / Float64(D * Float64(w * Float64(h * D))))), Float64(Float64(d / D) * Float64(Float64(d / D) * Float64(Float64(c0 / w) / h)))) / Float64(2.0 * w)))
	t_1 = Float64(c0 * Float64(0.0 / Float64(2.0 * w)))
	tmp = 0.0
	if (M <= 6.5e-221)
		tmp = t_1;
	elseif (M <= 5.2e-173)
		tmp = t_0;
	elseif (M <= 2.4e-154)
		tmp = t_1;
	elseif (M <= 8e+91)
		tmp = t_0;
	elseif (M <= 2.45e+150)
		tmp = t_1;
	else
		tmp = Float64(c0 * Float64(Float64(2.0 * Float64(Float64(Float64(c0 * (Float64(d / D) ^ 2.0)) / h) / w)) / Float64(2.0 * w)));
	end
	return tmp
end
code[c0_, w_, h_, D_, d_, M_] := Block[{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 / D), $MachinePrecision] * N[(N[(c0 / w), $MachinePrecision] / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(c0 * N[(0.0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[M, 6.5e-221], t$95$1, If[LessEqual[M, 5.2e-173], t$95$0, If[LessEqual[M, 2.4e-154], t$95$1, If[LessEqual[M, 8e+91], t$95$0, If[LessEqual[M, 2.45e+150], t$95$1, N[(c0 * N[(N[(2.0 * N[(N[(N[(c0 * N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision] / w), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 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 \left(\frac{d}{D} \cdot \frac{\frac{c0}{w}}{h}\right)\right)}{2 \cdot w}\\
t_1 := c0 \cdot \frac{0}{2 \cdot w}\\
\mathbf{if}\;M \leq 6.5 \cdot 10^{-221}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;M \leq 5.2 \cdot 10^{-173}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;M \leq 2.4 \cdot 10^{-154}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;M \leq 8 \cdot 10^{+91}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;M \leq 2.45 \cdot 10^{+150}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if M < 6.5e-221 or 5.20000000000000007e-173 < M < 2.39999999999999987e-154 or 8.00000000000000064e91 < M < 2.45000000000000003e150

    1. Initial program 25.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. Simplified34.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. Step-by-step derivation
      1. pow1/234.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}{{\left(\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)}^{0.5}}\right)}{2 \cdot w} \]
      2. *-commutative34.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}{\left(\left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right) - M\right) \cdot \mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right)\right)}}^{0.5}\right)}{2 \cdot w} \]
      3. unpow-prod-down35.5%

        \[\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 \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right) - M\right)}^{0.5} \cdot {\left(\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right)\right)}^{0.5}}\right)}{2 \cdot w} \]
      4. pow1/235.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}{\sqrt{c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right) - M}} \cdot {\left(\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right)\right)}^{0.5}\right)}{2 \cdot w} \]
      5. pow1/235.4%

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

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

      \[\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} \]
    7. Step-by-step derivation
      1. mul-1-neg5.1%

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.5e-221 < M < 5.20000000000000007e-173 or 2.39999999999999987e-154 < M < 8.00000000000000064e91

    1. Initial program 46.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. Simplified49.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 49.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}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
    5. Step-by-step derivation
      1. pow249.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 \color{blue}{\left(d \cdot d\right)}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)}{2 \cdot w} \]
      2. pow249.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 \left(d \cdot d\right)}{\color{blue}{\left(D \cdot D\right)} \cdot \left(h \cdot w\right)}\right)}{2 \cdot w} \]
      3. *-commutative49.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 \left(d \cdot d\right)}{\left(D \cdot D\right) \cdot \color{blue}{\left(w \cdot h\right)}}\right)}{2 \cdot w} \]
      4. *-commutative49.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 \left(d \cdot d\right)}{\color{blue}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}}\right)}{2 \cdot w} \]
      5. frac-times48.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 \frac{d \cdot d}{D \cdot D}}\right)}{2 \cdot w} \]
      6. frac-times54.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{c0}{w \cdot h} \cdot \color{blue}{\left(\frac{d}{D} \cdot \frac{d}{D}\right)}\right)}{2 \cdot w} \]
      7. associate-*r*57.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}{\left(\frac{c0}{w \cdot h} \cdot \frac{d}{D}\right) \cdot \frac{d}{D}}\right)}{2 \cdot w} \]
      8. associate-/r*59.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(\color{blue}{\frac{\frac{c0}{w}}{h}} \cdot \frac{d}{D}\right) \cdot \frac{d}{D}\right)}{2 \cdot w} \]
    6. Applied egg-rr59.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{\frac{c0}{w}}{h} \cdot \frac{d}{D}\right) \cdot \frac{d}{D}}\right)}{2 \cdot w} \]

    if 2.45000000000000003e150 < 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. Simplified29.1%

      \[\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 25.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}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
    5. Step-by-step derivation
      1. pow225.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 \color{blue}{\left(d \cdot d\right)}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)}{2 \cdot w} \]
      2. pow225.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 \left(d \cdot d\right)}{\color{blue}{\left(D \cdot D\right)} \cdot \left(h \cdot w\right)}\right)}{2 \cdot w} \]
      3. *-commutative25.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 \left(d \cdot d\right)}{\left(D \cdot D\right) \cdot \color{blue}{\left(w \cdot h\right)}}\right)}{2 \cdot w} \]
      4. *-commutative25.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 \left(d \cdot d\right)}{\color{blue}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}}\right)}{2 \cdot w} \]
      5. frac-times25.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}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}}\right)}{2 \cdot w} \]
      6. frac-times30.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}{w \cdot h} \cdot \color{blue}{\left(\frac{d}{D} \cdot \frac{d}{D}\right)}\right)}{2 \cdot w} \]
      7. associate-*r*30.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}{\left(\frac{c0}{w \cdot h} \cdot \frac{d}{D}\right) \cdot \frac{d}{D}}\right)}{2 \cdot w} \]
      8. associate-/r*30.8%

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \left(\color{blue}{\frac{\frac{c0}{w}}{h}} \cdot \frac{d}{D}\right) \cdot \frac{d}{D}\right)}{2 \cdot w} \]
    6. Applied egg-rr30.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}{\left(\frac{\frac{c0}{w}}{h} \cdot \frac{d}{D}\right) \cdot \frac{d}{D}}\right)}{2 \cdot w} \]
    7. Step-by-step derivation
      1. fma-undefine30.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 6.5 \cdot 10^{-221}:\\ \;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\ \mathbf{elif}\;M \leq 5.2 \cdot 10^{-173}:\\ \;\;\;\;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 \left(\frac{d}{D} \cdot \frac{\frac{c0}{w}}{h}\right)\right)}{2 \cdot w}\\ \mathbf{elif}\;M \leq 2.4 \cdot 10^{-154}:\\ \;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\ \mathbf{elif}\;M \leq 8 \cdot 10^{+91}:\\ \;\;\;\;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 \left(\frac{d}{D} \cdot \frac{\frac{c0}{w}}{h}\right)\right)}{2 \cdot w}\\ \mathbf{elif}\;M \leq 2.45 \cdot 10^{+150}:\\ \;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{2 \cdot \frac{\frac{c0 \cdot {\left(\frac{d}{D}\right)}^{2}}{h}}{w}}{2 \cdot w}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 38.1% 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 1.05 \cdot 10^{-220}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;M \leq 3.9 \cdot 10^{-173}:\\ \;\;\;\;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}\\ \mathbf{elif}\;M \leq 4.5 \cdot 10^{-155}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;M \leq 2.45 \cdot 10^{+92}:\\ \;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, t\_0, \frac{d}{D} \cdot \left(\frac{d}{D} \cdot \frac{\frac{c0}{w}}{h}\right)\right)}{2 \cdot w}\\ \mathbf{elif}\;M \leq 2.6 \cdot 10^{+150}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{2 \cdot \frac{\frac{c0 \cdot {\left(\frac{d}{D}\right)}^{2}}{h}}{w}}{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 1.05e-220)
     t_1
     (if (<= M 3.9e-173)
       (* c0 (/ (fma c0 t_0 (* (/ d D) (/ (* d (/ c0 w)) (* h D)))) (* 2.0 w)))
       (if (<= M 4.5e-155)
         t_1
         (if (<= M 2.45e+92)
           (*
            c0
            (/ (fma c0 t_0 (* (/ d D) (* (/ d D) (/ (/ c0 w) h)))) (* 2.0 w)))
           (if (<= M 2.6e+150)
             t_1
             (*
              c0
              (/
               (* 2.0 (/ (/ (* c0 (pow (/ d D) 2.0)) h) w))
               (* 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 <= 1.05e-220) {
		tmp = t_1;
	} else if (M <= 3.9e-173) {
		tmp = c0 * (fma(c0, t_0, ((d / D) * ((d * (c0 / w)) / (h * D)))) / (2.0 * w));
	} else if (M <= 4.5e-155) {
		tmp = t_1;
	} else if (M <= 2.45e+92) {
		tmp = c0 * (fma(c0, t_0, ((d / D) * ((d / D) * ((c0 / w) / h)))) / (2.0 * w));
	} else if (M <= 2.6e+150) {
		tmp = t_1;
	} else {
		tmp = c0 * ((2.0 * (((c0 * pow((d / D), 2.0)) / h) / w)) / (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 <= 1.05e-220)
		tmp = t_1;
	elseif (M <= 3.9e-173)
		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)));
	elseif (M <= 4.5e-155)
		tmp = t_1;
	elseif (M <= 2.45e+92)
		tmp = Float64(c0 * Float64(fma(c0, t_0, Float64(Float64(d / D) * Float64(Float64(d / D) * Float64(Float64(c0 / w) / h)))) / Float64(2.0 * w)));
	elseif (M <= 2.6e+150)
		tmp = t_1;
	else
		tmp = Float64(c0 * Float64(Float64(2.0 * Float64(Float64(Float64(c0 * (Float64(d / D) ^ 2.0)) / h) / w)) / 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, 1.05e-220], t$95$1, If[LessEqual[M, 3.9e-173], 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], If[LessEqual[M, 4.5e-155], t$95$1, If[LessEqual[M, 2.45e+92], N[(c0 * N[(N[(c0 * t$95$0 + N[(N[(d / D), $MachinePrecision] * N[(N[(d / D), $MachinePrecision] * N[(N[(c0 / w), $MachinePrecision] / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[M, 2.6e+150], t$95$1, N[(c0 * N[(N[(2.0 * N[(N[(N[(c0 * N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision] / w), $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 1.05 \cdot 10^{-220}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;M \leq 3.9 \cdot 10^{-173}:\\
\;\;\;\;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}\\

\mathbf{elif}\;M \leq 4.5 \cdot 10^{-155}:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;M \leq 2.6 \cdot 10^{+150}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if M < 1.04999999999999996e-220 or 3.89999999999999987e-173 < M < 4.5000000000000004e-155 or 2.4500000000000001e92 < M < 2.60000000000000006e150

    1. Initial program 25.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. Simplified34.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. Step-by-step derivation
      1. pow1/234.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}{{\left(\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)}^{0.5}}\right)}{2 \cdot w} \]
      2. *-commutative34.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}{\left(\left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right) - M\right) \cdot \mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right)\right)}}^{0.5}\right)}{2 \cdot w} \]
      3. unpow-prod-down35.5%

        \[\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 \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right) - M\right)}^{0.5} \cdot {\left(\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right)\right)}^{0.5}}\right)}{2 \cdot w} \]
      4. pow1/235.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}{\sqrt{c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right) - M}} \cdot {\left(\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right)\right)}^{0.5}\right)}{2 \cdot w} \]
      5. pow1/235.4%

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

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

      \[\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} \]
    7. Step-by-step derivation
      1. mul-1-neg5.1%

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.04999999999999996e-220 < M < 3.89999999999999987e-173

    1. Initial program 70.2%

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

      \[\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 83.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}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
    5. Step-by-step derivation
      1. pow283.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 \color{blue}{\left(d \cdot d\right)}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)}{2 \cdot w} \]
      2. pow283.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 \left(d \cdot d\right)}{\color{blue}{\left(D \cdot D\right)} \cdot \left(h \cdot w\right)}\right)}{2 \cdot w} \]
      3. *-commutative83.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 \left(d \cdot d\right)}{\left(D \cdot D\right) \cdot \color{blue}{\left(w \cdot h\right)}}\right)}{2 \cdot w} \]
      4. *-commutative83.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 \left(d \cdot d\right)}{\color{blue}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}}\right)}{2 \cdot w} \]
      5. frac-times78.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}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}}\right)}{2 \cdot w} \]
      6. frac-times78.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}{w \cdot h} \cdot \color{blue}{\left(\frac{d}{D} \cdot \frac{d}{D}\right)}\right)}{2 \cdot w} \]
      7. associate-*r*84.5%

        \[\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} \]
      8. associate-/r*84.5%

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

      \[\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{\frac{c0}{w}}{h} \cdot \frac{d}{D}\right) \cdot \frac{d}{D}}\right)}{2 \cdot w} \]
    7. Step-by-step derivation
      1. frac-times84.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{\frac{c0}{w} \cdot d}{h \cdot D}} \cdot \frac{d}{D}\right)}{2 \cdot w} \]
    8. Applied egg-rr84.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{\frac{c0}{w} \cdot d}{h \cdot D}} \cdot \frac{d}{D}\right)}{2 \cdot w} \]

    if 4.5000000000000004e-155 < M < 2.4500000000000001e92

    1. Initial program 39.8%

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

      \[\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 40.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{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
    5. Step-by-step derivation
      1. pow240.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{c0 \cdot \color{blue}{\left(d \cdot d\right)}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)}{2 \cdot w} \]
      2. pow240.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{c0 \cdot \left(d \cdot d\right)}{\color{blue}{\left(D \cdot D\right)} \cdot \left(h \cdot w\right)}\right)}{2 \cdot w} \]
      3. *-commutative40.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{c0 \cdot \left(d \cdot d\right)}{\left(D \cdot D\right) \cdot \color{blue}{\left(w \cdot h\right)}}\right)}{2 \cdot w} \]
      4. *-commutative40.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{c0 \cdot \left(d \cdot d\right)}{\color{blue}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}}\right)}{2 \cdot w} \]
      5. frac-times40.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 \frac{d \cdot d}{D \cdot D}}\right)}{2 \cdot w} \]
      6. frac-times48.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{c0}{w \cdot h} \cdot \color{blue}{\left(\frac{d}{D} \cdot \frac{d}{D}\right)}\right)}{2 \cdot w} \]
      7. associate-*r*51.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} \]
      8. associate-/r*53.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(\color{blue}{\frac{\frac{c0}{w}}{h}} \cdot \frac{d}{D}\right) \cdot \frac{d}{D}\right)}{2 \cdot w} \]
    6. Applied egg-rr53.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{\frac{c0}{w}}{h} \cdot \frac{d}{D}\right) \cdot \frac{d}{D}}\right)}{2 \cdot w} \]

    if 2.60000000000000006e150 < 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. Simplified29.1%

      \[\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 25.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}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
    5. Step-by-step derivation
      1. pow225.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 \color{blue}{\left(d \cdot d\right)}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)}{2 \cdot w} \]
      2. pow225.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 \left(d \cdot d\right)}{\color{blue}{\left(D \cdot D\right)} \cdot \left(h \cdot w\right)}\right)}{2 \cdot w} \]
      3. *-commutative25.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 \left(d \cdot d\right)}{\left(D \cdot D\right) \cdot \color{blue}{\left(w \cdot h\right)}}\right)}{2 \cdot w} \]
      4. *-commutative25.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 \left(d \cdot d\right)}{\color{blue}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}}\right)}{2 \cdot w} \]
      5. frac-times25.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}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}}\right)}{2 \cdot w} \]
      6. frac-times30.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}{w \cdot h} \cdot \color{blue}{\left(\frac{d}{D} \cdot \frac{d}{D}\right)}\right)}{2 \cdot w} \]
      7. associate-*r*30.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}{\left(\frac{c0}{w \cdot h} \cdot \frac{d}{D}\right) \cdot \frac{d}{D}}\right)}{2 \cdot w} \]
      8. associate-/r*30.8%

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \left(\color{blue}{\frac{\frac{c0}{w}}{h}} \cdot \frac{d}{D}\right) \cdot \frac{d}{D}\right)}{2 \cdot w} \]
    6. Applied egg-rr30.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}{\left(\frac{\frac{c0}{w}}{h} \cdot \frac{d}{D}\right) \cdot \frac{d}{D}}\right)}{2 \cdot w} \]
    7. Step-by-step derivation
      1. fma-undefine30.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 1.05 \cdot 10^{-220}:\\ \;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\ \mathbf{elif}\;M \leq 3.9 \cdot 10^{-173}:\\ \;\;\;\;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}\\ \mathbf{elif}\;M \leq 4.5 \cdot 10^{-155}:\\ \;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\ \mathbf{elif}\;M \leq 2.45 \cdot 10^{+92}:\\ \;\;\;\;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 \left(\frac{d}{D} \cdot \frac{\frac{c0}{w}}{h}\right)\right)}{2 \cdot w}\\ \mathbf{elif}\;M \leq 2.6 \cdot 10^{+150}:\\ \;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{2 \cdot \frac{\frac{c0 \cdot {\left(\frac{d}{D}\right)}^{2}}{h}}{w}}{2 \cdot w}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 39.1% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;M \leq 8.3 \cdot 10^{-221} \lor \neg \left(M \leq 4.9 \cdot 10^{-172}\right) \land M \leq 1.55 \cdot 10^{-150}:\\ \;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{2 \cdot \frac{\frac{c0 \cdot {\left(\frac{d}{D}\right)}^{2}}{h}}{w}}{2 \cdot w}\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (if (or (<= M 8.3e-221) (and (not (<= M 4.9e-172)) (<= M 1.55e-150)))
   (* c0 (/ 0.0 (* 2.0 w)))
   (* c0 (/ (* 2.0 (/ (/ (* c0 (pow (/ d D) 2.0)) h) w)) (* 2.0 w)))))
double code(double c0, double w, double h, double D, double d, double M) {
	double tmp;
	if ((M <= 8.3e-221) || (!(M <= 4.9e-172) && (M <= 1.55e-150))) {
		tmp = c0 * (0.0 / (2.0 * w));
	} else {
		tmp = c0 * ((2.0 * (((c0 * pow((d / D), 2.0)) / h) / w)) / (2.0 * w));
	}
	return tmp;
}
real(8) function code(c0, w, h, d, d_1, m)
    real(8), intent (in) :: c0
    real(8), intent (in) :: w
    real(8), intent (in) :: h
    real(8), intent (in) :: d
    real(8), intent (in) :: d_1
    real(8), intent (in) :: m
    real(8) :: tmp
    if ((m <= 8.3d-221) .or. (.not. (m <= 4.9d-172)) .and. (m <= 1.55d-150)) then
        tmp = c0 * (0.0d0 / (2.0d0 * w))
    else
        tmp = c0 * ((2.0d0 * (((c0 * ((d_1 / d) ** 2.0d0)) / h) / w)) / (2.0d0 * w))
    end if
    code = tmp
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
	double tmp;
	if ((M <= 8.3e-221) || (!(M <= 4.9e-172) && (M <= 1.55e-150))) {
		tmp = c0 * (0.0 / (2.0 * w));
	} else {
		tmp = c0 * ((2.0 * (((c0 * Math.pow((d / D), 2.0)) / h) / w)) / (2.0 * w));
	}
	return tmp;
}
def code(c0, w, h, D, d, M):
	tmp = 0
	if (M <= 8.3e-221) or (not (M <= 4.9e-172) and (M <= 1.55e-150)):
		tmp = c0 * (0.0 / (2.0 * w))
	else:
		tmp = c0 * ((2.0 * (((c0 * math.pow((d / D), 2.0)) / h) / w)) / (2.0 * w))
	return tmp
function code(c0, w, h, D, d, M)
	tmp = 0.0
	if ((M <= 8.3e-221) || (!(M <= 4.9e-172) && (M <= 1.55e-150)))
		tmp = Float64(c0 * Float64(0.0 / Float64(2.0 * w)));
	else
		tmp = Float64(c0 * Float64(Float64(2.0 * Float64(Float64(Float64(c0 * (Float64(d / D) ^ 2.0)) / h) / w)) / Float64(2.0 * w)));
	end
	return tmp
end
function tmp_2 = code(c0, w, h, D, d, M)
	tmp = 0.0;
	if ((M <= 8.3e-221) || (~((M <= 4.9e-172)) && (M <= 1.55e-150)))
		tmp = c0 * (0.0 / (2.0 * w));
	else
		tmp = c0 * ((2.0 * (((c0 * ((d / D) ^ 2.0)) / h) / w)) / (2.0 * w));
	end
	tmp_2 = tmp;
end
code[c0_, w_, h_, D_, d_, M_] := If[Or[LessEqual[M, 8.3e-221], And[N[Not[LessEqual[M, 4.9e-172]], $MachinePrecision], LessEqual[M, 1.55e-150]]], N[(c0 * N[(0.0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(N[(2.0 * N[(N[(N[(c0 * N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision] / w), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;M \leq 8.3 \cdot 10^{-221} \lor \neg \left(M \leq 4.9 \cdot 10^{-172}\right) \land M \leq 1.55 \cdot 10^{-150}:\\
\;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if M < 8.30000000000000035e-221 or 4.9000000000000001e-172 < M < 1.54999999999999999e-150

    1. Initial program 25.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. Simplified35.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. Step-by-step derivation
      1. pow1/235.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}{{\left(\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)}^{0.5}}\right)}{2 \cdot w} \]
      2. *-commutative35.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}{\left(\left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right) - M\right) \cdot \mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right)\right)}}^{0.5}\right)}{2 \cdot w} \]
      3. unpow-prod-down36.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 \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right) - M\right)}^{0.5} \cdot {\left(\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right)\right)}^{0.5}}\right)}{2 \cdot w} \]
      4. pow1/236.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}{\sqrt{c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right) - M}} \cdot {\left(\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right)\right)}^{0.5}\right)}{2 \cdot w} \]
      5. pow1/236.3%

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right) - M} \cdot \color{blue}{\sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right)}}\right)}{2 \cdot w} \]
    5. Applied egg-rr34.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}{\sqrt{\mathsf{fma}\left(\frac{c0}{w \cdot h}, {\left(\frac{d}{D}\right)}^{2}, -M\right)} \cdot \sqrt{\mathsf{fma}\left(\frac{c0}{w \cdot h}, {\left(\frac{d}{D}\right)}^{2}, M\right)}}\right)}{2 \cdot w} \]
    6. Taylor expanded in c0 around -inf 5.3%

      \[\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} \]
    7. Step-by-step derivation
      1. mul-1-neg5.3%

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

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

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

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

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

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

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

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

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

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

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

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

    if 8.30000000000000035e-221 < M < 4.9000000000000001e-172 or 1.54999999999999999e-150 < M

    1. Initial program 34.2%

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

      \[\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 42.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}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
    5. Step-by-step derivation
      1. pow242.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 \color{blue}{\left(d \cdot d\right)}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)}{2 \cdot w} \]
      2. pow242.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 \left(d \cdot d\right)}{\color{blue}{\left(D \cdot D\right)} \cdot \left(h \cdot w\right)}\right)}{2 \cdot w} \]
      3. *-commutative42.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 \left(d \cdot d\right)}{\left(D \cdot D\right) \cdot \color{blue}{\left(w \cdot h\right)}}\right)}{2 \cdot w} \]
      4. *-commutative42.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 \left(d \cdot d\right)}{\color{blue}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}}\right)}{2 \cdot w} \]
      5. frac-times41.5%

        \[\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 \frac{d \cdot d}{D \cdot D}}\right)}{2 \cdot w} \]
      6. frac-times47.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} \]
      7. associate-*r*49.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} \]
      8. associate-/r*49.6%

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \left(\color{blue}{\frac{\frac{c0}{w}}{h}} \cdot \frac{d}{D}\right) \cdot \frac{d}{D}\right)}{2 \cdot w} \]
    6. Applied egg-rr49.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}{\left(\frac{\frac{c0}{w}}{h} \cdot \frac{d}{D}\right) \cdot \frac{d}{D}}\right)}{2 \cdot w} \]
    7. Step-by-step derivation
      1. fma-undefine49.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 8.3 \cdot 10^{-221} \lor \neg \left(M \leq 4.9 \cdot 10^{-172}\right) \land M \leq 1.55 \cdot 10^{-150}:\\ \;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{2 \cdot \frac{\frac{c0 \cdot {\left(\frac{d}{D}\right)}^{2}}{h}}{w}}{2 \cdot w}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 34.6% 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 28.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. Simplified38.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. Step-by-step derivation
    1. pow1/238.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(\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)}^{0.5}}\right)}{2 \cdot w} \]
    2. *-commutative38.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(\left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right) - M\right) \cdot \mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right)\right)}}^{0.5}\right)}{2 \cdot w} \]
    3. unpow-prod-down39.5%

      \[\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 \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right) - M\right)}^{0.5} \cdot {\left(\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right)\right)}^{0.5}}\right)}{2 \cdot w} \]
    4. pow1/239.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}{\sqrt{c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right) - M}} \cdot {\left(\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right)\right)}^{0.5}\right)}{2 \cdot w} \]
    5. pow1/239.4%

      \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right) - M} \cdot \color{blue}{\sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right)}}\right)}{2 \cdot w} \]
  5. Applied egg-rr38.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}{\sqrt{\mathsf{fma}\left(\frac{c0}{w \cdot h}, {\left(\frac{d}{D}\right)}^{2}, -M\right)} \cdot \sqrt{\mathsf{fma}\left(\frac{c0}{w \cdot h}, {\left(\frac{d}{D}\right)}^{2}, M\right)}}\right)}{2 \cdot w} \]
  6. Taylor expanded in c0 around -inf 4.0%

    \[\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} \]
  7. Step-by-step derivation
    1. mul-1-neg4.0%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto c0 \cdot \frac{\color{blue}{0}}{2 \cdot w} \]
  9. Final simplification34.0%

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

Reproduce

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