Henrywood and Agarwal, Equation (13)

Percentage Accurate: 24.3% → 44.2%
Time: 46.1s
Alternatives: 10
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 10 alternatives:

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

Initial Program: 24.3% 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: 44.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\left(\frac{d}{D}\right)}^{2}\\ t_1 := c0 \cdot \frac{0}{2 \cdot w}\\ \mathbf{if}\;w \leq -6.2 \cdot 10^{+174}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;w \leq -4.2 \cdot 10^{+14}:\\ \;\;\;\;c0 \cdot \left(\frac{\frac{c0}{h}}{w} \cdot \frac{t\_0}{w}\right)\\ \mathbf{elif}\;w \leq -0.000195:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;w \leq 1.6 \cdot 10^{-112}:\\ \;\;\;\;c0 \cdot \frac{\frac{c0 \cdot 2}{w \cdot h} \cdot t\_0}{2 \cdot w}\\ \mathbf{elif}\;w \leq 3.9 \cdot 10^{-60} \lor \neg \left(w \leq 6.8 \cdot 10^{+103}\right):\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{2 \cdot \left(\frac{{d}^{2}}{D} \cdot \frac{c0}{h \cdot \left(w \cdot D\right)}\right)}{2 \cdot w}\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (let* ((t_0 (pow (/ d D) 2.0)) (t_1 (* c0 (/ 0.0 (* 2.0 w)))))
   (if (<= w -6.2e+174)
     t_1
     (if (<= w -4.2e+14)
       (* c0 (* (/ (/ c0 h) w) (/ t_0 w)))
       (if (<= w -0.000195)
         t_1
         (if (<= w 1.6e-112)
           (* c0 (/ (* (/ (* c0 2.0) (* w h)) t_0) (* 2.0 w)))
           (if (or (<= w 3.9e-60) (not (<= w 6.8e+103)))
             t_1
             (*
              c0
              (/
               (* 2.0 (* (/ (pow d 2.0) D) (/ c0 (* h (* w D)))))
               (* 2.0 w))))))))))
