Henrywood and Agarwal, Equation (13)

Percentage Accurate: 24.9% → 41.3%
Time: 33.6s
Alternatives: 9
Speedup: 30.2×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 9 alternatives:

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

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

\[\begin{array}{l} M_m = \left|M\right| \\ \begin{array}{l} t_0 := h \cdot {w}^{2}\\ t_1 := c0 \cdot \frac{d}{D}\\ t_2 := c0 \cdot \frac{0}{w}\\ \mathbf{if}\;M\_m \leq 1.85 \cdot 10^{-221}:\\ \;\;\;\;c0 \cdot \frac{\frac{c0 \cdot d}{D} \cdot \frac{d}{D}}{t\_0}\\ \mathbf{elif}\;M\_m \leq 1.55 \cdot 10^{-70}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;M\_m \leq 17000:\\ \;\;\;\;c0 \cdot \left(\frac{t\_1}{h} \cdot \frac{\frac{d}{D}}{{w}^{2}}\right)\\ \mathbf{elif}\;M\_m \leq 6.3 \cdot 10^{+32}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;M\_m \leq 6 \cdot 10^{+68}:\\ \;\;\;\;c0 \cdot \frac{\frac{d}{D} \cdot t\_1}{t\_0}\\ \mathbf{elif}\;M\_m \leq 9.2 \cdot 10^{+111}:\\ \;\;\;\;t\_2\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(M\_m + \frac{\frac{c0}{w} \cdot {\left(\frac{d}{D}\right)}^{2}}{h}\right)\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
(FPCore (c0 w h D d M_m)
 :precision binary64
 (let* ((t_0 (* h (pow w 2.0))) (t_1 (* c0 (/ d D))) (t_2 (* c0 (/ 0.0 w))))
   (if (<= M_m 1.85e-221)
     (* c0 (/ (* (/ (* c0 d) D) (/ d D)) t_0))
     (if (<= M_m 1.55e-70)
       t_2
       (if (<= M_m 17000.0)
         (* c0 (* (/ t_1 h) (/ (/ d D) (pow w 2.0))))
         (if (<= M_m 6.3e+32)
           t_2
           (if (<= M_m 6e+68)
             (* c0 (/ (* (/ d D) t_1) t_0))
             (if (<= M_m 9.2e+111)
               t_2
               (*
                (/ c0 (* 2.0 w))
                (+ M_m (/ (* (/ c0 w) (pow (/ d D) 2.0)) h)))))))))))
M_m = fabs(M);
double code(double c0, double w, double h, double D, double d, double M_m) {
	double t_0 = h * pow(w, 2.0);
	double t_1 = c0 * (d / D);
	double t_2 = c0 * (0.0 / w);
	double tmp;
	if (M_m <= 1.85e-221) {
		tmp = c0 * ((((c0 * d) / D) * (d / D)) / t_0);
	} else if (M_m <= 1.55e-70) {
		tmp = t_2;
	} else if (M_m <= 17000.0) {
		tmp = c0 * ((t_1 / h) * ((d / D) / pow(w, 2.0)));
	} else if (M_m <= 6.3e+32) {
		tmp = t_2;
	} else if (M_m <= 6e+68) {
		tmp = c0 * (((d / D) * t_1) / t_0);
	} else if (M_m <= 9.2e+111) {
		tmp = t_2;
	} else {
		tmp = (c0 / (2.0 * w)) * (M_m + (((c0 / w) * pow((d / D), 2.0)) / h));
	}
	return tmp;
}
M_m = abs(m)
real(8) function code(c0, w, h, d, d_1, m_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_m
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_0 = h * (w ** 2.0d0)
    t_1 = c0 * (d_1 / d)
    t_2 = c0 * (0.0d0 / w)
    if (m_m <= 1.85d-221) then
        tmp = c0 * ((((c0 * d_1) / d) * (d_1 / d)) / t_0)
    else if (m_m <= 1.55d-70) then
        tmp = t_2
    else if (m_m <= 17000.0d0) then
        tmp = c0 * ((t_1 / h) * ((d_1 / d) / (w ** 2.0d0)))
    else if (m_m <= 6.3d+32) then
        tmp = t_2
    else if (m_m <= 6d+68) then
        tmp = c0 * (((d_1 / d) * t_1) / t_0)
    else if (m_m <= 9.2d+111) then
        tmp = t_2
    else
        tmp = (c0 / (2.0d0 * w)) * (m_m + (((c0 / w) * ((d_1 / d) ** 2.0d0)) / h))
    end if
    code = tmp
end function
M_m = Math.abs(M);
public static double code(double c0, double w, double h, double D, double d, double M_m) {
	double t_0 = h * Math.pow(w, 2.0);
	double t_1 = c0 * (d / D);
	double t_2 = c0 * (0.0 / w);
	double tmp;
	if (M_m <= 1.85e-221) {
		tmp = c0 * ((((c0 * d) / D) * (d / D)) / t_0);
	} else if (M_m <= 1.55e-70) {
		tmp = t_2;
	} else if (M_m <= 17000.0) {
		tmp = c0 * ((t_1 / h) * ((d / D) / Math.pow(w, 2.0)));
	} else if (M_m <= 6.3e+32) {
		tmp = t_2;
	} else if (M_m <= 6e+68) {
		tmp = c0 * (((d / D) * t_1) / t_0);
	} else if (M_m <= 9.2e+111) {
		tmp = t_2;
	} else {
		tmp = (c0 / (2.0 * w)) * (M_m + (((c0 / w) * Math.pow((d / D), 2.0)) / h));
	}
	return tmp;
}
M_m = math.fabs(M)
def code(c0, w, h, D, d, M_m):
	t_0 = h * math.pow(w, 2.0)
	t_1 = c0 * (d / D)
	t_2 = c0 * (0.0 / w)
	tmp = 0
	if M_m <= 1.85e-221:
		tmp = c0 * ((((c0 * d) / D) * (d / D)) / t_0)
	elif M_m <= 1.55e-70:
		tmp = t_2
	elif M_m <= 17000.0:
		tmp = c0 * ((t_1 / h) * ((d / D) / math.pow(w, 2.0)))
	elif M_m <= 6.3e+32:
		tmp = t_2
	elif M_m <= 6e+68:
		tmp = c0 * (((d / D) * t_1) / t_0)
	elif M_m <= 9.2e+111:
		tmp = t_2
	else:
		tmp = (c0 / (2.0 * w)) * (M_m + (((c0 / w) * math.pow((d / D), 2.0)) / h))
	return tmp
M_m = abs(M)
function code(c0, w, h, D, d, M_m)
	t_0 = Float64(h * (w ^ 2.0))
	t_1 = Float64(c0 * Float64(d / D))
	t_2 = Float64(c0 * Float64(0.0 / w))
	tmp = 0.0
	if (M_m <= 1.85e-221)
		tmp = Float64(c0 * Float64(Float64(Float64(Float64(c0 * d) / D) * Float64(d / D)) / t_0));
	elseif (M_m <= 1.55e-70)
		tmp = t_2;
	elseif (M_m <= 17000.0)
		tmp = Float64(c0 * Float64(Float64(t_1 / h) * Float64(Float64(d / D) / (w ^ 2.0))));
	elseif (M_m <= 6.3e+32)
		tmp = t_2;
	elseif (M_m <= 6e+68)
		tmp = Float64(c0 * Float64(Float64(Float64(d / D) * t_1) / t_0));
	elseif (M_m <= 9.2e+111)
		tmp = t_2;
	else
		tmp = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(M_m + Float64(Float64(Float64(c0 / w) * (Float64(d / D) ^ 2.0)) / h)));
	end
	return tmp
end
M_m = abs(M);
function tmp_2 = code(c0, w, h, D, d, M_m)
	t_0 = h * (w ^ 2.0);
	t_1 = c0 * (d / D);
	t_2 = c0 * (0.0 / w);
	tmp = 0.0;
	if (M_m <= 1.85e-221)
		tmp = c0 * ((((c0 * d) / D) * (d / D)) / t_0);
	elseif (M_m <= 1.55e-70)
		tmp = t_2;
	elseif (M_m <= 17000.0)
		tmp = c0 * ((t_1 / h) * ((d / D) / (w ^ 2.0)));
	elseif (M_m <= 6.3e+32)
		tmp = t_2;
	elseif (M_m <= 6e+68)
		tmp = c0 * (((d / D) * t_1) / t_0);
	elseif (M_m <= 9.2e+111)
		tmp = t_2;
	else
		tmp = (c0 / (2.0 * w)) * (M_m + (((c0 / w) * ((d / D) ^ 2.0)) / h));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
code[c0_, w_, h_, D_, d_, M$95$m_] := Block[{t$95$0 = N[(h * N[Power[w, 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(c0 * N[(d / D), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(c0 * N[(0.0 / w), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[M$95$m, 1.85e-221], N[(c0 * N[(N[(N[(N[(c0 * d), $MachinePrecision] / D), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[M$95$m, 1.55e-70], t$95$2, If[LessEqual[M$95$m, 17000.0], N[(c0 * N[(N[(t$95$1 / h), $MachinePrecision] * N[(N[(d / D), $MachinePrecision] / N[Power[w, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[M$95$m, 6.3e+32], t$95$2, If[LessEqual[M$95$m, 6e+68], N[(c0 * N[(N[(N[(d / D), $MachinePrecision] * t$95$1), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[M$95$m, 9.2e+111], t$95$2, N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(M$95$m + N[(N[(N[(c0 / w), $MachinePrecision] * N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
M_m = \left|M\right|

\\
\begin{array}{l}
t_0 := h \cdot {w}^{2}\\
t_1 := c0 \cdot \frac{d}{D}\\
t_2 := c0 \cdot \frac{0}{w}\\
\mathbf{if}\;M\_m \leq 1.85 \cdot 10^{-221}:\\
\;\;\;\;c0 \cdot \frac{\frac{c0 \cdot d}{D} \cdot \frac{d}{D}}{t\_0}\\

\mathbf{elif}\;M\_m \leq 1.55 \cdot 10^{-70}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;M\_m \leq 17000:\\
\;\;\;\;c0 \cdot \left(\frac{t\_1}{h} \cdot \frac{\frac{d}{D}}{{w}^{2}}\right)\\

\mathbf{elif}\;M\_m \leq 6.3 \cdot 10^{+32}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;M\_m \leq 6 \cdot 10^{+68}:\\
\;\;\;\;c0 \cdot \frac{\frac{d}{D} \cdot t\_1}{t\_0}\\

\mathbf{elif}\;M\_m \leq 9.2 \cdot 10^{+111}:\\
\;\;\;\;t\_2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if M < 1.84999999999999993e-221

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

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

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

        \[\leadsto c0 \cdot \color{blue}{\frac{\frac{c0 \cdot {d}^{2}}{{D}^{2}}}{h \cdot {w}^{2}}} \]
    6. Simplified30.5%

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

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

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

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

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

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

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

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

    if 1.84999999999999993e-221 < M < 1.55e-70 or 17000 < M < 6.3000000000000002e32 or 6.0000000000000004e68 < M < 9.20000000000000008e111

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

      \[\leadsto c0 \cdot \color{blue}{\left(-0.5 \cdot \frac{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)}{w}\right)} \]
    5. Step-by-step derivation
      1. associate-*r/9.2%

        \[\leadsto c0 \cdot \color{blue}{\frac{-0.5 \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)}{w}} \]
      2. distribute-lft-in7.4%

        \[\leadsto c0 \cdot \frac{-0.5 \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)}}{w} \]
      3. mul-1-neg7.4%

        \[\leadsto c0 \cdot \frac{-0.5 \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)}{w} \]
      4. distribute-rgt-neg-in7.4%

        \[\leadsto c0 \cdot \frac{-0.5 \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)}{w} \]
      5. associate-/l*5.5%

        \[\leadsto c0 \cdot \frac{-0.5 \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)}{w} \]
      6. mul-1-neg5.5%

        \[\leadsto c0 \cdot \frac{-0.5 \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)}{w} \]
      7. associate-/l*7.2%

        \[\leadsto c0 \cdot \frac{-0.5 \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)}{w} \]
      8. distribute-lft1-in7.2%

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

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

        \[\leadsto c0 \cdot \frac{-0.5 \cdot \color{blue}{0}}{w} \]
      11. metadata-eval55.7%

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

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

    if 1.55e-70 < M < 17000

    1. Initial program 47.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. Simplified64.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 44.6%

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

        \[\leadsto c0 \cdot \color{blue}{\frac{\frac{c0 \cdot {d}^{2}}{{D}^{2}}}{h \cdot {w}^{2}}} \]
    6. Simplified47.4%

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

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

        \[\leadsto c0 \cdot \frac{c0 \cdot \frac{\color{blue}{d \cdot d}}{{D}^{2}}}{h \cdot {w}^{2}} \]
      3. unpow247.5%

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

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

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

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

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

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

    if 6.3000000000000002e32 < M < 6.0000000000000004e68

    1. Initial program 30.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. Simplified31.9%

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

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

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

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

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

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

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

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

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

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

    if 9.20000000000000008e111 < M

    1. Initial program 7.7%

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

      \[\leadsto \color{blue}{\frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D} + \sqrt{\left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}\right) \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}\right) - M \cdot M}\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. *-commutative7.7%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\frac{c0}{w}}{h} \cdot {\left(\frac{d}{D}\right)}^{2} + \sqrt{\left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2}\right) \cdot \left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2}\right) - \color{blue}{M \cdot M}}\right) \]
      6. difference-of-squares42.5%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\frac{c0}{w}}{h} \cdot {\left(\frac{d}{D}\right)}^{2} + \sqrt{\color{blue}{\left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2} + M\right) \cdot \left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2} - M\right)}}\right) \]
      7. add-sqr-sqrt42.5%

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\frac{c0}{w}}{h} \cdot {\left(\frac{d}{D}\right)}^{2} + \sqrt{\left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2} + \color{blue}{\sqrt{-M} \cdot \sqrt{-M}}\right) \cdot \left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2} - M\right)}\right) \]
      11. add-sqr-sqrt42.5%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 1.85 \cdot 10^{-221}:\\ \;\;\;\;c0 \cdot \frac{\frac{c0 \cdot d}{D} \cdot \frac{d}{D}}{h \cdot {w}^{2}}\\ \mathbf{elif}\;M \leq 1.55 \cdot 10^{-70}:\\ \;\;\;\;c0 \cdot \frac{0}{w}\\ \mathbf{elif}\;M \leq 17000:\\ \;\;\;\;c0 \cdot \left(\frac{c0 \cdot \frac{d}{D}}{h} \cdot \frac{\frac{d}{D}}{{w}^{2}}\right)\\ \mathbf{elif}\;M \leq 6.3 \cdot 10^{+32}:\\ \;\;\;\;c0 \cdot \frac{0}{w}\\ \mathbf{elif}\;M \leq 6 \cdot 10^{+68}:\\ \;\;\;\;c0 \cdot \frac{\frac{d}{D} \cdot \left(c0 \cdot \frac{d}{D}\right)}{h \cdot {w}^{2}}\\ \mathbf{elif}\;M \leq 9.2 \cdot 10^{+111}:\\ \;\;\;\;c0 \cdot \frac{0}{w}\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(M + \frac{\frac{c0}{w} \cdot {\left(\frac{d}{D}\right)}^{2}}{h}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 54.7% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 76.7%

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

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

    1. Initial program 0.0%

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

      \[\leadsto c0 \cdot \color{blue}{\left(-0.5 \cdot \frac{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)}{w}\right)} \]
    5. Step-by-step derivation
      1. associate-*r/0.9%

        \[\leadsto c0 \cdot \color{blue}{\frac{-0.5 \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)}{w}} \]
      2. distribute-lft-in0.2%

        \[\leadsto c0 \cdot \frac{-0.5 \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)}}{w} \]
      3. mul-1-neg0.2%

        \[\leadsto c0 \cdot \frac{-0.5 \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)}{w} \]
      4. distribute-rgt-neg-in0.2%

        \[\leadsto c0 \cdot \frac{-0.5 \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)}{w} \]
      5. associate-/l*0.7%

        \[\leadsto c0 \cdot \frac{-0.5 \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)}{w} \]
      6. mul-1-neg0.7%

        \[\leadsto c0 \cdot \frac{-0.5 \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)}{w} \]
      7. associate-/l*0.1%

        \[\leadsto c0 \cdot \frac{-0.5 \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)}{w} \]
      8. distribute-lft1-in0.1%

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

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

        \[\leadsto c0 \cdot \frac{-0.5 \cdot \color{blue}{0}}{w} \]
      11. metadata-eval43.5%

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

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

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

