Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 80.9% → 86.7%
Time: 38.9s
Alternatives: 11
Speedup: 1.7×

Specification

?
\[\begin{array}{l} \\ w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \end{array} \]
(FPCore (w0 M D h l d)
 :precision binary64
 (* w0 (sqrt (- 1.0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l))))))
double code(double w0, double M, double D, double h, double l, double d) {
	return w0 * sqrt((1.0 - (pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
}
real(8) function code(w0, m, d, h, l, d_1)
    real(8), intent (in) :: w0
    real(8), intent (in) :: m
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d_1
    code = w0 * sqrt((1.0d0 - ((((m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l))))
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
	return w0 * Math.sqrt((1.0 - (Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
}
def code(w0, M, D, h, l, d):
	return w0 * math.sqrt((1.0 - (math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))))
function code(w0, M, D, h, l, d)
	return Float64(w0 * sqrt(Float64(1.0 - Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)))))
end
function tmp = code(w0, M, D, h, l, d)
	tmp = w0 * sqrt((1.0 - ((((M * D) / (2.0 * d)) ^ 2.0) * (h / l))));
end
code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 11 alternatives:

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

Initial Program: 80.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \end{array} \]
(FPCore (w0 M D h l d)
 :precision binary64
 (* w0 (sqrt (- 1.0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l))))))
double code(double w0, double M, double D, double h, double l, double d) {
	return w0 * sqrt((1.0 - (pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
}
real(8) function code(w0, m, d, h, l, d_1)
    real(8), intent (in) :: w0
    real(8), intent (in) :: m
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d_1
    code = w0 * sqrt((1.0d0 - ((((m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l))))
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
	return w0 * Math.sqrt((1.0 - (Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
}
def code(w0, M, D, h, l, d):
	return w0 * math.sqrt((1.0 - (math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))))
function code(w0, M, D, h, l, d)
	return Float64(w0 * sqrt(Float64(1.0 - Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)))))
end
function tmp = code(w0, M, D, h, l, d)
	tmp = w0 * sqrt((1.0 - ((((M * D) / (2.0 * d)) ^ 2.0) * (h / l))));
end
code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}
\end{array}

Alternative 1: 86.7% accurate, 1.6× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;\frac{h}{\ell} \leq -5 \cdot 10^{-251}:\\ \;\;\;\;w0 \cdot \sqrt{1 + \frac{h \cdot \left(M\_m \cdot \left(D\_m \cdot \frac{0.5}{d}\right)\right)}{2 \cdot \frac{\frac{d}{D\_m}}{M\_m}} \cdot \frac{-1}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 + \frac{0.5 \cdot \frac{D\_m \cdot \left(h \cdot M\_m\right)}{\ell \cdot d}}{\frac{1}{D\_m \cdot \frac{M\_m}{d}} \cdot -2}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
 :precision binary64
 (if (<= (/ h l) -5e-251)
   (*
    w0
    (sqrt
     (+
      1.0
      (*
       (/ (* h (* M_m (* D_m (/ 0.5 d)))) (* 2.0 (/ (/ d D_m) M_m)))
       (/ -1.0 l)))))
   (*
    w0
    (sqrt
     (+
      1.0
      (/
       (* 0.5 (/ (* D_m (* h M_m)) (* l d)))
       (* (/ 1.0 (* D_m (/ M_m d))) -2.0)))))))
M_m = fabs(M);
D_m = fabs(D);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
	double tmp;
	if ((h / l) <= -5e-251) {
		tmp = w0 * sqrt((1.0 + (((h * (M_m * (D_m * (0.5 / d)))) / (2.0 * ((d / D_m) / M_m))) * (-1.0 / l))));
	} else {
		tmp = w0 * sqrt((1.0 + ((0.5 * ((D_m * (h * M_m)) / (l * d))) / ((1.0 / (D_m * (M_m / d))) * -2.0))));
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d)
    real(8), intent (in) :: w0
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d
    real(8) :: tmp
    if ((h / l) <= (-5d-251)) then
        tmp = w0 * sqrt((1.0d0 + (((h * (m_m * (d_m * (0.5d0 / d)))) / (2.0d0 * ((d / d_m) / m_m))) * ((-1.0d0) / l))))
    else
        tmp = w0 * sqrt((1.0d0 + ((0.5d0 * ((d_m * (h * m_m)) / (l * d))) / ((1.0d0 / (d_m * (m_m / d))) * (-2.0d0)))))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
	double tmp;
	if ((h / l) <= -5e-251) {
		tmp = w0 * Math.sqrt((1.0 + (((h * (M_m * (D_m * (0.5 / d)))) / (2.0 * ((d / D_m) / M_m))) * (-1.0 / l))));
	} else {
		tmp = w0 * Math.sqrt((1.0 + ((0.5 * ((D_m * (h * M_m)) / (l * d))) / ((1.0 / (D_m * (M_m / d))) * -2.0))));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d])
def code(w0, M_m, D_m, h, l, d):
	tmp = 0
	if (h / l) <= -5e-251:
		tmp = w0 * math.sqrt((1.0 + (((h * (M_m * (D_m * (0.5 / d)))) / (2.0 * ((d / D_m) / M_m))) * (-1.0 / l))))
	else:
		tmp = w0 * math.sqrt((1.0 + ((0.5 * ((D_m * (h * M_m)) / (l * d))) / ((1.0 / (D_m * (M_m / d))) * -2.0))))
	return tmp
M_m = abs(M)
D_m = abs(D)
w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d])
function code(w0, M_m, D_m, h, l, d)
	tmp = 0.0
	if (Float64(h / l) <= -5e-251)
		tmp = Float64(w0 * sqrt(Float64(1.0 + Float64(Float64(Float64(h * Float64(M_m * Float64(D_m * Float64(0.5 / d)))) / Float64(2.0 * Float64(Float64(d / D_m) / M_m))) * Float64(-1.0 / l)))));
	else
		tmp = Float64(w0 * sqrt(Float64(1.0 + Float64(Float64(0.5 * Float64(Float64(D_m * Float64(h * M_m)) / Float64(l * d))) / Float64(Float64(1.0 / Float64(D_m * Float64(M_m / d))) * -2.0)))));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d)
	tmp = 0.0;
	if ((h / l) <= -5e-251)
		tmp = w0 * sqrt((1.0 + (((h * (M_m * (D_m * (0.5 / d)))) / (2.0 * ((d / D_m) / M_m))) * (-1.0 / l))));
	else
		tmp = w0 * sqrt((1.0 + ((0.5 * ((D_m * (h * M_m)) / (l * d))) / ((1.0 / (D_m * (M_m / d))) * -2.0))));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[N[(h / l), $MachinePrecision], -5e-251], N[(w0 * N[Sqrt[N[(1.0 + N[(N[(N[(h * N[(M$95$m * N[(D$95$m * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * N[(N[(d / D$95$m), $MachinePrecision] / M$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 + N[(N[(0.5 * N[(N[(D$95$m * N[(h * M$95$m), $MachinePrecision]), $MachinePrecision] / N[(l * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 / N[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;\frac{h}{\ell} \leq -5 \cdot 10^{-251}:\\
\;\;\;\;w0 \cdot \sqrt{1 + \frac{h \cdot \left(M\_m \cdot \left(D\_m \cdot \frac{0.5}{d}\right)\right)}{2 \cdot \frac{\frac{d}{D\_m}}{M\_m}} \cdot \frac{-1}{\ell}}\\

\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 + \frac{0.5 \cdot \frac{D\_m \cdot \left(h \cdot M\_m\right)}{\ell \cdot d}}{\frac{1}{D\_m \cdot \frac{M\_m}{d}} \cdot -2}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 h l) < -5.0000000000000003e-251

    1. Initial program 80.8%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified80.8%

      \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. unpow280.8%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \left(D \cdot \frac{\frac{M}{2}}{d}\right)\right)} \cdot \frac{h}{\ell}} \]
      2. *-commutative80.8%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\left(\frac{\frac{M}{2}}{d} \cdot D\right)}\right) \cdot \frac{h}{\ell}} \]
      3. associate-*l/80.8%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\frac{\frac{M}{2} \cdot D}{d}}\right) \cdot \frac{h}{\ell}} \]
      4. associate-*r/80.2%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}\right) \cdot \frac{h}{\ell}} \]
      5. times-frac80.8%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\frac{M \cdot D}{2 \cdot d}}\right) \cdot \frac{h}{\ell}} \]
      6. clear-num80.8%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\frac{1}{\frac{2 \cdot d}{M \cdot D}}}\right) \cdot \frac{h}{\ell}} \]
      7. un-div-inv80.8%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{D \cdot \frac{\frac{M}{2}}{d}}{\frac{2 \cdot d}{M \cdot D}}} \cdot \frac{h}{\ell}} \]
      8. *-commutative80.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{\frac{M}{2}}{d} \cdot D}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      9. associate-*l/80.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{\frac{M}{2} \cdot D}{d}}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      10. associate-*r/80.1%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{M}{2} \cdot \frac{D}{d}}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      11. times-frac80.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{M \cdot D}{2 \cdot d}}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      12. associate-/l*80.1%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{M \cdot \frac{D}{2 \cdot d}}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      13. div-inv80.2%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \color{blue}{\left(D \cdot \frac{1}{2 \cdot d}\right)}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      14. associate-/r*80.2%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \left(D \cdot \color{blue}{\frac{\frac{1}{2}}{d}}\right)}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      15. metadata-eval80.2%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \left(D \cdot \frac{\color{blue}{0.5}}{d}\right)}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      16. times-frac80.2%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \left(D \cdot \frac{0.5}{d}\right)}{\color{blue}{\frac{2}{M} \cdot \frac{d}{D}}} \cdot \frac{h}{\ell}} \]
    5. Applied egg-rr80.2%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{M \cdot \left(D \cdot \frac{0.5}{d}\right)}{\frac{2}{M} \cdot \frac{d}{D}}} \cdot \frac{h}{\ell}} \]
    6. Step-by-step derivation
      1. associate-*r/87.6%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{\frac{M \cdot \left(D \cdot \frac{0.5}{d}\right)}{\frac{2}{M} \cdot \frac{d}{D}} \cdot h}{\ell}}} \]
      2. associate-*r*87.6%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{\color{blue}{\left(M \cdot D\right) \cdot \frac{0.5}{d}}}{\frac{2}{M} \cdot \frac{d}{D}} \cdot h}{\ell}} \]
      3. frac-times88.2%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{\left(M \cdot D\right) \cdot \frac{0.5}{d}}{\color{blue}{\frac{2 \cdot d}{M \cdot D}}} \cdot h}{\ell}} \]
    7. Applied egg-rr88.2%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{\frac{\left(M \cdot D\right) \cdot \frac{0.5}{d}}{\frac{2 \cdot d}{M \cdot D}} \cdot h}{\ell}}} \]
    8. Step-by-step derivation
      1. div-inv88.2%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\frac{\left(M \cdot D\right) \cdot \frac{0.5}{d}}{\frac{2 \cdot d}{M \cdot D}} \cdot h\right) \cdot \frac{1}{\ell}}} \]
      2. associate-*r*87.6%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\frac{\color{blue}{M \cdot \left(D \cdot \frac{0.5}{d}\right)}}{\frac{2 \cdot d}{M \cdot D}} \cdot h\right) \cdot \frac{1}{\ell}} \]
      3. associate-*l/88.3%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{\left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right) \cdot h}{\frac{2 \cdot d}{M \cdot D}}} \cdot \frac{1}{\ell}} \]
      4. *-commutative88.3%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right) \cdot h}{\frac{2 \cdot d}{\color{blue}{D \cdot M}}} \cdot \frac{1}{\ell}} \]
      5. associate-/l*88.3%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right) \cdot h}{\color{blue}{2 \cdot \frac{d}{D \cdot M}}} \cdot \frac{1}{\ell}} \]
      6. associate-/r*88.9%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right) \cdot h}{2 \cdot \color{blue}{\frac{\frac{d}{D}}{M}}} \cdot \frac{1}{\ell}} \]
    9. Applied egg-rr88.9%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{\left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right) \cdot h}{2 \cdot \frac{\frac{d}{D}}{M}} \cdot \frac{1}{\ell}}} \]

    if -5.0000000000000003e-251 < (/.f64 h l)

    1. Initial program 87.5%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified88.3%

      \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. unpow288.3%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \left(D \cdot \frac{\frac{M}{2}}{d}\right)\right)} \cdot \frac{h}{\ell}} \]
      2. *-commutative88.3%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\left(\frac{\frac{M}{2}}{d} \cdot D\right)}\right) \cdot \frac{h}{\ell}} \]
      3. associate-*l/87.5%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\frac{\frac{M}{2} \cdot D}{d}}\right) \cdot \frac{h}{\ell}} \]
      4. associate-*r/86.5%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}\right) \cdot \frac{h}{\ell}} \]
      5. times-frac87.5%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\frac{M \cdot D}{2 \cdot d}}\right) \cdot \frac{h}{\ell}} \]
      6. clear-num87.5%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\frac{1}{\frac{2 \cdot d}{M \cdot D}}}\right) \cdot \frac{h}{\ell}} \]
      7. un-div-inv87.5%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{D \cdot \frac{\frac{M}{2}}{d}}{\frac{2 \cdot d}{M \cdot D}}} \cdot \frac{h}{\ell}} \]
      8. *-commutative87.5%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{\frac{M}{2}}{d} \cdot D}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      9. associate-*l/87.5%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{\frac{M}{2} \cdot D}{d}}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      10. associate-*r/85.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{M}{2} \cdot \frac{D}{d}}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      11. times-frac87.5%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{M \cdot D}{2 \cdot d}}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      12. associate-/l*85.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{M \cdot \frac{D}{2 \cdot d}}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      13. div-inv85.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \color{blue}{\left(D \cdot \frac{1}{2 \cdot d}\right)}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      14. associate-/r*85.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \left(D \cdot \color{blue}{\frac{\frac{1}{2}}{d}}\right)}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      15. metadata-eval85.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \left(D \cdot \frac{\color{blue}{0.5}}{d}\right)}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      16. times-frac86.5%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \left(D \cdot \frac{0.5}{d}\right)}{\color{blue}{\frac{2}{M} \cdot \frac{d}{D}}} \cdot \frac{h}{\ell}} \]
    5. Applied egg-rr86.5%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{M \cdot \left(D \cdot \frac{0.5}{d}\right)}{\frac{2}{M} \cdot \frac{d}{D}}} \cdot \frac{h}{\ell}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity86.5%

        \[\leadsto w0 \cdot \color{blue}{\left(1 \cdot \sqrt{1 - \frac{M \cdot \left(D \cdot \frac{0.5}{d}\right)}{\frac{2}{M} \cdot \frac{d}{D}} \cdot \frac{h}{\ell}}\right)} \]
      2. associate-*r*86.6%

        \[\leadsto w0 \cdot \left(1 \cdot \sqrt{1 - \frac{\color{blue}{\left(M \cdot D\right) \cdot \frac{0.5}{d}}}{\frac{2}{M} \cdot \frac{d}{D}} \cdot \frac{h}{\ell}}\right) \]
      3. frac-times87.5%

        \[\leadsto w0 \cdot \left(1 \cdot \sqrt{1 - \frac{\left(M \cdot D\right) \cdot \frac{0.5}{d}}{\color{blue}{\frac{2 \cdot d}{M \cdot D}}} \cdot \frac{h}{\ell}}\right) \]
    7. Applied egg-rr87.5%

      \[\leadsto w0 \cdot \color{blue}{\left(1 \cdot \sqrt{1 - \frac{\left(M \cdot D\right) \cdot \frac{0.5}{d}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}}\right)} \]
    8. Step-by-step derivation
      1. *-lft-identity87.5%

        \[\leadsto w0 \cdot \color{blue}{\sqrt{1 - \frac{\left(M \cdot D\right) \cdot \frac{0.5}{d}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}}} \]
      2. sub-neg87.5%

        \[\leadsto w0 \cdot \sqrt{\color{blue}{1 + \left(-\frac{\left(M \cdot D\right) \cdot \frac{0.5}{d}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}\right)}} \]
      3. associate-*l/92.0%

        \[\leadsto w0 \cdot \sqrt{1 + \left(-\color{blue}{\frac{\left(\left(M \cdot D\right) \cdot \frac{0.5}{d}\right) \cdot \frac{h}{\ell}}{\frac{2 \cdot d}{M \cdot D}}}\right)} \]
      4. distribute-neg-frac292.0%

        \[\leadsto w0 \cdot \sqrt{1 + \color{blue}{\frac{\left(\left(M \cdot D\right) \cdot \frac{0.5}{d}\right) \cdot \frac{h}{\ell}}{-\frac{2 \cdot d}{M \cdot D}}}} \]
      5. *-commutative92.0%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\color{blue}{\frac{h}{\ell} \cdot \left(\left(M \cdot D\right) \cdot \frac{0.5}{d}\right)}}{-\frac{2 \cdot d}{M \cdot D}}} \]
      6. associate-*l*89.3%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \color{blue}{\left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}}{-\frac{2 \cdot d}{M \cdot D}}} \]
      7. associate-/l*89.3%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{-\color{blue}{2 \cdot \frac{d}{M \cdot D}}}} \]
      8. *-commutative89.3%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{-2 \cdot \frac{d}{\color{blue}{D \cdot M}}}} \]
      9. *-commutative89.3%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{-\color{blue}{\frac{d}{D \cdot M} \cdot 2}}} \]
      10. distribute-rgt-neg-in89.3%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{\frac{d}{D \cdot M} \cdot \left(-2\right)}}} \]
      11. metadata-eval89.3%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\frac{d}{D \cdot M} \cdot \color{blue}{-2}}} \]
    9. Simplified89.3%

      \[\leadsto w0 \cdot \color{blue}{\sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\frac{d}{D \cdot M} \cdot -2}}} \]
    10. Step-by-step derivation
      1. clear-num89.3%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{\frac{1}{\frac{D \cdot M}{d}}} \cdot -2}} \]
      2. inv-pow89.3%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{{\left(\frac{D \cdot M}{d}\right)}^{-1}} \cdot -2}} \]
      3. *-commutative89.3%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{{\left(\frac{\color{blue}{M \cdot D}}{d}\right)}^{-1} \cdot -2}} \]
    11. Applied egg-rr89.3%

      \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{{\left(\frac{M \cdot D}{d}\right)}^{-1}} \cdot -2}} \]
    12. Step-by-step derivation
      1. unpow-189.3%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{\frac{1}{\frac{M \cdot D}{d}}} \cdot -2}} \]
      2. *-commutative89.3%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\frac{1}{\frac{\color{blue}{D \cdot M}}{d}} \cdot -2}} \]
      3. associate-/l*91.9%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\frac{1}{\color{blue}{D \cdot \frac{M}{d}}} \cdot -2}} \]
    13. Simplified91.9%

      \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{\frac{1}{D \cdot \frac{M}{d}}} \cdot -2}} \]
    14. Taylor expanded in h around 0 95.2%

      \[\leadsto w0 \cdot \sqrt{1 + \frac{\color{blue}{0.5 \cdot \frac{D \cdot \left(M \cdot h\right)}{d \cdot \ell}}}{\frac{1}{D \cdot \frac{M}{d}} \cdot -2}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification91.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{h}{\ell} \leq -5 \cdot 10^{-251}:\\ \;\;\;\;w0 \cdot \sqrt{1 + \frac{h \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{2 \cdot \frac{\frac{d}{D}}{M}} \cdot \frac{-1}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 + \frac{0.5 \cdot \frac{D \cdot \left(h \cdot M\right)}{\ell \cdot d}}{\frac{1}{D \cdot \frac{M}{d}} \cdot -2}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 88.4% accurate, 1.7× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;M\_m \cdot D\_m \leq 10^{+176}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{\frac{h \cdot \left(M\_m \cdot \left(D\_m \cdot 0.5\right)\right)}{d}}{\ell \cdot \frac{d \cdot 2}{M\_m \cdot D\_m}}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M\_m \cdot \left(D\_m \cdot \frac{0.5}{d}\right)\right)}{\frac{\frac{-2}{D\_m}}{\frac{M\_m}{d}}}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
 :precision binary64
 (if (<= (* M_m D_m) 1e+176)
   (*
    w0
    (sqrt
     (-
      1.0
      (/ (/ (* h (* M_m (* D_m 0.5))) d) (* l (/ (* d 2.0) (* M_m D_m)))))))
   (*
    w0
    (sqrt
     (+
      1.0
      (/ (* (/ h l) (* M_m (* D_m (/ 0.5 d)))) (/ (/ -2.0 D_m) (/ M_m d))))))))
M_m = fabs(M);
D_m = fabs(D);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
	double tmp;
	if ((M_m * D_m) <= 1e+176) {
		tmp = w0 * sqrt((1.0 - (((h * (M_m * (D_m * 0.5))) / d) / (l * ((d * 2.0) / (M_m * D_m))))));
	} else {
		tmp = w0 * sqrt((1.0 + (((h / l) * (M_m * (D_m * (0.5 / d)))) / ((-2.0 / D_m) / (M_m / d)))));
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d)
    real(8), intent (in) :: w0
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d
    real(8) :: tmp
    if ((m_m * d_m) <= 1d+176) then
        tmp = w0 * sqrt((1.0d0 - (((h * (m_m * (d_m * 0.5d0))) / d) / (l * ((d * 2.0d0) / (m_m * d_m))))))
    else
        tmp = w0 * sqrt((1.0d0 + (((h / l) * (m_m * (d_m * (0.5d0 / d)))) / (((-2.0d0) / d_m) / (m_m / d)))))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
	double tmp;
	if ((M_m * D_m) <= 1e+176) {
		tmp = w0 * Math.sqrt((1.0 - (((h * (M_m * (D_m * 0.5))) / d) / (l * ((d * 2.0) / (M_m * D_m))))));
	} else {
		tmp = w0 * Math.sqrt((1.0 + (((h / l) * (M_m * (D_m * (0.5 / d)))) / ((-2.0 / D_m) / (M_m / d)))));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d])