double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = pow((d / D), 2.0);
	double t_1 = c0 * (0.0 / (2.0 * w));
	double tmp;
	if (w <= -6.2e+174) {
		tmp = t_1;
	} else if (w <= -4.2e+14) {
		tmp = c0 * (((c0 / h) / w) * (t_0 / w));
	} else if (w <= -0.000195) {
		tmp = t_1;
	} else if (w <= 1.6e-112) {
		tmp = c0 * ((((c0 * 2.0) / (w * h)) * t_0) / (2.0 * w));
	} else if ((w <= 3.9e-60) || !(w <= 6.8e+103)) {
		tmp = t_1;
	} else {
		tmp = c0 * ((2.0 * ((pow(d, 2.0) / D) * (c0 / (h * (w * D))))) / (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) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (d_1 / d) ** 2.0d0
    t_1 = c0 * (0.0d0 / (2.0d0 * w))
    if (w <= (-6.2d+174)) then
        tmp = t_1
    else if (w <= (-4.2d+14)) then
        tmp = c0 * (((c0 / h) / w) * (t_0 / w))
    else if (w <= (-0.000195d0)) then
        tmp = t_1
    else if (w <= 1.6d-112) then
        tmp = c0 * ((((c0 * 2.0d0) / (w * h)) * t_0) / (2.0d0 * w))
    else if ((w <= 3.9d-60) .or. (.not. (w <= 6.8d+103))) then
        tmp = t_1
    else
        tmp = c0 * ((2.0d0 * (((d_1 ** 2.0d0) / d) * (c0 / (h * (w * d))))) / (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 t_0 = Math.pow((d / D), 2.0);
	double t_1 = c0 * (0.0 / (2.0 * w));
	double tmp;
	if (w <= -6.2e+174) {
		tmp = t_1;
	} else if (w <= -4.2e+14) {
		tmp = c0 * (((c0 / h) / w) * (t_0 / w));
	} else if (w <= -0.000195) {
		tmp = t_1;
	} else if (w <= 1.6e-112) {
		tmp = c0 * ((((c0 * 2.0) / (w * h)) * t_0) / (2.0 * w));
	} else if ((w <= 3.9e-60) || !(w <= 6.8e+103)) {
		tmp = t_1;
	} else {
		tmp = c0 * ((2.0 * ((Math.pow(d, 2.0) / D) * (c0 / (h * (w * D))))) / (2.0 * w));
	}
	return tmp;
}
def code(c0, w, h, D, d, M):
	t_0 = math.pow((d / D), 2.0)
	t_1 = c0 * (0.0 / (2.0 * w))
	tmp = 0
	if w <= -6.2e+174:
		tmp = t_1
	elif w <= -4.2e+14:
		tmp = c0 * (((c0 / h) / w) * (t_0 / w))
	elif w <= -0.000195:
		tmp = t_1
	elif w <= 1.6e-112:
		tmp = c0 * ((((c0 * 2.0) / (w * h)) * t_0) / (2.0 * w))
	elif (w <= 3.9e-60) or not (w <= 6.8e+103):
		tmp = t_1
	else:
		tmp = c0 * ((2.0 * ((math.pow(d, 2.0) / D) * (c0 / (h * (w * D))))) / (2.0 * w))
	return tmp
function code(c0, w, h, D, d, M)
	t_0 = Float64(d / D) ^ 2.0
	t_1 = Float64(c0 * Float64(0.0 / Float64(2.0 * w)))
	tmp = 0.0
	if (w <= -6.2e+174)
		tmp = t_1;
	elseif (w <= -4.2e+14)
		tmp = Float64(c0 * Float64(Float64(Float64(c0 / h) / w) * Float64(t_0 / w)));
	elseif (w <= -0.000195)
		tmp = t_1;
	elseif (w <= 1.6e-112)
		tmp = Float64(c0 * Float64(Float64(Float64(Float64(c0 * 2.0) / Float64(w * h)) * t_0) / Float64(2.0 * w)));
	elseif ((w <= 3.9e-60) || !(w <= 6.8e+103))
		tmp = t_1;
	else
		tmp = Float64(c0 * Float64(Float64(2.0 * Float64(Float64((d ^ 2.0) / D) * Float64(c0 / Float64(h * Float64(w * D))))) / Float64(2.0 * w)));
	end
	return tmp
end
function tmp_2 = code(c0, w, h, D, d, M)
	t_0 = (d / D) ^ 2.0;
	t_1 = c0 * (0.0 / (2.0 * w));
	tmp = 0.0;
	if (w <= -6.2e+174)
		tmp = t_1;
	elseif (w <= -4.2e+14)
		tmp = c0 * (((c0 / h) / w) * (t_0 / w));
	elseif (w <= -0.000195)
		tmp = t_1;
	elseif (w <= 1.6e-112)
		tmp = c0 * ((((c0 * 2.0) / (w * h)) * t_0) / (2.0 * w));
	elseif ((w <= 3.9e-60) || ~((w <= 6.8e+103)))
		tmp = t_1;
	else
		tmp = c0 * ((2.0 * (((d ^ 2.0) / D) * (c0 / (h * (w * D))))) / (2.0 * w));
	end
	tmp_2 = tmp;
end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(c0 * N[(0.0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[w, -6.2e+174], t$95$1, If[LessEqual[w, -4.2e+14], N[(c0 * N[(N[(N[(c0 / h), $MachinePrecision] / w), $MachinePrecision] * N[(t$95$0 / w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[w, -0.000195], t$95$1, If[LessEqual[w, 1.6e-112], N[(c0 * N[(N[(N[(N[(c0 * 2.0), $MachinePrecision] / N[(w * h), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[w, 3.9e-60], N[Not[LessEqual[w, 6.8e+103]], $MachinePrecision]], t$95$1, N[(c0 * N[(N[(2.0 * N[(N[(N[Power[d, 2.0], $MachinePrecision] / D), $MachinePrecision] * N[(c0 / N[(h * N[(w * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;w \leq -4.2 \cdot 10^{+14}:\\
\;\;\;\;c0 \cdot \left(\frac{\frac{c0}{h}}{w} \cdot \frac{t\_0}{w}\right)\\

\mathbf{elif}\;w \leq -0.000195:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;w \leq 3.9 \cdot 10^{-60} \lor \neg \left(w \leq 6.8 \cdot 10^{+103}\right):\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if w < -6.2e174 or -4.2e14 < w < -1.94999999999999996e-4 or 1.59999999999999997e-112 < w < 3.9000000000000002e-60 or 6.7999999999999997e103 < w

    1. Initial program 18.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.2e174 < w < -4.2e14

    1. Initial program 27.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. Simplified50.8%

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

      \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \color{blue}{-1 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
    5. Step-by-step derivation
      1. mul-1-neg4.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} \]
    6. Simplified4.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} \]
    7. Step-by-step derivation
      1. associate-/l*4.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}{c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
      2. unpow24.6%

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

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

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

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

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

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

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, -c0 \cdot \color{blue}{\left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)}\right)}{2 \cdot w} \]
      9. add-cbrt-cube9.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}{\sqrt[3]{\left(\left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right) \cdot \left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right)\right) \cdot \left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right)}}\right)}{2 \cdot w} \]
      10. pow1/310.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(\left(\left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right) \cdot \left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right)\right) \cdot \left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right)\right)}^{0.3333333333333333}}\right)}{2 \cdot w} \]
    8. Applied egg-rr5.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({\left(\frac{c0}{{D}^{2}} \cdot \frac{{d}^{2}}{h \cdot w}\right)}^{3}\right)}^{0.3333333333333333}}\right)}{2 \cdot w} \]
    9. Applied egg-rr60.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.94999999999999996e-4 < w < 1.59999999999999997e-112

    1. Initial program 33.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. Simplified58.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, -c0 \cdot \color{blue}{\left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)}\right)}{2 \cdot w} \]
      9. add-cbrt-cube1.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[3]{\left(\left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right) \cdot \left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right)\right) \cdot \left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right)}}\right)}{2 \cdot w} \]
      10. pow1/35.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(\left(\left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right) \cdot \left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right)\right) \cdot \left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right)\right)}^{0.3333333333333333}}\right)}{2 \cdot w} \]
    8. Applied egg-rr3.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(\frac{c0}{{D}^{2}} \cdot \frac{{d}^{2}}{h \cdot w}\right)}^{3}\right)}^{0.3333333333333333}}\right)}{2 \cdot w} \]
    9. Applied egg-rr61.7%

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.9000000000000002e-60 < w < 6.7999999999999997e103

    1. Initial program 18.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. Simplified52.8%

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

      \[\leadsto 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 \color{blue}{\left(D \cdot \left(h \cdot w\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} \]
    5. Taylor expanded in c0 around inf 46.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;w \leq -6.2 \cdot 10^{+174}:\\ \;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\ \mathbf{elif}\;w \leq -4.2 \cdot 10^{+14}:\\ \;\;\;\;c0 \cdot \left(\frac{\frac{c0}{h}}{w} \cdot \frac{{\left(\frac{d}{D}\right)}^{2}}{w}\right)\\ \mathbf{elif}\;w \leq -0.000195:\\ \;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\ \mathbf{elif}\;w \leq 1.6 \cdot 10^{-112}:\\ \;\;\;\;c0 \cdot \frac{\frac{c0 \cdot 2}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2}}{2 \cdot w}\\ \mathbf{elif}\;w \leq 3.9 \cdot 10^{-60} \lor \neg \left(w \leq 6.8 \cdot 10^{+103}\right):\\ \;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{2 \cdot \left(\frac{{d}^{2}}{D} \cdot \frac{c0}{h \cdot \left(w \cdot D\right)}\right)}{2 \cdot w}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 54.3% accurate, 0.3× speedup?

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

    1. Initial program 78.9%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Simplified83.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. Applied egg-rr79.3%

      \[\leadsto c0 \cdot \frac{\color{blue}{{\left(\mathsf{hypot}\left({\left({\left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2}\right)}^{2} - {M}^{2}\right)}^{0.25}, \sqrt{\frac{c0}{w \cdot h}} \cdot \frac{d}{D}\right)\right)}^{2}}}{2 \cdot w} \]
    5. Taylor expanded in M around 0 86.7%

      \[\leadsto c0 \cdot \frac{{\left(\mathsf{hypot}\left(\color{blue}{{1}^{0.25} \cdot \left(\frac{d}{D} \cdot \sqrt{\frac{c0}{h \cdot w}}\right)}, \sqrt{\frac{c0}{w \cdot h}} \cdot \frac{d}{D}\right)\right)}^{2}}{2 \cdot w} \]
    6. Step-by-step derivation
      1. pow-base-186.7%

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

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

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

    if +inf.0 < (*.f64 (/.f64 c0 (*.f64 2 w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M)))))

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 54.0% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := w \cdot \left(h \cdot D\right)\\ t_1 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(D \cdot D\right) \cdot \left(w \cdot h\right)}\\ \mathbf{if}\;\frac{c0}{2 \cdot w} \cdot \left(t\_1 + \sqrt{t\_1 \cdot t\_1 - M \cdot M}\right) \leq \infty:\\ \;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot t\_0}, c0 \cdot \left(\frac{d}{D} \cdot \frac{d}{t\_0}\right)\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 (* w (* h D))) (t_1 (/ (* c0 (* d d)) (* (* D D) (* w h)))))
   (if (<=
        (* (/ c0 (* 2.0 w)) (+ t_1 (sqrt (- (* t_1 t_1) (* M M)))))
        INFINITY)
     (*
      c0
      (/
       (fma c0 (* d (/ d (* D t_0))) (* c0 (* (/ d D) (/ d t_0))))
       (* 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 = w * (h * D);
	double t_1 = (c0 * (d * d)) / ((D * D) * (w * h));
	double tmp;
	if (((c0 / (2.0 * w)) * (t_1 + sqrt(((t_1 * t_1) - (M * M))))) <= ((double) INFINITY)) {
		tmp = c0 * (fma(c0, (d * (d / (D * t_0))), (c0 * ((d / D) * (d / t_0)))) / (2.0 * w));
	} else {
		tmp = c0 * (0.0 / (2.0 * w));
	}
	return tmp;
}
function code(c0, w, h, D, d, M)
	t_0 = Float64(w * Float64(h * D))
	t_1 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(D * D) * Float64(w * h)))
	tmp = 0.0
	if (Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_1 + sqrt(Float64(Float64(t_1 * t_1) - Float64(M * M))))) <= Inf)
		tmp = Float64(c0 * Float64(fma(c0, Float64(d * Float64(d / Float64(D * t_0))), Float64(c0 * Float64(Float64(d / D) * Float64(d / t_0)))) / 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[(w * N[(h * D), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(D * D), $MachinePrecision] * N[(w * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(t$95$1 + N[Sqrt[N[(N[(t$95$1 * t$95$1), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(c0 * N[(N[(c0 * N[(d * N[(d / N[(D * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(c0 * N[(N[(d / D), $MachinePrecision] * N[(d / t$95$0), $MachinePrecision]), $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 := w \cdot \left(h \cdot D\right)\\
t_1 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(D \cdot D\right) \cdot \left(w \cdot h\right)}\\
\mathbf{if}\;\frac{c0}{2 \cdot w} \cdot \left(t\_1 + \sqrt{t\_1 \cdot t\_1 - M \cdot M}\right) \leq \infty:\\
\;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot t\_0}, c0 \cdot \left(\frac{d}{D} \cdot \frac{d}{t\_0}\right)\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 2 w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) < +inf.0

    1. Initial program 78.9%

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

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

      \[\leadsto 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 \color{blue}{\left(D \cdot \left(h \cdot w\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} \]
    5. Taylor expanded in c0 around inf 81.3%

      \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \color{blue}{\frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
    6. Step-by-step derivation
      1. associate-*r/81.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}{c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
    7. Simplified81.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}{c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
    8. Step-by-step derivation
      1. frac-2neg81.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if +inf.0 < (*.f64 (/.f64 c0 (*.f64 2 w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M)))))

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 37.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := c0 \cdot \frac{0}{2 \cdot w}\\ \mathbf{if}\;D \leq 8 \cdot 10^{-288}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;D \leq 1.5 \cdot 10^{-167}:\\ \;\;\;\;c0 \cdot \frac{\frac{c0 \cdot 2}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2}}{2 \cdot w}\\ \mathbf{elif}\;D \leq 1.95 \cdot 10^{-66} \lor \neg \left(D \leq 4.6 \cdot 10^{-37}\right):\\ \;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, c0 \cdot \left(\frac{d}{w \cdot D} \cdot \frac{d}{h \cdot D}\right)\right)}{2 \cdot w}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (let* ((t_0 (* c0 (/ 0.0 (* 2.0 w)))))
   (if (<= D 8e-288)
     t_0
     (if (<= D 1.5e-167)
       (* c0 (/ (* (/ (* c0 2.0) (* w h)) (pow (/ d D) 2.0)) (* 2.0 w)))
       (if (or (<= D 1.95e-66) (not (<= D 4.6e-37)))
         (*
          c0
          (/
           (fma
            c0
            (* d (/ d (* D (* w (* h D)))))
            (* c0 (* (/ d (* w D)) (/ d (* h D)))))
           (* 2.0 w)))
         t_0)))))
double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = c0 * (0.0 / (2.0 * w));
	double tmp;
	if (D <= 8e-288) {
		tmp = t_0;
	} else if (D <= 1.5e-167) {
		tmp = c0 * ((((c0 * 2.0) / (w * h)) * pow((d / D), 2.0)) / (2.0 * w));
	} else if ((D <= 1.95e-66) || !(D <= 4.6e-37)) {
		tmp = c0 * (fma(c0, (d * (d / (D * (w * (h * D))))), (c0 * ((d / (w * D)) * (d / (h * D))))) / (2.0 * w));
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(c0, w, h, D, d, M)
	t_0 = Float64(c0 * Float64(0.0 / Float64(2.0 * w)))
	tmp = 0.0
	if (D <= 8e-288)
		tmp = t_0;
	elseif (D <= 1.5e-167)
		tmp = Float64(c0 * Float64(Float64(Float64(Float64(c0 * 2.0) / Float64(w * h)) * (Float64(d / D) ^ 2.0)) / Float64(2.0 * w)));
	elseif ((D <= 1.95e-66) || !(D <= 4.6e-37))
		tmp = Float64(c0 * Float64(fma(c0, Float64(d * Float64(d / Float64(D * Float64(w * Float64(h * D))))), Float64(c0 * Float64(Float64(d / Float64(w * D)) * Float64(d / Float64(h * D))))) / Float64(2.0 * w)));
	else
		tmp = t_0;
	end
	return tmp
end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(c0 * N[(0.0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[D, 8e-288], t$95$0, If[LessEqual[D, 1.5e-167], N[(c0 * N[(N[(N[(N[(c0 * 2.0), $MachinePrecision] / N[(w * h), $MachinePrecision]), $MachinePrecision] * N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[D, 1.95e-66], N[Not[LessEqual[D, 4.6e-37]], $MachinePrecision]], N[(c0 * N[(N[(c0 * N[(d * N[(d / N[(D * N[(w * N[(h * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(c0 * N[(N[(d / N[(w * D), $MachinePrecision]), $MachinePrecision] * N[(d / N[(h * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

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

\mathbf{elif}\;D \leq 1.5 \cdot 10^{-167}:\\
\;\;\;\;c0 \cdot \frac{\frac{c0 \cdot 2}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2}}{2 \cdot w}\\

\mathbf{elif}\;D \leq 1.95 \cdot 10^{-66} \lor \neg \left(D \leq 4.6 \cdot 10^{-37}\right):\\
\;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, c0 \cdot \left(\frac{d}{w \cdot D} \cdot \frac{d}{h \cdot D}\right)\right)}{2 \cdot w}\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if D < 8.00000000000000046e-288 or 1.94999999999999991e-66 < D < 4.5999999999999999e-37

    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. Simplified44.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 3.8%

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

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

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

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

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

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

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

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

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

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

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

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

    if 8.00000000000000046e-288 < D < 1.4999999999999999e-167

    1. Initial program 21.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. Simplified46.3%

      \[\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 0.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}{-1 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
    5. Step-by-step derivation
      1. mul-1-neg0.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}{-\frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
    6. Simplified0.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}{-\frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
    7. Step-by-step derivation
      1. associate-/l*0.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}{c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
      2. unpow20.1%

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

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

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

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

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

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

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, -c0 \cdot \color{blue}{\left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)}\right)}{2 \cdot w} \]
      9. add-cbrt-cube4.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}{\sqrt[3]{\left(\left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right) \cdot \left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right)\right) \cdot \left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right)}}\right)}{2 \cdot w} \]
      10. pow1/311.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(\left(\left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right) \cdot \left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right)\right) \cdot \left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right)\right)}^{0.3333333333333333}}\right)}{2 \cdot w} \]
    8. Applied egg-rr4.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(\frac{c0}{{D}^{2}} \cdot \frac{{d}^{2}}{h \cdot w}\right)}^{3}\right)}^{0.3333333333333333}}\right)}{2 \cdot w} \]
    9. Applied egg-rr55.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.4999999999999999e-167 < D < 1.94999999999999991e-66 or 4.5999999999999999e-37 < D

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

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

      \[\leadsto 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 \color{blue}{\left(D \cdot \left(h \cdot w\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} \]
    5. Taylor expanded in c0 around inf 44.9%

      \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \color{blue}{\frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
    6. Step-by-step derivation
      1. associate-*r/46.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}{c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
    7. Simplified46.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}{c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
    8. Step-by-step derivation
      1. frac-2neg46.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;D \leq 8 \cdot 10^{-288}:\\ \;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\ \mathbf{elif}\;D \leq 1.5 \cdot 10^{-167}:\\ \;\;\;\;c0 \cdot \frac{\frac{c0 \cdot 2}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2}}{2 \cdot w}\\ \mathbf{elif}\;D \leq 1.95 \cdot 10^{-66} \lor \neg \left(D \leq 4.6 \cdot 10^{-37}\right):\\ \;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, c0 \cdot \left(\frac{d}{w \cdot D} \cdot \frac{d}{h \cdot D}\right)\right)}{2 \cdot w}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 45.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\frac{c0}{h}}{w}\\ t_1 := {\left(\frac{d}{D}\right)}^{2}\\ t_2 := c0 \cdot \frac{0}{2 \cdot w}\\ \mathbf{if}\;w \leq -5.2 \cdot 10^{+175}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;w \leq -6.6 \cdot 10^{+17}:\\ \;\;\;\;c0 \cdot \left(t\_0 \cdot \frac{t\_1}{w}\right)\\ \mathbf{elif}\;w \leq -0.0026:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;w \leq 3 \cdot 10^{-111}:\\ \;\;\;\;c0 \cdot \frac{\frac{c0 \cdot 2}{w \cdot h} \cdot t\_1}{2 \cdot w}\\ \mathbf{elif}\;w \leq 1.4 \cdot 10^{-88} \lor \neg \left(w \leq 2.35 \cdot 10^{+107}\right):\\ \;\;\;\;t\_2\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{\left(2 \cdot t\_1\right) \cdot t\_0}{2 \cdot w}\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (let* ((t_0 (/ (/ c0 h) w))
        (t_1 (pow (/ d D) 2.0))
        (t_2 (* c0 (/ 0.0 (* 2.0 w)))))
   (if (<= w -5.2e+175)
     t_2
     (if (<= w -6.6e+17)
       (* c0 (* t_0 (/ t_1 w)))
       (if (<= w -0.0026)
         t_2
         (if (<= w 3e-111)
           (* c0 (/ (* (/ (* c0 2.0) (* w h)) t_1) (* 2.0 w)))
           (if (or (<= w 1.4e-88) (not (<= w 2.35e+107)))
             t_2
             (* c0 (/ (* (* 2.0 t_1) t_0) (* 2.0 w))))))))))
double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = (c0 / h) / w;
	double t_1 = pow((d / D), 2.0);
	double t_2 = c0 * (0.0 / (2.0 * w));
	double tmp;
	if (w <= -5.2e+175) {
		tmp = t_2;
	} else if (w <= -6.6e+17) {
		tmp = c0 * (t_0 * (t_1 / w));
	} else if (w <= -0.0026) {
		tmp = t_2;
	} else if (w <= 3e-111) {
		tmp = c0 * ((((c0 * 2.0) / (w * h)) * t_1) / (2.0 * w));
	} else if ((w <= 1.4e-88) || !(w <= 2.35e+107)) {
		tmp = t_2;
	} else {
		tmp = c0 * (((2.0 * t_1) * t_0) / (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) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_0 = (c0 / h) / w
    t_1 = (d_1 / d) ** 2.0d0
    t_2 = c0 * (0.0d0 / (2.0d0 * w))
    if (w <= (-5.2d+175)) then
        tmp = t_2
    else if (w <= (-6.6d+17)) then
        tmp = c0 * (t_0 * (t_1 / w))
    else if (w <= (-0.0026d0)) then
        tmp = t_2
    else if (w <= 3d-111) then
        tmp = c0 * ((((c0 * 2.0d0) / (w * h)) * t_1) / (2.0d0 * w))
    else if ((w <= 1.4d-88) .or. (.not. (w <= 2.35d+107))) then
        tmp = t_2
    else
        tmp = c0 * (((2.0d0 * t_1) * t_0) / (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 t_0 = (c0 / h) / w;
	double t_1 = Math.pow((d / D), 2.0);
	double t_2 = c0 * (0.0 / (2.0 * w));
	double tmp;
	if (w <= -5.2e+175) {
		tmp = t_2;
	} else if (w <= -6.6e+17) {
		tmp = c0 * (t_0 * (t_1 / w));
	} else if (w <= -0.0026) {
		tmp = t_2;
	} else if (w <= 3e-111) {
		tmp = c0 * ((((c0 * 2.0) / (w * h)) * t_1) / (2.0 * w));
	} else if ((w <= 1.4e-88) || !(w <= 2.35e+107)) {
		tmp = t_2;
	} else {
		tmp = c0 * (((2.0 * t_1) * t_0) / (2.0 * w));
	}
	return tmp;
}
def code(c0, w, h, D, d, M):
	t_0 = (c0 / h) / w
	t_1 = math.pow((d / D), 2.0)
	t_2 = c0 * (0.0 / (2.0 * w))
	tmp = 0
	if w <= -5.2e+175:
		tmp = t_2
	elif w <= -6.6e+17:
		tmp = c0 * (t_0 * (t_1 / w))
	elif w <= -0.0026:
		tmp = t_2
	elif w <= 3e-111:
		tmp = c0 * ((((c0 * 2.0) / (w * h)) * t_1) / (2.0 * w))
	elif (w <= 1.4e-88) or not (w <= 2.35e+107):
		tmp = t_2
	else:
		tmp = c0 * (((2.0 * t_1) * t_0) / (2.0 * w))
	return tmp
function code(c0, w, h, D, d, M)
	t_0 = Float64(Float64(c0 / h) / w)
	t_1 = Float64(d / D) ^ 2.0
	t_2 = Float64(c0 * Float64(0.0 / Float64(2.0 * w)))
	tmp = 0.0
	if (w <= -5.2e+175)
		tmp = t_2;
	elseif (w <= -6.6e+17)
		tmp = Float64(c0 * Float64(t_0 * Float64(t_1 / w)));
	elseif (w <= -0.0026)
		tmp = t_2;
	elseif (w <= 3e-111)
		tmp = Float64(c0 * Float64(Float64(Float64(Float64(c0 * 2.0) / Float64(w * h)) * t_1) / Float64(2.0 * w)));
	elseif ((w <= 1.4e-88) || !(w <= 2.35e+107))
		tmp = t_2;
	else
		tmp = Float64(c0 * Float64(Float64(Float64(2.0 * t_1) * t_0) / Float64(2.0 * w)));
	end
	return tmp
end
function tmp_2 = code(c0, w, h, D, d, M)
	t_0 = (c0 / h) / w;
	t_1 = (d / D) ^ 2.0;
	t_2 = c0 * (0.0 / (2.0 * w));
	tmp = 0.0;
	if (w <= -5.2e+175)
		tmp = t_2;
	elseif (w <= -6.6e+17)
		tmp = c0 * (t_0 * (t_1 / w));
	elseif (w <= -0.0026)
		tmp = t_2;
	elseif (w <= 3e-111)
		tmp = c0 * ((((c0 * 2.0) / (w * h)) * t_1) / (2.0 * w));
	elseif ((w <= 1.4e-88) || ~((w <= 2.35e+107)))
		tmp = t_2;
	else
		tmp = c0 * (((2.0 * t_1) * t_0) / (2.0 * w));
	end
	tmp_2 = tmp;
end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(N[(c0 / h), $MachinePrecision] / w), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(c0 * N[(0.0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[w, -5.2e+175], t$95$2, If[LessEqual[w, -6.6e+17], N[(c0 * N[(t$95$0 * N[(t$95$1 / w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[w, -0.0026], t$95$2, If[LessEqual[w, 3e-111], N[(c0 * N[(N[(N[(N[(c0 * 2.0), $MachinePrecision] / N[(w * h), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[w, 1.4e-88], N[Not[LessEqual[w, 2.35e+107]], $MachinePrecision]], t$95$2, N[(c0 * N[(N[(N[(2.0 * t$95$1), $MachinePrecision] * t$95$0), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\frac{c0}{h}}{w}\\
t_1 := {\left(\frac{d}{D}\right)}^{2}\\
t_2 := c0 \cdot \frac{0}{2 \cdot w}\\
\mathbf{if}\;w \leq -5.2 \cdot 10^{+175}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;w \leq -6.6 \cdot 10^{+17}:\\
\;\;\;\;c0 \cdot \left(t\_0 \cdot \frac{t\_1}{w}\right)\\

\mathbf{elif}\;w \leq -0.0026:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;w \leq 3 \cdot 10^{-111}:\\
\;\;\;\;c0 \cdot \frac{\frac{c0 \cdot 2}{w \cdot h} \cdot t\_1}{2 \cdot w}\\

\mathbf{elif}\;w \leq 1.4 \cdot 10^{-88} \lor \neg \left(w \leq 2.35 \cdot 10^{+107}\right):\\
\;\;\;\;t\_2\\

\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{\left(2 \cdot t\_1\right) \cdot t\_0}{2 \cdot w}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if w < -5.2000000000000001e175 or -6.6e17 < w < -0.0025999999999999999 or 3.00000000000000008e-111 < w < 1.39999999999999988e-88 or 2.35e107 < w

    1. Initial program 16.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. Simplified30.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.2000000000000001e175 < w < -6.6e17

    1. Initial program 27.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. Simplified50.8%

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

      \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \color{blue}{-1 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
    5. Step-by-step derivation
      1. mul-1-neg4.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} \]
    6. Simplified4.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} \]
    7. Step-by-step derivation
      1. associate-/l*4.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}{c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
      2. unpow24.6%

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

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

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

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

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

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

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, -c0 \cdot \color{blue}{\left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)}\right)}{2 \cdot w} \]
      9. add-cbrt-cube9.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}{\sqrt[3]{\left(\left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right) \cdot \left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right)\right) \cdot \left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right)}}\right)}{2 \cdot w} \]
      10. pow1/310.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(\left(\left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right) \cdot \left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right)\right) \cdot \left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right)\right)}^{0.3333333333333333}}\right)}{2 \cdot w} \]
    8. Applied egg-rr5.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({\left(\frac{c0}{{D}^{2}} \cdot \frac{{d}^{2}}{h \cdot w}\right)}^{3}\right)}^{0.3333333333333333}}\right)}{2 \cdot w} \]
    9. Applied egg-rr60.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -0.0025999999999999999 < w < 3.00000000000000008e-111

    1. Initial program 33.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. Simplified58.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, -c0 \cdot \color{blue}{\left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)}\right)}{2 \cdot w} \]
      9. add-cbrt-cube1.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[3]{\left(\left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right) \cdot \left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right)\right) \cdot \left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right)}}\right)}{2 \cdot w} \]
      10. pow1/35.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(\left(\left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right) \cdot \left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right)\right) \cdot \left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right)\right)}^{0.3333333333333333}}\right)}{2 \cdot w} \]
    8. Applied egg-rr3.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(\frac{c0}{{D}^{2}} \cdot \frac{{d}^{2}}{h \cdot w}\right)}^{3}\right)}^{0.3333333333333333}}\right)}{2 \cdot w} \]
    9. Applied egg-rr61.7%

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.39999999999999988e-88 < w < 2.35e107

    1. Initial program 22.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. Simplified52.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 0.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}{-1 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
    5. Step-by-step derivation
      1. mul-1-neg0.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 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
    6. Simplified0.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 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
    7. Step-by-step derivation
      1. associate-/l*3.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}{c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
      2. unpow23.2%

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

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

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

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

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

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

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, -c0 \cdot \color{blue}{\left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)}\right)}{2 \cdot w} \]
      9. add-cbrt-cube0.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[3]{\left(\left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right) \cdot \left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right)\right) \cdot \left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right)}}\right)}{2 \cdot w} \]
      10. pow1/30.7%

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, -\color{blue}{{\left(\left(\left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right) \cdot \left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right)\right) \cdot \left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right)\right)}^{0.3333333333333333}}\right)}{2 \cdot w} \]
    8. Applied egg-rr0.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({\left(\frac{c0}{{D}^{2}} \cdot \frac{{d}^{2}}{h \cdot w}\right)}^{3}\right)}^{0.3333333333333333}}\right)}{2 \cdot w} \]
    9. Applied egg-rr47.3%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;w \leq -5.2 \cdot 10^{+175}:\\ \;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\ \mathbf{elif}\;w \leq -6.6 \cdot 10^{+17}:\\ \;\;\;\;c0 \cdot \left(\frac{\frac{c0}{h}}{w} \cdot \frac{{\left(\frac{d}{D}\right)}^{2}}{w}\right)\\ \mathbf{elif}\;w \leq -0.0026:\\ \;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\ \mathbf{elif}\;w \leq 3 \cdot 10^{-111}:\\ \;\;\;\;c0 \cdot \frac{\frac{c0 \cdot 2}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2}}{2 \cdot w}\\ \mathbf{elif}\;w \leq 1.4 \cdot 10^{-88} \lor \neg \left(w \leq 2.35 \cdot 10^{+107}\right):\\ \;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{\left(2 \cdot {\left(\frac{d}{D}\right)}^{2}\right) \cdot \frac{\frac{c0}{h}}{w}}{2 \cdot w}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 45.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\left(\frac{d}{D}\right)}^{2}\\ t_1 := c0 \cdot \left(\frac{\frac{c0}{h}}{w} \cdot \frac{t\_0}{w}\right)\\ t_2 := c0 \cdot \frac{0}{2 \cdot w}\\ \mathbf{if}\;w \leq -4.6 \cdot 10^{+178}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;w \leq -1.15 \cdot 10^{+14}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;w \leq -0.0028:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;w \leq 4.2 \cdot 10^{-114}:\\ \;\;\;\;c0 \cdot \frac{\frac{c0 \cdot 2}{w \cdot h} \cdot t\_0}{2 \cdot w}\\ \mathbf{elif}\;w \leq 5.5 \cdot 10^{-87} \lor \neg \left(w \leq 1.3 \cdot 10^{+106}\right):\\ \;\;\;\;t\_2\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (let* ((t_0 (pow (/ d D) 2.0))
        (t_1 (* c0 (* (/ (/ c0 h) w) (/ t_0 w))))
        (t_2 (* c0 (/ 0.0 (* 2.0 w)))))
   (if (<= w -4.6e+178)
     t_2
     (if (<= w -1.15e+14)
       t_1
       (if (<= w -0.0028)
         t_2
         (if (<= w 4.2e-114)
           (* c0 (/ (* (/ (* c0 2.0) (* w h)) t_0) (* 2.0 w)))
           (if (or (<= w 5.5e-87) (not (<= w 1.3e+106))) t_2 t_1)))))))