Alternative 3: 41.1% accurate, 1.0× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ \begin{array}{l} t_0 := h \cdot {w}^{2}\\ t_1 := c0 \cdot \frac{d}{D}\\ t_2 := c0 \cdot \frac{0}{w}\\ \mathbf{if}\;M\_m \leq 2.4 \cdot 10^{-221}:\\ \;\;\;\;c0 \cdot \frac{\frac{c0 \cdot d}{D} \cdot \frac{d}{D}}{t\_0}\\ \mathbf{elif}\;M\_m \leq 2.05 \cdot 10^{-69}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;M\_m \leq 18000:\\ \;\;\;\;c0 \cdot \left(\frac{t\_1}{h} \cdot \frac{\frac{d}{D}}{{w}^{2}}\right)\\ \mathbf{elif}\;M\_m \leq 3.6 \cdot 10^{+32}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;M\_m \leq 2.05 \cdot 10^{+65}:\\ \;\;\;\;c0 \cdot \frac{\frac{d}{D} \cdot t\_1}{t\_0}\\ \mathbf{elif}\;M\_m \leq 1.6 \cdot 10^{+111}:\\ \;\;\;\;t\_2\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(M\_m + {\left(\frac{d}{D}\right)}^{2} \cdot \frac{\frac{c0}{w}}{h}\right)\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
(FPCore (c0 w h D d M_m)
 :precision binary64
 (let* ((t_0 (* h (pow w 2.0))) (t_1 (* c0 (/ d D))) (t_2 (* c0 (/ 0.0 w))))
   (if (<= M_m 2.4e-221)
     (* c0 (/ (* (/ (* c0 d) D) (/ d D)) t_0))
     (if (<= M_m 2.05e-69)
       t_2
       (if (<= M_m 18000.0)
         (* c0 (* (/ t_1 h) (/ (/ d D) (pow w 2.0))))
         (if (<= M_m 3.6e+32)
           t_2
           (if (<= M_m 2.05e+65)
             (* c0 (/ (* (/ d D) t_1) t_0))
             (if (<= M_m 1.6e+111)
               t_2
               (*
                (/ c0 (* 2.0 w))
                (+ M_m (* (pow (/ d D) 2.0) (/ (/ c0 w) h))))))))))))