def code(w0, M_m, D_m, h, l, d):
	tmp = 0
	if (M_m * D_m) <= 1e+176:
		tmp = w0 * math.sqrt((1.0 - (((h * (M_m * (D_m * 0.5))) / d) / (l * ((d * 2.0) / (M_m * D_m))))))
	else:
		tmp = w0 * math.sqrt((1.0 + (((h / l) * (M_m * (D_m * (0.5 / d)))) / ((-2.0 / D_m) / (M_m / d)))))
	return tmp
M_m = abs(M)
D_m = abs(D)
w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d])
function code(w0, M_m, D_m, h, l, d)
	tmp = 0.0
	if (Float64(M_m * D_m) <= 1e+176)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(h * Float64(M_m * Float64(D_m * 0.5))) / d) / Float64(l * Float64(Float64(d * 2.0) / Float64(M_m * D_m)))))));
	else
		tmp = Float64(w0 * sqrt(Float64(1.0 + Float64(Float64(Float64(h / l) * Float64(M_m * Float64(D_m * Float64(0.5 / d)))) / Float64(Float64(-2.0 / D_m) / Float64(M_m / d))))));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d)
	tmp = 0.0;
	if ((M_m * D_m) <= 1e+176)
		tmp = w0 * sqrt((1.0 - (((h * (M_m * (D_m * 0.5))) / d) / (l * ((d * 2.0) / (M_m * D_m))))));
	else
		tmp = w0 * sqrt((1.0 + (((h / l) * (M_m * (D_m * (0.5 / d)))) / ((-2.0 / D_m) / (M_m / d)))));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 1e+176], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(h * N[(M$95$m * N[(D$95$m * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision] / N[(l * N[(N[(d * 2.0), $MachinePrecision] / N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 + N[(N[(N[(h / l), $MachinePrecision] * N[(M$95$m * N[(D$95$m * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(-2.0 / D$95$m), $MachinePrecision] / N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;M\_m \cdot D\_m \leq 10^{+176}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{\frac{h \cdot \left(M\_m \cdot \left(D\_m \cdot 0.5\right)\right)}{d}}{\ell \cdot \frac{d \cdot 2}{M\_m \cdot D\_m}}}\\

\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M\_m \cdot \left(D\_m \cdot \frac{0.5}{d}\right)\right)}{\frac{\frac{-2}{D\_m}}{\frac{M\_m}{d}}}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 M D) < 1e176

    1. Initial program 84.1%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified84.5%

      \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. unpow284.5%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \left(D \cdot \frac{\frac{M}{2}}{d}\right)\right)} \cdot \frac{h}{\ell}} \]
      2. *-commutative84.5%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\left(\frac{\frac{M}{2}}{d} \cdot D\right)}\right) \cdot \frac{h}{\ell}} \]
      3. associate-*l/84.1%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\frac{\frac{M}{2} \cdot D}{d}}\right) \cdot \frac{h}{\ell}} \]
      4. associate-*r/83.3%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}\right) \cdot \frac{h}{\ell}} \]
      5. times-frac84.1%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\frac{M \cdot D}{2 \cdot d}}\right) \cdot \frac{h}{\ell}} \]
      6. clear-num84.1%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\frac{1}{\frac{2 \cdot d}{M \cdot D}}}\right) \cdot \frac{h}{\ell}} \]
      7. un-div-inv84.1%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{D \cdot \frac{\frac{M}{2}}{d}}{\frac{2 \cdot d}{M \cdot D}}} \cdot \frac{h}{\ell}} \]
      8. *-commutative84.1%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{\frac{M}{2}}{d} \cdot D}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      9. associate-*l/84.1%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{\frac{M}{2} \cdot D}{d}}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      10. associate-*r/82.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{M}{2} \cdot \frac{D}{d}}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      11. times-frac84.1%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{M \cdot D}{2 \cdot d}}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      12. associate-/l*82.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{M \cdot \frac{D}{2 \cdot d}}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      13. div-inv82.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \color{blue}{\left(D \cdot \frac{1}{2 \cdot d}\right)}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      14. associate-/r*82.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \left(D \cdot \color{blue}{\frac{\frac{1}{2}}{d}}\right)}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      15. metadata-eval82.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \left(D \cdot \frac{\color{blue}{0.5}}{d}\right)}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      16. times-frac83.3%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \left(D \cdot \frac{0.5}{d}\right)}{\color{blue}{\frac{2}{M} \cdot \frac{d}{D}}} \cdot \frac{h}{\ell}} \]
    5. Applied egg-rr83.3%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{M \cdot \left(D \cdot \frac{0.5}{d}\right)}{\frac{2}{M} \cdot \frac{d}{D}}} \cdot \frac{h}{\ell}} \]
    6. Step-by-step derivation
      1. frac-times91.4%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{\left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right) \cdot h}{\left(\frac{2}{M} \cdot \frac{d}{D}\right) \cdot \ell}}} \]
      2. associate-*r*90.9%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\left(\left(M \cdot D\right) \cdot \frac{0.5}{d}\right)} \cdot h}{\left(\frac{2}{M} \cdot \frac{d}{D}\right) \cdot \ell}} \]
      3. frac-times92.2%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\left(\left(M \cdot D\right) \cdot \frac{0.5}{d}\right) \cdot h}{\color{blue}{\frac{2 \cdot d}{M \cdot D}} \cdot \ell}} \]
    7. Applied egg-rr92.2%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{\left(\left(M \cdot D\right) \cdot \frac{0.5}{d}\right) \cdot h}{\frac{2 \cdot d}{M \cdot D} \cdot \ell}}} \]
    8. Step-by-step derivation
      1. *-commutative92.2%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{h \cdot \left(\left(M \cdot D\right) \cdot \frac{0.5}{d}\right)}}{\frac{2 \cdot d}{M \cdot D} \cdot \ell}} \]
      2. associate-*r/92.2%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{h \cdot \color{blue}{\frac{\left(M \cdot D\right) \cdot 0.5}{d}}}{\frac{2 \cdot d}{M \cdot D} \cdot \ell}} \]
      3. associate-*r*92.2%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{h \cdot \frac{\color{blue}{M \cdot \left(D \cdot 0.5\right)}}{d}}{\frac{2 \cdot d}{M \cdot D} \cdot \ell}} \]
      4. associate-*r/91.6%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{h \cdot \left(M \cdot \left(D \cdot 0.5\right)\right)}{d}}}{\frac{2 \cdot d}{M \cdot D} \cdot \ell}} \]
      5. *-commutative91.6%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{h \cdot \left(M \cdot \left(D \cdot 0.5\right)\right)}{d}}{\color{blue}{\ell \cdot \frac{2 \cdot d}{M \cdot D}}}} \]
      6. *-commutative91.6%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{h \cdot \left(M \cdot \left(D \cdot 0.5\right)\right)}{d}}{\ell \cdot \frac{2 \cdot d}{\color{blue}{D \cdot M}}}} \]
    9. Simplified91.6%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{\frac{h \cdot \left(M \cdot \left(D \cdot 0.5\right)\right)}{d}}{\ell \cdot \frac{2 \cdot d}{D \cdot M}}}} \]

    if 1e176 < (*.f64 M D)

    1. Initial program 79.3%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified79.3%

      \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. unpow279.3%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \left(D \cdot \frac{\frac{M}{2}}{d}\right)\right)} \cdot \frac{h}{\ell}} \]
      2. *-commutative79.3%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\left(\frac{\frac{M}{2}}{d} \cdot D\right)}\right) \cdot \frac{h}{\ell}} \]
      3. associate-*l/79.3%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\frac{\frac{M}{2} \cdot D}{d}}\right) \cdot \frac{h}{\ell}} \]
      4. associate-*r/79.3%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}\right) \cdot \frac{h}{\ell}} \]
      5. times-frac79.3%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\frac{M \cdot D}{2 \cdot d}}\right) \cdot \frac{h}{\ell}} \]
      6. clear-num79.3%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\frac{1}{\frac{2 \cdot d}{M \cdot D}}}\right) \cdot \frac{h}{\ell}} \]
      7. un-div-inv79.3%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{D \cdot \frac{\frac{M}{2}}{d}}{\frac{2 \cdot d}{M \cdot D}}} \cdot \frac{h}{\ell}} \]
      8. *-commutative79.3%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{\frac{M}{2}}{d} \cdot D}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      9. associate-*l/79.3%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{\frac{M}{2} \cdot D}{d}}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      10. associate-*r/79.3%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{M}{2} \cdot \frac{D}{d}}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      11. times-frac79.3%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{M \cdot D}{2 \cdot d}}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      12. associate-/l*79.3%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{M \cdot \frac{D}{2 \cdot d}}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      13. div-inv79.3%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \color{blue}{\left(D \cdot \frac{1}{2 \cdot d}\right)}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      14. associate-/r*79.3%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \left(D \cdot \color{blue}{\frac{\frac{1}{2}}{d}}\right)}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      15. metadata-eval79.3%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \left(D \cdot \frac{\color{blue}{0.5}}{d}\right)}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      16. times-frac79.3%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \left(D \cdot \frac{0.5}{d}\right)}{\color{blue}{\frac{2}{M} \cdot \frac{d}{D}}} \cdot \frac{h}{\ell}} \]
    5. Applied egg-rr79.3%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{M \cdot \left(D \cdot \frac{0.5}{d}\right)}{\frac{2}{M} \cdot \frac{d}{D}}} \cdot \frac{h}{\ell}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity79.3%

        \[\leadsto w0 \cdot \color{blue}{\left(1 \cdot \sqrt{1 - \frac{M \cdot \left(D \cdot \frac{0.5}{d}\right)}{\frac{2}{M} \cdot \frac{d}{D}} \cdot \frac{h}{\ell}}\right)} \]
      2. associate-*r*79.3%

        \[\leadsto w0 \cdot \left(1 \cdot \sqrt{1 - \frac{\color{blue}{\left(M \cdot D\right) \cdot \frac{0.5}{d}}}{\frac{2}{M} \cdot \frac{d}{D}} \cdot \frac{h}{\ell}}\right) \]
      3. frac-times79.3%

        \[\leadsto w0 \cdot \left(1 \cdot \sqrt{1 - \frac{\left(M \cdot D\right) \cdot \frac{0.5}{d}}{\color{blue}{\frac{2 \cdot d}{M \cdot D}}} \cdot \frac{h}{\ell}}\right) \]
    7. Applied egg-rr79.3%

      \[\leadsto w0 \cdot \color{blue}{\left(1 \cdot \sqrt{1 - \frac{\left(M \cdot D\right) \cdot \frac{0.5}{d}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}}\right)} \]
    8. Step-by-step derivation
      1. *-lft-identity79.3%

        \[\leadsto w0 \cdot \color{blue}{\sqrt{1 - \frac{\left(M \cdot D\right) \cdot \frac{0.5}{d}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}}} \]
      2. sub-neg79.3%

        \[\leadsto w0 \cdot \sqrt{\color{blue}{1 + \left(-\frac{\left(M \cdot D\right) \cdot \frac{0.5}{d}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}\right)}} \]
      3. associate-*l/79.3%

        \[\leadsto w0 \cdot \sqrt{1 + \left(-\color{blue}{\frac{\left(\left(M \cdot D\right) \cdot \frac{0.5}{d}\right) \cdot \frac{h}{\ell}}{\frac{2 \cdot d}{M \cdot D}}}\right)} \]
      4. distribute-neg-frac279.3%

        \[\leadsto w0 \cdot \sqrt{1 + \color{blue}{\frac{\left(\left(M \cdot D\right) \cdot \frac{0.5}{d}\right) \cdot \frac{h}{\ell}}{-\frac{2 \cdot d}{M \cdot D}}}} \]
      5. *-commutative79.3%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\color{blue}{\frac{h}{\ell} \cdot \left(\left(M \cdot D\right) \cdot \frac{0.5}{d}\right)}}{-\frac{2 \cdot d}{M \cdot D}}} \]
      6. associate-*l*79.3%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \color{blue}{\left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}}{-\frac{2 \cdot d}{M \cdot D}}} \]
      7. associate-/l*79.3%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{-\color{blue}{2 \cdot \frac{d}{M \cdot D}}}} \]
      8. *-commutative79.3%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{-2 \cdot \frac{d}{\color{blue}{D \cdot M}}}} \]
      9. *-commutative79.3%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{-\color{blue}{\frac{d}{D \cdot M} \cdot 2}}} \]
      10. distribute-rgt-neg-in79.3%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{\frac{d}{D \cdot M} \cdot \left(-2\right)}}} \]
      11. metadata-eval79.3%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\frac{d}{D \cdot M} \cdot \color{blue}{-2}}} \]
    9. Simplified79.3%

      \[\leadsto w0 \cdot \color{blue}{\sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\frac{d}{D \cdot M} \cdot -2}}} \]
    10. Step-by-step derivation
      1. clear-num79.3%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{\frac{1}{\frac{D \cdot M}{d}}} \cdot -2}} \]
      2. inv-pow79.3%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{{\left(\frac{D \cdot M}{d}\right)}^{-1}} \cdot -2}} \]
      3. *-commutative79.3%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{{\left(\frac{\color{blue}{M \cdot D}}{d}\right)}^{-1} \cdot -2}} \]
    11. Applied egg-rr79.3%

      \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{{\left(\frac{M \cdot D}{d}\right)}^{-1}} \cdot -2}} \]
    12. Step-by-step derivation
      1. unpow-179.3%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{\frac{1}{\frac{M \cdot D}{d}}} \cdot -2}} \]
      2. *-commutative79.3%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\frac{1}{\frac{\color{blue}{D \cdot M}}{d}} \cdot -2}} \]
      3. associate-/l*91.6%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\frac{1}{\color{blue}{D \cdot \frac{M}{d}}} \cdot -2}} \]
    13. Simplified91.6%

      \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{\frac{1}{D \cdot \frac{M}{d}}} \cdot -2}} \]
    14. Taylor expanded in D around 0 79.3%

      \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{-2 \cdot \frac{d}{D \cdot M}}}} \]
    15. Step-by-step derivation
      1. associate-*r/79.3%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{\frac{-2 \cdot d}{D \cdot M}}}} \]
      2. *-commutative79.3%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\frac{-2 \cdot d}{\color{blue}{M \cdot D}}}} \]
      3. associate-*l/79.3%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{\frac{-2}{M \cdot D} \cdot d}}} \]
      4. associate-/r/79.3%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{\frac{-2}{\frac{M \cdot D}{d}}}}} \]
      5. *-commutative79.3%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\frac{-2}{\frac{\color{blue}{D \cdot M}}{d}}}} \]
      6. associate-/l*91.6%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\frac{-2}{\color{blue}{D \cdot \frac{M}{d}}}}} \]
      7. associate-/r*91.7%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{\frac{\frac{-2}{D}}{\frac{M}{d}}}}} \]
    16. Simplified91.7%

      \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{\frac{\frac{-2}{D}}{\frac{M}{d}}}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification91.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \cdot D \leq 10^{+176}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{\frac{h \cdot \left(M \cdot \left(D \cdot 0.5\right)\right)}{d}}{\ell \cdot \frac{d \cdot 2}{M \cdot D}}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\frac{\frac{-2}{D}}{\frac{M}{d}}}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 86.6% accurate, 1.7× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;M\_m \cdot D\_m \leq 5 \cdot 10^{-9}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h \cdot \frac{\frac{0.5}{d} \cdot \left(M\_m \cdot D\_m\right)}{\frac{d \cdot 2}{M\_m \cdot D\_m}}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M\_m \cdot \left(D\_m \cdot \frac{0.5}{d}\right)\right)}{\frac{\frac{-2}{D\_m}}{\frac{M\_m}{d}}}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
 :precision binary64
 (if (<= (* M_m D_m) 5e-9)
   (*
    w0
    (sqrt
     (-
      1.0
      (/ (* h (/ (* (/ 0.5 d) (* M_m D_m)) (/ (* d 2.0) (* M_m D_m)))) l))))
   (*
    w0
    (sqrt
     (+
      1.0
      (/ (* (/ h l) (* M_m (* D_m (/ 0.5 d)))) (/ (/ -2.0 D_m) (/ M_m d))))))))