double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = pow((d / D), 2.0);
	double t_1 = c0 * (((c0 / h) / w) * (t_0 / w));
	double t_2 = c0 * (0.0 / (2.0 * w));
	double tmp;
	if (w <= -4.6e+178) {
		tmp = t_2;
	} else if (w <= -1.15e+14) {
		tmp = t_1;
	} else if (w <= -0.0028) {
		tmp = t_2;
	} else if (w <= 4.2e-114) {
		tmp = c0 * ((((c0 * 2.0) / (w * h)) * t_0) / (2.0 * w));
	} else if ((w <= 5.5e-87) || !(w <= 1.3e+106)) {
		tmp = t_2;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(c0, w, h, d, d_1, m)
    real(8), intent (in) :: c0
    real(8), intent (in) :: w
    real(8), intent (in) :: h
    real(8), intent (in) :: d
    real(8), intent (in) :: d_1
    real(8), intent (in) :: m
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_0 = (d_1 / d) ** 2.0d0
    t_1 = c0 * (((c0 / h) / w) * (t_0 / w))
    t_2 = c0 * (0.0d0 / (2.0d0 * w))
    if (w <= (-4.6d+178)) then
        tmp = t_2
    else if (w <= (-1.15d+14)) then
        tmp = t_1
    else if (w <= (-0.0028d0)) then
        tmp = t_2
    else if (w <= 4.2d-114) then
        tmp = c0 * ((((c0 * 2.0d0) / (w * h)) * t_0) / (2.0d0 * w))
    else if ((w <= 5.5d-87) .or. (.not. (w <= 1.3d+106))) then
        tmp = t_2
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = Math.pow((d / D), 2.0);
	double t_1 = c0 * (((c0 / h) / w) * (t_0 / w));
	double t_2 = c0 * (0.0 / (2.0 * w));
	double tmp;
	if (w <= -4.6e+178) {
		tmp = t_2;
	} else if (w <= -1.15e+14) {
		tmp = t_1;
	} else if (w <= -0.0028) {
		tmp = t_2;
	} else if (w <= 4.2e-114) {
		tmp = c0 * ((((c0 * 2.0) / (w * h)) * t_0) / (2.0 * w));
	} else if ((w <= 5.5e-87) || !(w <= 1.3e+106)) {
		tmp = t_2;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(c0, w, h, D, d, M):
	t_0 = math.pow((d / D), 2.0)
	t_1 = c0 * (((c0 / h) / w) * (t_0 / w))
	t_2 = c0 * (0.0 / (2.0 * w))
	tmp = 0
	if w <= -4.6e+178:
		tmp = t_2
	elif w <= -1.15e+14:
		tmp = t_1
	elif w <= -0.0028:
		tmp = t_2
	elif w <= 4.2e-114:
		tmp = c0 * ((((c0 * 2.0) / (w * h)) * t_0) / (2.0 * w))
	elif (w <= 5.5e-87) or not (w <= 1.3e+106):
		tmp = t_2
	else:
		tmp = t_1
	return tmp
function code(c0, w, h, D, d, M)
	t_0 = Float64(d / D) ^ 2.0
	t_1 = Float64(c0 * Float64(Float64(Float64(c0 / h) / w) * Float64(t_0 / w)))
	t_2 = Float64(c0 * Float64(0.0 / Float64(2.0 * w)))
	tmp = 0.0
	if (w <= -4.6e+178)
		tmp = t_2;
	elseif (w <= -1.15e+14)
		tmp = t_1;
	elseif (w <= -0.0028)
		tmp = t_2;
	elseif (w <= 4.2e-114)
		tmp = Float64(c0 * Float64(Float64(Float64(Float64(c0 * 2.0) / Float64(w * h)) * t_0) / Float64(2.0 * w)));
	elseif ((w <= 5.5e-87) || !(w <= 1.3e+106))
		tmp = t_2;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(c0, w, h, D, d, M)
	t_0 = (d / D) ^ 2.0;
	t_1 = c0 * (((c0 / h) / w) * (t_0 / w));
	t_2 = c0 * (0.0 / (2.0 * w));
	tmp = 0.0;
	if (w <= -4.6e+178)
		tmp = t_2;
	elseif (w <= -1.15e+14)
		tmp = t_1;
	elseif (w <= -0.0028)
		tmp = t_2;
	elseif (w <= 4.2e-114)
		tmp = c0 * ((((c0 * 2.0) / (w * h)) * t_0) / (2.0 * w));
	elseif ((w <= 5.5e-87) || ~((w <= 1.3e+106)))
		tmp = t_2;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(c0 * N[(N[(N[(c0 / h), $MachinePrecision] / w), $MachinePrecision] * N[(t$95$0 / w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(c0 * N[(0.0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[w, -4.6e+178], t$95$2, If[LessEqual[w, -1.15e+14], t$95$1, If[LessEqual[w, -0.0028], t$95$2, If[LessEqual[w, 4.2e-114], N[(c0 * N[(N[(N[(N[(c0 * 2.0), $MachinePrecision] / N[(w * h), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[w, 5.5e-87], N[Not[LessEqual[w, 1.3e+106]], $MachinePrecision]], t$95$2, t$95$1]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;w \leq -1.15 \cdot 10^{+14}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;w \leq -0.0028:\\
\;\;\;\;t\_2\\

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

\mathbf{elif}\;w \leq 5.5 \cdot 10^{-87} \lor \neg \left(w \leq 1.3 \cdot 10^{+106}\right):\\
\;\;\;\;t\_2\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if w < -4.6000000000000002e178 or -1.15e14 < w < -0.00279999999999999997 or 4.19999999999999985e-114 < w < 5.5000000000000004e-87 or 1.3000000000000001e106 < w

    1. Initial program 16.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. Simplified30.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.6000000000000002e178 < w < -1.15e14 or 5.5000000000000004e-87 < w < 1.3000000000000001e106

    1. Initial program 24.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. Simplified51.7%

      \[\leadsto \color{blue}{c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right) \cdot \left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right) - M\right)}\right)}{2 \cdot w}} \]
    3. Add Preprocessing
    4. Taylor expanded in c0 around -inf 2.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}{-1 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
    5. Step-by-step derivation
      1. mul-1-neg2.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}{-\frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
    6. Simplified2.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}{-\frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
    7. Step-by-step derivation
      1. associate-/l*3.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}{c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
      2. unpow23.7%

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

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

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

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

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

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

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, -c0 \cdot \color{blue}{\left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)}\right)}{2 \cdot w} \]
      9. add-cbrt-cube3.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[3]{\left(\left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right) \cdot \left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right)\right) \cdot \left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right)}}\right)}{2 \cdot w} \]
      10. pow1/34.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -0.00279999999999999997 < w < 4.19999999999999985e-114

    1. Initial program 33.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. Simplified58.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, -c0 \cdot \color{blue}{\left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)}\right)}{2 \cdot w} \]
      9. add-cbrt-cube1.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[3]{\left(\left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right) \cdot \left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right)\right) \cdot \left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right)}}\right)}{2 \cdot w} \]
      10. pow1/35.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(\left(\left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right) \cdot \left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right)\right) \cdot \left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right)\right)}^{0.3333333333333333}}\right)}{2 \cdot w} \]
    8. Applied egg-rr3.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(\frac{c0}{{D}^{2}} \cdot \frac{{d}^{2}}{h \cdot w}\right)}^{3}\right)}^{0.3333333333333333}}\right)}{2 \cdot w} \]
    9. Applied egg-rr61.7%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;w \leq -4.6 \cdot 10^{+178}:\\ \;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\ \mathbf{elif}\;w \leq -1.15 \cdot 10^{+14}:\\ \;\;\;\;c0 \cdot \left(\frac{\frac{c0}{h}}{w} \cdot \frac{{\left(\frac{d}{D}\right)}^{2}}{w}\right)\\ \mathbf{elif}\;w \leq -0.0028:\\ \;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\ \mathbf{elif}\;w \leq 4.2 \cdot 10^{-114}:\\ \;\;\;\;c0 \cdot \frac{\frac{c0 \cdot 2}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2}}{2 \cdot w}\\ \mathbf{elif}\;w \leq 5.5 \cdot 10^{-87} \lor \neg \left(w \leq 1.3 \cdot 10^{+106}\right):\\ \;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \left(\frac{\frac{c0}{h}}{w} \cdot \frac{{\left(\frac{d}{D}\right)}^{2}}{w}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 45.4% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\left(\frac{d}{D}\right)}^{2}\\ t_1 := c0 \cdot \frac{0}{2 \cdot w}\\ \mathbf{if}\;w \leq -9 \cdot 10^{+176}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;w \leq -3.2 \cdot 10^{+14}:\\ \;\;\;\;c0 \cdot \left(\frac{\frac{c0}{h}}{w} \cdot \frac{t\_0}{w}\right)\\ \mathbf{elif}\;w \leq -0.000125 \lor \neg \left(w \leq 8.2 \cdot 10^{+106}\right):\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{2 \cdot \left(c0 \cdot \frac{t\_0}{w \cdot h}\right)}{2 \cdot w}\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (let* ((t_0 (pow (/ d D) 2.0)) (t_1 (* c0 (/ 0.0 (* 2.0 w)))))
   (if (<= w -9e+176)
     t_1
     (if (<= w -3.2e+14)
       (* c0 (* (/ (/ c0 h) w) (/ t_0 w)))
       (if (or (<= w -0.000125) (not (<= w 8.2e+106)))
         t_1
         (* c0 (/ (* 2.0 (* c0 (/ t_0 (* w h)))) (* 2.0 w))))))))