M_m = fabs(M);
double code(double c0, double w, double h, double D, double d, double M_m) {
	double t_0 = h * pow(w, 2.0);
	double t_1 = c0 * (d / D);
	double t_2 = c0 * (0.0 / w);
	double tmp;
	if (M_m <= 2.4e-221) {
		tmp = c0 * ((((c0 * d) / D) * (d / D)) / t_0);
	} else if (M_m <= 2.05e-69) {
		tmp = t_2;
	} else if (M_m <= 18000.0) {
		tmp = c0 * ((t_1 / h) * ((d / D) / pow(w, 2.0)));
	} else if (M_m <= 3.6e+32) {
		tmp = t_2;
	} else if (M_m <= 2.05e+65) {
		tmp = c0 * (((d / D) * t_1) / t_0);
	} else if (M_m <= 1.6e+111) {
		tmp = t_2;
	} else {
		tmp = (c0 / (2.0 * w)) * (M_m + (pow((d / D), 2.0) * ((c0 / w) / h)));
	}
	return tmp;
}
M_m = abs(m)
real(8) function code(c0, w, h, d, d_1, m_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_m
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_0 = h * (w ** 2.0d0)
    t_1 = c0 * (d_1 / d)
    t_2 = c0 * (0.0d0 / w)
    if (m_m <= 2.4d-221) then
        tmp = c0 * ((((c0 * d_1) / d) * (d_1 / d)) / t_0)
    else if (m_m <= 2.05d-69) then
        tmp = t_2
    else if (m_m <= 18000.0d0) then
        tmp = c0 * ((t_1 / h) * ((d_1 / d) / (w ** 2.0d0)))
    else if (m_m <= 3.6d+32) then
        tmp = t_2
    else if (m_m <= 2.05d+65) then
        tmp = c0 * (((d_1 / d) * t_1) / t_0)
    else if (m_m <= 1.6d+111) then
        tmp = t_2
    else
        tmp = (c0 / (2.0d0 * w)) * (m_m + (((d_1 / d) ** 2.0d0) * ((c0 / w) / h)))
    end if
    code = tmp
end function
M_m = Math.abs(M);
public static double code(double c0, double w, double h, double D, double d, double M_m) {
	double t_0 = h * Math.pow(w, 2.0);
	double t_1 = c0 * (d / D);
	double t_2 = c0 * (0.0 / w);
	double tmp;
	if (M_m <= 2.4e-221) {
		tmp = c0 * ((((c0 * d) / D) * (d / D)) / t_0);
	} else if (M_m <= 2.05e-69) {
		tmp = t_2;
	} else if (M_m <= 18000.0) {
		tmp = c0 * ((t_1 / h) * ((d / D) / Math.pow(w, 2.0)));
	} else if (M_m <= 3.6e+32) {
		tmp = t_2;
	} else if (M_m <= 2.05e+65) {
		tmp = c0 * (((d / D) * t_1) / t_0);
	} else if (M_m <= 1.6e+111) {
		tmp = t_2;
	} else {
		tmp = (c0 / (2.0 * w)) * (M_m + (Math.pow((d / D), 2.0) * ((c0 / w) / h)));
	}
	return tmp;
}
M_m = math.fabs(M)
def code(c0, w, h, D, d, M_m):
	t_0 = h * math.pow(w, 2.0)
	t_1 = c0 * (d / D)
	t_2 = c0 * (0.0 / w)
	tmp = 0
	if M_m <= 2.4e-221:
		tmp = c0 * ((((c0 * d) / D) * (d / D)) / t_0)
	elif M_m <= 2.05e-69:
		tmp = t_2
	elif M_m <= 18000.0:
		tmp = c0 * ((t_1 / h) * ((d / D) / math.pow(w, 2.0)))
	elif M_m <= 3.6e+32:
		tmp = t_2
	elif M_m <= 2.05e+65:
		tmp = c0 * (((d / D) * t_1) / t_0)
	elif M_m <= 1.6e+111:
		tmp = t_2
	else:
		tmp = (c0 / (2.0 * w)) * (M_m + (math.pow((d / D), 2.0) * ((c0 / w) / h)))
	return tmp
M_m = abs(M)
function code(c0, w, h, D, d, M_m)
	t_0 = Float64(h * (w ^ 2.0))
	t_1 = Float64(c0 * Float64(d / D))
	t_2 = Float64(c0 * Float64(0.0 / w))
	tmp = 0.0
	if (M_m <= 2.4e-221)
		tmp = Float64(c0 * Float64(Float64(Float64(Float64(c0 * d) / D) * Float64(d / D)) / t_0));
	elseif (M_m <= 2.05e-69)
		tmp = t_2;
	elseif (M_m <= 18000.0)
		tmp = Float64(c0 * Float64(Float64(t_1 / h) * Float64(Float64(d / D) / (w ^ 2.0))));
	elseif (M_m <= 3.6e+32)
		tmp = t_2;
	elseif (M_m <= 2.05e+65)
		tmp = Float64(c0 * Float64(Float64(Float64(d / D) * t_1) / t_0));
	elseif (M_m <= 1.6e+111)
		tmp = t_2;
	else
		tmp = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(M_m + Float64((Float64(d / D) ^ 2.0) * Float64(Float64(c0 / w) / h))));
	end
	return tmp
end
M_m = abs(M);
function tmp_2 = code(c0, w, h, D, d, M_m)
	t_0 = h * (w ^ 2.0);
	t_1 = c0 * (d / D);
	t_2 = c0 * (0.0 / w);
	tmp = 0.0;
	if (M_m <= 2.4e-221)
		tmp = c0 * ((((c0 * d) / D) * (d / D)) / t_0);
	elseif (M_m <= 2.05e-69)
		tmp = t_2;
	elseif (M_m <= 18000.0)
		tmp = c0 * ((t_1 / h) * ((d / D) / (w ^ 2.0)));
	elseif (M_m <= 3.6e+32)
		tmp = t_2;
	elseif (M_m <= 2.05e+65)
		tmp = c0 * (((d / D) * t_1) / t_0);
	elseif (M_m <= 1.6e+111)
		tmp = t_2;
	else
		tmp = (c0 / (2.0 * w)) * (M_m + (((d / D) ^ 2.0) * ((c0 / w) / h)));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