M_m = fabs(M);
D_m = fabs(D);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
	double tmp;
	if ((M_m * D_m) <= 5e-9) {
		tmp = w0 * sqrt((1.0 - ((h * (((0.5 / d) * (M_m * D_m)) / ((d * 2.0) / (M_m * D_m)))) / l)));
	} else {
		tmp = w0 * sqrt((1.0 + (((h / l) * (M_m * (D_m * (0.5 / d)))) / ((-2.0 / D_m) / (M_m / d)))));
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d)
    real(8), intent (in) :: w0
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d
    real(8) :: tmp
    if ((m_m * d_m) <= 5d-9) then
        tmp = w0 * sqrt((1.0d0 - ((h * (((0.5d0 / d) * (m_m * d_m)) / ((d * 2.0d0) / (m_m * d_m)))) / l)))
    else
        tmp = w0 * sqrt((1.0d0 + (((h / l) * (m_m * (d_m * (0.5d0 / d)))) / (((-2.0d0) / d_m) / (m_m / d)))))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
	double tmp;
	if ((M_m * D_m) <= 5e-9) {
		tmp = w0 * Math.sqrt((1.0 - ((h * (((0.5 / d) * (M_m * D_m)) / ((d * 2.0) / (M_m * D_m)))) / l)));
	} else {
		tmp = w0 * Math.sqrt((1.0 + (((h / l) * (M_m * (D_m * (0.5 / d)))) / ((-2.0 / D_m) / (M_m / d)))));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d])
def code(w0, M_m, D_m, h, l, d):
	tmp = 0
	if (M_m * D_m) <= 5e-9:
		tmp = w0 * math.sqrt((1.0 - ((h * (((0.5 / d) * (M_m * D_m)) / ((d * 2.0) / (M_m * D_m)))) / l)))
	else:
		tmp = w0 * math.sqrt((1.0 + (((h / l) * (M_m * (D_m * (0.5 / d)))) / ((-2.0 / D_m) / (M_m / d)))))
	return tmp
M_m = abs(M)
D_m = abs(D)
w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d])
function code(w0, M_m, D_m, h, l, d)
	tmp = 0.0
	if (Float64(M_m * D_m) <= 5e-9)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h * Float64(Float64(Float64(0.5 / d) * Float64(M_m * D_m)) / Float64(Float64(d * 2.0) / Float64(M_m * D_m)))) / l))));
	else
		tmp = Float64(w0 * sqrt(Float64(1.0 + Float64(Float64(Float64(h / l) * Float64(M_m * Float64(D_m * Float64(0.5 / d)))) / Float64(Float64(-2.0 / D_m) / Float64(M_m / d))))));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d)
	tmp = 0.0;
	if ((M_m * D_m) <= 5e-9)
		tmp = w0 * sqrt((1.0 - ((h * (((0.5 / d) * (M_m * D_m)) / ((d * 2.0) / (M_m * D_m)))) / l)));
	else
		tmp = w0 * sqrt((1.0 + (((h / l) * (M_m * (D_m * (0.5 / d)))) / ((-2.0 / D_m) / (M_m / d)))));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 5e-9], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h * N[(N[(N[(0.5 / d), $MachinePrecision] * N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] / N[(N[(d * 2.0), $MachinePrecision] / N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 + N[(N[(N[(h / l), $MachinePrecision] * N[(M$95$m * N[(D$95$m * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(-2.0 / D$95$m), $MachinePrecision] / N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;M\_m \cdot D\_m \leq 5 \cdot 10^{-9}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h \cdot \frac{\frac{0.5}{d} \cdot \left(M\_m \cdot D\_m\right)}{\frac{d \cdot 2}{M\_m \cdot D\_m}}}{\ell}}\\

\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M\_m \cdot \left(D\_m \cdot \frac{0.5}{d}\right)\right)}{\frac{\frac{-2}{D\_m}}{\frac{M\_m}{d}}}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 M D) < 5.0000000000000001e-9

    1. Initial program 84.9%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified85.4%

      \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. unpow285.4%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \left(D \cdot \frac{\frac{M}{2}}{d}\right)\right)} \cdot \frac{h}{\ell}} \]
      2. *-commutative85.4%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\left(\frac{\frac{M}{2}}{d} \cdot D\right)}\right) \cdot \frac{h}{\ell}} \]
      3. associate-*l/84.9%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\frac{\frac{M}{2} \cdot D}{d}}\right) \cdot \frac{h}{\ell}} \]
      4. associate-*r/84.0%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}\right) \cdot \frac{h}{\ell}} \]
      5. times-frac84.9%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\frac{M \cdot D}{2 \cdot d}}\right) \cdot \frac{h}{\ell}} \]
      6. clear-num84.9%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\frac{1}{\frac{2 \cdot d}{M \cdot D}}}\right) \cdot \frac{h}{\ell}} \]
      7. un-div-inv84.9%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{D \cdot \frac{\frac{M}{2}}{d}}{\frac{2 \cdot d}{M \cdot D}}} \cdot \frac{h}{\ell}} \]
      8. *-commutative84.9%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{\frac{M}{2}}{d} \cdot D}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      9. associate-*l/84.9%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{\frac{M}{2} \cdot D}{d}}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      10. associate-*r/83.5%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{M}{2} \cdot \frac{D}{d}}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      11. times-frac84.9%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{M \cdot D}{2 \cdot d}}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      12. associate-/l*83.5%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{M \cdot \frac{D}{2 \cdot d}}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      13. div-inv83.5%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \color{blue}{\left(D \cdot \frac{1}{2 \cdot d}\right)}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      14. associate-/r*83.5%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \left(D \cdot \color{blue}{\frac{\frac{1}{2}}{d}}\right)}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      15. metadata-eval83.5%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \left(D \cdot \frac{\color{blue}{0.5}}{d}\right)}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      16. times-frac84.0%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \left(D \cdot \frac{0.5}{d}\right)}{\color{blue}{\frac{2}{M} \cdot \frac{d}{D}}} \cdot \frac{h}{\ell}} \]
    5. Applied egg-rr84.0%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{M \cdot \left(D \cdot \frac{0.5}{d}\right)}{\frac{2}{M} \cdot \frac{d}{D}}} \cdot \frac{h}{\ell}} \]
    6. Step-by-step derivation
      1. associate-*r/90.7%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{\frac{M \cdot \left(D \cdot \frac{0.5}{d}\right)}{\frac{2}{M} \cdot \frac{d}{D}} \cdot h}{\ell}}} \]
      2. associate-*r*90.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{\color{blue}{\left(M \cdot D\right) \cdot \frac{0.5}{d}}}{\frac{2}{M} \cdot \frac{d}{D}} \cdot h}{\ell}} \]
      3. frac-times91.6%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{\left(M \cdot D\right) \cdot \frac{0.5}{d}}{\color{blue}{\frac{2 \cdot d}{M \cdot D}}} \cdot h}{\ell}} \]
    7. Applied egg-rr91.6%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{\frac{\left(M \cdot D\right) \cdot \frac{0.5}{d}}{\frac{2 \cdot d}{M \cdot D}} \cdot h}{\ell}}} \]

    if 5.0000000000000001e-9 < (*.f64 M D)

    1. Initial program 78.1%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified78.1%

      \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. unpow278.1%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \left(D \cdot \frac{\frac{M}{2}}{d}\right)\right)} \cdot \frac{h}{\ell}} \]
      2. *-commutative78.1%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\left(\frac{\frac{M}{2}}{d} \cdot D\right)}\right) \cdot \frac{h}{\ell}} \]
      3. associate-*l/78.1%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\frac{\frac{M}{2} \cdot D}{d}}\right) \cdot \frac{h}{\ell}} \]
      4. associate-*r/78.1%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}\right) \cdot \frac{h}{\ell}} \]
      5. times-frac78.1%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\frac{M \cdot D}{2 \cdot d}}\right) \cdot \frac{h}{\ell}} \]
      6. clear-num78.1%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\frac{1}{\frac{2 \cdot d}{M \cdot D}}}\right) \cdot \frac{h}{\ell}} \]
      7. un-div-inv78.1%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{D \cdot \frac{\frac{M}{2}}{d}}{\frac{2 \cdot d}{M \cdot D}}} \cdot \frac{h}{\ell}} \]
      8. *-commutative78.1%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{\frac{M}{2}}{d} \cdot D}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      9. associate-*l/78.1%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{\frac{M}{2} \cdot D}{d}}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      10. associate-*r/78.1%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{M}{2} \cdot \frac{D}{d}}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      11. times-frac78.1%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{M \cdot D}{2 \cdot d}}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      12. associate-/l*78.1%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{M \cdot \frac{D}{2 \cdot d}}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      13. div-inv78.1%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \color{blue}{\left(D \cdot \frac{1}{2 \cdot d}\right)}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      14. associate-/r*78.1%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \left(D \cdot \color{blue}{\frac{\frac{1}{2}}{d}}\right)}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      15. metadata-eval78.1%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \left(D \cdot \frac{\color{blue}{0.5}}{d}\right)}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      16. times-frac78.1%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \left(D \cdot \frac{0.5}{d}\right)}{\color{blue}{\frac{2}{M} \cdot \frac{d}{D}}} \cdot \frac{h}{\ell}} \]
    5. Applied egg-rr78.1%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{M \cdot \left(D \cdot \frac{0.5}{d}\right)}{\frac{2}{M} \cdot \frac{d}{D}}} \cdot \frac{h}{\ell}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity78.1%

        \[\leadsto w0 \cdot \color{blue}{\left(1 \cdot \sqrt{1 - \frac{M \cdot \left(D \cdot \frac{0.5}{d}\right)}{\frac{2}{M} \cdot \frac{d}{D}} \cdot \frac{h}{\ell}}\right)} \]
      2. associate-*r*78.1%

        \[\leadsto w0 \cdot \left(1 \cdot \sqrt{1 - \frac{\color{blue}{\left(M \cdot D\right) \cdot \frac{0.5}{d}}}{\frac{2}{M} \cdot \frac{d}{D}} \cdot \frac{h}{\ell}}\right) \]
      3. frac-times78.1%

        \[\leadsto w0 \cdot \left(1 \cdot \sqrt{1 - \frac{\left(M \cdot D\right) \cdot \frac{0.5}{d}}{\color{blue}{\frac{2 \cdot d}{M \cdot D}}} \cdot \frac{h}{\ell}}\right) \]
    7. Applied egg-rr78.1%

      \[\leadsto w0 \cdot \color{blue}{\left(1 \cdot \sqrt{1 - \frac{\left(M \cdot D\right) \cdot \frac{0.5}{d}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}}\right)} \]
    8. Step-by-step derivation
      1. *-lft-identity78.1%

        \[\leadsto w0 \cdot \color{blue}{\sqrt{1 - \frac{\left(M \cdot D\right) \cdot \frac{0.5}{d}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}}} \]
      2. sub-neg78.1%

        \[\leadsto w0 \cdot \sqrt{\color{blue}{1 + \left(-\frac{\left(M \cdot D\right) \cdot \frac{0.5}{d}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}\right)}} \]
      3. associate-*l/78.1%

        \[\leadsto w0 \cdot \sqrt{1 + \left(-\color{blue}{\frac{\left(\left(M \cdot D\right) \cdot \frac{0.5}{d}\right) \cdot \frac{h}{\ell}}{\frac{2 \cdot d}{M \cdot D}}}\right)} \]
      4. distribute-neg-frac278.1%

        \[\leadsto w0 \cdot \sqrt{1 + \color{blue}{\frac{\left(\left(M \cdot D\right) \cdot \frac{0.5}{d}\right) \cdot \frac{h}{\ell}}{-\frac{2 \cdot d}{M \cdot D}}}} \]
      5. *-commutative78.1%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\color{blue}{\frac{h}{\ell} \cdot \left(\left(M \cdot D\right) \cdot \frac{0.5}{d}\right)}}{-\frac{2 \cdot d}{M \cdot D}}} \]
      6. associate-*l*78.1%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \color{blue}{\left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}}{-\frac{2 \cdot d}{M \cdot D}}} \]
      7. associate-/l*78.1%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{-\color{blue}{2 \cdot \frac{d}{M \cdot D}}}} \]
      8. *-commutative78.1%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{-2 \cdot \frac{d}{\color{blue}{D \cdot M}}}} \]
      9. *-commutative78.1%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{-\color{blue}{\frac{d}{D \cdot M} \cdot 2}}} \]
      10. distribute-rgt-neg-in78.1%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{\frac{d}{D \cdot M} \cdot \left(-2\right)}}} \]
      11. metadata-eval78.1%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\frac{d}{D \cdot M} \cdot \color{blue}{-2}}} \]
    9. Simplified78.1%

      \[\leadsto w0 \cdot \color{blue}{\sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\frac{d}{D \cdot M} \cdot -2}}} \]
    10. Step-by-step derivation
      1. clear-num78.1%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{\frac{1}{\frac{D \cdot M}{d}}} \cdot -2}} \]
      2. inv-pow78.1%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{{\left(\frac{D \cdot M}{d}\right)}^{-1}} \cdot -2}} \]
      3. *-commutative78.1%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{{\left(\frac{\color{blue}{M \cdot D}}{d}\right)}^{-1} \cdot -2}} \]
    11. Applied egg-rr78.1%

      \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{{\left(\frac{M \cdot D}{d}\right)}^{-1}} \cdot -2}} \]
    12. Step-by-step derivation
      1. unpow-178.1%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{\frac{1}{\frac{M \cdot D}{d}}} \cdot -2}} \]
      2. *-commutative78.1%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\frac{1}{\frac{\color{blue}{D \cdot M}}{d}} \cdot -2}} \]
      3. associate-/l*84.0%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\frac{1}{\color{blue}{D \cdot \frac{M}{d}}} \cdot -2}} \]
    13. Simplified84.0%

      \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{\frac{1}{D \cdot \frac{M}{d}}} \cdot -2}} \]
    14. Taylor expanded in D around 0 78.1%

      \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{-2 \cdot \frac{d}{D \cdot M}}}} \]
    15. Step-by-step derivation
      1. associate-*r/78.1%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{\frac{-2 \cdot d}{D \cdot M}}}} \]
      2. *-commutative78.1%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\frac{-2 \cdot d}{\color{blue}{M \cdot D}}}} \]
      3. associate-*l/78.1%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{\frac{-2}{M \cdot D} \cdot d}}} \]
      4. associate-/r/78.1%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{\frac{-2}{\frac{M \cdot D}{d}}}}} \]
      5. *-commutative78.1%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\frac{-2}{\frac{\color{blue}{D \cdot M}}{d}}}} \]
      6. associate-/l*84.0%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\frac{-2}{\color{blue}{D \cdot \frac{M}{d}}}}} \]
      7. associate-/r*84.0%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{\frac{\frac{-2}{D}}{\frac{M}{d}}}}} \]
    16. Simplified84.0%

      \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{\frac{\frac{-2}{D}}{\frac{M}{d}}}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification90.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \cdot D \leq 5 \cdot 10^{-9}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h \cdot \frac{\frac{0.5}{d} \cdot \left(M \cdot D\right)}{\frac{d \cdot 2}{M \cdot D}}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\frac{\frac{-2}{D}}{\frac{M}{d}}}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 84.0% accurate, 1.7× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;M\_m \cdot D\_m \leq 4 \cdot 10^{-140}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M\_m \cdot \left(D\_m \cdot \frac{0.5}{d}\right)\right)}{\frac{\frac{-2}{D\_m}}{\frac{M\_m}{d}}}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
 :precision binary64
 (if (<= (* M_m D_m) 4e-140)
   w0
   (*
    w0
    (sqrt
     (+
      1.0
      (/ (* (/ h l) (* M_m (* D_m (/ 0.5 d)))) (/ (/ -2.0 D_m) (/ M_m d))))))))