double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = pow((d / D), 2.0);
	double t_1 = c0 * (0.0 / (2.0 * w));
	double tmp;
	if (w <= -9e+176) {
		tmp = t_1;
	} else if (w <= -3.2e+14) {
		tmp = c0 * (((c0 / h) / w) * (t_0 / w));
	} else if ((w <= -0.000125) || !(w <= 8.2e+106)) {
		tmp = t_1;
	} else {
		tmp = c0 * ((2.0 * (c0 * (t_0 / (w * h)))) / (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) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (d_1 / d) ** 2.0d0
    t_1 = c0 * (0.0d0 / (2.0d0 * w))
    if (w <= (-9d+176)) then
        tmp = t_1
    else if (w <= (-3.2d+14)) then
        tmp = c0 * (((c0 / h) / w) * (t_0 / w))
    else if ((w <= (-0.000125d0)) .or. (.not. (w <= 8.2d+106))) then
        tmp = t_1
    else
        tmp = c0 * ((2.0d0 * (c0 * (t_0 / (w * h)))) / (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 t_0 = Math.pow((d / D), 2.0);
	double t_1 = c0 * (0.0 / (2.0 * w));
	double tmp;
	if (w <= -9e+176) {
		tmp = t_1;
	} else if (w <= -3.2e+14) {
		tmp = c0 * (((c0 / h) / w) * (t_0 / w));
	} else if ((w <= -0.000125) || !(w <= 8.2e+106)) {
		tmp = t_1;
	} else {
		tmp = c0 * ((2.0 * (c0 * (t_0 / (w * h)))) / (2.0 * w));
	}
	return tmp;
}
def code(c0, w, h, D, d, M):
	t_0 = math.pow((d / D), 2.0)
	t_1 = c0 * (0.0 / (2.0 * w))
	tmp = 0
	if w <= -9e+176:
		tmp = t_1
	elif w <= -3.2e+14:
		tmp = c0 * (((c0 / h) / w) * (t_0 / w))
	elif (w <= -0.000125) or not (w <= 8.2e+106):
		tmp = t_1
	else:
		tmp = c0 * ((2.0 * (c0 * (t_0 / (w * h)))) / (2.0 * w))
	return tmp
function code(c0, w, h, D, d, M)
	t_0 = Float64(d / D) ^ 2.0
	t_1 = Float64(c0 * Float64(0.0 / Float64(2.0 * w)))
	tmp = 0.0
	if (w <= -9e+176)
		tmp = t_1;
	elseif (w <= -3.2e+14)
		tmp = Float64(c0 * Float64(Float64(Float64(c0 / h) / w) * Float64(t_0 / w)));
	elseif ((w <= -0.000125) || !(w <= 8.2e+106))
		tmp = t_1;
	else
		tmp = Float64(c0 * Float64(Float64(2.0 * Float64(c0 * Float64(t_0 / Float64(w * h)))) / Float64(2.0 * w)));
	end
	return tmp
end
function tmp_2 = code(c0, w, h, D, d, M)
	t_0 = (d / D) ^ 2.0;
	t_1 = c0 * (0.0 / (2.0 * w));
	tmp = 0.0;
	if (w <= -9e+176)
		tmp = t_1;
	elseif (w <= -3.2e+14)
		tmp = c0 * (((c0 / h) / w) * (t_0 / w));
	elseif ((w <= -0.000125) || ~((w <= 8.2e+106)))
		tmp = t_1;
	else
		tmp = c0 * ((2.0 * (c0 * (t_0 / (w * h)))) / (2.0 * w));
	end
	tmp_2 = tmp;
end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(c0 * N[(0.0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[w, -9e+176], t$95$1, If[LessEqual[w, -3.2e+14], N[(c0 * N[(N[(N[(c0 / h), $MachinePrecision] / w), $MachinePrecision] * N[(t$95$0 / w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[w, -0.000125], N[Not[LessEqual[w, 8.2e+106]], $MachinePrecision]], t$95$1, N[(c0 * N[(N[(2.0 * N[(c0 * N[(t$95$0 / N[(w * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;w \leq -3.2 \cdot 10^{+14}:\\
\;\;\;\;c0 \cdot \left(\frac{\frac{c0}{h}}{w} \cdot \frac{t\_0}{w}\right)\\

\mathbf{elif}\;w \leq -0.000125 \lor \neg \left(w \leq 8.2 \cdot 10^{+106}\right):\\
\;\;\;\;t\_1\\

\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{2 \cdot \left(c0 \cdot \frac{t\_0}{w \cdot h}\right)}{2 \cdot w}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if w < -9.00000000000000007e176 or -3.2e14 < w < -1.25e-4 or 8.2000000000000005e106 < w

    1. Initial program 15.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. Simplified33.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 5.7%

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.00000000000000007e176 < w < -3.2e14

    1. Initial program 27.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. Simplified50.8%

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

      \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \color{blue}{-1 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
    5. Step-by-step derivation
      1. mul-1-neg4.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} \]
    6. Simplified4.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} \]
    7. Step-by-step derivation
      1. associate-/l*4.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}{c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
      2. unpow24.6%

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

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

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

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

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

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

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, -c0 \cdot \color{blue}{\left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)}\right)}{2 \cdot w} \]
      9. add-cbrt-cube9.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}{\sqrt[3]{\left(\left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right) \cdot \left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right)\right) \cdot \left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right)}}\right)}{2 \cdot w} \]
      10. pow1/310.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(\left(\left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right) \cdot \left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right)\right) \cdot \left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right)\right)}^{0.3333333333333333}}\right)}{2 \cdot w} \]
    8. Applied egg-rr5.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({\left(\frac{c0}{{D}^{2}} \cdot \frac{{d}^{2}}{h \cdot w}\right)}^{3}\right)}^{0.3333333333333333}}\right)}{2 \cdot w} \]
    9. Applied egg-rr60.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.25e-4 < w < 8.2000000000000005e106

    1. Initial program 30.1%

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

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

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

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

      \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \color{blue}{-\frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
    7. Step-by-step derivation
      1. associate-/l*1.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}{c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
      2. unpow21.6%

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

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

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

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

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

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

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, -c0 \cdot \color{blue}{\left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)}\right)}{2 \cdot w} \]
      9. add-cbrt-cube1.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}{\sqrt[3]{\left(\left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right) \cdot \left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right)\right) \cdot \left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right)}}\right)}{2 \cdot w} \]
      10. pow1/34.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(\left(\left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right) \cdot \left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right)\right) \cdot \left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right)\right)}^{0.3333333333333333}}\right)}{2 \cdot w} \]
    8. Applied egg-rr3.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({\left(\frac{c0}{{D}^{2}} \cdot \frac{{d}^{2}}{h \cdot w}\right)}^{3}\right)}^{0.3333333333333333}}\right)}{2 \cdot w} \]
    9. Applied egg-rr56.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;w \leq -9 \cdot 10^{+176}:\\ \;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\ \mathbf{elif}\;w \leq -3.2 \cdot 10^{+14}:\\ \;\;\;\;c0 \cdot \left(\frac{\frac{c0}{h}}{w} \cdot \frac{{\left(\frac{d}{D}\right)}^{2}}{w}\right)\\ \mathbf{elif}\;w \leq -0.000125 \lor \neg \left(w \leq 8.2 \cdot 10^{+106}\right):\\ \;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{2 \cdot \left(c0 \cdot \frac{{\left(\frac{d}{D}\right)}^{2}}{w \cdot h}\right)}{2 \cdot w}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 37.8% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;D \leq 2.9 \cdot 10^{-273} \lor \neg \left(D \leq 10^{-65}\right) \land D \leq 2.65 \cdot 10^{-45}:\\ \;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{\frac{1}{h \cdot \frac{w}{c0}} \cdot \left(2 \cdot {\left(\frac{d}{D}\right)}^{2}\right)}{2 \cdot w}\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (if (or (<= D 2.9e-273) (and (not (<= D 1e-65)) (<= D 2.65e-45)))
   (* c0 (/ 0.0 (* 2.0 w)))
   (* c0 (/ (* (/ 1.0 (* h (/ w c0))) (* 2.0 (pow (/ d D) 2.0))) (* 2.0 w)))))