code[c0_, w_, h_, D_, d_, M$95$m_] := Block[{t$95$0 = N[(h * N[Power[w, 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(c0 * N[(d / D), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(c0 * N[(0.0 / w), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[M$95$m, 2.4e-221], N[(c0 * N[(N[(N[(N[(c0 * d), $MachinePrecision] / D), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[M$95$m, 2.05e-69], t$95$2, If[LessEqual[M$95$m, 18000.0], N[(c0 * N[(N[(t$95$1 / h), $MachinePrecision] * N[(N[(d / D), $MachinePrecision] / N[Power[w, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[M$95$m, 3.6e+32], t$95$2, If[LessEqual[M$95$m, 2.05e+65], N[(c0 * N[(N[(N[(d / D), $MachinePrecision] * t$95$1), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[M$95$m, 1.6e+111], t$95$2, N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(M$95$m + N[(N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[(c0 / w), $MachinePrecision] / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
M_m = \left|M\right|

\\
\begin{array}{l}
t_0 := h \cdot {w}^{2}\\
t_1 := c0 \cdot \frac{d}{D}\\
t_2 := c0 \cdot \frac{0}{w}\\
\mathbf{if}\;M\_m \leq 2.4 \cdot 10^{-221}:\\
\;\;\;\;c0 \cdot \frac{\frac{c0 \cdot d}{D} \cdot \frac{d}{D}}{t\_0}\\

\mathbf{elif}\;M\_m \leq 2.05 \cdot 10^{-69}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;M\_m \leq 18000:\\
\;\;\;\;c0 \cdot \left(\frac{t\_1}{h} \cdot \frac{\frac{d}{D}}{{w}^{2}}\right)\\

\mathbf{elif}\;M\_m \leq 3.6 \cdot 10^{+32}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;M\_m \leq 2.05 \cdot 10^{+65}:\\
\;\;\;\;c0 \cdot \frac{\frac{d}{D} \cdot t\_1}{t\_0}\\

\mathbf{elif}\;M\_m \leq 1.6 \cdot 10^{+111}:\\
\;\;\;\;t\_2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if M < 2.40000000000000024e-221

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

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

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

        \[\leadsto c0 \cdot \color{blue}{\frac{\frac{c0 \cdot {d}^{2}}{{D}^{2}}}{h \cdot {w}^{2}}} \]
    6. Simplified30.5%

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

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

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

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

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

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

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

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

    if 2.40000000000000024e-221 < M < 2.04999999999999995e-69 or 18000 < M < 3.5999999999999997e32 or 2.0500000000000001e65 < M < 1.6e111

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

      \[\leadsto c0 \cdot \color{blue}{\left(-0.5 \cdot \frac{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)}{w}\right)} \]
    5. Step-by-step derivation
      1. associate-*r/9.2%

        \[\leadsto c0 \cdot \color{blue}{\frac{-0.5 \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)}{w}} \]
      2. distribute-lft-in7.4%

        \[\leadsto c0 \cdot \frac{-0.5 \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)}}{w} \]
      3. mul-1-neg7.4%

        \[\leadsto c0 \cdot \frac{-0.5 \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)}{w} \]
      4. distribute-rgt-neg-in7.4%

        \[\leadsto c0 \cdot \frac{-0.5 \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)}{w} \]
      5. associate-/l*5.5%

        \[\leadsto c0 \cdot \frac{-0.5 \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)}{w} \]
      6. mul-1-neg5.5%

        \[\leadsto c0 \cdot \frac{-0.5 \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)}{w} \]
      7. associate-/l*7.2%

        \[\leadsto c0 \cdot \frac{-0.5 \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)}{w} \]
      8. distribute-lft1-in7.2%

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

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

        \[\leadsto c0 \cdot \frac{-0.5 \cdot \color{blue}{0}}{w} \]
      11. metadata-eval55.7%

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

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

    if 2.04999999999999995e-69 < M < 18000

    1. Initial program 47.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. Simplified64.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 44.6%

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

        \[\leadsto c0 \cdot \color{blue}{\frac{\frac{c0 \cdot {d}^{2}}{{D}^{2}}}{h \cdot {w}^{2}}} \]
    6. Simplified47.4%

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

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

        \[\leadsto c0 \cdot \frac{c0 \cdot \frac{\color{blue}{d \cdot d}}{{D}^{2}}}{h \cdot {w}^{2}} \]
      3. unpow247.5%

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

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

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

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

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

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

    if 3.5999999999999997e32 < M < 2.0500000000000001e65

    1. Initial program 30.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. Simplified31.9%

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

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

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

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

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

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

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

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

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

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

    if 1.6e111 < M

    1. Initial program 7.7%

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

      \[\leadsto \color{blue}{\frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D} + \sqrt{\left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}\right) \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}\right) - M \cdot M}\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. *-commutative7.7%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\frac{c0}{w}}{h} \cdot {\left(\frac{d}{D}\right)}^{2} + \sqrt{\left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2}\right) \cdot \left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2}\right) - \color{blue}{M \cdot M}}\right) \]
      6. difference-of-squares42.5%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\frac{c0}{w}}{h} \cdot {\left(\frac{d}{D}\right)}^{2} + \sqrt{\color{blue}{\left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2} + M\right) \cdot \left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2} - M\right)}}\right) \]
      7. add-sqr-sqrt42.5%

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\frac{c0}{w}}{h} \cdot {\left(\frac{d}{D}\right)}^{2} + \sqrt{\left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2} + \color{blue}{\sqrt{-M} \cdot \sqrt{-M}}\right) \cdot \left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2} - M\right)}\right) \]
      11. add-sqr-sqrt42.5%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 2.4 \cdot 10^{-221}:\\ \;\;\;\;c0 \cdot \frac{\frac{c0 \cdot d}{D} \cdot \frac{d}{D}}{h \cdot {w}^{2}}\\ \mathbf{elif}\;M \leq 2.05 \cdot 10^{-69}:\\ \;\;\;\;c0 \cdot \frac{0}{w}\\ \mathbf{elif}\;M \leq 18000:\\ \;\;\;\;c0 \cdot \left(\frac{c0 \cdot \frac{d}{D}}{h} \cdot \frac{\frac{d}{D}}{{w}^{2}}\right)\\ \mathbf{elif}\;M \leq 3.6 \cdot 10^{+32}:\\ \;\;\;\;c0 \cdot \frac{0}{w}\\ \mathbf{elif}\;M \leq 2.05 \cdot 10^{+65}:\\ \;\;\;\;c0 \cdot \frac{\frac{d}{D} \cdot \left(c0 \cdot \frac{d}{D}\right)}{h \cdot {w}^{2}}\\ \mathbf{elif}\;M \leq 1.6 \cdot 10^{+111}:\\ \;\;\;\;c0 \cdot \frac{0}{w}\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(M + {\left(\frac{d}{D}\right)}^{2} \cdot \frac{\frac{c0}{w}}{h}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 41.0% accurate, 1.1× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ \begin{array}{l} t_0 := c0 \cdot \frac{d}{D}\\ \mathbf{if}\;d \leq 9.5 \cdot 10^{-112}:\\ \;\;\;\;c0 \cdot \frac{\frac{d}{D} \cdot t\_0}{h \cdot {w}^{2}}\\ \mathbf{elif}\;d \leq 1.05 \cdot 10^{-32}:\\ \;\;\;\;0.5 \cdot \left(-1 + \mathsf{fma}\left(c0, \frac{M\_m}{w}, 1\right)\right)\\ \mathbf{elif}\;d \leq 1.3 \cdot 10^{+66} \lor \neg \left(d \leq 9 \cdot 10^{+110}\right) \land d \leq 2.6 \cdot 10^{+228}:\\ \;\;\;\;c0 \cdot \left(\frac{t\_0}{h} \cdot \frac{\frac{d}{D}}{{w}^{2}}\right)\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{0}{w}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
(FPCore (c0 w h D d M_m)
 :precision binary64
 (let* ((t_0 (* c0 (/ d D))))
   (if (<= d 9.5e-112)
     (* c0 (/ (* (/ d D) t_0) (* h (pow w 2.0))))
     (if (<= d 1.05e-32)
       (* 0.5 (+ -1.0 (fma c0 (/ M_m w) 1.0)))
       (if (or (<= d 1.3e+66) (and (not (<= d 9e+110)) (<= d 2.6e+228)))
         (* c0 (* (/ t_0 h) (/ (/ d D) (pow w 2.0))))
         (* c0 (/ 0.0 w)))))))
M_m = fabs(M);
double code(double c0, double w, double h, double D, double d, double M_m) {
	double t_0 = c0 * (d / D);
	double tmp;
	if (d <= 9.5e-112) {
		tmp = c0 * (((d / D) * t_0) / (h * pow(w, 2.0)));
	} else if (d <= 1.05e-32) {
		tmp = 0.5 * (-1.0 + fma(c0, (M_m / w), 1.0));
	} else if ((d <= 1.3e+66) || (!(d <= 9e+110) && (d <= 2.6e+228))) {
		tmp = c0 * ((t_0 / h) * ((d / D) / pow(w, 2.0)));
	} else {
		tmp = c0 * (0.0 / w);
	}
	return tmp;
}
M_m = abs(M)
function code(c0, w, h, D, d, M_m)
	t_0 = Float64(c0 * Float64(d / D))
	tmp = 0.0
	if (d <= 9.5e-112)
		tmp = Float64(c0 * Float64(Float64(Float64(d / D) * t_0) / Float64(h * (w ^ 2.0))));
	elseif (d <= 1.05e-32)
		tmp = Float64(0.5 * Float64(-1.0 + fma(c0, Float64(M_m / w), 1.0)));
	elseif ((d <= 1.3e+66) || (!(d <= 9e+110) && (d <= 2.6e+228)))
		tmp = Float64(c0 * Float64(Float64(t_0 / h) * Float64(Float64(d / D) / (w ^ 2.0))));
	else
		tmp = Float64(c0 * Float64(0.0 / w));
	end
	return tmp
end
M_m = N[Abs[M], $MachinePrecision]
code[c0_, w_, h_, D_, d_, M$95$m_] := Block[{t$95$0 = N[(c0 * N[(d / D), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, 9.5e-112], N[(c0 * N[(N[(N[(d / D), $MachinePrecision] * t$95$0), $MachinePrecision] / N[(h * N[Power[w, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.05e-32], N[(0.5 * N[(-1.0 + N[(c0 * N[(M$95$m / w), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[d, 1.3e+66], And[N[Not[LessEqual[d, 9e+110]], $MachinePrecision], LessEqual[d, 2.6e+228]]], N[(c0 * N[(N[(t$95$0 / h), $MachinePrecision] * N[(N[(d / D), $MachinePrecision] / N[Power[w, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(0.0 / w), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
M_m = \left|M\right|

\\
\begin{array}{l}
t_0 := c0 \cdot \frac{d}{D}\\
\mathbf{if}\;d \leq 9.5 \cdot 10^{-112}:\\
\;\;\;\;c0 \cdot \frac{\frac{d}{D} \cdot t\_0}{h \cdot {w}^{2}}\\

\mathbf{elif}\;d \leq 1.05 \cdot 10^{-32}:\\
\;\;\;\;0.5 \cdot \left(-1 + \mathsf{fma}\left(c0, \frac{M\_m}{w}, 1\right)\right)\\

\mathbf{elif}\;d \leq 1.3 \cdot 10^{+66} \lor \neg \left(d \leq 9 \cdot 10^{+110}\right) \land d \leq 2.6 \cdot 10^{+228}:\\
\;\;\;\;c0 \cdot \left(\frac{t\_0}{h} \cdot \frac{\frac{d}{D}}{{w}^{2}}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < 9.50000000000000056e-112

    1. Initial program 23.8%

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

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

        \[\leadsto c0 \cdot \color{blue}{\frac{\frac{c0 \cdot {d}^{2}}{{D}^{2}}}{h \cdot {w}^{2}}} \]
    6. Simplified28.8%

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

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

        \[\leadsto c0 \cdot \frac{c0 \cdot \frac{\color{blue}{d \cdot d}}{{D}^{2}}}{h \cdot {w}^{2}} \]
      3. unpow229.5%

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

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

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

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

    if 9.50000000000000056e-112 < d < 1.05e-32

    1. Initial program 20.0%

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

      \[\leadsto \color{blue}{\frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D} + \sqrt{\left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}\right) \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}\right) - M \cdot M}\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. *-commutative20.4%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\frac{c0}{w}}{h} \cdot {\left(\frac{d}{D}\right)}^{2} + \sqrt{\left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2}\right) \cdot \left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2}\right) - \color{blue}{M \cdot M}}\right) \]
      6. difference-of-squares33.7%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\frac{c0}{w}}{h} \cdot {\left(\frac{d}{D}\right)}^{2} + \sqrt{\color{blue}{\left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2} + M\right) \cdot \left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2} - M\right)}}\right) \]
      7. add-sqr-sqrt13.3%

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\frac{c0}{w}}{h} \cdot {\left(\frac{d}{D}\right)}^{2} + \sqrt{\left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2} + \color{blue}{\sqrt{-M} \cdot \sqrt{-M}}\right) \cdot \left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2} - M\right)}\right) \]
      11. add-sqr-sqrt34.1%

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

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{M \cdot c0}{w}} \]
    9. Step-by-step derivation
      1. associate-/l*16.5%

        \[\leadsto 0.5 \cdot \color{blue}{\left(M \cdot \frac{c0}{w}\right)} \]
    10. Simplified16.5%

      \[\leadsto \color{blue}{0.5 \cdot \left(M \cdot \frac{c0}{w}\right)} \]
    11. Step-by-step derivation
      1. expm1-log1p-u16.4%

        \[\leadsto 0.5 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(M \cdot \frac{c0}{w}\right)\right)} \]
      2. expm1-undefine47.9%

        \[\leadsto 0.5 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(M \cdot \frac{c0}{w}\right)} - 1\right)} \]
      3. associate-*r/47.9%

        \[\leadsto 0.5 \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{\frac{M \cdot c0}{w}}\right)} - 1\right) \]
    12. Applied egg-rr47.9%

      \[\leadsto 0.5 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{M \cdot c0}{w}\right)} - 1\right)} \]
    13. Step-by-step derivation
      1. sub-neg47.9%

        \[\leadsto 0.5 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{M \cdot c0}{w}\right)} + \left(-1\right)\right)} \]
      2. metadata-eval47.9%

        \[\leadsto 0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{M \cdot c0}{w}\right)} + \color{blue}{-1}\right) \]
      3. +-commutative47.9%

        \[\leadsto 0.5 \cdot \color{blue}{\left(-1 + e^{\mathsf{log1p}\left(\frac{M \cdot c0}{w}\right)}\right)} \]
      4. log1p-undefine47.9%

        \[\leadsto 0.5 \cdot \left(-1 + e^{\color{blue}{\log \left(1 + \frac{M \cdot c0}{w}\right)}}\right) \]
      5. rem-exp-log48.0%

        \[\leadsto 0.5 \cdot \left(-1 + \color{blue}{\left(1 + \frac{M \cdot c0}{w}\right)}\right) \]
      6. +-commutative48.0%

        \[\leadsto 0.5 \cdot \left(-1 + \color{blue}{\left(\frac{M \cdot c0}{w} + 1\right)}\right) \]
      7. *-commutative48.0%

        \[\leadsto 0.5 \cdot \left(-1 + \left(\frac{\color{blue}{c0 \cdot M}}{w} + 1\right)\right) \]
      8. associate-/l*48.0%

        \[\leadsto 0.5 \cdot \left(-1 + \left(\color{blue}{c0 \cdot \frac{M}{w}} + 1\right)\right) \]
      9. fma-define48.0%

        \[\leadsto 0.5 \cdot \left(-1 + \color{blue}{\mathsf{fma}\left(c0, \frac{M}{w}, 1\right)}\right) \]
    14. Simplified48.0%

      \[\leadsto 0.5 \cdot \color{blue}{\left(-1 + \mathsf{fma}\left(c0, \frac{M}{w}, 1\right)\right)} \]

    if 1.05e-32 < d < 1.30000000000000006e66 or 9.0000000000000005e110 < d < 2.60000000000000007e228

    1. Initial program 30.2%

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

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

        \[\leadsto c0 \cdot \color{blue}{\frac{\frac{c0 \cdot {d}^{2}}{{D}^{2}}}{h \cdot {w}^{2}}} \]
    6. Simplified40.9%

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

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

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

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

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

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

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

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

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

    if 1.30000000000000006e66 < d < 9.0000000000000005e110 or 2.60000000000000007e228 < d

    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. Simplified22.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 9.9%

      \[\leadsto c0 \cdot \color{blue}{\left(-0.5 \cdot \frac{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)}{w}\right)} \]
    5. Step-by-step derivation
      1. associate-*r/9.9%

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

        \[\leadsto c0 \cdot \frac{-0.5 \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)}}{w} \]
      3. mul-1-neg7.5%

        \[\leadsto c0 \cdot \frac{-0.5 \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)}{w} \]
      4. distribute-rgt-neg-in7.5%

        \[\leadsto c0 \cdot \frac{-0.5 \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)}{w} \]
      5. associate-/l*2.7%

        \[\leadsto c0 \cdot \frac{-0.5 \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)}{w} \]
      6. mul-1-neg2.7%

        \[\leadsto c0 \cdot \frac{-0.5 \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)}{w} \]
      7. associate-/l*7.3%

        \[\leadsto c0 \cdot \frac{-0.5 \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)}{w} \]
      8. distribute-lft1-in7.3%

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

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

        \[\leadsto c0 \cdot \frac{-0.5 \cdot \color{blue}{0}}{w} \]
      11. metadata-eval48.4%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq 9.5 \cdot 10^{-112}:\\ \;\;\;\;c0 \cdot \frac{\frac{d}{D} \cdot \left(c0 \cdot \frac{d}{D}\right)}{h \cdot {w}^{2}}\\ \mathbf{elif}\;d \leq 1.05 \cdot 10^{-32}:\\ \;\;\;\;0.5 \cdot \left(-1 + \mathsf{fma}\left(c0, \frac{M}{w}, 1\right)\right)\\ \mathbf{elif}\;d \leq 1.3 \cdot 10^{+66} \lor \neg \left(d \leq 9 \cdot 10^{+110}\right) \land d \leq 2.6 \cdot 10^{+228}:\\ \;\;\;\;c0 \cdot \left(\frac{c0 \cdot \frac{d}{D}}{h} \cdot \frac{\frac{d}{D}}{{w}^{2}}\right)\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{0}{w}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 43.6% accurate, 1.2× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ \begin{array}{l} \mathbf{if}\;d \leq 4.8 \cdot 10^{+66} \lor \neg \left(d \leq 1.6 \cdot 10^{+111}\right) \land d \leq 2.95 \cdot 10^{+228}:\\ \;\;\;\;c0 \cdot \left(\frac{c0 \cdot \frac{d}{D}}{h} \cdot \frac{\frac{d}{D}}{{w}^{2}}\right)\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{0}{w}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