M_m = fabs(M);
D_m = fabs(D);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
	double tmp;
	if ((M_m * D_m) <= 4e-140) {
		tmp = w0;
	} else {
		tmp = w0 * sqrt((1.0 + (((h / l) * (M_m * (D_m * (0.5 / d)))) / ((-2.0 / D_m) / (M_m / d)))));
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d)
    real(8), intent (in) :: w0
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d
    real(8) :: tmp
    if ((m_m * d_m) <= 4d-140) then
        tmp = w0
    else
        tmp = w0 * sqrt((1.0d0 + (((h / l) * (m_m * (d_m * (0.5d0 / d)))) / (((-2.0d0) / d_m) / (m_m / d)))))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
	double tmp;
	if ((M_m * D_m) <= 4e-140) {
		tmp = w0;
	} else {
		tmp = w0 * Math.sqrt((1.0 + (((h / l) * (M_m * (D_m * (0.5 / d)))) / ((-2.0 / D_m) / (M_m / d)))));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d])
def code(w0, M_m, D_m, h, l, d):
	tmp = 0
	if (M_m * D_m) <= 4e-140:
		tmp = w0
	else:
		tmp = w0 * math.sqrt((1.0 + (((h / l) * (M_m * (D_m * (0.5 / d)))) / ((-2.0 / D_m) / (M_m / d)))))
	return tmp
M_m = abs(M)
D_m = abs(D)
w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d])
function code(w0, M_m, D_m, h, l, d)
	tmp = 0.0
	if (Float64(M_m * D_m) <= 4e-140)
		tmp = w0;
	else
		tmp = Float64(w0 * sqrt(Float64(1.0 + Float64(Float64(Float64(h / l) * Float64(M_m * Float64(D_m * Float64(0.5 / d)))) / Float64(Float64(-2.0 / D_m) / Float64(M_m / d))))));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d)
	tmp = 0.0;
	if ((M_m * D_m) <= 4e-140)
		tmp = w0;
	else
		tmp = w0 * sqrt((1.0 + (((h / l) * (M_m * (D_m * (0.5 / d)))) / ((-2.0 / D_m) / (M_m / d)))));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 4e-140], w0, N[(w0 * N[Sqrt[N[(1.0 + N[(N[(N[(h / l), $MachinePrecision] * N[(M$95$m * N[(D$95$m * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(-2.0 / D$95$m), $MachinePrecision] / N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;M\_m \cdot D\_m \leq 4 \cdot 10^{-140}:\\
\;\;\;\;w0\\

\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M\_m \cdot \left(D\_m \cdot \frac{0.5}{d}\right)\right)}{\frac{\frac{-2}{D\_m}}{\frac{M\_m}{d}}}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 M D) < 3.9999999999999999e-140

    1. Initial program 83.7%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified84.2%

      \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Add Preprocessing
    4. Taylor expanded in D around 0 80.1%

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

    if 3.9999999999999999e-140 < (*.f64 M D)

    1. Initial program 83.6%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified83.5%

      \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. unpow283.5%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \left(D \cdot \frac{\frac{M}{2}}{d}\right)\right)} \cdot \frac{h}{\ell}} \]
      2. *-commutative83.5%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\left(\frac{\frac{M}{2}}{d} \cdot D\right)}\right) \cdot \frac{h}{\ell}} \]
      3. associate-*l/83.6%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\frac{\frac{M}{2} \cdot D}{d}}\right) \cdot \frac{h}{\ell}} \]
      4. associate-*r/82.1%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}\right) \cdot \frac{h}{\ell}} \]
      5. times-frac83.6%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\frac{M \cdot D}{2 \cdot d}}\right) \cdot \frac{h}{\ell}} \]
      6. clear-num83.6%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\frac{1}{\frac{2 \cdot d}{M \cdot D}}}\right) \cdot \frac{h}{\ell}} \]
      7. un-div-inv83.6%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{D \cdot \frac{\frac{M}{2}}{d}}{\frac{2 \cdot d}{M \cdot D}}} \cdot \frac{h}{\ell}} \]
      8. *-commutative83.6%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{\frac{M}{2}}{d} \cdot D}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      9. associate-*l/83.6%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{\frac{M}{2} \cdot D}{d}}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      10. associate-*r/82.1%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{M}{2} \cdot \frac{D}{d}}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      11. times-frac83.6%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{M \cdot D}{2 \cdot d}}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      12. associate-/l*82.1%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{M \cdot \frac{D}{2 \cdot d}}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      13. div-inv82.1%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \color{blue}{\left(D \cdot \frac{1}{2 \cdot d}\right)}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      14. associate-/r*82.1%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \left(D \cdot \color{blue}{\frac{\frac{1}{2}}{d}}\right)}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      15. metadata-eval82.1%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \left(D \cdot \frac{\color{blue}{0.5}}{d}\right)}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      16. times-frac82.1%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \left(D \cdot \frac{0.5}{d}\right)}{\color{blue}{\frac{2}{M} \cdot \frac{d}{D}}} \cdot \frac{h}{\ell}} \]
    5. Applied egg-rr82.1%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{M \cdot \left(D \cdot \frac{0.5}{d}\right)}{\frac{2}{M} \cdot \frac{d}{D}}} \cdot \frac{h}{\ell}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity82.1%

        \[\leadsto w0 \cdot \color{blue}{\left(1 \cdot \sqrt{1 - \frac{M \cdot \left(D \cdot \frac{0.5}{d}\right)}{\frac{2}{M} \cdot \frac{d}{D}} \cdot \frac{h}{\ell}}\right)} \]
      2. associate-*r*83.6%

        \[\leadsto w0 \cdot \left(1 \cdot \sqrt{1 - \frac{\color{blue}{\left(M \cdot D\right) \cdot \frac{0.5}{d}}}{\frac{2}{M} \cdot \frac{d}{D}} \cdot \frac{h}{\ell}}\right) \]
      3. frac-times83.6%

        \[\leadsto w0 \cdot \left(1 \cdot \sqrt{1 - \frac{\left(M \cdot D\right) \cdot \frac{0.5}{d}}{\color{blue}{\frac{2 \cdot d}{M \cdot D}}} \cdot \frac{h}{\ell}}\right) \]
    7. Applied egg-rr83.6%

      \[\leadsto w0 \cdot \color{blue}{\left(1 \cdot \sqrt{1 - \frac{\left(M \cdot D\right) \cdot \frac{0.5}{d}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}}\right)} \]
    8. Step-by-step derivation
      1. *-lft-identity83.6%

        \[\leadsto w0 \cdot \color{blue}{\sqrt{1 - \frac{\left(M \cdot D\right) \cdot \frac{0.5}{d}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}}} \]
      2. sub-neg83.6%

        \[\leadsto w0 \cdot \sqrt{\color{blue}{1 + \left(-\frac{\left(M \cdot D\right) \cdot \frac{0.5}{d}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}\right)}} \]
      3. associate-*l/85.0%

        \[\leadsto w0 \cdot \sqrt{1 + \left(-\color{blue}{\frac{\left(\left(M \cdot D\right) \cdot \frac{0.5}{d}\right) \cdot \frac{h}{\ell}}{\frac{2 \cdot d}{M \cdot D}}}\right)} \]
      4. distribute-neg-frac285.0%

        \[\leadsto w0 \cdot \sqrt{1 + \color{blue}{\frac{\left(\left(M \cdot D\right) \cdot \frac{0.5}{d}\right) \cdot \frac{h}{\ell}}{-\frac{2 \cdot d}{M \cdot D}}}} \]
      5. *-commutative85.0%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\color{blue}{\frac{h}{\ell} \cdot \left(\left(M \cdot D\right) \cdot \frac{0.5}{d}\right)}}{-\frac{2 \cdot d}{M \cdot D}}} \]
      6. associate-*l*83.5%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \color{blue}{\left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}}{-\frac{2 \cdot d}{M \cdot D}}} \]
      7. associate-/l*83.5%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{-\color{blue}{2 \cdot \frac{d}{M \cdot D}}}} \]
      8. *-commutative83.5%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{-2 \cdot \frac{d}{\color{blue}{D \cdot M}}}} \]
      9. *-commutative83.5%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{-\color{blue}{\frac{d}{D \cdot M} \cdot 2}}} \]
      10. distribute-rgt-neg-in83.5%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{\frac{d}{D \cdot M} \cdot \left(-2\right)}}} \]
      11. metadata-eval83.5%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\frac{d}{D \cdot M} \cdot \color{blue}{-2}}} \]
    9. Simplified83.5%

      \[\leadsto w0 \cdot \color{blue}{\sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\frac{d}{D \cdot M} \cdot -2}}} \]
    10. Step-by-step derivation
      1. clear-num83.6%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{\frac{1}{\frac{D \cdot M}{d}}} \cdot -2}} \]
      2. inv-pow83.6%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{{\left(\frac{D \cdot M}{d}\right)}^{-1}} \cdot -2}} \]
      3. *-commutative83.6%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{{\left(\frac{\color{blue}{M \cdot D}}{d}\right)}^{-1} \cdot -2}} \]
    11. Applied egg-rr83.6%

      \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{{\left(\frac{M \cdot D}{d}\right)}^{-1}} \cdot -2}} \]
    12. Step-by-step derivation
      1. unpow-183.6%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{\frac{1}{\frac{M \cdot D}{d}}} \cdot -2}} \]
      2. *-commutative83.6%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\frac{1}{\frac{\color{blue}{D \cdot M}}{d}} \cdot -2}} \]
      3. associate-/l*86.2%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\frac{1}{\color{blue}{D \cdot \frac{M}{d}}} \cdot -2}} \]
    13. Simplified86.2%

      \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{\frac{1}{D \cdot \frac{M}{d}}} \cdot -2}} \]
    14. Taylor expanded in D around 0 83.5%

      \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{-2 \cdot \frac{d}{D \cdot M}}}} \]
    15. Step-by-step derivation
      1. associate-*r/83.5%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{\frac{-2 \cdot d}{D \cdot M}}}} \]
      2. *-commutative83.5%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\frac{-2 \cdot d}{\color{blue}{M \cdot D}}}} \]
      3. associate-*l/83.5%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{\frac{-2}{M \cdot D} \cdot d}}} \]
      4. associate-/r/83.6%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{\frac{-2}{\frac{M \cdot D}{d}}}}} \]
      5. *-commutative83.6%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\frac{-2}{\frac{\color{blue}{D \cdot M}}{d}}}} \]
      6. associate-/l*86.2%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\frac{-2}{\color{blue}{D \cdot \frac{M}{d}}}}} \]
      7. associate-/r*86.2%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{\frac{\frac{-2}{D}}{\frac{M}{d}}}}} \]
    16. Simplified86.2%

      \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{\frac{\frac{-2}{D}}{\frac{M}{d}}}}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 5: 83.2% accurate, 1.7× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;M\_m \cdot D\_m \leq 4 \cdot 10^{-140}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M\_m \cdot \left(D\_m \cdot \frac{0.5}{d}\right)\right)}{-2 \cdot \frac{d}{M\_m \cdot D\_m}}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
 :precision binary64
 (if (<= (* M_m D_m) 4e-140)
   w0
   (*
    w0
    (sqrt
     (+
      1.0
      (/ (* (/ h l) (* M_m (* D_m (/ 0.5 d)))) (* -2.0 (/ d (* M_m D_m)))))))))
M_m = fabs(M);
D_m = fabs(D);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
	double tmp;
	if ((M_m * D_m) <= 4e-140) {
		tmp = w0;
	} else {
		tmp = w0 * sqrt((1.0 + (((h / l) * (M_m * (D_m * (0.5 / d)))) / (-2.0 * (d / (M_m * D_m))))));
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d)
    real(8), intent (in) :: w0
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d
    real(8) :: tmp
    if ((m_m * d_m) <= 4d-140) then
        tmp = w0
    else
        tmp = w0 * sqrt((1.0d0 + (((h / l) * (m_m * (d_m * (0.5d0 / d)))) / ((-2.0d0) * (d / (m_m * d_m))))))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
	double tmp;
	if ((M_m * D_m) <= 4e-140) {
		tmp = w0;
	} else {
		tmp = w0 * Math.sqrt((1.0 + (((h / l) * (M_m * (D_m * (0.5 / d)))) / (-2.0 * (d / (M_m * D_m))))));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d])
def code(w0, M_m, D_m, h, l, d):
	tmp = 0
	if (M_m * D_m) <= 4e-140:
		tmp = w0
	else:
		tmp = w0 * math.sqrt((1.0 + (((h / l) * (M_m * (D_m * (0.5 / d)))) / (-2.0 * (d / (M_m * D_m))))))
	return tmp
M_m = abs(M)
D_m = abs(D)
w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d])
function code(w0, M_m, D_m, h, l, d)
	tmp = 0.0
	if (Float64(M_m * D_m) <= 4e-140)
		tmp = w0;
	else
		tmp = Float64(w0 * sqrt(Float64(1.0 + Float64(Float64(Float64(h / l) * Float64(M_m * Float64(D_m * Float64(0.5 / d)))) / Float64(-2.0 * Float64(d / Float64(M_m * D_m)))))));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d)
	tmp = 0.0;
	if ((M_m * D_m) <= 4e-140)
		tmp = w0;
	else
		tmp = w0 * sqrt((1.0 + (((h / l) * (M_m * (D_m * (0.5 / d)))) / (-2.0 * (d / (M_m * D_m))))));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 4e-140], w0, N[(w0 * N[Sqrt[N[(1.0 + N[(N[(N[(h / l), $MachinePrecision] * N[(M$95$m * N[(D$95$m * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(-2.0 * N[(d / N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;M\_m \cdot D\_m \leq 4 \cdot 10^{-140}:\\
\;\;\;\;w0\\

\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M\_m \cdot \left(D\_m \cdot \frac{0.5}{d}\right)\right)}{-2 \cdot \frac{d}{M\_m \cdot D\_m}}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 M D) < 3.9999999999999999e-140

    1. Initial program 83.7%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified84.2%

      \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Add Preprocessing
    4. Taylor expanded in D around 0 80.1%

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

    if 3.9999999999999999e-140 < (*.f64 M D)

    1. Initial program 83.6%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified83.5%

      \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. unpow283.5%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \left(D \cdot \frac{\frac{M}{2}}{d}\right)\right)} \cdot \frac{h}{\ell}} \]
      2. *-commutative83.5%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\left(\frac{\frac{M}{2}}{d} \cdot D\right)}\right) \cdot \frac{h}{\ell}} \]
      3. associate-*l/83.6%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\frac{\frac{M}{2} \cdot D}{d}}\right) \cdot \frac{h}{\ell}} \]
      4. associate-*r/82.1%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}\right) \cdot \frac{h}{\ell}} \]
      5. times-frac83.6%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\frac{M \cdot D}{2 \cdot d}}\right) \cdot \frac{h}{\ell}} \]
      6. clear-num83.6%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\frac{1}{\frac{2 \cdot d}{M \cdot D}}}\right) \cdot \frac{h}{\ell}} \]
      7. un-div-inv83.6%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{D \cdot \frac{\frac{M}{2}}{d}}{\frac{2 \cdot d}{M \cdot D}}} \cdot \frac{h}{\ell}} \]
      8. *-commutative83.6%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{\frac{M}{2}}{d} \cdot D}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      9. associate-*l/83.6%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{\frac{M}{2} \cdot D}{d}}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      10. associate-*r/82.1%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{M}{2} \cdot \frac{D}{d}}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      11. times-frac83.6%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{M \cdot D}{2 \cdot d}}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      12. associate-/l*82.1%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{M \cdot \frac{D}{2 \cdot d}}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      13. div-inv82.1%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \color{blue}{\left(D \cdot \frac{1}{2 \cdot d}\right)}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      14. associate-/r*82.1%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \left(D \cdot \color{blue}{\frac{\frac{1}{2}}{d}}\right)}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      15. metadata-eval82.1%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \left(D \cdot \frac{\color{blue}{0.5}}{d}\right)}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      16. times-frac82.1%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \left(D \cdot \frac{0.5}{d}\right)}{\color{blue}{\frac{2}{M} \cdot \frac{d}{D}}} \cdot \frac{h}{\ell}} \]
    5. Applied egg-rr82.1%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{M \cdot \left(D \cdot \frac{0.5}{d}\right)}{\frac{2}{M} \cdot \frac{d}{D}}} \cdot \frac{h}{\ell}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity82.1%

        \[\leadsto w0 \cdot \color{blue}{\left(1 \cdot \sqrt{1 - \frac{M \cdot \left(D \cdot \frac{0.5}{d}\right)}{\frac{2}{M} \cdot \frac{d}{D}} \cdot \frac{h}{\ell}}\right)} \]
      2. associate-*r*83.6%

        \[\leadsto w0 \cdot \left(1 \cdot \sqrt{1 - \frac{\color{blue}{\left(M \cdot D\right) \cdot \frac{0.5}{d}}}{\frac{2}{M} \cdot \frac{d}{D}} \cdot \frac{h}{\ell}}\right) \]
      3. frac-times83.6%

        \[\leadsto w0 \cdot \left(1 \cdot \sqrt{1 - \frac{\left(M \cdot D\right) \cdot \frac{0.5}{d}}{\color{blue}{\frac{2 \cdot d}{M \cdot D}}} \cdot \frac{h}{\ell}}\right) \]
    7. Applied egg-rr83.6%

      \[\leadsto w0 \cdot \color{blue}{\left(1 \cdot \sqrt{1 - \frac{\left(M \cdot D\right) \cdot \frac{0.5}{d}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}}\right)} \]
    8. Step-by-step derivation
      1. *-lft-identity83.6%

        \[\leadsto w0 \cdot \color{blue}{\sqrt{1 - \frac{\left(M \cdot D\right) \cdot \frac{0.5}{d}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}}} \]
      2. sub-neg83.6%

        \[\leadsto w0 \cdot \sqrt{\color{blue}{1 + \left(-\frac{\left(M \cdot D\right) \cdot \frac{0.5}{d}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}\right)}} \]
      3. associate-*l/85.0%

        \[\leadsto w0 \cdot \sqrt{1 + \left(-\color{blue}{\frac{\left(\left(M \cdot D\right) \cdot \frac{0.5}{d}\right) \cdot \frac{h}{\ell}}{\frac{2 \cdot d}{M \cdot D}}}\right)} \]
      4. distribute-neg-frac285.0%

        \[\leadsto w0 \cdot \sqrt{1 + \color{blue}{\frac{\left(\left(M \cdot D\right) \cdot \frac{0.5}{d}\right) \cdot \frac{h}{\ell}}{-\frac{2 \cdot d}{M \cdot D}}}} \]
      5. *-commutative85.0%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\color{blue}{\frac{h}{\ell} \cdot \left(\left(M \cdot D\right) \cdot \frac{0.5}{d}\right)}}{-\frac{2 \cdot d}{M \cdot D}}} \]
      6. associate-*l*83.5%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \color{blue}{\left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}}{-\frac{2 \cdot d}{M \cdot D}}} \]
      7. associate-/l*83.5%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{-\color{blue}{2 \cdot \frac{d}{M \cdot D}}}} \]
      8. *-commutative83.5%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{-2 \cdot \frac{d}{\color{blue}{D \cdot M}}}} \]
      9. *-commutative83.5%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{-\color{blue}{\frac{d}{D \cdot M} \cdot 2}}} \]
      10. distribute-rgt-neg-in83.5%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{\frac{d}{D \cdot M} \cdot \left(-2\right)}}} \]
      11. metadata-eval83.5%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\frac{d}{D \cdot M} \cdot \color{blue}{-2}}} \]
    9. Simplified83.5%

      \[\leadsto w0 \cdot \color{blue}{\sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\frac{d}{D \cdot M} \cdot -2}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification81.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \cdot D \leq 4 \cdot 10^{-140}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{-2 \cdot \frac{d}{M \cdot D}}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 85.9% accurate, 1.7× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;M\_m \leq 0.00016:\\ \;\;\;\;w0 \cdot \sqrt{1 + \frac{\frac{h \cdot \left(0.5 \cdot \left(M\_m \cdot D\_m\right)\right)}{\ell \cdot d}}{-2 \cdot \frac{d}{M\_m \cdot D\_m}}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M\_m \cdot \left(D\_m \cdot \frac{0.5}{d}\right)\right)}{\frac{\frac{-2}{D\_m}}{\frac{M\_m}{d}}}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
 :precision binary64
 (if (<= M_m 0.00016)
   (*
    w0
    (sqrt
     (+
      1.0
      (/ (/ (* h (* 0.5 (* M_m D_m))) (* l d)) (* -2.0 (/ d (* M_m D_m)))))))
   (*
    w0
    (sqrt
     (+
      1.0
      (/ (* (/ h l) (* M_m (* D_m (/ 0.5 d)))) (/ (/ -2.0 D_m) (/ M_m d))))))))