double code(double c0, double w, double h, double D, double d, double M) {
	double tmp;
	if ((D <= 2.9e-273) || (!(D <= 1e-65) && (D <= 2.65e-45))) {
		tmp = c0 * (0.0 / (2.0 * w));
	} else {
		tmp = c0 * (((1.0 / (h * (w / c0))) * (2.0 * pow((d / D), 2.0))) / (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 ((d <= 2.9d-273) .or. (.not. (d <= 1d-65)) .and. (d <= 2.65d-45)) then
        tmp = c0 * (0.0d0 / (2.0d0 * w))
    else
        tmp = c0 * (((1.0d0 / (h * (w / c0))) * (2.0d0 * ((d_1 / d) ** 2.0d0))) / (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 ((D <= 2.9e-273) || (!(D <= 1e-65) && (D <= 2.65e-45))) {
		tmp = c0 * (0.0 / (2.0 * w));
	} else {
		tmp = c0 * (((1.0 / (h * (w / c0))) * (2.0 * Math.pow((d / D), 2.0))) / (2.0 * w));
	}
	return tmp;
}
def code(c0, w, h, D, d, M):
	tmp = 0
	if (D <= 2.9e-273) or (not (D <= 1e-65) and (D <= 2.65e-45)):
		tmp = c0 * (0.0 / (2.0 * w))
	else:
		tmp = c0 * (((1.0 / (h * (w / c0))) * (2.0 * math.pow((d / D), 2.0))) / (2.0 * w))
	return tmp
function code(c0, w, h, D, d, M)
	tmp = 0.0
	if ((D <= 2.9e-273) || (!(D <= 1e-65) && (D <= 2.65e-45)))
		tmp = Float64(c0 * Float64(0.0 / Float64(2.0 * w)));
	else
		tmp = Float64(c0 * Float64(Float64(Float64(1.0 / Float64(h * Float64(w / c0))) * Float64(2.0 * (Float64(d / D) ^ 2.0))) / Float64(2.0 * w)));
	end
	return tmp
end
function tmp_2 = code(c0, w, h, D, d, M)
	tmp = 0.0;
	if ((D <= 2.9e-273) || (~((D <= 1e-65)) && (D <= 2.65e-45)))
		tmp = c0 * (0.0 / (2.0 * w));
	else
		tmp = c0 * (((1.0 / (h * (w / c0))) * (2.0 * ((d / D) ^ 2.0))) / (2.0 * w));
	end
	tmp_2 = tmp;
end
code[c0_, w_, h_, D_, d_, M_] := If[Or[LessEqual[D, 2.9e-273], And[N[Not[LessEqual[D, 1e-65]], $MachinePrecision], LessEqual[D, 2.65e-45]]], N[(c0 * N[(0.0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(N[(N[(1.0 / N[(h * N[(w / c0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(2.0 * N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;D \leq 2.9 \cdot 10^{-273} \lor \neg \left(D \leq 10^{-65}\right) \land D \leq 2.65 \cdot 10^{-45}:\\
\;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if D < 2.89999999999999986e-273 or 9.99999999999999923e-66 < D < 2.6499999999999999e-45

    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. Simplified45.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 3.6%

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.89999999999999986e-273 < D < 9.99999999999999923e-66 or 2.6499999999999999e-45 < D

    1. Initial program 27.1%

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

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

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

      \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \color{blue}{-\frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
    7. Step-by-step derivation
      1. associate-/l*2.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}{c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
      2. unpow22.8%

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

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

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

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

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

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

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, -c0 \cdot \color{blue}{\left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)}\right)}{2 \cdot w} \]
      9. add-cbrt-cube6.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[3]{\left(\left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right) \cdot \left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right)\right) \cdot \left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right)}}\right)}{2 \cdot w} \]
      10. pow1/38.7%

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, -\color{blue}{{\left(\left(\left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right) \cdot \left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right)\right) \cdot \left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right)\right)}^{0.3333333333333333}}\right)}{2 \cdot w} \]
    8. Applied egg-rr3.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({\left(\frac{c0}{{D}^{2}} \cdot \frac{{d}^{2}}{h \cdot w}\right)}^{3}\right)}^{0.3333333333333333}}\right)}{2 \cdot w} \]
    9. Applied egg-rr53.0%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;D \leq 2.9 \cdot 10^{-273} \lor \neg \left(D \leq 10^{-65}\right) \land D \leq 2.65 \cdot 10^{-45}:\\ \;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{\frac{1}{h \cdot \frac{w}{c0}} \cdot \left(2 \cdot {\left(\frac{d}{D}\right)}^{2}\right)}{2 \cdot w}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 37.2% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;D \leq 3.1 \cdot 10^{-273} \lor \neg \left(D \leq 1.35 \cdot 10^{-65}\right) \land D \leq 3.3 \cdot 10^{-45}:\\