(FPCore (c0 w h D d M_m)
 :precision binary64
 (if (or (<= d 4.8e+66) (and (not (<= d 1.6e+111)) (<= d 2.95e+228)))
   (* c0 (* (/ (* c0 (/ d D)) h) (/ (/ d D) (pow w 2.0))))
   (* c0 (/ 0.0 w))))
M_m = fabs(M);
double code(double c0, double w, double h, double D, double d, double M_m) {
	double tmp;
	if ((d <= 4.8e+66) || (!(d <= 1.6e+111) && (d <= 2.95e+228))) {
		tmp = c0 * (((c0 * (d / D)) / h) * ((d / D) / pow(w, 2.0)));
	} else {
		tmp = c0 * (0.0 / w);
	}
	return tmp;
}
M_m = abs(m)
real(8) function code(c0, w, h, d, d_1, m_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_m
    real(8) :: tmp
    if ((d_1 <= 4.8d+66) .or. (.not. (d_1 <= 1.6d+111)) .and. (d_1 <= 2.95d+228)) then
        tmp = c0 * (((c0 * (d_1 / d)) / h) * ((d_1 / d) / (w ** 2.0d0)))
    else
        tmp = c0 * (0.0d0 / w)
    end if
    code = tmp
end function
M_m = Math.abs(M);
public static double code(double c0, double w, double h, double D, double d, double M_m) {
	double tmp;
	if ((d <= 4.8e+66) || (!(d <= 1.6e+111) && (d <= 2.95e+228))) {
		tmp = c0 * (((c0 * (d / D)) / h) * ((d / D) / Math.pow(w, 2.0)));
	} else {
		tmp = c0 * (0.0 / w);
	}
	return tmp;
}
M_m = math.fabs(M)
def code(c0, w, h, D, d, M_m):
	tmp = 0
	if (d <= 4.8e+66) or (not (d <= 1.6e+111) and (d <= 2.95e+228)):
		tmp = c0 * (((c0 * (d / D)) / h) * ((d / D) / math.pow(w, 2.0)))
	else:
		tmp = c0 * (0.0 / w)
	return tmp
M_m = abs(M)
function code(c0, w, h, D, d, M_m)
	tmp = 0.0
	if ((d <= 4.8e+66) || (!(d <= 1.6e+111) && (d <= 2.95e+228)))
		tmp = Float64(c0 * Float64(Float64(Float64(c0 * Float64(d / D)) / h) * Float64(Float64(d / D) / (w ^ 2.0))));
	else
		tmp = Float64(c0 * Float64(0.0 / w));
	end
	return tmp
end
M_m = abs(M);
function tmp_2 = code(c0, w, h, D, d, M_m)
	tmp = 0.0;
	if ((d <= 4.8e+66) || (~((d <= 1.6e+111)) && (d <= 2.95e+228)))
		tmp = c0 * (((c0 * (d / D)) / h) * ((d / D) / (w ^ 2.0)));
	else
		tmp = c0 * (0.0 / w);
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
code[c0_, w_, h_, D_, d_, M$95$m_] := If[Or[LessEqual[d, 4.8e+66], And[N[Not[LessEqual[d, 1.6e+111]], $MachinePrecision], LessEqual[d, 2.95e+228]]], N[(c0 * N[(N[(N[(c0 * N[(d / D), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision] * N[(N[(d / D), $MachinePrecision] / N[Power[w, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(0.0 / w), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|

\\
\begin{array}{l}
\mathbf{if}\;d \leq 4.8 \cdot 10^{+66} \lor \neg \left(d \leq 1.6 \cdot 10^{+111}\right) \land d \leq 2.95 \cdot 10^{+228}:\\
\;\;\;\;c0 \cdot \left(\frac{c0 \cdot \frac{d}{D}}{h} \cdot \frac{\frac{d}{D}}{{w}^{2}}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < 4.8000000000000003e66 or 1.6e111 < d < 2.9499999999999999e228

    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.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 29.8%

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

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

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

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

        \[\leadsto c0 \cdot \frac{c0 \cdot \frac{\color{blue}{d \cdot d}}{{D}^{2}}}{h \cdot {w}^{2}} \]
      3. unpow231.7%

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

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

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

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

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

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

    if 4.8000000000000003e66 < d < 1.6e111 or 2.9499999999999999e228 < d

    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. Simplified22.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 9.9%

      \[\leadsto c0 \cdot \color{blue}{\left(-0.5 \cdot \frac{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)}{w}\right)} \]
    5. Step-by-step derivation
      1. associate-*r/9.9%

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

        \[\leadsto c0 \cdot \frac{-0.5 \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)}}{w} \]
      3. mul-1-neg7.5%

        \[\leadsto c0 \cdot \frac{-0.5 \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)}{w} \]
      4. distribute-rgt-neg-in7.5%

        \[\leadsto c0 \cdot \frac{-0.5 \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)}{w} \]
      5. associate-/l*2.7%

        \[\leadsto c0 \cdot \frac{-0.5 \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)}{w} \]
      6. mul-1-neg2.7%

        \[\leadsto c0 \cdot \frac{-0.5 \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)}{w} \]
      7. associate-/l*7.3%

        \[\leadsto c0 \cdot \frac{-0.5 \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)}{w} \]
      8. distribute-lft1-in7.3%

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

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

        \[\leadsto c0 \cdot \frac{-0.5 \cdot \color{blue}{0}}{w} \]
      11. metadata-eval48.4%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq 4.8 \cdot 10^{+66} \lor \neg \left(d \leq 1.6 \cdot 10^{+111}\right) \land d \leq 2.95 \cdot 10^{+228}:\\ \;\;\;\;c0 \cdot \left(\frac{c0 \cdot \frac{d}{D}}{h} \cdot \frac{\frac{d}{D}}{{w}^{2}}\right)\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{0}{w}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 37.1% accurate, 1.2× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ \begin{array}{l} \mathbf{if}\;M\_m \leq 3.15 \cdot 10^{-29} \lor \neg \left(M\_m \leq 16000\right) \land M\_m \leq 1.05 \cdot 10^{+156}:\\ \;\;\;\;c0 \cdot \frac{0}{w}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(-1 + \mathsf{fma}\left(c0, \frac{M\_m}{w}, 1\right)\right)\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
(FPCore (c0 w h D d M_m)
 :precision binary64
 (if (or (<= M_m 3.15e-29) (and (not (<= M_m 16000.0)) (<= M_m 1.05e+156)))
   (* c0 (/ 0.0 w))
   (* 0.5 (+ -1.0 (fma c0 (/ M_m w) 1.0)))))
M_m = fabs(M);
double code(double c0, double w, double h, double D, double d, double M_m) {
	double tmp;
	if ((M_m <= 3.15e-29) || (!(M_m <= 16000.0) && (M_m <= 1.05e+156))) {
		tmp = c0 * (0.0 / w);
	} else {
		tmp = 0.5 * (-1.0 + fma(c0, (M_m / w), 1.0));
	}
	return tmp;
}
M_m = abs(M)
function code(c0, w, h, D, d, M_m)
	tmp = 0.0
	if ((M_m <= 3.15e-29) || (!(M_m <= 16000.0) && (M_m <= 1.05e+156)))
		tmp = Float64(c0 * Float64(0.0 / w));
	else
		tmp = Float64(0.5 * Float64(-1.0 + fma(c0, Float64(M_m / w), 1.0)));
	end
	return tmp
end
M_m = N[Abs[M], $MachinePrecision]
code[c0_, w_, h_, D_, d_, M$95$m_] := If[Or[LessEqual[M$95$m, 3.15e-29], And[N[Not[LessEqual[M$95$m, 16000.0]], $MachinePrecision], LessEqual[M$95$m, 1.05e+156]]], N[(c0 * N[(0.0 / w), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(-1.0 + N[(c0 * N[(M$95$m / w), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|

\\
\begin{array}{l}
\mathbf{if}\;M\_m \leq 3.15 \cdot 10^{-29} \lor \neg \left(M\_m \leq 16000\right) \land M\_m \leq 1.05 \cdot 10^{+156}:\\
\;\;\;\;c0 \cdot \frac{0}{w}\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(-1 + \mathsf{fma}\left(c0, \frac{M\_m}{w}, 1\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if M < 3.14999999999999998e-29 or 16000 < M < 1.04999999999999991e156

    1. Initial program 26.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. Simplified38.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 4.8%

      \[\leadsto c0 \cdot \color{blue}{\left(-0.5 \cdot \frac{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)}{w}\right)} \]
    5. Step-by-step derivation
      1. associate-*r/4.8%

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

        \[\leadsto c0 \cdot \frac{-0.5 \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)}}{w} \]
      3. mul-1-neg4.3%

        \[\leadsto c0 \cdot \frac{-0.5 \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)}{w} \]
      4. distribute-rgt-neg-in4.3%

        \[\leadsto c0 \cdot \frac{-0.5 \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)}{w} \]
      5. associate-/l*3.8%

        \[\leadsto c0 \cdot \frac{-0.5 \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)}{w} \]
      6. mul-1-neg3.8%

        \[\leadsto c0 \cdot \frac{-0.5 \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)}{w} \]
      7. associate-/l*4.3%

        \[\leadsto c0 \cdot \frac{-0.5 \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)}{w} \]
      8. distribute-lft1-in4.3%

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

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

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

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

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

    if 3.14999999999999998e-29 < M < 16000 or 1.04999999999999991e156 < M

    1. Initial program 14.8%

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

      \[\leadsto \color{blue}{\frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D} + \sqrt{\left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}\right) \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}\right) - M \cdot M}\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. *-commutative14.8%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\frac{c0}{w}}{h} \cdot {\left(\frac{d}{D}\right)}^{2} + \sqrt{\left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2}\right) \cdot \left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2}\right) - \color{blue}{M \cdot M}}\right) \]
      6. difference-of-squares52.1%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\frac{c0}{w}}{h} \cdot {\left(\frac{d}{D}\right)}^{2} + \sqrt{\color{blue}{\left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2} + M\right) \cdot \left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2} - M\right)}}\right) \]
      7. add-sqr-sqrt52.1%

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\frac{c0}{w}}{h} \cdot {\left(\frac{d}{D}\right)}^{2} + \sqrt{\left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2} + \color{blue}{\sqrt{-M} \cdot \sqrt{-M}}\right) \cdot \left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2} - M\right)}\right) \]
      11. add-sqr-sqrt52.1%

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

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{M \cdot c0}{w}} \]
    9. Step-by-step derivation
      1. associate-/l*36.1%

        \[\leadsto 0.5 \cdot \color{blue}{\left(M \cdot \frac{c0}{w}\right)} \]
    10. Simplified36.1%

      \[\leadsto \color{blue}{0.5 \cdot \left(M \cdot \frac{c0}{w}\right)} \]
    11. Step-by-step derivation
      1. expm1-log1p-u16.6%

        \[\leadsto 0.5 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(M \cdot \frac{c0}{w}\right)\right)} \]
      2. expm1-undefine16.7%

        \[\leadsto 0.5 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(M \cdot \frac{c0}{w}\right)} - 1\right)} \]
      3. associate-*r/16.7%

        \[\leadsto 0.5 \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{\frac{M \cdot c0}{w}}\right)} - 1\right) \]
    12. Applied egg-rr16.7%

      \[\leadsto 0.5 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{M \cdot c0}{w}\right)} - 1\right)} \]
    13. Step-by-step derivation
      1. sub-neg16.7%

        \[\leadsto 0.5 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{M \cdot c0}{w}\right)} + \left(-1\right)\right)} \]
      2. metadata-eval16.7%

        \[\leadsto 0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{M \cdot c0}{w}\right)} + \color{blue}{-1}\right) \]
      3. +-commutative16.7%

        \[\leadsto 0.5 \cdot \color{blue}{\left(-1 + e^{\mathsf{log1p}\left(\frac{M \cdot c0}{w}\right)}\right)} \]
      4. log1p-undefine16.7%

        \[\leadsto 0.5 \cdot \left(-1 + e^{\color{blue}{\log \left(1 + \frac{M \cdot c0}{w}\right)}}\right) \]
      5. rem-exp-log39.6%

        \[\leadsto 0.5 \cdot \left(-1 + \color{blue}{\left(1 + \frac{M \cdot c0}{w}\right)}\right) \]
      6. +-commutative39.6%

        \[\leadsto 0.5 \cdot \left(-1 + \color{blue}{\left(\frac{M \cdot c0}{w} + 1\right)}\right) \]
      7. *-commutative39.6%

        \[\leadsto 0.5 \cdot \left(-1 + \left(\frac{\color{blue}{c0 \cdot M}}{w} + 1\right)\right) \]
      8. associate-/l*39.7%

        \[\leadsto 0.5 \cdot \left(-1 + \left(\color{blue}{c0 \cdot \frac{M}{w}} + 1\right)\right) \]
      9. fma-define39.7%

        \[\leadsto 0.5 \cdot \left(-1 + \color{blue}{\mathsf{fma}\left(c0, \frac{M}{w}, 1\right)}\right) \]
    14. Simplified39.7%

      \[\leadsto 0.5 \cdot \color{blue}{\left(-1 + \mathsf{fma}\left(c0, \frac{M}{w}, 1\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification37.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 3.15 \cdot 10^{-29} \lor \neg \left(M \leq 16000\right) \land M \leq 1.05 \cdot 10^{+156}:\\ \;\;\;\;c0 \cdot \frac{0}{w}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(-1 + \mathsf{fma}\left(c0, \frac{M}{w}, 1\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 36.6% accurate, 12.6× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ \begin{array}{l} \mathbf{if}\;M\_m \leq 3.1 \cdot 10^{+156}:\\ \;\;\;\;c0 \cdot \frac{0}{w}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(M\_m \cdot \frac{c0}{w}\right)\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
(FPCore (c0 w h D d M_m)
 :precision binary64
 (if (<= M_m 3.1e+156) (* c0 (/ 0.0 w)) (* 0.5 (* M_m (/ c0 w)))))
M_m = fabs(M);
double code(double c0, double w, double h, double D, double d, double M_m) {
	double tmp;
	if (M_m <= 3.1e+156) {
		tmp = c0 * (0.0 / w);
	} else {
		tmp = 0.5 * (M_m * (c0 / w));
	}
	return tmp;
}
M_m = abs(m)
real(8) function code(c0, w, h, d, d_1, m_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_m
    real(8) :: tmp
    if (m_m <= 3.1d+156) then
        tmp = c0 * (0.0d0 / w)
    else
        tmp = 0.5d0 * (m_m * (c0 / w))
    end if
    code = tmp
end function
M_m = Math.abs(M);
public static double code(double c0, double w, double h, double D, double d, double M_m) {
	double tmp;
	if (M_m <= 3.1e+156) {
		tmp = c0 * (0.0 / w);
	} else {
		tmp = 0.5 * (M_m * (c0 / w));
	}
	return tmp;
}
M_m = math.fabs(M)
def code(c0, w, h, D, d, M_m):
	tmp = 0
	if M_m <= 3.1e+156:
		tmp = c0 * (0.0 / w)
	else:
		tmp = 0.5 * (M_m * (c0 / w))
	return tmp
M_m = abs(M)
function code(c0, w, h, D, d, M_m)
	tmp = 0.0
	if (M_m <= 3.1e+156)
		tmp = Float64(c0 * Float64(0.0 / w));
	else
		tmp = Float64(0.5 * Float64(M_m * Float64(c0 / w)));
	end
	return tmp
end
M_m = abs(M);
function tmp_2 = code(c0, w, h, D, d, M_m)
	tmp = 0.0;
	if (M_m <= 3.1e+156)
		tmp = c0 * (0.0 / w);
	else
		tmp = 0.5 * (M_m * (c0 / w));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
code[c0_, w_, h_, D_, d_, M$95$m_] := If[LessEqual[M$95$m, 3.1e+156], N[(c0 * N[(0.0 / w), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(M$95$m * N[(c0 / w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|

\\
\begin{array}{l}
\mathbf{if}\;M\_m \leq 3.1 \cdot 10^{+156}:\\
\;\;\;\;c0 \cdot \frac{0}{w}\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(M\_m \cdot \frac{c0}{w}\right)\\


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

    1. Initial program 26.8%

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

      \[\leadsto c0 \cdot \color{blue}{\left(-0.5 \cdot \frac{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)}{w}\right)} \]
    5. Step-by-step derivation
      1. associate-*r/4.7%

        \[\leadsto c0 \cdot \color{blue}{\frac{-0.5 \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)}{w}} \]
      2. distribute-lft-in4.2%

        \[\leadsto c0 \cdot \frac{-0.5 \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)}}{w} \]
      3. mul-1-neg4.2%

        \[\leadsto c0 \cdot \frac{-0.5 \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)}{w} \]
      4. distribute-rgt-neg-in4.2%

        \[\leadsto c0 \cdot \frac{-0.5 \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)}{w} \]
      5. associate-/l*3.7%

        \[\leadsto c0 \cdot \frac{-0.5 \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)}{w} \]
      6. mul-1-neg3.7%

        \[\leadsto c0 \cdot \frac{-0.5 \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)}{w} \]
      7. associate-/l*4.1%

        \[\leadsto c0 \cdot \frac{-0.5 \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)}{w} \]
      8. distribute-lft1-in4.1%

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

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

        \[\leadsto c0 \cdot \frac{-0.5 \cdot \color{blue}{0}}{w} \]
      11. metadata-eval36.0%

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

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

    if 3.1000000000000002e156 < M

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\frac{c0}{w}}{h} \cdot {\left(\frac{d}{D}\right)}^{2} + \sqrt{\left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2}\right) \cdot \left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2}\right) - \color{blue}{M \cdot M}}\right) \]
      6. difference-of-squares42.4%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\frac{c0}{w}}{h} \cdot {\left(\frac{d}{D}\right)}^{2} + \sqrt{\color{blue}{\left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2} + M\right) \cdot \left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2} - M\right)}}\right) \]
      7. add-sqr-sqrt42.4%

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\frac{c0}{w}}{h} \cdot {\left(\frac{d}{D}\right)}^{2} + \sqrt{\left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2} + \color{blue}{\sqrt{-M} \cdot \sqrt{-M}}\right) \cdot \left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2} - M\right)}\right) \]
      11. add-sqr-sqrt42.4%

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

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{M \cdot c0}{w}} \]
    9. Step-by-step derivation
      1. associate-/l*33.8%

        \[\leadsto 0.5 \cdot \color{blue}{\left(M \cdot \frac{c0}{w}\right)} \]
    10. Simplified33.8%

      \[\leadsto \color{blue}{0.5 \cdot \left(M \cdot \frac{c0}{w}\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification35.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 3.1 \cdot 10^{+156}:\\ \;\;\;\;c0 \cdot \frac{0}{w}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(M \cdot \frac{c0}{w}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 36.9% accurate, 12.6× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ \begin{array}{l} \mathbf{if}\;M\_m \leq 1.7 \cdot 10^{+157}:\\ \;\;\;\;c0 \cdot \frac{0}{w}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(c0 \cdot \frac{M\_m}{w}\right)\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
(FPCore (c0 w h D d M_m)
 :precision binary64
 (if (<= M_m 1.7e+157) (* c0 (/ 0.0 w)) (* 0.5 (* c0 (/ M_m w)))))
M_m = fabs(M);
double code(double c0, double w, double h, double D, double d, double M_m) {
	double tmp;
	if (M_m <= 1.7e+157) {
		tmp = c0 * (0.0 / w);
	} else {
		tmp = 0.5 * (c0 * (M_m / w));
	}
	return tmp;
}
M_m = abs(m)
real(8) function code(c0, w, h, d, d_1, m_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_m
    real(8) :: tmp
    if (m_m <= 1.7d+157) then
        tmp = c0 * (0.0d0 / w)
    else
        tmp = 0.5d0 * (c0 * (m_m / w))
    end if
    code = tmp
end function
M_m = Math.abs(M);
public static double code(double c0, double w, double h, double D, double d, double M_m) {
	double tmp;
	if (M_m <= 1.7e+157) {
		tmp = c0 * (0.0 / w);
	} else {
		tmp = 0.5 * (c0 * (M_m / w));
	}
	return tmp;
}
M_m = math.fabs(M)
def code(c0, w, h, D, d, M_m):
	tmp = 0
	if M_m <= 1.7e+157:
		tmp = c0 * (0.0 / w)
	else:
		tmp = 0.5 * (c0 * (M_m / w))
	return tmp
M_m = abs(M)
function code(c0, w, h, D, d, M_m)
	tmp = 0.0
	if (M_m <= 1.7e+157)
		tmp = Float64(c0 * Float64(0.0 / w));
	else
		tmp = Float64(0.5 * Float64(c0 * Float64(M_m / w)));
	end
	return tmp
end
M_m = abs(M);
function tmp_2 = code(c0, w, h, D, d, M_m)
	tmp = 0.0;
	if (M_m <= 1.7e+157)
		tmp = c0 * (0.0 / w);
	else
		tmp = 0.5 * (c0 * (M_m / w));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
code[c0_, w_, h_, D_, d_, M$95$m_] := If[LessEqual[M$95$m, 1.7e+157], N[(c0 * N[(0.0 / w), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(c0 * N[(M$95$m / w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|

\\
\begin{array}{l}
\mathbf{if}\;M\_m \leq 1.7 \cdot 10^{+157}:\\
\;\;\;\;c0 \cdot \frac{0}{w}\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(c0 \cdot \frac{M\_m}{w}\right)\\


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

    1. Initial program 26.8%

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

      \[\leadsto c0 \cdot \color{blue}{\left(-0.5 \cdot \frac{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)}{w}\right)} \]
    5. Step-by-step derivation
      1. associate-*r/4.7%

        \[\leadsto c0 \cdot \color{blue}{\frac{-0.5 \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)}{w}} \]
      2. distribute-lft-in4.2%

        \[\leadsto c0 \cdot \frac{-0.5 \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)}}{w} \]
      3. mul-1-neg4.2%

        \[\leadsto c0 \cdot \frac{-0.5 \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)}{w} \]
      4. distribute-rgt-neg-in4.2%

        \[\leadsto c0 \cdot \frac{-0.5 \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)}{w} \]
      5. associate-/l*3.7%

        \[\leadsto c0 \cdot \frac{-0.5 \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)}{w} \]
      6. mul-1-neg3.7%

        \[\leadsto c0 \cdot \frac{-0.5 \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)}{w} \]
      7. associate-/l*4.1%

        \[\leadsto c0 \cdot \frac{-0.5 \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)}{w} \]
      8. distribute-lft1-in4.1%

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

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

        \[\leadsto c0 \cdot \frac{-0.5 \cdot \color{blue}{0}}{w} \]
      11. metadata-eval36.0%

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

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

    if 1.6999999999999999e157 < M

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\frac{c0}{w}}{h} \cdot {\left(\frac{d}{D}\right)}^{2} + \sqrt{\left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2}\right) \cdot \left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2}\right) - \color{blue}{M \cdot M}}\right) \]
      6. difference-of-squares42.4%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\frac{c0}{w}}{h} \cdot {\left(\frac{d}{D}\right)}^{2} + \sqrt{\color{blue}{\left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2} + M\right) \cdot \left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2} - M\right)}}\right) \]
      7. add-sqr-sqrt42.4%

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\frac{c0}{w}}{h} \cdot {\left(\frac{d}{D}\right)}^{2} + \sqrt{\left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2} + \color{blue}{\sqrt{-M} \cdot \sqrt{-M}}\right) \cdot \left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2} - M\right)}\right) \]
      11. add-sqr-sqrt42.4%

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

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{M \cdot c0}{w}} \]
    9. Step-by-step derivation
      1. associate-*r/38.7%

        \[\leadsto \color{blue}{\frac{0.5 \cdot \left(M \cdot c0\right)}{w}} \]
      2. associate-*r*38.7%

        \[\leadsto \frac{\color{blue}{\left(0.5 \cdot M\right) \cdot c0}}{w} \]
      3. associate-*l/38.9%

        \[\leadsto \color{blue}{\frac{0.5 \cdot M}{w} \cdot c0} \]
      4. associate-*r/38.9%

        \[\leadsto \color{blue}{\left(0.5 \cdot \frac{M}{w}\right)} \cdot c0 \]
      5. associate-*l*38.9%

        \[\leadsto \color{blue}{0.5 \cdot \left(\frac{M}{w} \cdot c0\right)} \]
    10. Simplified38.9%

      \[\leadsto \color{blue}{0.5 \cdot \left(\frac{M}{w} \cdot c0\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification36.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 1.7 \cdot 10^{+157}:\\ \;\;\;\;c0 \cdot \frac{0}{w}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(c0 \cdot \frac{M}{w}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 33.6% accurate, 30.2× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ c0 \cdot \frac{0}{w} \end{array} \]
M_m = (fabs.f64 M)
(FPCore (c0 w h D d M_m) :precision binary64 (* c0 (/ 0.0 w)))
M_m = fabs(M);
double code(double c0, double w, double h, double D, double d, double M_m) {
	return c0 * (0.0 / w);
}
M_m = abs(m)
real(8) function code(c0, w, h, d, d_1, m_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_m
    code = c0 * (0.0d0 / w)
end function
M_m = Math.abs(M);
public static double code(double c0, double w, double h, double D, double d, double M_m) {
	return c0 * (0.0 / w);
}
M_m = math.fabs(M)
def code(c0, w, h, D, d, M_m):
	return c0 * (0.0 / w)
M_m = abs(M)
function code(c0, w, h, D, d, M_m)
	return Float64(c0 * Float64(0.0 / w))
end
M_m = abs(M);
function tmp = code(c0, w, h, D, d, M_m)
	tmp = c0 * (0.0 / w);
end
M_m = N[Abs[M], $MachinePrecision]
code[c0_, w_, h_, D_, d_, M$95$m_] := N[(c0 * N[(0.0 / w), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|

\\
c0 \cdot \frac{0}{w}
\end{array}
Derivation
  1. Initial program 24.9%

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

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

    \[\leadsto c0 \cdot \color{blue}{\left(-0.5 \cdot \frac{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)}{w}\right)} \]
  5. Step-by-step derivation
    1. associate-*r/4.3%

      \[\leadsto c0 \cdot \color{blue}{\frac{-0.5 \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)}{w}} \]
    2. distribute-lft-in3.9%

      \[\leadsto c0 \cdot \frac{-0.5 \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)}}{w} \]
    3. mul-1-neg3.9%

      \[\leadsto c0 \cdot \frac{-0.5 \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)}{w} \]
    4. distribute-rgt-neg-in3.9%

      \[\leadsto c0 \cdot \frac{-0.5 \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)}{w} \]
    5. associate-/l*3.4%

      \[\leadsto c0 \cdot \frac{-0.5 \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)}{w} \]
    6. mul-1-neg3.4%

      \[\leadsto c0 \cdot \frac{-0.5 \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)}{w} \]
    7. associate-/l*3.8%

      \[\leadsto c0 \cdot \frac{-0.5 \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)}{w} \]
    8. distribute-lft1-in3.8%

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

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

      \[\leadsto c0 \cdot \frac{-0.5 \cdot \color{blue}{0}}{w} \]
    11. metadata-eval33.5%

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

    \[\leadsto c0 \cdot \color{blue}{\frac{0}{w}} \]
  7. Final simplification33.5%

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

Reproduce

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