M_m = fabs(M);
D_m = fabs(D);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
	double tmp;
	if (M_m <= 0.00016) {
		tmp = w0 * sqrt((1.0 + (((h * (0.5 * (M_m * D_m))) / (l * d)) / (-2.0 * (d / (M_m * D_m))))));
	} else {
		tmp = w0 * sqrt((1.0 + (((h / l) * (M_m * (D_m * (0.5 / d)))) / ((-2.0 / D_m) / (M_m / d)))));
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d)
    real(8), intent (in) :: w0
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d
    real(8) :: tmp
    if (m_m <= 0.00016d0) then
        tmp = w0 * sqrt((1.0d0 + (((h * (0.5d0 * (m_m * d_m))) / (l * d)) / ((-2.0d0) * (d / (m_m * d_m))))))
    else
        tmp = w0 * sqrt((1.0d0 + (((h / l) * (m_m * (d_m * (0.5d0 / d)))) / (((-2.0d0) / d_m) / (m_m / d)))))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
	double tmp;
	if (M_m <= 0.00016) {
		tmp = w0 * Math.sqrt((1.0 + (((h * (0.5 * (M_m * D_m))) / (l * d)) / (-2.0 * (d / (M_m * D_m))))));
	} else {
		tmp = w0 * Math.sqrt((1.0 + (((h / l) * (M_m * (D_m * (0.5 / d)))) / ((-2.0 / D_m) / (M_m / d)))));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d])
def code(w0, M_m, D_m, h, l, d):
	tmp = 0
	if M_m <= 0.00016:
		tmp = w0 * math.sqrt((1.0 + (((h * (0.5 * (M_m * D_m))) / (l * d)) / (-2.0 * (d / (M_m * D_m))))))
	else:
		tmp = w0 * math.sqrt((1.0 + (((h / l) * (M_m * (D_m * (0.5 / d)))) / ((-2.0 / D_m) / (M_m / d)))))
	return tmp
M_m = abs(M)
D_m = abs(D)
w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d])
function code(w0, M_m, D_m, h, l, d)
	tmp = 0.0
	if (M_m <= 0.00016)
		tmp = Float64(w0 * sqrt(Float64(1.0 + Float64(Float64(Float64(h * Float64(0.5 * Float64(M_m * D_m))) / Float64(l * d)) / Float64(-2.0 * Float64(d / Float64(M_m * D_m)))))));
	else
		tmp = Float64(w0 * sqrt(Float64(1.0 + Float64(Float64(Float64(h / l) * Float64(M_m * Float64(D_m * Float64(0.5 / d)))) / Float64(Float64(-2.0 / D_m) / Float64(M_m / d))))));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d)
	tmp = 0.0;
	if (M_m <= 0.00016)
		tmp = w0 * sqrt((1.0 + (((h * (0.5 * (M_m * D_m))) / (l * d)) / (-2.0 * (d / (M_m * D_m))))));
	else
		tmp = w0 * sqrt((1.0 + (((h / l) * (M_m * (D_m * (0.5 / d)))) / ((-2.0 / D_m) / (M_m / d)))));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[M$95$m, 0.00016], N[(w0 * N[Sqrt[N[(1.0 + N[(N[(N[(h * N[(0.5 * N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(l * d), $MachinePrecision]), $MachinePrecision] / N[(-2.0 * N[(d / N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 + N[(N[(N[(h / l), $MachinePrecision] * N[(M$95$m * N[(D$95$m * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(-2.0 / D$95$m), $MachinePrecision] / N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;M\_m \leq 0.00016:\\
\;\;\;\;w0 \cdot \sqrt{1 + \frac{\frac{h \cdot \left(0.5 \cdot \left(M\_m \cdot D\_m\right)\right)}{\ell \cdot d}}{-2 \cdot \frac{d}{M\_m \cdot D\_m}}}\\

\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M\_m \cdot \left(D\_m \cdot \frac{0.5}{d}\right)\right)}{\frac{\frac{-2}{D\_m}}{\frac{M\_m}{d}}}}\\


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

    1. Initial program 85.4%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified85.4%

      \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. unpow285.4%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \left(D \cdot \frac{\frac{M}{2}}{d}\right)\right)} \cdot \frac{h}{\ell}} \]
      2. *-commutative85.4%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\left(\frac{\frac{M}{2}}{d} \cdot D\right)}\right) \cdot \frac{h}{\ell}} \]
      3. associate-*l/85.4%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\frac{\frac{M}{2} \cdot D}{d}}\right) \cdot \frac{h}{\ell}} \]
      4. associate-*r/84.4%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}\right) \cdot \frac{h}{\ell}} \]
      5. times-frac85.4%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\frac{M \cdot D}{2 \cdot d}}\right) \cdot \frac{h}{\ell}} \]
      6. clear-num85.4%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\frac{1}{\frac{2 \cdot d}{M \cdot D}}}\right) \cdot \frac{h}{\ell}} \]
      7. un-div-inv85.4%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{D \cdot \frac{\frac{M}{2}}{d}}{\frac{2 \cdot d}{M \cdot D}}} \cdot \frac{h}{\ell}} \]
      8. *-commutative85.4%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{\frac{M}{2}}{d} \cdot D}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      9. associate-*l/85.4%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{\frac{M}{2} \cdot D}{d}}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      10. associate-*r/84.4%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{M}{2} \cdot \frac{D}{d}}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      11. times-frac85.4%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{M \cdot D}{2 \cdot d}}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      12. associate-/l*84.4%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{M \cdot \frac{D}{2 \cdot d}}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      13. div-inv84.4%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \color{blue}{\left(D \cdot \frac{1}{2 \cdot d}\right)}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      14. associate-/r*84.4%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \left(D \cdot \color{blue}{\frac{\frac{1}{2}}{d}}\right)}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      15. metadata-eval84.4%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \left(D \cdot \frac{\color{blue}{0.5}}{d}\right)}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      16. times-frac84.5%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \left(D \cdot \frac{0.5}{d}\right)}{\color{blue}{\frac{2}{M} \cdot \frac{d}{D}}} \cdot \frac{h}{\ell}} \]
    5. Applied egg-rr84.5%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{M \cdot \left(D \cdot \frac{0.5}{d}\right)}{\frac{2}{M} \cdot \frac{d}{D}}} \cdot \frac{h}{\ell}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity84.5%

        \[\leadsto w0 \cdot \color{blue}{\left(1 \cdot \sqrt{1 - \frac{M \cdot \left(D \cdot \frac{0.5}{d}\right)}{\frac{2}{M} \cdot \frac{d}{D}} \cdot \frac{h}{\ell}}\right)} \]
      2. associate-*r*85.0%

        \[\leadsto w0 \cdot \left(1 \cdot \sqrt{1 - \frac{\color{blue}{\left(M \cdot D\right) \cdot \frac{0.5}{d}}}{\frac{2}{M} \cdot \frac{d}{D}} \cdot \frac{h}{\ell}}\right) \]
      3. frac-times85.4%

        \[\leadsto w0 \cdot \left(1 \cdot \sqrt{1 - \frac{\left(M \cdot D\right) \cdot \frac{0.5}{d}}{\color{blue}{\frac{2 \cdot d}{M \cdot D}}} \cdot \frac{h}{\ell}}\right) \]
    7. Applied egg-rr85.4%

      \[\leadsto w0 \cdot \color{blue}{\left(1 \cdot \sqrt{1 - \frac{\left(M \cdot D\right) \cdot \frac{0.5}{d}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}}\right)} \]
    8. Step-by-step derivation
      1. *-lft-identity85.4%

        \[\leadsto w0 \cdot \color{blue}{\sqrt{1 - \frac{\left(M \cdot D\right) \cdot \frac{0.5}{d}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}}} \]
      2. sub-neg85.4%

        \[\leadsto w0 \cdot \sqrt{\color{blue}{1 + \left(-\frac{\left(M \cdot D\right) \cdot \frac{0.5}{d}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}\right)}} \]
      3. associate-*l/86.9%

        \[\leadsto w0 \cdot \sqrt{1 + \left(-\color{blue}{\frac{\left(\left(M \cdot D\right) \cdot \frac{0.5}{d}\right) \cdot \frac{h}{\ell}}{\frac{2 \cdot d}{M \cdot D}}}\right)} \]
      4. distribute-neg-frac286.9%

        \[\leadsto w0 \cdot \sqrt{1 + \color{blue}{\frac{\left(\left(M \cdot D\right) \cdot \frac{0.5}{d}\right) \cdot \frac{h}{\ell}}{-\frac{2 \cdot d}{M \cdot D}}}} \]
      5. *-commutative86.9%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\color{blue}{\frac{h}{\ell} \cdot \left(\left(M \cdot D\right) \cdot \frac{0.5}{d}\right)}}{-\frac{2 \cdot d}{M \cdot D}}} \]
      6. associate-*l*85.4%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \color{blue}{\left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}}{-\frac{2 \cdot d}{M \cdot D}}} \]
      7. associate-/l*85.4%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{-\color{blue}{2 \cdot \frac{d}{M \cdot D}}}} \]
      8. *-commutative85.4%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{-2 \cdot \frac{d}{\color{blue}{D \cdot M}}}} \]
      9. *-commutative85.4%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{-\color{blue}{\frac{d}{D \cdot M} \cdot 2}}} \]
      10. distribute-rgt-neg-in85.4%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{\frac{d}{D \cdot M} \cdot \left(-2\right)}}} \]
      11. metadata-eval85.4%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\frac{d}{D \cdot M} \cdot \color{blue}{-2}}} \]
    9. Simplified85.4%

      \[\leadsto w0 \cdot \color{blue}{\sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\frac{d}{D \cdot M} \cdot -2}}} \]
    10. Taylor expanded in h around 0 87.4%

      \[\leadsto w0 \cdot \sqrt{1 + \frac{\color{blue}{0.5 \cdot \frac{D \cdot \left(M \cdot h\right)}{d \cdot \ell}}}{\frac{d}{D \cdot M} \cdot -2}} \]
    11. Step-by-step derivation
      1. associate-*r/87.4%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\color{blue}{\frac{0.5 \cdot \left(D \cdot \left(M \cdot h\right)\right)}{d \cdot \ell}}}{\frac{d}{D \cdot M} \cdot -2}} \]
      2. associate-*r*87.4%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{\color{blue}{\left(0.5 \cdot D\right) \cdot \left(M \cdot h\right)}}{d \cdot \ell}}{\frac{d}{D \cdot M} \cdot -2}} \]
      3. *-commutative87.4%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{\color{blue}{\left(D \cdot 0.5\right)} \cdot \left(M \cdot h\right)}{d \cdot \ell}}{\frac{d}{D \cdot M} \cdot -2}} \]
      4. *-commutative87.4%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{\left(D \cdot 0.5\right) \cdot \color{blue}{\left(h \cdot M\right)}}{d \cdot \ell}}{\frac{d}{D \cdot M} \cdot -2}} \]
      5. *-commutative87.4%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{\color{blue}{\left(h \cdot M\right) \cdot \left(D \cdot 0.5\right)}}{d \cdot \ell}}{\frac{d}{D \cdot M} \cdot -2}} \]
      6. associate-*l*90.3%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{\color{blue}{h \cdot \left(M \cdot \left(D \cdot 0.5\right)\right)}}{d \cdot \ell}}{\frac{d}{D \cdot M} \cdot -2}} \]
      7. associate-*r*90.3%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h \cdot \color{blue}{\left(\left(M \cdot D\right) \cdot 0.5\right)}}{d \cdot \ell}}{\frac{d}{D \cdot M} \cdot -2}} \]
      8. *-commutative90.3%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h \cdot \left(\color{blue}{\left(D \cdot M\right)} \cdot 0.5\right)}{d \cdot \ell}}{\frac{d}{D \cdot M} \cdot -2}} \]
      9. *-commutative90.3%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h \cdot \color{blue}{\left(0.5 \cdot \left(D \cdot M\right)\right)}}{d \cdot \ell}}{\frac{d}{D \cdot M} \cdot -2}} \]
    12. Simplified90.3%

      \[\leadsto w0 \cdot \sqrt{1 + \frac{\color{blue}{\frac{h \cdot \left(0.5 \cdot \left(D \cdot M\right)\right)}{d \cdot \ell}}}{\frac{d}{D \cdot M} \cdot -2}} \]

    if 1.60000000000000013e-4 < M

    1. Initial program 77.2%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified78.9%

      \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. unpow278.9%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \left(D \cdot \frac{\frac{M}{2}}{d}\right)\right)} \cdot \frac{h}{\ell}} \]
      2. *-commutative78.9%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\left(\frac{\frac{M}{2}}{d} \cdot D\right)}\right) \cdot \frac{h}{\ell}} \]
      3. associate-*l/77.2%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\frac{\frac{M}{2} \cdot D}{d}}\right) \cdot \frac{h}{\ell}} \]
      4. associate-*r/77.3%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}\right) \cdot \frac{h}{\ell}} \]
      5. times-frac77.2%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\frac{M \cdot D}{2 \cdot d}}\right) \cdot \frac{h}{\ell}} \]
      6. clear-num77.2%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\frac{1}{\frac{2 \cdot d}{M \cdot D}}}\right) \cdot \frac{h}{\ell}} \]
      7. un-div-inv77.2%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{D \cdot \frac{\frac{M}{2}}{d}}{\frac{2 \cdot d}{M \cdot D}}} \cdot \frac{h}{\ell}} \]
      8. *-commutative77.2%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{\frac{M}{2}}{d} \cdot D}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      9. associate-*l/77.2%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{\frac{M}{2} \cdot D}{d}}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      10. associate-*r/75.5%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{M}{2} \cdot \frac{D}{d}}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      11. times-frac77.2%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{M \cdot D}{2 \cdot d}}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      12. associate-/l*75.5%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{M \cdot \frac{D}{2 \cdot d}}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      13. div-inv75.5%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \color{blue}{\left(D \cdot \frac{1}{2 \cdot d}\right)}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      14. associate-/r*75.5%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \left(D \cdot \color{blue}{\frac{\frac{1}{2}}{d}}\right)}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      15. metadata-eval75.5%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \left(D \cdot \frac{\color{blue}{0.5}}{d}\right)}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      16. times-frac77.3%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \left(D \cdot \frac{0.5}{d}\right)}{\color{blue}{\frac{2}{M} \cdot \frac{d}{D}}} \cdot \frac{h}{\ell}} \]
    5. Applied egg-rr77.3%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{M \cdot \left(D \cdot \frac{0.5}{d}\right)}{\frac{2}{M} \cdot \frac{d}{D}}} \cdot \frac{h}{\ell}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity77.3%

        \[\leadsto w0 \cdot \color{blue}{\left(1 \cdot \sqrt{1 - \frac{M \cdot \left(D \cdot \frac{0.5}{d}\right)}{\frac{2}{M} \cdot \frac{d}{D}} \cdot \frac{h}{\ell}}\right)} \]
      2. associate-*r*75.5%

        \[\leadsto w0 \cdot \left(1 \cdot \sqrt{1 - \frac{\color{blue}{\left(M \cdot D\right) \cdot \frac{0.5}{d}}}{\frac{2}{M} \cdot \frac{d}{D}} \cdot \frac{h}{\ell}}\right) \]
      3. frac-times77.2%

        \[\leadsto w0 \cdot \left(1 \cdot \sqrt{1 - \frac{\left(M \cdot D\right) \cdot \frac{0.5}{d}}{\color{blue}{\frac{2 \cdot d}{M \cdot D}}} \cdot \frac{h}{\ell}}\right) \]
    7. Applied egg-rr77.2%

      \[\leadsto w0 \cdot \color{blue}{\left(1 \cdot \sqrt{1 - \frac{\left(M \cdot D\right) \cdot \frac{0.5}{d}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}}\right)} \]
    8. Step-by-step derivation
      1. *-lft-identity77.2%

        \[\leadsto w0 \cdot \color{blue}{\sqrt{1 - \frac{\left(M \cdot D\right) \cdot \frac{0.5}{d}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}}} \]
      2. sub-neg77.2%

        \[\leadsto w0 \cdot \sqrt{\color{blue}{1 + \left(-\frac{\left(M \cdot D\right) \cdot \frac{0.5}{d}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}\right)}} \]
      3. associate-*l/82.5%

        \[\leadsto w0 \cdot \sqrt{1 + \left(-\color{blue}{\frac{\left(\left(M \cdot D\right) \cdot \frac{0.5}{d}\right) \cdot \frac{h}{\ell}}{\frac{2 \cdot d}{M \cdot D}}}\right)} \]
      4. distribute-neg-frac282.5%

        \[\leadsto w0 \cdot \sqrt{1 + \color{blue}{\frac{\left(\left(M \cdot D\right) \cdot \frac{0.5}{d}\right) \cdot \frac{h}{\ell}}{-\frac{2 \cdot d}{M \cdot D}}}} \]
      5. *-commutative82.5%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\color{blue}{\frac{h}{\ell} \cdot \left(\left(M \cdot D\right) \cdot \frac{0.5}{d}\right)}}{-\frac{2 \cdot d}{M \cdot D}}} \]
      6. associate-*l*80.8%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \color{blue}{\left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}}{-\frac{2 \cdot d}{M \cdot D}}} \]
      7. associate-/l*80.8%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{-\color{blue}{2 \cdot \frac{d}{M \cdot D}}}} \]
      8. *-commutative80.8%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{-2 \cdot \frac{d}{\color{blue}{D \cdot M}}}} \]
      9. *-commutative80.8%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{-\color{blue}{\frac{d}{D \cdot M} \cdot 2}}} \]
      10. distribute-rgt-neg-in80.8%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{\frac{d}{D \cdot M} \cdot \left(-2\right)}}} \]
      11. metadata-eval80.8%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\frac{d}{D \cdot M} \cdot \color{blue}{-2}}} \]
    9. Simplified80.8%

      \[\leadsto w0 \cdot \color{blue}{\sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\frac{d}{D \cdot M} \cdot -2}}} \]
    10. Step-by-step derivation
      1. clear-num80.8%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{\frac{1}{\frac{D \cdot M}{d}}} \cdot -2}} \]
      2. inv-pow80.8%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{{\left(\frac{D \cdot M}{d}\right)}^{-1}} \cdot -2}} \]
      3. *-commutative80.8%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{{\left(\frac{\color{blue}{M \cdot D}}{d}\right)}^{-1} \cdot -2}} \]
    11. Applied egg-rr80.8%

      \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{{\left(\frac{M \cdot D}{d}\right)}^{-1}} \cdot -2}} \]
    12. Step-by-step derivation
      1. unpow-180.8%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{\frac{1}{\frac{M \cdot D}{d}}} \cdot -2}} \]
      2. *-commutative80.8%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\frac{1}{\frac{\color{blue}{D \cdot M}}{d}} \cdot -2}} \]
      3. associate-/l*82.6%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\frac{1}{\color{blue}{D \cdot \frac{M}{d}}} \cdot -2}} \]
    13. Simplified82.6%

      \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{\frac{1}{D \cdot \frac{M}{d}}} \cdot -2}} \]
    14. Taylor expanded in D around 0 80.8%

      \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{-2 \cdot \frac{d}{D \cdot M}}}} \]
    15. Step-by-step derivation
      1. associate-*r/80.8%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{\frac{-2 \cdot d}{D \cdot M}}}} \]
      2. *-commutative80.8%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\frac{-2 \cdot d}{\color{blue}{M \cdot D}}}} \]
      3. associate-*l/80.8%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{\frac{-2}{M \cdot D} \cdot d}}} \]
      4. associate-/r/80.8%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{\frac{-2}{\frac{M \cdot D}{d}}}}} \]
      5. *-commutative80.8%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\frac{-2}{\frac{\color{blue}{D \cdot M}}{d}}}} \]
      6. associate-/l*82.6%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\frac{-2}{\color{blue}{D \cdot \frac{M}{d}}}}} \]
      7. associate-/r*82.7%

        \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{\frac{\frac{-2}{D}}{\frac{M}{d}}}}} \]
    16. Simplified82.7%

      \[\leadsto w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\color{blue}{\frac{\frac{-2}{D}}{\frac{M}{d}}}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification88.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 0.00016:\\ \;\;\;\;w0 \cdot \sqrt{1 + \frac{\frac{h \cdot \left(0.5 \cdot \left(M \cdot D\right)\right)}{\ell \cdot d}}{-2 \cdot \frac{d}{M \cdot D}}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 + \frac{\frac{h}{\ell} \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}{\frac{\frac{-2}{D}}{\frac{M}{d}}}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 83.9% accurate, 1.7× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;\frac{h}{\ell} \leq -1 \cdot 10^{-298}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot \left(0.25 \cdot \frac{\frac{M\_m \cdot D\_m}{d}}{\frac{d}{M\_m \cdot D\_m}}\right)}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
 :precision binary64
 (if (<= (/ h l) -1e-298)
   (*
    w0
    (sqrt
     (- 1.0 (* (/ h l) (* 0.25 (/ (/ (* M_m D_m) d) (/ d (* M_m D_m))))))))
   w0))