\;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if D < 3.09999999999999988e-273 or 1.3499999999999999e-65 < D < 3.3000000000000001e-45

    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. Simplified45.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 3.6%

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.09999999999999988e-273 < D < 1.3499999999999999e-65 or 3.3000000000000001e-45 < D

    1. Initial program 27.1%

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

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

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

      \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \color{blue}{-\frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
    7. Step-by-step derivation
      1. associate-/l*2.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}{c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
      2. unpow22.8%

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

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

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

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

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

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

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, -c0 \cdot \color{blue}{\left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)}\right)}{2 \cdot w} \]
      9. add-cbrt-cube6.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[3]{\left(\left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right) \cdot \left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right)\right) \cdot \left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right)}}\right)}{2 \cdot w} \]
      10. pow1/38.7%

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, -\color{blue}{{\left(\left(\left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right) \cdot \left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right)\right) \cdot \left(c0 \cdot \left(d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\right)\right)\right)}^{0.3333333333333333}}\right)}{2 \cdot w} \]
    8. Applied egg-rr3.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({\left(\frac{c0}{{D}^{2}} \cdot \frac{{d}^{2}}{h \cdot w}\right)}^{3}\right)}^{0.3333333333333333}}\right)}{2 \cdot w} \]
    9. Applied egg-rr53.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;D \leq 3.1 \cdot 10^{-273} \lor \neg \left(D \leq 1.35 \cdot 10^{-65}\right) \land D \leq 3.3 \cdot 10^{-45}:\\ \;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \left(\frac{\frac{c0}{h}}{w} \cdot \frac{{\left(\frac{d}{D}\right)}^{2}}{w}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 34.0% 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 26.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. Simplified48.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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