M_m = fabs(M);
D_m = fabs(D);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
	double tmp;
	if ((h / l) <= -1e-298) {
		tmp = w0 * sqrt((1.0 - ((h / l) * (0.25 * (((M_m * D_m) / d) / (d / (M_m * D_m)))))));
	} else {
		tmp = w0;
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d)
    real(8), intent (in) :: w0
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d
    real(8) :: tmp
    if ((h / l) <= (-1d-298)) then
        tmp = w0 * sqrt((1.0d0 - ((h / l) * (0.25d0 * (((m_m * d_m) / d) / (d / (m_m * d_m)))))))
    else
        tmp = w0
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
	double tmp;
	if ((h / l) <= -1e-298) {
		tmp = w0 * Math.sqrt((1.0 - ((h / l) * (0.25 * (((M_m * D_m) / d) / (d / (M_m * D_m)))))));
	} else {
		tmp = w0;
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d])
def code(w0, M_m, D_m, h, l, d):
	tmp = 0
	if (h / l) <= -1e-298:
		tmp = w0 * math.sqrt((1.0 - ((h / l) * (0.25 * (((M_m * D_m) / d) / (d / (M_m * D_m)))))))
	else:
		tmp = w0
	return tmp
M_m = abs(M)
D_m = abs(D)
w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d])
function code(w0, M_m, D_m, h, l, d)
	tmp = 0.0
	if (Float64(h / l) <= -1e-298)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h / l) * Float64(0.25 * Float64(Float64(Float64(M_m * D_m) / d) / Float64(d / Float64(M_m * D_m))))))));
	else
		tmp = w0;
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d)
	tmp = 0.0;
	if ((h / l) <= -1e-298)
		tmp = w0 * sqrt((1.0 - ((h / l) * (0.25 * (((M_m * D_m) / d) / (d / (M_m * D_m)))))));
	else
		tmp = w0;
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[N[(h / l), $MachinePrecision], -1e-298], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[(0.25 * N[(N[(N[(M$95$m * D$95$m), $MachinePrecision] / d), $MachinePrecision] / N[(d / N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;\frac{h}{\ell} \leq -1 \cdot 10^{-298}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot \left(0.25 \cdot \frac{\frac{M\_m \cdot D\_m}{d}}{\frac{d}{M\_m \cdot D\_m}}\right)}\\

\mathbf{else}:\\
\;\;\;\;w0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 h l) < -9.99999999999999912e-299

    1. Initial program 81.0%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified81.0%

      \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. unpow281.0%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \left(D \cdot \frac{\frac{M}{2}}{d}\right)\right)} \cdot \frac{h}{\ell}} \]
      2. *-commutative81.0%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\left(\frac{\frac{M}{2}}{d} \cdot D\right)}\right) \cdot \frac{h}{\ell}} \]
      3. associate-*l/81.0%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\frac{\frac{M}{2} \cdot D}{d}}\right) \cdot \frac{h}{\ell}} \]
      4. associate-*r/79.8%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}\right) \cdot \frac{h}{\ell}} \]
      5. times-frac81.0%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\frac{M \cdot D}{2 \cdot d}}\right) \cdot \frac{h}{\ell}} \]
      6. clear-num81.0%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\frac{1}{\frac{2 \cdot d}{M \cdot D}}}\right) \cdot \frac{h}{\ell}} \]
      7. un-div-inv81.0%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{D \cdot \frac{\frac{M}{2}}{d}}{\frac{2 \cdot d}{M \cdot D}}} \cdot \frac{h}{\ell}} \]
      8. *-commutative81.0%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{\frac{M}{2}}{d} \cdot D}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      9. associate-*l/81.0%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{\frac{M}{2} \cdot D}{d}}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      10. associate-*r/79.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{M}{2} \cdot \frac{D}{d}}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      11. times-frac81.0%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{M \cdot D}{2 \cdot d}}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      12. associate-/l*79.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{M \cdot \frac{D}{2 \cdot d}}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      13. div-inv79.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \color{blue}{\left(D \cdot \frac{1}{2 \cdot d}\right)}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      14. associate-/r*79.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \left(D \cdot \color{blue}{\frac{\frac{1}{2}}{d}}\right)}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      15. metadata-eval79.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \left(D \cdot \frac{\color{blue}{0.5}}{d}\right)}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      16. times-frac79.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \left(D \cdot \frac{0.5}{d}\right)}{\color{blue}{\frac{2}{M} \cdot \frac{d}{D}}} \cdot \frac{h}{\ell}} \]
    5. Applied egg-rr79.8%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{M \cdot \left(D \cdot \frac{0.5}{d}\right)}{\frac{2}{M} \cdot \frac{d}{D}}} \cdot \frac{h}{\ell}} \]
    6. Step-by-step derivation
      1. associate-*r/86.9%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{\frac{M \cdot \left(D \cdot \frac{0.5}{d}\right)}{\frac{2}{M} \cdot \frac{d}{D}} \cdot h}{\ell}}} \]
      2. associate-*r*86.9%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{\color{blue}{\left(M \cdot D\right) \cdot \frac{0.5}{d}}}{\frac{2}{M} \cdot \frac{d}{D}} \cdot h}{\ell}} \]
      3. frac-times88.1%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{\left(M \cdot D\right) \cdot \frac{0.5}{d}}{\color{blue}{\frac{2 \cdot d}{M \cdot D}}} \cdot h}{\ell}} \]
    7. Applied egg-rr88.1%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{\frac{\left(M \cdot D\right) \cdot \frac{0.5}{d}}{\frac{2 \cdot d}{M \cdot D}} \cdot h}{\ell}}} \]
    8. Step-by-step derivation
      1. *-un-lft-identity88.1%

        \[\leadsto w0 \cdot \color{blue}{\left(1 \cdot \sqrt{1 - \frac{\frac{\left(M \cdot D\right) \cdot \frac{0.5}{d}}{\frac{2 \cdot d}{M \cdot D}} \cdot h}{\ell}}\right)} \]
      2. associate-/l*81.0%

        \[\leadsto w0 \cdot \left(1 \cdot \sqrt{1 - \color{blue}{\frac{\left(M \cdot D\right) \cdot \frac{0.5}{d}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}}}\right) \]
      3. associate-/l*79.1%

        \[\leadsto w0 \cdot \left(1 \cdot \sqrt{1 - \color{blue}{\left(\left(M \cdot D\right) \cdot \frac{\frac{0.5}{d}}{\frac{2 \cdot d}{M \cdot D}}\right)} \cdot \frac{h}{\ell}}\right) \]
      4. *-commutative79.1%

        \[\leadsto w0 \cdot \left(1 \cdot \sqrt{1 - \left(\left(M \cdot D\right) \cdot \frac{\frac{0.5}{d}}{\frac{2 \cdot d}{\color{blue}{D \cdot M}}}\right) \cdot \frac{h}{\ell}}\right) \]
      5. associate-/l*79.1%

        \[\leadsto w0 \cdot \left(1 \cdot \sqrt{1 - \left(\left(M \cdot D\right) \cdot \frac{\frac{0.5}{d}}{\color{blue}{2 \cdot \frac{d}{D \cdot M}}}\right) \cdot \frac{h}{\ell}}\right) \]
      6. associate-/r*78.6%

        \[\leadsto w0 \cdot \left(1 \cdot \sqrt{1 - \left(\left(M \cdot D\right) \cdot \frac{\frac{0.5}{d}}{2 \cdot \color{blue}{\frac{\frac{d}{D}}{M}}}\right) \cdot \frac{h}{\ell}}\right) \]
    9. Applied egg-rr78.6%

      \[\leadsto w0 \cdot \color{blue}{\left(1 \cdot \sqrt{1 - \left(\left(M \cdot D\right) \cdot \frac{\frac{0.5}{d}}{2 \cdot \frac{\frac{d}{D}}{M}}\right) \cdot \frac{h}{\ell}}\right)} \]
    10. Step-by-step derivation
      1. *-lft-identity78.6%

        \[\leadsto w0 \cdot \color{blue}{\sqrt{1 - \left(\left(M \cdot D\right) \cdot \frac{\frac{0.5}{d}}{2 \cdot \frac{\frac{d}{D}}{M}}\right) \cdot \frac{h}{\ell}}} \]
      2. *-commutative78.6%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{h}{\ell} \cdot \left(\left(M \cdot D\right) \cdot \frac{\frac{0.5}{d}}{2 \cdot \frac{\frac{d}{D}}{M}}\right)}} \]
      3. associate-*r/79.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot \color{blue}{\frac{\left(M \cdot D\right) \cdot \frac{0.5}{d}}{2 \cdot \frac{\frac{d}{D}}{M}}}} \]
      4. associate-*r/79.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot \frac{\color{blue}{\frac{\left(M \cdot D\right) \cdot 0.5}{d}}}{2 \cdot \frac{\frac{d}{D}}{M}}} \]
      5. associate-*l/79.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot \frac{\color{blue}{\frac{M \cdot D}{d} \cdot 0.5}}{2 \cdot \frac{\frac{d}{D}}{M}}} \]
      6. *-commutative79.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot \frac{\frac{\color{blue}{D \cdot M}}{d} \cdot 0.5}{2 \cdot \frac{\frac{d}{D}}{M}}} \]
      7. *-commutative79.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot \frac{\color{blue}{0.5 \cdot \frac{D \cdot M}{d}}}{2 \cdot \frac{\frac{d}{D}}{M}}} \]
      8. times-frac79.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot \color{blue}{\left(\frac{0.5}{2} \cdot \frac{\frac{D \cdot M}{d}}{\frac{\frac{d}{D}}{M}}\right)}} \]
      9. metadata-eval79.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot \left(\color{blue}{0.25} \cdot \frac{\frac{D \cdot M}{d}}{\frac{\frac{d}{D}}{M}}\right)} \]
      10. associate-/l*79.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot \left(0.25 \cdot \frac{\color{blue}{D \cdot \frac{M}{d}}}{\frac{\frac{d}{D}}{M}}\right)} \]
      11. associate-/r*81.0%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot \left(0.25 \cdot \frac{D \cdot \frac{M}{d}}{\color{blue}{\frac{d}{D \cdot M}}}\right)} \]
    11. Simplified81.0%

      \[\leadsto w0 \cdot \color{blue}{\sqrt{1 - \frac{h}{\ell} \cdot \left(0.25 \cdot \frac{D \cdot \frac{M}{d}}{\frac{d}{D \cdot M}}\right)}} \]
    12. Step-by-step derivation
      1. associate-*r/81.0%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot \left(0.25 \cdot \frac{\color{blue}{\frac{D \cdot M}{d}}}{\frac{d}{D \cdot M}}\right)} \]
      2. *-commutative81.0%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot \left(0.25 \cdot \frac{\frac{\color{blue}{M \cdot D}}{d}}{\frac{d}{D \cdot M}}\right)} \]
    13. Applied egg-rr81.0%

      \[\leadsto w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot \left(0.25 \cdot \frac{\color{blue}{\frac{M \cdot D}{d}}}{\frac{d}{D \cdot M}}\right)} \]

    if -9.99999999999999912e-299 < (/.f64 h l)

    1. Initial program 87.5%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified88.5%

      \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Add Preprocessing
    4. Taylor expanded in D around 0 97.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{h}{\ell} \leq -1 \cdot 10^{-298}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot \left(0.25 \cdot \frac{\frac{M \cdot D}{d}}{\frac{d}{M \cdot D}}\right)}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 83.7% accurate, 1.7× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;\frac{h}{\ell} \leq -1 \cdot 10^{-298}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot \left(0.25 \cdot \frac{D\_m \cdot \frac{M\_m}{d}}{\frac{d}{M\_m \cdot D\_m}}\right)}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
 :precision binary64
 (if (<= (/ h l) -1e-298)
   (*
    w0
    (sqrt
     (- 1.0 (* (/ h l) (* 0.25 (/ (* D_m (/ M_m d)) (/ d (* M_m D_m))))))))
   w0))
M_m = fabs(M);
D_m = fabs(D);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
	double tmp;
	if ((h / l) <= -1e-298) {
		tmp = w0 * sqrt((1.0 - ((h / l) * (0.25 * ((D_m * (M_m / d)) / (d / (M_m * D_m)))))));
	} else {
		tmp = w0;
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d)
    real(8), intent (in) :: w0
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d
    real(8) :: tmp
    if ((h / l) <= (-1d-298)) then
        tmp = w0 * sqrt((1.0d0 - ((h / l) * (0.25d0 * ((d_m * (m_m / d)) / (d / (m_m * d_m)))))))
    else
        tmp = w0
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
	double tmp;
	if ((h / l) <= -1e-298) {
		tmp = w0 * Math.sqrt((1.0 - ((h / l) * (0.25 * ((D_m * (M_m / d)) / (d / (M_m * D_m)))))));
	} else {
		tmp = w0;
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d])
def code(w0, M_m, D_m, h, l, d):
	tmp = 0
	if (h / l) <= -1e-298:
		tmp = w0 * math.sqrt((1.0 - ((h / l) * (0.25 * ((D_m * (M_m / d)) / (d / (M_m * D_m)))))))
	else:
		tmp = w0
	return tmp
M_m = abs(M)
D_m = abs(D)
w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d])
function code(w0, M_m, D_m, h, l, d)
	tmp = 0.0
	if (Float64(h / l) <= -1e-298)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h / l) * Float64(0.25 * Float64(Float64(D_m * Float64(M_m / d)) / Float64(d / Float64(M_m * D_m))))))));
	else
		tmp = w0;
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d)
	tmp = 0.0;
	if ((h / l) <= -1e-298)
		tmp = w0 * sqrt((1.0 - ((h / l) * (0.25 * ((D_m * (M_m / d)) / (d / (M_m * D_m)))))));
	else
		tmp = w0;
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[N[(h / l), $MachinePrecision], -1e-298], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[(0.25 * N[(N[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision] / N[(d / N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;\frac{h}{\ell} \leq -1 \cdot 10^{-298}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot \left(0.25 \cdot \frac{D\_m \cdot \frac{M\_m}{d}}{\frac{d}{M\_m \cdot D\_m}}\right)}\\

\mathbf{else}:\\
\;\;\;\;w0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 h l) < -9.99999999999999912e-299

    1. Initial program 81.0%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified81.0%

      \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. unpow281.0%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \left(D \cdot \frac{\frac{M}{2}}{d}\right)\right)} \cdot \frac{h}{\ell}} \]
      2. *-commutative81.0%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\left(\frac{\frac{M}{2}}{d} \cdot D\right)}\right) \cdot \frac{h}{\ell}} \]
      3. associate-*l/81.0%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\frac{\frac{M}{2} \cdot D}{d}}\right) \cdot \frac{h}{\ell}} \]
      4. associate-*r/79.8%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}\right) \cdot \frac{h}{\ell}} \]
      5. times-frac81.0%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\frac{M \cdot D}{2 \cdot d}}\right) \cdot \frac{h}{\ell}} \]
      6. clear-num81.0%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \color{blue}{\frac{1}{\frac{2 \cdot d}{M \cdot D}}}\right) \cdot \frac{h}{\ell}} \]
      7. un-div-inv81.0%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{D \cdot \frac{\frac{M}{2}}{d}}{\frac{2 \cdot d}{M \cdot D}}} \cdot \frac{h}{\ell}} \]
      8. *-commutative81.0%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{\frac{M}{2}}{d} \cdot D}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      9. associate-*l/81.0%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{\frac{M}{2} \cdot D}{d}}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      10. associate-*r/79.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{M}{2} \cdot \frac{D}{d}}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      11. times-frac81.0%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{M \cdot D}{2 \cdot d}}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      12. associate-/l*79.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{M \cdot \frac{D}{2 \cdot d}}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      13. div-inv79.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \color{blue}{\left(D \cdot \frac{1}{2 \cdot d}\right)}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      14. associate-/r*79.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \left(D \cdot \color{blue}{\frac{\frac{1}{2}}{d}}\right)}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      15. metadata-eval79.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \left(D \cdot \frac{\color{blue}{0.5}}{d}\right)}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      16. times-frac79.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \left(D \cdot \frac{0.5}{d}\right)}{\color{blue}{\frac{2}{M} \cdot \frac{d}{D}}} \cdot \frac{h}{\ell}} \]
    5. Applied egg-rr79.8%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{M \cdot \left(D \cdot \frac{0.5}{d}\right)}{\frac{2}{M} \cdot \frac{d}{D}}} \cdot \frac{h}{\ell}} \]
    6. Step-by-step derivation
      1. associate-*r/86.9%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{\frac{M \cdot \left(D \cdot \frac{0.5}{d}\right)}{\frac{2}{M} \cdot \frac{d}{D}} \cdot h}{\ell}}} \]
      2. associate-*r*86.9%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{\color{blue}{\left(M \cdot D\right) \cdot \frac{0.5}{d}}}{\frac{2}{M} \cdot \frac{d}{D}} \cdot h}{\ell}} \]
      3. frac-times88.1%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{\left(M \cdot D\right) \cdot \frac{0.5}{d}}{\color{blue}{\frac{2 \cdot d}{M \cdot D}}} \cdot h}{\ell}} \]
    7. Applied egg-rr88.1%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{\frac{\left(M \cdot D\right) \cdot \frac{0.5}{d}}{\frac{2 \cdot d}{M \cdot D}} \cdot h}{\ell}}} \]
    8. Step-by-step derivation
      1. *-un-lft-identity88.1%

        \[\leadsto w0 \cdot \color{blue}{\left(1 \cdot \sqrt{1 - \frac{\frac{\left(M \cdot D\right) \cdot \frac{0.5}{d}}{\frac{2 \cdot d}{M \cdot D}} \cdot h}{\ell}}\right)} \]
      2. associate-/l*81.0%

        \[\leadsto w0 \cdot \left(1 \cdot \sqrt{1 - \color{blue}{\frac{\left(M \cdot D\right) \cdot \frac{0.5}{d}}{\frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}}}\right) \]
      3. associate-/l*79.1%

        \[\leadsto w0 \cdot \left(1 \cdot \sqrt{1 - \color{blue}{\left(\left(M \cdot D\right) \cdot \frac{\frac{0.5}{d}}{\frac{2 \cdot d}{M \cdot D}}\right)} \cdot \frac{h}{\ell}}\right) \]
      4. *-commutative79.1%

        \[\leadsto w0 \cdot \left(1 \cdot \sqrt{1 - \left(\left(M \cdot D\right) \cdot \frac{\frac{0.5}{d}}{\frac{2 \cdot d}{\color{blue}{D \cdot M}}}\right) \cdot \frac{h}{\ell}}\right) \]
      5. associate-/l*79.1%

        \[\leadsto w0 \cdot \left(1 \cdot \sqrt{1 - \left(\left(M \cdot D\right) \cdot \frac{\frac{0.5}{d}}{\color{blue}{2 \cdot \frac{d}{D \cdot M}}}\right) \cdot \frac{h}{\ell}}\right) \]
      6. associate-/r*78.6%

        \[\leadsto w0 \cdot \left(1 \cdot \sqrt{1 - \left(\left(M \cdot D\right) \cdot \frac{\frac{0.5}{d}}{2 \cdot \color{blue}{\frac{\frac{d}{D}}{M}}}\right) \cdot \frac{h}{\ell}}\right) \]
    9. Applied egg-rr78.6%

      \[\leadsto w0 \cdot \color{blue}{\left(1 \cdot \sqrt{1 - \left(\left(M \cdot D\right) \cdot \frac{\frac{0.5}{d}}{2 \cdot \frac{\frac{d}{D}}{M}}\right) \cdot \frac{h}{\ell}}\right)} \]
    10. Step-by-step derivation
      1. *-lft-identity78.6%

        \[\leadsto w0 \cdot \color{blue}{\sqrt{1 - \left(\left(M \cdot D\right) \cdot \frac{\frac{0.5}{d}}{2 \cdot \frac{\frac{d}{D}}{M}}\right) \cdot \frac{h}{\ell}}} \]
      2. *-commutative78.6%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{h}{\ell} \cdot \left(\left(M \cdot D\right) \cdot \frac{\frac{0.5}{d}}{2 \cdot \frac{\frac{d}{D}}{M}}\right)}} \]
      3. associate-*r/79.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot \color{blue}{\frac{\left(M \cdot D\right) \cdot \frac{0.5}{d}}{2 \cdot \frac{\frac{d}{D}}{M}}}} \]
      4. associate-*r/79.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot \frac{\color{blue}{\frac{\left(M \cdot D\right) \cdot 0.5}{d}}}{2 \cdot \frac{\frac{d}{D}}{M}}} \]
      5. associate-*l/79.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot \frac{\color{blue}{\frac{M \cdot D}{d} \cdot 0.5}}{2 \cdot \frac{\frac{d}{D}}{M}}} \]
      6. *-commutative79.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot \frac{\frac{\color{blue}{D \cdot M}}{d} \cdot 0.5}{2 \cdot \frac{\frac{d}{D}}{M}}} \]
      7. *-commutative79.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot \frac{\color{blue}{0.5 \cdot \frac{D \cdot M}{d}}}{2 \cdot \frac{\frac{d}{D}}{M}}} \]
      8. times-frac79.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot \color{blue}{\left(\frac{0.5}{2} \cdot \frac{\frac{D \cdot M}{d}}{\frac{\frac{d}{D}}{M}}\right)}} \]
      9. metadata-eval79.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot \left(\color{blue}{0.25} \cdot \frac{\frac{D \cdot M}{d}}{\frac{\frac{d}{D}}{M}}\right)} \]
      10. associate-/l*79.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot \left(0.25 \cdot \frac{\color{blue}{D \cdot \frac{M}{d}}}{\frac{\frac{d}{D}}{M}}\right)} \]
      11. associate-/r*81.0%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot \left(0.25 \cdot \frac{D \cdot \frac{M}{d}}{\color{blue}{\frac{d}{D \cdot M}}}\right)} \]
    11. Simplified81.0%

      \[\leadsto w0 \cdot \color{blue}{\sqrt{1 - \frac{h}{\ell} \cdot \left(0.25 \cdot \frac{D \cdot \frac{M}{d}}{\frac{d}{D \cdot M}}\right)}} \]

    if -9.99999999999999912e-299 < (/.f64 h l)

    1. Initial program 87.5%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified88.5%

      \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Add Preprocessing
    4. Taylor expanded in D around 0 97.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{h}{\ell} \leq -1 \cdot 10^{-298}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot \left(0.25 \cdot \frac{D \cdot \frac{M}{d}}{\frac{d}{M \cdot D}}\right)}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 71.3% accurate, 1.7× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;M\_m \cdot D\_m \leq 2 \cdot 10^{+161}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;-0.125 \cdot \left(\left(\left(M\_m \cdot D\_m\right) \cdot \left(M\_m \cdot D\_m\right)\right) \cdot \left(\frac{h}{\ell} \cdot \frac{w0}{{d}^{2}}\right)\right)\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
 :precision binary64
 (if (<= (* M_m D_m) 2e+161)
   w0
   (* -0.125 (* (* (* M_m D_m) (* M_m D_m)) (* (/ h l) (/ w0 (pow d 2.0)))))))
M_m = fabs(M);
D_m = fabs(D);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
	double tmp;
	if ((M_m * D_m) <= 2e+161) {
		tmp = w0;
	} else {
		tmp = -0.125 * (((M_m * D_m) * (M_m * D_m)) * ((h / l) * (w0 / pow(d, 2.0))));
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d)
    real(8), intent (in) :: w0
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d
    real(8) :: tmp
    if ((m_m * d_m) <= 2d+161) then
        tmp = w0
    else
        tmp = (-0.125d0) * (((m_m * d_m) * (m_m * d_m)) * ((h / l) * (w0 / (d ** 2.0d0))))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
	double tmp;
	if ((M_m * D_m) <= 2e+161) {
		tmp = w0;
	} else {
		tmp = -0.125 * (((M_m * D_m) * (M_m * D_m)) * ((h / l) * (w0 / Math.pow(d, 2.0))));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d])
def code(w0, M_m, D_m, h, l, d):
	tmp = 0
	if (M_m * D_m) <= 2e+161:
		tmp = w0
	else:
		tmp = -0.125 * (((M_m * D_m) * (M_m * D_m)) * ((h / l) * (w0 / math.pow(d, 2.0))))
	return tmp
M_m = abs(M)
D_m = abs(D)
w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d])
function code(w0, M_m, D_m, h, l, d)
	tmp = 0.0
	if (Float64(M_m * D_m) <= 2e+161)
		tmp = w0;
	else
		tmp = Float64(-0.125 * Float64(Float64(Float64(M_m * D_m) * Float64(M_m * D_m)) * Float64(Float64(h / l) * Float64(w0 / (d ^ 2.0)))));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d)
	tmp = 0.0;
	if ((M_m * D_m) <= 2e+161)
		tmp = w0;
	else
		tmp = -0.125 * (((M_m * D_m) * (M_m * D_m)) * ((h / l) * (w0 / (d ^ 2.0))));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 2e+161], w0, N[(-0.125 * N[(N[(N[(M$95$m * D$95$m), $MachinePrecision] * N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] * N[(N[(h / l), $MachinePrecision] * N[(w0 / N[Power[d, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;M\_m \cdot D\_m \leq 2 \cdot 10^{+161}:\\
\;\;\;\;w0\\

\mathbf{else}:\\
\;\;\;\;-0.125 \cdot \left(\left(\left(M\_m \cdot D\_m\right) \cdot \left(M\_m \cdot D\_m\right)\right) \cdot \left(\frac{h}{\ell} \cdot \frac{w0}{{d}^{2}}\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 M D) < 2.0000000000000001e161

    1. Initial program 84.7%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified85.1%

      \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Add Preprocessing
    4. Taylor expanded in D around 0 78.1%

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

    if 2.0000000000000001e161 < (*.f64 M D)

    1. Initial program 74.2%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified74.2%

      \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. unpow274.2%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \left(D \cdot \frac{\frac{M}{2}}{d}\right)\right)} \cdot \frac{h}{\ell}} \]
      2. unpow274.2%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{{\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2}} \cdot \frac{h}{\ell}} \]
      3. *-commutative74.2%

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

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{\frac{M}{2} \cdot D}{d}\right)}}^{2} \cdot \frac{h}{\ell}} \]
      5. associate-*r/74.2%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}}^{2} \cdot \frac{h}{\ell}} \]
      6. times-frac74.2%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{M \cdot D}{2 \cdot d}\right)}}^{2} \cdot \frac{h}{\ell}} \]
      7. associate-*r/74.4%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot h}{\ell}}} \]
      8. *-commutative74.4%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{h \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}}}{\ell}} \]
      9. associate-/l*74.4%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{h \cdot {\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)}}^{2}}{\ell}} \]
      10. div-inv74.4%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{h \cdot {\left(M \cdot \color{blue}{\left(D \cdot \frac{1}{2 \cdot d}\right)}\right)}^{2}}{\ell}} \]
      11. associate-/r*74.4%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{h \cdot {\left(M \cdot \left(D \cdot \color{blue}{\frac{\frac{1}{2}}{d}}\right)\right)}^{2}}{\ell}} \]
      12. metadata-eval74.4%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{h \cdot {\left(M \cdot \left(D \cdot \frac{\color{blue}{0.5}}{d}\right)\right)}^{2}}{\ell}} \]
    5. Applied egg-rr74.4%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{h \cdot {\left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}}} \]
    6. Taylor expanded in h around 0 65.7%

      \[\leadsto \color{blue}{w0 + -0.125 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(h \cdot w0\right)\right)}{{d}^{2} \cdot \ell}} \]
    7. Step-by-step derivation
      1. +-commutative65.7%

        \[\leadsto \color{blue}{-0.125 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(h \cdot w0\right)\right)}{{d}^{2} \cdot \ell} + w0} \]
      2. fma-define65.7%

        \[\leadsto \color{blue}{\mathsf{fma}\left(-0.125, \frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(h \cdot w0\right)\right)}{{d}^{2} \cdot \ell}, w0\right)} \]
      3. associate-*r*65.9%

        \[\leadsto \mathsf{fma}\left(-0.125, \frac{\color{blue}{\left({D}^{2} \cdot {M}^{2}\right) \cdot \left(h \cdot w0\right)}}{{d}^{2} \cdot \ell}, w0\right) \]
      4. unpow265.9%

        \[\leadsto \mathsf{fma}\left(-0.125, \frac{\left(\color{blue}{\left(D \cdot D\right)} \cdot {M}^{2}\right) \cdot \left(h \cdot w0\right)}{{d}^{2} \cdot \ell}, w0\right) \]
      5. unpow265.9%

        \[\leadsto \mathsf{fma}\left(-0.125, \frac{\left(\left(D \cdot D\right) \cdot \color{blue}{\left(M \cdot M\right)}\right) \cdot \left(h \cdot w0\right)}{{d}^{2} \cdot \ell}, w0\right) \]
      6. swap-sqr65.9%

        \[\leadsto \mathsf{fma}\left(-0.125, \frac{\color{blue}{\left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)} \cdot \left(h \cdot w0\right)}{{d}^{2} \cdot \ell}, w0\right) \]
      7. unpow265.9%

        \[\leadsto \mathsf{fma}\left(-0.125, \frac{\color{blue}{{\left(D \cdot M\right)}^{2}} \cdot \left(h \cdot w0\right)}{{d}^{2} \cdot \ell}, w0\right) \]
      8. *-commutative65.9%

        \[\leadsto \mathsf{fma}\left(-0.125, \frac{{\left(D \cdot M\right)}^{2} \cdot \color{blue}{\left(w0 \cdot h\right)}}{{d}^{2} \cdot \ell}, w0\right) \]
    8. Simplified65.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-0.125, \frac{{\left(D \cdot M\right)}^{2} \cdot \left(w0 \cdot h\right)}{{d}^{2} \cdot \ell}, w0\right)} \]
    9. Taylor expanded in D around inf 65.7%

      \[\leadsto \color{blue}{-0.125 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(h \cdot w0\right)\right)}{{d}^{2} \cdot \ell}} \]
    10. Step-by-step derivation
      1. associate-*r*65.9%

        \[\leadsto -0.125 \cdot \frac{\color{blue}{\left({D}^{2} \cdot {M}^{2}\right) \cdot \left(h \cdot w0\right)}}{{d}^{2} \cdot \ell} \]
      2. *-commutative65.9%

        \[\leadsto -0.125 \cdot \frac{\color{blue}{\left({M}^{2} \cdot {D}^{2}\right)} \cdot \left(h \cdot w0\right)}{{d}^{2} \cdot \ell} \]
      3. unpow265.9%

        \[\leadsto -0.125 \cdot \frac{\left(\color{blue}{\left(M \cdot M\right)} \cdot {D}^{2}\right) \cdot \left(h \cdot w0\right)}{{d}^{2} \cdot \ell} \]
      4. unpow265.9%

        \[\leadsto -0.125 \cdot \frac{\left(\left(M \cdot M\right) \cdot \color{blue}{\left(D \cdot D\right)}\right) \cdot \left(h \cdot w0\right)}{{d}^{2} \cdot \ell} \]
      5. swap-sqr65.9%

        \[\leadsto -0.125 \cdot \frac{\color{blue}{\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right)} \cdot \left(h \cdot w0\right)}{{d}^{2} \cdot \ell} \]
      6. unpow265.9%

        \[\leadsto -0.125 \cdot \frac{\color{blue}{{\left(M \cdot D\right)}^{2}} \cdot \left(h \cdot w0\right)}{{d}^{2} \cdot \ell} \]
      7. *-commutative65.9%

        \[\leadsto -0.125 \cdot \frac{{\left(M \cdot D\right)}^{2} \cdot \left(h \cdot w0\right)}{\color{blue}{\ell \cdot {d}^{2}}} \]
      8. associate-*r/65.7%

        \[\leadsto -0.125 \cdot \color{blue}{\left({\left(M \cdot D\right)}^{2} \cdot \frac{h \cdot w0}{\ell \cdot {d}^{2}}\right)} \]
      9. *-commutative65.7%

        \[\leadsto -0.125 \cdot \left({\color{blue}{\left(D \cdot M\right)}}^{2} \cdot \frac{h \cdot w0}{\ell \cdot {d}^{2}}\right) \]
      10. times-frac73.9%

        \[\leadsto -0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \color{blue}{\left(\frac{h}{\ell} \cdot \frac{w0}{{d}^{2}}\right)}\right) \]
    11. Simplified73.9%

      \[\leadsto \color{blue}{-0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \left(\frac{h}{\ell} \cdot \frac{w0}{{d}^{2}}\right)\right)} \]
    12. Step-by-step derivation
      1. *-commutative73.9%

        \[\leadsto -0.125 \cdot \left({\color{blue}{\left(M \cdot D\right)}}^{2} \cdot \left(\frac{h}{\ell} \cdot \frac{w0}{{d}^{2}}\right)\right) \]
      2. pow273.9%

        \[\leadsto -0.125 \cdot \left(\color{blue}{\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right)} \cdot \left(\frac{h}{\ell} \cdot \frac{w0}{{d}^{2}}\right)\right) \]
    13. Applied egg-rr73.9%

      \[\leadsto -0.125 \cdot \left(\color{blue}{\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right)} \cdot \left(\frac{h}{\ell} \cdot \frac{w0}{{d}^{2}}\right)\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 10: 71.7% accurate, 1.8× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;M\_m \leq 1650:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;-0.125 \cdot \left({\left(D\_m \cdot \frac{M\_m}{d}\right)}^{2} \cdot \left(h \cdot \frac{w0}{\ell}\right)\right)\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
 :precision binary64
 (if (<= M_m 1650.0)
   w0
   (* -0.125 (* (pow (* D_m (/ M_m d)) 2.0) (* h (/ w0 l))))))
M_m = fabs(M);
D_m = fabs(D);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
	double tmp;
	if (M_m <= 1650.0) {
		tmp = w0;
	} else {
		tmp = -0.125 * (pow((D_m * (M_m / d)), 2.0) * (h * (w0 / l)));
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d)
    real(8), intent (in) :: w0
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d
    real(8) :: tmp
    if (m_m <= 1650.0d0) then
        tmp = w0
    else
        tmp = (-0.125d0) * (((d_m * (m_m / d)) ** 2.0d0) * (h * (w0 / l)))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
	double tmp;
	if (M_m <= 1650.0) {
		tmp = w0;
	} else {
		tmp = -0.125 * (Math.pow((D_m * (M_m / d)), 2.0) * (h * (w0 / l)));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d])
def code(w0, M_m, D_m, h, l, d):
	tmp = 0
	if M_m <= 1650.0:
		tmp = w0
	else:
		tmp = -0.125 * (math.pow((D_m * (M_m / d)), 2.0) * (h * (w0 / l)))
	return tmp
M_m = abs(M)
D_m = abs(D)
w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d])
function code(w0, M_m, D_m, h, l, d)
	tmp = 0.0
	if (M_m <= 1650.0)
		tmp = w0;
	else
		tmp = Float64(-0.125 * Float64((Float64(D_m * Float64(M_m / d)) ^ 2.0) * Float64(h * Float64(w0 / l))));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d)
	tmp = 0.0;
	if (M_m <= 1650.0)
		tmp = w0;
	else
		tmp = -0.125 * (((D_m * (M_m / d)) ^ 2.0) * (h * (w0 / l)));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[M$95$m, 1650.0], w0, N[(-0.125 * N[(N[Power[N[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h * N[(w0 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;M\_m \leq 1650:\\
\;\;\;\;w0\\

\mathbf{else}:\\
\;\;\;\;-0.125 \cdot \left({\left(D\_m \cdot \frac{M\_m}{d}\right)}^{2} \cdot \left(h \cdot \frac{w0}{\ell}\right)\right)\\


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

    1. Initial program 85.5%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified85.5%

      \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Add Preprocessing
    4. Taylor expanded in D around 0 76.5%

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

    if 1650 < M

    1. Initial program 76.8%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified78.5%

      \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. unpow278.5%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \left(D \cdot \frac{\frac{M}{2}}{d}\right)\right)} \cdot \frac{h}{\ell}} \]
      2. unpow278.5%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{{\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2}} \cdot \frac{h}{\ell}} \]
      3. *-commutative78.5%

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

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{\frac{M}{2} \cdot D}{d}\right)}}^{2} \cdot \frac{h}{\ell}} \]
      5. associate-*r/76.8%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}}^{2} \cdot \frac{h}{\ell}} \]
      6. times-frac76.8%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{M \cdot D}{2 \cdot d}\right)}}^{2} \cdot \frac{h}{\ell}} \]
      7. associate-*r/82.3%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot h}{\ell}}} \]
      8. *-commutative82.3%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{h \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}}}{\ell}} \]
      9. associate-/l*82.4%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{h \cdot {\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)}}^{2}}{\ell}} \]
      10. div-inv82.4%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{h \cdot {\left(M \cdot \color{blue}{\left(D \cdot \frac{1}{2 \cdot d}\right)}\right)}^{2}}{\ell}} \]
      11. associate-/r*82.4%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{h \cdot {\left(M \cdot \left(D \cdot \color{blue}{\frac{\frac{1}{2}}{d}}\right)\right)}^{2}}{\ell}} \]
      12. metadata-eval82.4%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{h \cdot {\left(M \cdot \left(D \cdot \frac{\color{blue}{0.5}}{d}\right)\right)}^{2}}{\ell}} \]
    5. Applied egg-rr82.4%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{h \cdot {\left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}}} \]
    6. Taylor expanded in h around 0 40.0%

      \[\leadsto \color{blue}{w0 + -0.125 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(h \cdot w0\right)\right)}{{d}^{2} \cdot \ell}} \]
    7. Step-by-step derivation
      1. +-commutative40.0%

        \[\leadsto \color{blue}{-0.125 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(h \cdot w0\right)\right)}{{d}^{2} \cdot \ell} + w0} \]
      2. fma-define40.0%

        \[\leadsto \color{blue}{\mathsf{fma}\left(-0.125, \frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(h \cdot w0\right)\right)}{{d}^{2} \cdot \ell}, w0\right)} \]
      3. associate-*r*43.6%

        \[\leadsto \mathsf{fma}\left(-0.125, \frac{\color{blue}{\left({D}^{2} \cdot {M}^{2}\right) \cdot \left(h \cdot w0\right)}}{{d}^{2} \cdot \ell}, w0\right) \]
      4. unpow243.6%

        \[\leadsto \mathsf{fma}\left(-0.125, \frac{\left(\color{blue}{\left(D \cdot D\right)} \cdot {M}^{2}\right) \cdot \left(h \cdot w0\right)}{{d}^{2} \cdot \ell}, w0\right) \]
      5. unpow243.6%

        \[\leadsto \mathsf{fma}\left(-0.125, \frac{\left(\left(D \cdot D\right) \cdot \color{blue}{\left(M \cdot M\right)}\right) \cdot \left(h \cdot w0\right)}{{d}^{2} \cdot \ell}, w0\right) \]
      6. swap-sqr58.6%

        \[\leadsto \mathsf{fma}\left(-0.125, \frac{\color{blue}{\left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)} \cdot \left(h \cdot w0\right)}{{d}^{2} \cdot \ell}, w0\right) \]
      7. unpow258.6%

        \[\leadsto \mathsf{fma}\left(-0.125, \frac{\color{blue}{{\left(D \cdot M\right)}^{2}} \cdot \left(h \cdot w0\right)}{{d}^{2} \cdot \ell}, w0\right) \]
      8. *-commutative58.6%

        \[\leadsto \mathsf{fma}\left(-0.125, \frac{{\left(D \cdot M\right)}^{2} \cdot \color{blue}{\left(w0 \cdot h\right)}}{{d}^{2} \cdot \ell}, w0\right) \]
    8. Simplified58.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-0.125, \frac{{\left(D \cdot M\right)}^{2} \cdot \left(w0 \cdot h\right)}{{d}^{2} \cdot \ell}, w0\right)} \]
    9. Taylor expanded in D around inf 27.6%

      \[\leadsto \color{blue}{-0.125 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(h \cdot w0\right)\right)}{{d}^{2} \cdot \ell}} \]
    10. Step-by-step derivation
      1. associate-*r*27.6%

        \[\leadsto -0.125 \cdot \frac{\color{blue}{\left({D}^{2} \cdot {M}^{2}\right) \cdot \left(h \cdot w0\right)}}{{d}^{2} \cdot \ell} \]
      2. *-commutative27.6%

        \[\leadsto -0.125 \cdot \frac{\color{blue}{\left({M}^{2} \cdot {D}^{2}\right)} \cdot \left(h \cdot w0\right)}{{d}^{2} \cdot \ell} \]
      3. unpow227.6%

        \[\leadsto -0.125 \cdot \frac{\left(\color{blue}{\left(M \cdot M\right)} \cdot {D}^{2}\right) \cdot \left(h \cdot w0\right)}{{d}^{2} \cdot \ell} \]
      4. unpow227.6%

        \[\leadsto -0.125 \cdot \frac{\left(\left(M \cdot M\right) \cdot \color{blue}{\left(D \cdot D\right)}\right) \cdot \left(h \cdot w0\right)}{{d}^{2} \cdot \ell} \]
      5. swap-sqr30.3%

        \[\leadsto -0.125 \cdot \frac{\color{blue}{\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right)} \cdot \left(h \cdot w0\right)}{{d}^{2} \cdot \ell} \]
      6. unpow230.3%

        \[\leadsto -0.125 \cdot \frac{\color{blue}{{\left(M \cdot D\right)}^{2}} \cdot \left(h \cdot w0\right)}{{d}^{2} \cdot \ell} \]
      7. *-commutative30.3%

        \[\leadsto -0.125 \cdot \frac{{\left(M \cdot D\right)}^{2} \cdot \left(h \cdot w0\right)}{\color{blue}{\ell \cdot {d}^{2}}} \]
      8. associate-*r/30.2%

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

        \[\leadsto -0.125 \cdot \left({\color{blue}{\left(D \cdot M\right)}}^{2} \cdot \frac{h \cdot w0}{\ell \cdot {d}^{2}}\right) \]
      10. times-frac31.9%

        \[\leadsto -0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \color{blue}{\left(\frac{h}{\ell} \cdot \frac{w0}{{d}^{2}}\right)}\right) \]
    11. Simplified31.9%

      \[\leadsto \color{blue}{-0.125 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \left(\frac{h}{\ell} \cdot \frac{w0}{{d}^{2}}\right)\right)} \]
    12. Taylor expanded in D around 0 27.6%

      \[\leadsto \color{blue}{-0.125 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(h \cdot w0\right)\right)}{{d}^{2} \cdot \ell}} \]
    13. Step-by-step derivation
      1. associate-*r*27.6%

        \[\leadsto -0.125 \cdot \frac{\color{blue}{\left({D}^{2} \cdot {M}^{2}\right) \cdot \left(h \cdot w0\right)}}{{d}^{2} \cdot \ell} \]
      2. times-frac29.3%

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

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

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

        \[\leadsto -0.125 \cdot \left(\left(\color{blue}{\left(M \cdot M\right)} \cdot \frac{{D}^{2}}{{d}^{2}}\right) \cdot \frac{h \cdot w0}{\ell}\right) \]
      6. unpow227.2%

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

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

        \[\leadsto -0.125 \cdot \left(\left(\left(M \cdot M\right) \cdot \color{blue}{\left(\frac{D}{d} \cdot \frac{D}{d}\right)}\right) \cdot \frac{h \cdot w0}{\ell}\right) \]
      9. swap-sqr32.4%

        \[\leadsto -0.125 \cdot \left(\color{blue}{\left(\left(M \cdot \frac{D}{d}\right) \cdot \left(M \cdot \frac{D}{d}\right)\right)} \cdot \frac{h \cdot w0}{\ell}\right) \]
      10. associate-/l*32.3%

        \[\leadsto -0.125 \cdot \left(\left(\color{blue}{\frac{M \cdot D}{d}} \cdot \left(M \cdot \frac{D}{d}\right)\right) \cdot \frac{h \cdot w0}{\ell}\right) \]
      11. associate-/l*32.4%

        \[\leadsto -0.125 \cdot \left(\left(\frac{M \cdot D}{d} \cdot \color{blue}{\frac{M \cdot D}{d}}\right) \cdot \frac{h \cdot w0}{\ell}\right) \]
      12. unpow232.4%

        \[\leadsto -0.125 \cdot \left(\color{blue}{{\left(\frac{M \cdot D}{d}\right)}^{2}} \cdot \frac{h \cdot w0}{\ell}\right) \]
      13. *-commutative32.4%

        \[\leadsto -0.125 \cdot \left({\left(\frac{\color{blue}{D \cdot M}}{d}\right)}^{2} \cdot \frac{h \cdot w0}{\ell}\right) \]
      14. associate-/l*32.5%

        \[\leadsto -0.125 \cdot \left({\color{blue}{\left(D \cdot \frac{M}{d}\right)}}^{2} \cdot \frac{h \cdot w0}{\ell}\right) \]
      15. associate-/l*32.3%

        \[\leadsto -0.125 \cdot \left({\left(D \cdot \frac{M}{d}\right)}^{2} \cdot \color{blue}{\left(h \cdot \frac{w0}{\ell}\right)}\right) \]
    14. Simplified32.3%

      \[\leadsto \color{blue}{-0.125 \cdot \left({\left(D \cdot \frac{M}{d}\right)}^{2} \cdot \left(h \cdot \frac{w0}{\ell}\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 11: 67.8% accurate, 216.0× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\ \\ w0 \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d) :precision binary64 w0)
M_m = fabs(M);
D_m = fabs(D);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
	return w0;
}
M_m = abs(m)
D_m = abs(d)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d)
    real(8), intent (in) :: w0
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d
    code = w0
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
	return w0;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d])
def code(w0, M_m, D_m, h, l, d):
	return w0
M_m = abs(M)
D_m = abs(D)
w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d])
function code(w0, M_m, D_m, h, l, d)
	return w0
end
M_m = abs(M);
D_m = abs(D);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp = code(w0, M_m, D_m, h, l, d)
	tmp = w0;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := w0
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
w0
\end{array}
Derivation
  1. Initial program 83.7%

    \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
  2. Simplified84.0%

    \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
  3. Add Preprocessing
  4. Taylor expanded in D around 0 71.0%

    \[\leadsto \color{blue}{w0} \]
  5. Add Preprocessing

Reproduce

?
herbie shell --seed 2024143 
(FPCore (w0 M D h l d)
  :name "Henrywood and Agarwal, Equation (9a)"
  :precision binary64
  (* w0 (sqrt (- 1.0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l))))))