Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 81.0% → 85.6%
Time: 13.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: 81.0% 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: 85.6% accurate, 1.0× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;\frac{h}{\ell} \leq -\infty:\\ \;\;\;\;w0 \cdot \sqrt{1 - 0.25 \cdot \frac{D}{\frac{\frac{\frac{d}{M} \cdot \frac{d}{M}}{h}}{\frac{D}{\ell}}}}\\ \mathbf{elif}\;\frac{h}{\ell} \leq -1 \cdot 10^{-206}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(\frac{M}{d} \cdot \frac{D}{2}\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \end{array} \]
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (w0 M D h l d)
 :precision binary64
 (if (<= (/ h l) (- INFINITY))
   (* w0 (sqrt (- 1.0 (* 0.25 (/ D (/ (/ (* (/ d M) (/ d M)) h) (/ D l)))))))
   (if (<= (/ h l) -1e-206)
     (* w0 (sqrt (- 1.0 (* (/ h l) (pow (* (/ M d) (/ D 2.0)) 2.0)))))
     w0)))
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if ((h / l) <= -((double) INFINITY)) {
		tmp = w0 * sqrt((1.0 - (0.25 * (D / ((((d / M) * (d / M)) / h) / (D / l))))));
	} else if ((h / l) <= -1e-206) {
		tmp = w0 * sqrt((1.0 - ((h / l) * pow(((M / d) * (D / 2.0)), 2.0))));
	} else {
		tmp = w0;
	}
	return tmp;
}
assert M < D;
public static double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if ((h / l) <= -Double.POSITIVE_INFINITY) {
		tmp = w0 * Math.sqrt((1.0 - (0.25 * (D / ((((d / M) * (d / M)) / h) / (D / l))))));
	} else if ((h / l) <= -1e-206) {
		tmp = w0 * Math.sqrt((1.0 - ((h / l) * Math.pow(((M / d) * (D / 2.0)), 2.0))));
	} else {
		tmp = w0;
	}
	return tmp;
}
[M, D] = sort([M, D])
def code(w0, M, D, h, l, d):
	tmp = 0
	if (h / l) <= -math.inf:
		tmp = w0 * math.sqrt((1.0 - (0.25 * (D / ((((d / M) * (d / M)) / h) / (D / l))))))
	elif (h / l) <= -1e-206:
		tmp = w0 * math.sqrt((1.0 - ((h / l) * math.pow(((M / d) * (D / 2.0)), 2.0))))
	else:
		tmp = w0
	return tmp
M, D = sort([M, D])
function code(w0, M, D, h, l, d)
	tmp = 0.0
	if (Float64(h / l) <= Float64(-Inf))
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(0.25 * Float64(D / Float64(Float64(Float64(Float64(d / M) * Float64(d / M)) / h) / Float64(D / l)))))));
	elseif (Float64(h / l) <= -1e-206)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h / l) * (Float64(Float64(M / d) * Float64(D / 2.0)) ^ 2.0)))));
	else
		tmp = w0;
	end
	return tmp
end
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(w0, M, D, h, l, d)
	tmp = 0.0;
	if ((h / l) <= -Inf)
		tmp = w0 * sqrt((1.0 - (0.25 * (D / ((((d / M) * (d / M)) / h) / (D / l))))));
	elseif ((h / l) <= -1e-206)
		tmp = w0 * sqrt((1.0 - ((h / l) * (((M / d) * (D / 2.0)) ^ 2.0))));
	else
		tmp = w0;
	end
	tmp_2 = tmp;
end
NOTE: M and D should be sorted in increasing order before calling this function.
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[N[(h / l), $MachinePrecision], (-Infinity)], N[(w0 * N[Sqrt[N[(1.0 - N[(0.25 * N[(D / N[(N[(N[(N[(d / M), $MachinePrecision] * N[(d / M), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision] / N[(D / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(h / l), $MachinePrecision], -1e-206], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(M / d), $MachinePrecision] * N[(D / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\frac{h}{\ell} \leq -\infty:\\
\;\;\;\;w0 \cdot \sqrt{1 - 0.25 \cdot \frac{D}{\frac{\frac{\frac{d}{M} \cdot \frac{d}{M}}{h}}{\frac{D}{\ell}}}}\\

\mathbf{elif}\;\frac{h}{\ell} \leq -1 \cdot 10^{-206}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(\frac{M}{d} \cdot \frac{D}{2}\right)}^{2}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 h l) < -inf.0

    1. Initial program 39.1%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Step-by-step derivation
      1. *-commutative39.1%

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

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

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

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

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

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

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

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

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

        \[\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}} \]
      8. metadata-eval83.9%

        \[\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-rr83.9%

      \[\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 57.6%

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

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

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

        \[\leadsto w0 \cdot \sqrt{1 - 0.25 \cdot \frac{D \cdot D}{\frac{\color{blue}{{d}^{2} \cdot \ell}}{h \cdot {M}^{2}}}} \]
      4. unpow257.6%

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

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

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

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

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

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

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

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

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

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

    if -inf.0 < (/.f64 h l) < -1.00000000000000003e-206

    1. Initial program 86.5%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Step-by-step derivation
      1. *-commutative86.5%

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

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

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

    if -1.00000000000000003e-206 < (/.f64 h l)

    1. Initial program 86.0%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Step-by-step derivation
      1. *-commutative86.0%

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

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

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

      \[\leadsto \color{blue}{w0} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification90.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{h}{\ell} \leq -\infty:\\ \;\;\;\;w0 \cdot \sqrt{1 - 0.25 \cdot \frac{D}{\frac{\frac{\frac{d}{M} \cdot \frac{d}{M}}{h}}{\frac{D}{\ell}}}}\\ \mathbf{elif}\;\frac{h}{\ell} \leq -1 \cdot 10^{-206}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(\frac{M}{d} \cdot \frac{D}{2}\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]

Alternative 2: 86.7% accurate, 0.7× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := 1 - {\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell}\\ \mathbf{if}\;t_0 \leq 2 \cdot 10^{+160}:\\ \;\;\;\;w0 \cdot \sqrt{t_0}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - 0.25 \cdot \frac{D}{\frac{\frac{\frac{d}{M} \cdot \frac{d}{M}}{h}}{\frac{D}{\ell}}}}\\ \end{array} \end{array} \]
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (w0 M D h l d)
 :precision binary64
 (let* ((t_0 (- 1.0 (* (pow (/ (* M D) (* d 2.0)) 2.0) (/ h l)))))
   (if (<= t_0 2e+160)
     (* w0 (sqrt t_0))
     (*
      w0
      (sqrt (- 1.0 (* 0.25 (/ D (/ (/ (* (/ d M) (/ d M)) h) (/ D l))))))))))
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
	double t_0 = 1.0 - (pow(((M * D) / (d * 2.0)), 2.0) * (h / l));
	double tmp;
	if (t_0 <= 2e+160) {
		tmp = w0 * sqrt(t_0);
	} else {
		tmp = w0 * sqrt((1.0 - (0.25 * (D / ((((d / M) * (d / M)) / h) / (D / l))))));
	}
	return tmp;
}
NOTE: M and D should be sorted in increasing order before calling this function.
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
    real(8) :: t_0
    real(8) :: tmp
    t_0 = 1.0d0 - ((((m * d) / (d_1 * 2.0d0)) ** 2.0d0) * (h / l))
    if (t_0 <= 2d+160) then
        tmp = w0 * sqrt(t_0)
    else
        tmp = w0 * sqrt((1.0d0 - (0.25d0 * (d / ((((d_1 / m) * (d_1 / m)) / h) / (d / l))))))
    end if
    code = tmp
end function
assert M < D;
public static double code(double w0, double M, double D, double h, double l, double d) {
	double t_0 = 1.0 - (Math.pow(((M * D) / (d * 2.0)), 2.0) * (h / l));
	double tmp;
	if (t_0 <= 2e+160) {
		tmp = w0 * Math.sqrt(t_0);
	} else {
		tmp = w0 * Math.sqrt((1.0 - (0.25 * (D / ((((d / M) * (d / M)) / h) / (D / l))))));
	}
	return tmp;
}
[M, D] = sort([M, D])
def code(w0, M, D, h, l, d):
	t_0 = 1.0 - (math.pow(((M * D) / (d * 2.0)), 2.0) * (h / l))
	tmp = 0
	if t_0 <= 2e+160:
		tmp = w0 * math.sqrt(t_0)
	else:
		tmp = w0 * math.sqrt((1.0 - (0.25 * (D / ((((d / M) * (d / M)) / h) / (D / l))))))
	return tmp
M, D = sort([M, D])
function code(w0, M, D, h, l, d)
	t_0 = Float64(1.0 - Float64((Float64(Float64(M * D) / Float64(d * 2.0)) ^ 2.0) * Float64(h / l)))
	tmp = 0.0
	if (t_0 <= 2e+160)
		tmp = Float64(w0 * sqrt(t_0));
	else
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(0.25 * Float64(D / Float64(Float64(Float64(Float64(d / M) * Float64(d / M)) / h) / Float64(D / l)))))));
	end
	return tmp
end
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(w0, M, D, h, l, d)
	t_0 = 1.0 - ((((M * D) / (d * 2.0)) ^ 2.0) * (h / l));
	tmp = 0.0;
	if (t_0 <= 2e+160)
		tmp = w0 * sqrt(t_0);
	else
		tmp = w0 * sqrt((1.0 - (0.25 * (D / ((((d / M) * (d / M)) / h) / (D / l))))));
	end
	tmp_2 = tmp;
end
NOTE: M and D should be sorted in increasing order before calling this function.
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[(1.0 - N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 2e+160], N[(w0 * N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(0.25 * N[(D / N[(N[(N[(N[(d / M), $MachinePrecision] * N[(d / M), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision] / N[(D / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := 1 - {\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell}\\
\mathbf{if}\;t_0 \leq 2 \cdot 10^{+160}:\\
\;\;\;\;w0 \cdot \sqrt{t_0}\\

\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - 0.25 \cdot \frac{D}{\frac{\frac{\frac{d}{M} \cdot \frac{d}{M}}{h}}{\frac{D}{\ell}}}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 1 (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l))) < 2.00000000000000001e160

    1. Initial program 99.4%

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

    if 2.00000000000000001e160 < (-.f64 1 (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)))

    1. Initial program 42.8%

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

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

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

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

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

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

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

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

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

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

        \[\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}} \]
      8. metadata-eval72.5%

        \[\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-rr72.5%

      \[\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 52.7%

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

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

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

        \[\leadsto w0 \cdot \sqrt{1 - 0.25 \cdot \frac{D \cdot D}{\frac{\color{blue}{{d}^{2} \cdot \ell}}{h \cdot {M}^{2}}}} \]
      4. unpow254.0%

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

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

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

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

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

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

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

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

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

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{0.25 \cdot \frac{D}{\frac{\frac{\frac{d}{M} \cdot \frac{d}{M}}{h}}{\frac{D}{\ell}}}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification90.0%

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

Alternative 3: 86.5% accurate, 1.0× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ w0 \cdot \sqrt{1 - \frac{h \cdot {\left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}} \end{array} \]
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (w0 M D h l d)
 :precision binary64
 (* w0 (sqrt (- 1.0 (/ (* h (pow (* M (* D (/ 0.5 d))) 2.0)) l)))))
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
	return w0 * sqrt((1.0 - ((h * pow((M * (D * (0.5 / d))), 2.0)) / l)));
}
NOTE: M and D should be sorted in increasing order before calling this function.
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 - ((h * ((m * (d * (0.5d0 / d_1))) ** 2.0d0)) / l)))
end function
assert M < D;
public static double code(double w0, double M, double D, double h, double l, double d) {
	return w0 * Math.sqrt((1.0 - ((h * Math.pow((M * (D * (0.5 / d))), 2.0)) / l)));
}
[M, D] = sort([M, D])
def code(w0, M, D, h, l, d):
	return w0 * math.sqrt((1.0 - ((h * math.pow((M * (D * (0.5 / d))), 2.0)) / l)))
M, D = sort([M, D])
function code(w0, M, D, h, l, d)
	return Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h * (Float64(M * Float64(D * Float64(0.5 / d))) ^ 2.0)) / l))))
end
M, D = num2cell(sort([M, D])){:}
function tmp = code(w0, M, D, h, l, d)
	tmp = w0 * sqrt((1.0 - ((h * ((M * (D * (0.5 / d))) ^ 2.0)) / l)));
end
NOTE: M and D should be sorted in increasing order before calling this function.
code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h * N[Power[N[(M * N[(D * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
w0 \cdot \sqrt{1 - \frac{h \cdot {\left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}}
\end{array}
Derivation
  1. Initial program 82.4%

    \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
  2. Step-by-step derivation
    1. *-commutative82.4%

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

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

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

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

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

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

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

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

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

      \[\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}} \]
    8. metadata-eval91.7%

      \[\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-rr91.7%

    \[\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. Final simplification91.7%

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

Alternative 4: 81.8% accurate, 1.7× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \frac{d}{M} \cdot \frac{d}{M}\\ \mathbf{if}\;D \leq -2.15 \cdot 10^{-203}:\\ \;\;\;\;w0 \cdot \sqrt{1 - 0.25 \cdot \frac{D}{\frac{\frac{t_0}{h}}{\frac{D}{\ell}}}}\\ \mathbf{elif}\;D \leq 8 \cdot 10^{-116}:\\ \;\;\;\;w0\\ \mathbf{elif}\;D \leq 2.9 \cdot 10^{+136}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{0.25 \cdot \left(\left(D \cdot D\right) \cdot \frac{h}{t_0}\right)}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \left(1 + \frac{D}{\ell \cdot \frac{\frac{{\left(\frac{d}{M}\right)}^{2}}{h}}{D}} \cdot -0.125\right)\\ \end{array} \end{array} \]
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (w0 M D h l d)
 :precision binary64
 (let* ((t_0 (* (/ d M) (/ d M))))
   (if (<= D -2.15e-203)
     (* w0 (sqrt (- 1.0 (* 0.25 (/ D (/ (/ t_0 h) (/ D l)))))))
     (if (<= D 8e-116)
       w0
       (if (<= D 2.9e+136)
         (* w0 (sqrt (- 1.0 (/ (* 0.25 (* (* D D) (/ h t_0))) l))))
         (*
          w0
          (+ 1.0 (* (/ D (* l (/ (/ (pow (/ d M) 2.0) h) D))) -0.125))))))))
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
	double t_0 = (d / M) * (d / M);
	double tmp;
	if (D <= -2.15e-203) {
		tmp = w0 * sqrt((1.0 - (0.25 * (D / ((t_0 / h) / (D / l))))));
	} else if (D <= 8e-116) {
		tmp = w0;
	} else if (D <= 2.9e+136) {
		tmp = w0 * sqrt((1.0 - ((0.25 * ((D * D) * (h / t_0))) / l)));
	} else {
		tmp = w0 * (1.0 + ((D / (l * ((pow((d / M), 2.0) / h) / D))) * -0.125));
	}
	return tmp;
}
NOTE: M and D should be sorted in increasing order before calling this function.
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
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (d_1 / m) * (d_1 / m)
    if (d <= (-2.15d-203)) then
        tmp = w0 * sqrt((1.0d0 - (0.25d0 * (d / ((t_0 / h) / (d / l))))))
    else if (d <= 8d-116) then
        tmp = w0
    else if (d <= 2.9d+136) then
        tmp = w0 * sqrt((1.0d0 - ((0.25d0 * ((d * d) * (h / t_0))) / l)))
    else
        tmp = w0 * (1.0d0 + ((d / (l * ((((d_1 / m) ** 2.0d0) / h) / d))) * (-0.125d0)))
    end if
    code = tmp
end function
assert M < D;
public static double code(double w0, double M, double D, double h, double l, double d) {
	double t_0 = (d / M) * (d / M);
	double tmp;
	if (D <= -2.15e-203) {
		tmp = w0 * Math.sqrt((1.0 - (0.25 * (D / ((t_0 / h) / (D / l))))));
	} else if (D <= 8e-116) {
		tmp = w0;
	} else if (D <= 2.9e+136) {
		tmp = w0 * Math.sqrt((1.0 - ((0.25 * ((D * D) * (h / t_0))) / l)));
	} else {
		tmp = w0 * (1.0 + ((D / (l * ((Math.pow((d / M), 2.0) / h) / D))) * -0.125));
	}
	return tmp;
}
[M, D] = sort([M, D])
def code(w0, M, D, h, l, d):
	t_0 = (d / M) * (d / M)
	tmp = 0
	if D <= -2.15e-203:
		tmp = w0 * math.sqrt((1.0 - (0.25 * (D / ((t_0 / h) / (D / l))))))
	elif D <= 8e-116:
		tmp = w0
	elif D <= 2.9e+136:
		tmp = w0 * math.sqrt((1.0 - ((0.25 * ((D * D) * (h / t_0))) / l)))
	else:
		tmp = w0 * (1.0 + ((D / (l * ((math.pow((d / M), 2.0) / h) / D))) * -0.125))
	return tmp
M, D = sort([M, D])
function code(w0, M, D, h, l, d)
	t_0 = Float64(Float64(d / M) * Float64(d / M))
	tmp = 0.0
	if (D <= -2.15e-203)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(0.25 * Float64(D / Float64(Float64(t_0 / h) / Float64(D / l)))))));
	elseif (D <= 8e-116)
		tmp = w0;
	elseif (D <= 2.9e+136)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(0.25 * Float64(Float64(D * D) * Float64(h / t_0))) / l))));
	else
		tmp = Float64(w0 * Float64(1.0 + Float64(Float64(D / Float64(l * Float64(Float64((Float64(d / M) ^ 2.0) / h) / D))) * -0.125)));
	end
	return tmp
end
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(w0, M, D, h, l, d)
	t_0 = (d / M) * (d / M);
	tmp = 0.0;
	if (D <= -2.15e-203)
		tmp = w0 * sqrt((1.0 - (0.25 * (D / ((t_0 / h) / (D / l))))));
	elseif (D <= 8e-116)
		tmp = w0;
	elseif (D <= 2.9e+136)
		tmp = w0 * sqrt((1.0 - ((0.25 * ((D * D) * (h / t_0))) / l)));
	else
		tmp = w0 * (1.0 + ((D / (l * ((((d / M) ^ 2.0) / h) / D))) * -0.125));
	end
	tmp_2 = tmp;
end
NOTE: M and D should be sorted in increasing order before calling this function.
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[(N[(d / M), $MachinePrecision] * N[(d / M), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[D, -2.15e-203], N[(w0 * N[Sqrt[N[(1.0 - N[(0.25 * N[(D / N[(N[(t$95$0 / h), $MachinePrecision] / N[(D / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[D, 8e-116], w0, If[LessEqual[D, 2.9e+136], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(0.25 * N[(N[(D * D), $MachinePrecision] * N[(h / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[(1.0 + N[(N[(D / N[(l * N[(N[(N[Power[N[(d / M), $MachinePrecision], 2.0], $MachinePrecision] / h), $MachinePrecision] / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \frac{d}{M} \cdot \frac{d}{M}\\
\mathbf{if}\;D \leq -2.15 \cdot 10^{-203}:\\
\;\;\;\;w0 \cdot \sqrt{1 - 0.25 \cdot \frac{D}{\frac{\frac{t_0}{h}}{\frac{D}{\ell}}}}\\

\mathbf{elif}\;D \leq 8 \cdot 10^{-116}:\\
\;\;\;\;w0\\

\mathbf{elif}\;D \leq 2.9 \cdot 10^{+136}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{0.25 \cdot \left(\left(D \cdot D\right) \cdot \frac{h}{t_0}\right)}{\ell}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if D < -2.15000000000000014e-203

    1. Initial program 78.4%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Step-by-step derivation
      1. *-commutative78.4%

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

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

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

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

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

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

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

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

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

        \[\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}} \]
      8. metadata-eval91.2%

        \[\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-rr91.2%

      \[\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 w0 \cdot \sqrt{1 - \color{blue}{0.25 \cdot \frac{{D}^{2} \cdot \left(h \cdot {M}^{2}\right)}{\ell \cdot {d}^{2}}}} \]
    7. Step-by-step derivation
      1. unpow265.7%

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

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

        \[\leadsto w0 \cdot \sqrt{1 - 0.25 \cdot \frac{D \cdot D}{\frac{\color{blue}{{d}^{2} \cdot \ell}}{h \cdot {M}^{2}}}} \]
      4. unpow267.9%

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

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

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

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

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

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

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

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

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

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

    if -2.15000000000000014e-203 < D < 8e-116

    1. Initial program 89.5%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Step-by-step derivation
      1. *-commutative89.5%

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

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

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

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

    if 8e-116 < D < 2.89999999999999974e136

    1. Initial program 79.5%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Step-by-step derivation
      1. *-commutative79.5%

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

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

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

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

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

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

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

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

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

        \[\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}} \]
      8. metadata-eval91.7%

        \[\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-rr91.7%

      \[\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 76.2%

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

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

        \[\leadsto w0 \cdot \sqrt{1 - \frac{0.25 \cdot \color{blue}{\frac{D \cdot D}{\frac{{d}^{2}}{h \cdot {M}^{2}}}}}{\ell}} \]
      3. unpow278.1%

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.89999999999999974e136 < D

    1. Initial program 82.3%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Step-by-step derivation
      1. *-commutative82.3%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto w0 \cdot \color{blue}{\left(1 + \left(\frac{D \cdot D}{d \cdot d} \cdot \frac{\left(M \cdot M\right) \cdot h}{\ell}\right) \cdot -0.125\right)} \]
    7. Taylor expanded in D around 0 25.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;D \leq -2.15 \cdot 10^{-203}:\\ \;\;\;\;w0 \cdot \sqrt{1 - 0.25 \cdot \frac{D}{\frac{\frac{\frac{d}{M} \cdot \frac{d}{M}}{h}}{\frac{D}{\ell}}}}\\ \mathbf{elif}\;D \leq 8 \cdot 10^{-116}:\\ \;\;\;\;w0\\ \mathbf{elif}\;D \leq 2.9 \cdot 10^{+136}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{0.25 \cdot \left(\left(D \cdot D\right) \cdot \frac{h}{\frac{d}{M} \cdot \frac{d}{M}}\right)}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \left(1 + \frac{D}{\ell \cdot \frac{\frac{{\left(\frac{d}{M}\right)}^{2}}{h}}{D}} \cdot -0.125\right)\\ \end{array} \]

Alternative 5: 79.8% accurate, 1.8× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;D \leq -1.1 \cdot 10^{-202}:\\ \;\;\;\;w0 \cdot \sqrt{1 - 0.25 \cdot \frac{D}{\frac{\frac{\frac{d}{M} \cdot \frac{d}{M}}{h}}{\frac{D}{\ell}}}}\\ \mathbf{elif}\;D \leq 1.8 \cdot 10^{-115}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \left(1 + \frac{D}{\ell \cdot \frac{\frac{{\left(\frac{d}{M}\right)}^{2}}{h}}{D}} \cdot -0.125\right)\\ \end{array} \end{array} \]
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (w0 M D h l d)
 :precision binary64
 (if (<= D -1.1e-202)
   (* w0 (sqrt (- 1.0 (* 0.25 (/ D (/ (/ (* (/ d M) (/ d M)) h) (/ D l)))))))
   (if (<= D 1.8e-115)
     w0
     (* w0 (+ 1.0 (* (/ D (* l (/ (/ (pow (/ d M) 2.0) h) D))) -0.125))))))
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if (D <= -1.1e-202) {
		tmp = w0 * sqrt((1.0 - (0.25 * (D / ((((d / M) * (d / M)) / h) / (D / l))))));
	} else if (D <= 1.8e-115) {
		tmp = w0;
	} else {
		tmp = w0 * (1.0 + ((D / (l * ((pow((d / M), 2.0) / h) / D))) * -0.125));
	}
	return tmp;
}
NOTE: M and D should be sorted in increasing order before calling this function.
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
    real(8) :: tmp
    if (d <= (-1.1d-202)) then
        tmp = w0 * sqrt((1.0d0 - (0.25d0 * (d / ((((d_1 / m) * (d_1 / m)) / h) / (d / l))))))
    else if (d <= 1.8d-115) then
        tmp = w0
    else
        tmp = w0 * (1.0d0 + ((d / (l * ((((d_1 / m) ** 2.0d0) / h) / d))) * (-0.125d0)))
    end if
    code = tmp
end function
assert M < D;
public static double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if (D <= -1.1e-202) {
		tmp = w0 * Math.sqrt((1.0 - (0.25 * (D / ((((d / M) * (d / M)) / h) / (D / l))))));
	} else if (D <= 1.8e-115) {
		tmp = w0;
	} else {
		tmp = w0 * (1.0 + ((D / (l * ((Math.pow((d / M), 2.0) / h) / D))) * -0.125));
	}
	return tmp;
}
[M, D] = sort([M, D])
def code(w0, M, D, h, l, d):
	tmp = 0
	if D <= -1.1e-202:
		tmp = w0 * math.sqrt((1.0 - (0.25 * (D / ((((d / M) * (d / M)) / h) / (D / l))))))
	elif D <= 1.8e-115:
		tmp = w0
	else:
		tmp = w0 * (1.0 + ((D / (l * ((math.pow((d / M), 2.0) / h) / D))) * -0.125))
	return tmp
M, D = sort([M, D])
function code(w0, M, D, h, l, d)
	tmp = 0.0
	if (D <= -1.1e-202)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(0.25 * Float64(D / Float64(Float64(Float64(Float64(d / M) * Float64(d / M)) / h) / Float64(D / l)))))));
	elseif (D <= 1.8e-115)
		tmp = w0;
	else
		tmp = Float64(w0 * Float64(1.0 + Float64(Float64(D / Float64(l * Float64(Float64((Float64(d / M) ^ 2.0) / h) / D))) * -0.125)));
	end
	return tmp
end
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(w0, M, D, h, l, d)
	tmp = 0.0;
	if (D <= -1.1e-202)
		tmp = w0 * sqrt((1.0 - (0.25 * (D / ((((d / M) * (d / M)) / h) / (D / l))))));
	elseif (D <= 1.8e-115)
		tmp = w0;
	else
		tmp = w0 * (1.0 + ((D / (l * ((((d / M) ^ 2.0) / h) / D))) * -0.125));
	end
	tmp_2 = tmp;
end
NOTE: M and D should be sorted in increasing order before calling this function.
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[D, -1.1e-202], N[(w0 * N[Sqrt[N[(1.0 - N[(0.25 * N[(D / N[(N[(N[(N[(d / M), $MachinePrecision] * N[(d / M), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision] / N[(D / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[D, 1.8e-115], w0, N[(w0 * N[(1.0 + N[(N[(D / N[(l * N[(N[(N[Power[N[(d / M), $MachinePrecision], 2.0], $MachinePrecision] / h), $MachinePrecision] / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;D \leq -1.1 \cdot 10^{-202}:\\
\;\;\;\;w0 \cdot \sqrt{1 - 0.25 \cdot \frac{D}{\frac{\frac{\frac{d}{M} \cdot \frac{d}{M}}{h}}{\frac{D}{\ell}}}}\\

\mathbf{elif}\;D \leq 1.8 \cdot 10^{-115}:\\
\;\;\;\;w0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if D < -1.10000000000000004e-202

    1. Initial program 78.4%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Step-by-step derivation
      1. *-commutative78.4%

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

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

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

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

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

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

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

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

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

        \[\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}} \]
      8. metadata-eval91.2%

        \[\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-rr91.2%

      \[\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 w0 \cdot \sqrt{1 - \color{blue}{0.25 \cdot \frac{{D}^{2} \cdot \left(h \cdot {M}^{2}\right)}{\ell \cdot {d}^{2}}}} \]
    7. Step-by-step derivation
      1. unpow265.7%

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

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

        \[\leadsto w0 \cdot \sqrt{1 - 0.25 \cdot \frac{D \cdot D}{\frac{\color{blue}{{d}^{2} \cdot \ell}}{h \cdot {M}^{2}}}} \]
      4. unpow267.9%

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

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

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

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

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

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

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

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

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

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

    if -1.10000000000000004e-202 < D < 1.80000000000000005e-115

    1. Initial program 89.5%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Step-by-step derivation
      1. *-commutative89.5%

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

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

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

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

    if 1.80000000000000005e-115 < D

    1. Initial program 80.5%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Step-by-step derivation
      1. *-commutative80.5%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 \cdot \left(1 + \left(\frac{D \cdot D}{d \cdot d} \cdot \frac{\color{blue}{\left(M \cdot M\right)} \cdot h}{\ell}\right) \cdot -0.125\right) \]
    6. Simplified53.8%

      \[\leadsto w0 \cdot \color{blue}{\left(1 + \left(\frac{D \cdot D}{d \cdot d} \cdot \frac{\left(M \cdot M\right) \cdot h}{\ell}\right) \cdot -0.125\right)} \]
    7. Taylor expanded in D around 0 51.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;D \leq -1.1 \cdot 10^{-202}:\\ \;\;\;\;w0 \cdot \sqrt{1 - 0.25 \cdot \frac{D}{\frac{\frac{\frac{d}{M} \cdot \frac{d}{M}}{h}}{\frac{D}{\ell}}}}\\ \mathbf{elif}\;D \leq 1.8 \cdot 10^{-115}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \left(1 + \frac{D}{\ell \cdot \frac{\frac{{\left(\frac{d}{M}\right)}^{2}}{h}}{D}} \cdot -0.125\right)\\ \end{array} \]

Alternative 6: 74.3% accurate, 1.8× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;w0 \leq -6.6 \cdot 10^{+56}:\\ \;\;\;\;w0 \cdot \left(1 + \frac{D}{\frac{\frac{\frac{d}{M} \cdot \frac{d}{M}}{h}}{\frac{D}{\ell}}} \cdot -0.125\right)\\ \mathbf{elif}\;w0 \leq 1.05 \cdot 10^{-57}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \left(1 + -0.125 \cdot \left(\frac{D}{\ell} \cdot \frac{D}{\frac{{\left(\frac{d}{M}\right)}^{2}}{h}}\right)\right)\\ \end{array} \end{array} \]
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (w0 M D h l d)
 :precision binary64
 (if (<= w0 -6.6e+56)
   (* w0 (+ 1.0 (* (/ D (/ (/ (* (/ d M) (/ d M)) h) (/ D l))) -0.125)))
   (if (<= w0 1.05e-57)
     w0
     (* w0 (+ 1.0 (* -0.125 (* (/ D l) (/ D (/ (pow (/ d M) 2.0) h)))))))))
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if (w0 <= -6.6e+56) {
		tmp = w0 * (1.0 + ((D / ((((d / M) * (d / M)) / h) / (D / l))) * -0.125));
	} else if (w0 <= 1.05e-57) {
		tmp = w0;
	} else {
		tmp = w0 * (1.0 + (-0.125 * ((D / l) * (D / (pow((d / M), 2.0) / h)))));
	}
	return tmp;
}
NOTE: M and D should be sorted in increasing order before calling this function.
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
    real(8) :: tmp
    if (w0 <= (-6.6d+56)) then
        tmp = w0 * (1.0d0 + ((d / ((((d_1 / m) * (d_1 / m)) / h) / (d / l))) * (-0.125d0)))
    else if (w0 <= 1.05d-57) then
        tmp = w0
    else
        tmp = w0 * (1.0d0 + ((-0.125d0) * ((d / l) * (d / (((d_1 / m) ** 2.0d0) / h)))))
    end if
    code = tmp
end function
assert M < D;
public static double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if (w0 <= -6.6e+56) {
		tmp = w0 * (1.0 + ((D / ((((d / M) * (d / M)) / h) / (D / l))) * -0.125));
	} else if (w0 <= 1.05e-57) {
		tmp = w0;
	} else {
		tmp = w0 * (1.0 + (-0.125 * ((D / l) * (D / (Math.pow((d / M), 2.0) / h)))));
	}
	return tmp;
}
[M, D] = sort([M, D])
def code(w0, M, D, h, l, d):
	tmp = 0
	if w0 <= -6.6e+56:
		tmp = w0 * (1.0 + ((D / ((((d / M) * (d / M)) / h) / (D / l))) * -0.125))
	elif w0 <= 1.05e-57:
		tmp = w0
	else:
		tmp = w0 * (1.0 + (-0.125 * ((D / l) * (D / (math.pow((d / M), 2.0) / h)))))
	return tmp
M, D = sort([M, D])
function code(w0, M, D, h, l, d)
	tmp = 0.0
	if (w0 <= -6.6e+56)
		tmp = Float64(w0 * Float64(1.0 + Float64(Float64(D / Float64(Float64(Float64(Float64(d / M) * Float64(d / M)) / h) / Float64(D / l))) * -0.125)));
	elseif (w0 <= 1.05e-57)
		tmp = w0;
	else
		tmp = Float64(w0 * Float64(1.0 + Float64(-0.125 * Float64(Float64(D / l) * Float64(D / Float64((Float64(d / M) ^ 2.0) / h))))));
	end
	return tmp
end
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(w0, M, D, h, l, d)
	tmp = 0.0;
	if (w0 <= -6.6e+56)
		tmp = w0 * (1.0 + ((D / ((((d / M) * (d / M)) / h) / (D / l))) * -0.125));
	elseif (w0 <= 1.05e-57)
		tmp = w0;
	else
		tmp = w0 * (1.0 + (-0.125 * ((D / l) * (D / (((d / M) ^ 2.0) / h)))));
	end
	tmp_2 = tmp;
end
NOTE: M and D should be sorted in increasing order before calling this function.
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[w0, -6.6e+56], N[(w0 * N[(1.0 + N[(N[(D / N[(N[(N[(N[(d / M), $MachinePrecision] * N[(d / M), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision] / N[(D / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[w0, 1.05e-57], w0, N[(w0 * N[(1.0 + N[(-0.125 * N[(N[(D / l), $MachinePrecision] * N[(D / N[(N[Power[N[(d / M), $MachinePrecision], 2.0], $MachinePrecision] / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;w0 \leq -6.6 \cdot 10^{+56}:\\
\;\;\;\;w0 \cdot \left(1 + \frac{D}{\frac{\frac{\frac{d}{M} \cdot \frac{d}{M}}{h}}{\frac{D}{\ell}}} \cdot -0.125\right)\\

\mathbf{elif}\;w0 \leq 1.05 \cdot 10^{-57}:\\
\;\;\;\;w0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if w0 < -6.60000000000000004e56

    1. Initial program 89.3%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Step-by-step derivation
      1. *-commutative89.3%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto w0 \cdot \color{blue}{\left(1 + \left(\frac{D \cdot D}{d \cdot d} \cdot \frac{\left(M \cdot M\right) \cdot h}{\ell}\right) \cdot -0.125\right)} \]
    7. Taylor expanded in D around 0 71.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.60000000000000004e56 < w0 < 1.05e-57

    1. Initial program 79.4%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Step-by-step derivation
      1. *-commutative79.4%

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

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

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

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

    if 1.05e-57 < w0

    1. Initial program 82.1%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Step-by-step derivation
      1. *-commutative82.1%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto w0 \cdot \color{blue}{\left(1 + \left(\frac{D \cdot D}{d \cdot d} \cdot \frac{\left(M \cdot M\right) \cdot h}{\ell}\right) \cdot -0.125\right)} \]
    7. Taylor expanded in D around 0 56.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;w0 \leq -6.6 \cdot 10^{+56}:\\ \;\;\;\;w0 \cdot \left(1 + \frac{D}{\frac{\frac{\frac{d}{M} \cdot \frac{d}{M}}{h}}{\frac{D}{\ell}}} \cdot -0.125\right)\\ \mathbf{elif}\;w0 \leq 1.05 \cdot 10^{-57}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \left(1 + -0.125 \cdot \left(\frac{D}{\ell} \cdot \frac{D}{\frac{{\left(\frac{d}{M}\right)}^{2}}{h}}\right)\right)\\ \end{array} \]

Alternative 7: 77.1% accurate, 1.8× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq 10^{+138}:\\ \;\;\;\;w0 \cdot \left(1 + \frac{D}{\ell \cdot \frac{\frac{{\left(\frac{d}{M}\right)}^{2}}{h}}{D}} \cdot -0.125\right)\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \end{array} \]
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (w0 M D h l d)
 :precision binary64
 (if (<= l 1e+138)
   (* w0 (+ 1.0 (* (/ D (* l (/ (/ (pow (/ d M) 2.0) h) D))) -0.125)))
   w0))
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if (l <= 1e+138) {
		tmp = w0 * (1.0 + ((D / (l * ((pow((d / M), 2.0) / h) / D))) * -0.125));
	} else {
		tmp = w0;
	}
	return tmp;
}
NOTE: M and D should be sorted in increasing order before calling this function.
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
    real(8) :: tmp
    if (l <= 1d+138) then
        tmp = w0 * (1.0d0 + ((d / (l * ((((d_1 / m) ** 2.0d0) / h) / d))) * (-0.125d0)))
    else
        tmp = w0
    end if
    code = tmp
end function
assert M < D;
public static double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if (l <= 1e+138) {
		tmp = w0 * (1.0 + ((D / (l * ((Math.pow((d / M), 2.0) / h) / D))) * -0.125));
	} else {
		tmp = w0;
	}
	return tmp;
}
[M, D] = sort([M, D])
def code(w0, M, D, h, l, d):
	tmp = 0
	if l <= 1e+138:
		tmp = w0 * (1.0 + ((D / (l * ((math.pow((d / M), 2.0) / h) / D))) * -0.125))
	else:
		tmp = w0
	return tmp
M, D = sort([M, D])
function code(w0, M, D, h, l, d)
	tmp = 0.0
	if (l <= 1e+138)
		tmp = Float64(w0 * Float64(1.0 + Float64(Float64(D / Float64(l * Float64(Float64((Float64(d / M) ^ 2.0) / h) / D))) * -0.125)));
	else
		tmp = w0;
	end
	return tmp
end
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(w0, M, D, h, l, d)
	tmp = 0.0;
	if (l <= 1e+138)
		tmp = w0 * (1.0 + ((D / (l * ((((d / M) ^ 2.0) / h) / D))) * -0.125));
	else
		tmp = w0;
	end
	tmp_2 = tmp;
end
NOTE: M and D should be sorted in increasing order before calling this function.
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[l, 1e+138], N[(w0 * N[(1.0 + N[(N[(D / N[(l * N[(N[(N[Power[N[(d / M), $MachinePrecision], 2.0], $MachinePrecision] / h), $MachinePrecision] / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], w0]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 10^{+138}:\\
\;\;\;\;w0 \cdot \left(1 + \frac{D}{\ell \cdot \frac{\frac{{\left(\frac{d}{M}\right)}^{2}}{h}}{D}} \cdot -0.125\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < 1e138

    1. Initial program 82.2%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Step-by-step derivation
      1. *-commutative82.2%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto w0 \cdot \color{blue}{\left(1 + \left(\frac{D \cdot D}{d \cdot d} \cdot \frac{\left(M \cdot M\right) \cdot h}{\ell}\right) \cdot -0.125\right)} \]
    7. Taylor expanded in D around 0 56.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1e138 < l

    1. Initial program 83.5%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Step-by-step derivation
      1. *-commutative83.5%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 10^{+138}:\\ \;\;\;\;w0 \cdot \left(1 + \frac{D}{\ell \cdot \frac{\frac{{\left(\frac{d}{M}\right)}^{2}}{h}}{D}} \cdot -0.125\right)\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]

Alternative 8: 74.4% accurate, 8.6× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;w0 \leq -6.2 \cdot 10^{+57} \lor \neg \left(w0 \leq 1.06 \cdot 10^{-57}\right):\\ \;\;\;\;w0 \cdot \left(1 + \frac{D}{\frac{\frac{\frac{d}{M} \cdot \frac{d}{M}}{h}}{\frac{D}{\ell}}} \cdot -0.125\right)\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \end{array} \]
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (w0 M D h l d)
 :precision binary64
 (if (or (<= w0 -6.2e+57) (not (<= w0 1.06e-57)))
   (* w0 (+ 1.0 (* (/ D (/ (/ (* (/ d M) (/ d M)) h) (/ D l))) -0.125)))
   w0))
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if ((w0 <= -6.2e+57) || !(w0 <= 1.06e-57)) {
		tmp = w0 * (1.0 + ((D / ((((d / M) * (d / M)) / h) / (D / l))) * -0.125));
	} else {
		tmp = w0;
	}
	return tmp;
}
NOTE: M and D should be sorted in increasing order before calling this function.
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
    real(8) :: tmp
    if ((w0 <= (-6.2d+57)) .or. (.not. (w0 <= 1.06d-57))) then
        tmp = w0 * (1.0d0 + ((d / ((((d_1 / m) * (d_1 / m)) / h) / (d / l))) * (-0.125d0)))
    else
        tmp = w0
    end if
    code = tmp
end function
assert M < D;
public static double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if ((w0 <= -6.2e+57) || !(w0 <= 1.06e-57)) {
		tmp = w0 * (1.0 + ((D / ((((d / M) * (d / M)) / h) / (D / l))) * -0.125));
	} else {
		tmp = w0;
	}
	return tmp;
}
[M, D] = sort([M, D])
def code(w0, M, D, h, l, d):
	tmp = 0
	if (w0 <= -6.2e+57) or not (w0 <= 1.06e-57):
		tmp = w0 * (1.0 + ((D / ((((d / M) * (d / M)) / h) / (D / l))) * -0.125))
	else:
		tmp = w0
	return tmp
M, D = sort([M, D])
function code(w0, M, D, h, l, d)
	tmp = 0.0
	if ((w0 <= -6.2e+57) || !(w0 <= 1.06e-57))
		tmp = Float64(w0 * Float64(1.0 + Float64(Float64(D / Float64(Float64(Float64(Float64(d / M) * Float64(d / M)) / h) / Float64(D / l))) * -0.125)));
	else
		tmp = w0;
	end
	return tmp
end
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(w0, M, D, h, l, d)
	tmp = 0.0;
	if ((w0 <= -6.2e+57) || ~((w0 <= 1.06e-57)))
		tmp = w0 * (1.0 + ((D / ((((d / M) * (d / M)) / h) / (D / l))) * -0.125));
	else
		tmp = w0;
	end
	tmp_2 = tmp;
end
NOTE: M and D should be sorted in increasing order before calling this function.
code[w0_, M_, D_, h_, l_, d_] := If[Or[LessEqual[w0, -6.2e+57], N[Not[LessEqual[w0, 1.06e-57]], $MachinePrecision]], N[(w0 * N[(1.0 + N[(N[(D / N[(N[(N[(N[(d / M), $MachinePrecision] * N[(d / M), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision] / N[(D / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], w0]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;w0 \leq -6.2 \cdot 10^{+57} \lor \neg \left(w0 \leq 1.06 \cdot 10^{-57}\right):\\
\;\;\;\;w0 \cdot \left(1 + \frac{D}{\frac{\frac{\frac{d}{M} \cdot \frac{d}{M}}{h}}{\frac{D}{\ell}}} \cdot -0.125\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if w0 < -6.20000000000000026e57 or 1.0600000000000001e-57 < w0

    1. Initial program 85.1%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Step-by-step derivation
      1. *-commutative85.1%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto w0 \cdot \color{blue}{\left(1 + \left(\frac{D \cdot D}{d \cdot d} \cdot \frac{\left(M \cdot M\right) \cdot h}{\ell}\right) \cdot -0.125\right)} \]
    7. Taylor expanded in D around 0 62.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.20000000000000026e57 < w0 < 1.0600000000000001e-57

    1. Initial program 79.4%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Step-by-step derivation
      1. *-commutative79.4%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;w0 \leq -6.2 \cdot 10^{+57} \lor \neg \left(w0 \leq 1.06 \cdot 10^{-57}\right):\\ \;\;\;\;w0 \cdot \left(1 + \frac{D}{\frac{\frac{\frac{d}{M} \cdot \frac{d}{M}}{h}}{\frac{D}{\ell}}} \cdot -0.125\right)\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]

Alternative 9: 73.3% accurate, 8.6× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;d \leq -2.1 \cdot 10^{-67}:\\ \;\;\;\;w0\\ \mathbf{elif}\;d \leq 1.35 \cdot 10^{-96}:\\ \;\;\;\;w0 \cdot \left(1 + -0.125 \cdot \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \left(h \cdot \frac{M}{\frac{\ell}{M}}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \end{array} \]
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (w0 M D h l d)
 :precision binary64
 (if (<= d -2.1e-67)
   w0
   (if (<= d 1.35e-96)
     (* w0 (+ 1.0 (* -0.125 (* (* (/ D d) (/ D d)) (* h (/ M (/ l M)))))))
     w0)))
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if (d <= -2.1e-67) {
		tmp = w0;
	} else if (d <= 1.35e-96) {
		tmp = w0 * (1.0 + (-0.125 * (((D / d) * (D / d)) * (h * (M / (l / M))))));
	} else {
		tmp = w0;
	}
	return tmp;
}
NOTE: M and D should be sorted in increasing order before calling this function.
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
    real(8) :: tmp
    if (d_1 <= (-2.1d-67)) then
        tmp = w0
    else if (d_1 <= 1.35d-96) then
        tmp = w0 * (1.0d0 + ((-0.125d0) * (((d / d_1) * (d / d_1)) * (h * (m / (l / m))))))
    else
        tmp = w0
    end if
    code = tmp
end function
assert M < D;
public static double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if (d <= -2.1e-67) {
		tmp = w0;
	} else if (d <= 1.35e-96) {
		tmp = w0 * (1.0 + (-0.125 * (((D / d) * (D / d)) * (h * (M / (l / M))))));
	} else {
		tmp = w0;
	}
	return tmp;
}
[M, D] = sort([M, D])
def code(w0, M, D, h, l, d):
	tmp = 0
	if d <= -2.1e-67:
		tmp = w0
	elif d <= 1.35e-96:
		tmp = w0 * (1.0 + (-0.125 * (((D / d) * (D / d)) * (h * (M / (l / M))))))
	else:
		tmp = w0
	return tmp
M, D = sort([M, D])
function code(w0, M, D, h, l, d)
	tmp = 0.0
	if (d <= -2.1e-67)
		tmp = w0;
	elseif (d <= 1.35e-96)
		tmp = Float64(w0 * Float64(1.0 + Float64(-0.125 * Float64(Float64(Float64(D / d) * Float64(D / d)) * Float64(h * Float64(M / Float64(l / M)))))));
	else
		tmp = w0;
	end
	return tmp
end
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(w0, M, D, h, l, d)
	tmp = 0.0;
	if (d <= -2.1e-67)
		tmp = w0;
	elseif (d <= 1.35e-96)
		tmp = w0 * (1.0 + (-0.125 * (((D / d) * (D / d)) * (h * (M / (l / M))))));
	else
		tmp = w0;
	end
	tmp_2 = tmp;
end
NOTE: M and D should be sorted in increasing order before calling this function.
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[d, -2.1e-67], w0, If[LessEqual[d, 1.35e-96], N[(w0 * N[(1.0 + N[(-0.125 * N[(N[(N[(D / d), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision] * N[(h * N[(M / N[(l / M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], w0]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.1 \cdot 10^{-67}:\\
\;\;\;\;w0\\

\mathbf{elif}\;d \leq 1.35 \cdot 10^{-96}:\\
\;\;\;\;w0 \cdot \left(1 + -0.125 \cdot \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \left(h \cdot \frac{M}{\frac{\ell}{M}}\right)\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -2.1000000000000002e-67 or 1.35e-96 < d

    1. Initial program 83.8%

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

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

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

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

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

    if -2.1000000000000002e-67 < d < 1.35e-96

    1. Initial program 78.9%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Step-by-step derivation
      1. *-commutative78.9%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 \cdot \left(1 + \left(\frac{D \cdot D}{d \cdot d} \cdot \frac{\color{blue}{\left(M \cdot M\right)} \cdot h}{\ell}\right) \cdot -0.125\right) \]
    6. Simplified46.7%

      \[\leadsto w0 \cdot \color{blue}{\left(1 + \left(\frac{D \cdot D}{d \cdot d} \cdot \frac{\left(M \cdot M\right) \cdot h}{\ell}\right) \cdot -0.125\right)} \]
    7. Taylor expanded in M around 0 46.7%

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

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

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

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

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

      \[\leadsto w0 \cdot \left(1 + \left(\frac{D \cdot D}{d \cdot d} \cdot \color{blue}{\left(h \cdot \frac{M}{\frac{\ell}{M}}\right)}\right) \cdot -0.125\right) \]
    10. Step-by-step derivation
      1. times-frac75.4%

        \[\leadsto w0 \cdot \left(1 + \left(\color{blue}{\left(\frac{D}{d} \cdot \frac{D}{d}\right)} \cdot \left(h \cdot \frac{M}{\frac{\ell}{M}}\right)\right) \cdot -0.125\right) \]
    11. Applied egg-rr75.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.1 \cdot 10^{-67}:\\ \;\;\;\;w0\\ \mathbf{elif}\;d \leq 1.35 \cdot 10^{-96}:\\ \;\;\;\;w0 \cdot \left(1 + -0.125 \cdot \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \left(h \cdot \frac{M}{\frac{\ell}{M}}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]

Alternative 10: 68.0% accurate, 10.3× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;M \leq -2.55 \cdot 10^{+269}:\\ \;\;\;\;-0.125 \cdot \left(h \cdot \frac{w0}{\frac{\frac{d}{M} \cdot \frac{d}{M}}{\frac{D}{\frac{\ell}{D}}}}\right)\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \end{array} \]
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (w0 M D h l d)
 :precision binary64
 (if (<= M -2.55e+269)
   (* -0.125 (* h (/ w0 (/ (* (/ d M) (/ d M)) (/ D (/ l D))))))
   w0))
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if (M <= -2.55e+269) {
		tmp = -0.125 * (h * (w0 / (((d / M) * (d / M)) / (D / (l / D)))));
	} else {
		tmp = w0;
	}
	return tmp;
}
NOTE: M and D should be sorted in increasing order before calling this function.
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
    real(8) :: tmp
    if (m <= (-2.55d+269)) then
        tmp = (-0.125d0) * (h * (w0 / (((d_1 / m) * (d_1 / m)) / (d / (l / d)))))
    else
        tmp = w0
    end if
    code = tmp
end function
assert M < D;
public static double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if (M <= -2.55e+269) {
		tmp = -0.125 * (h * (w0 / (((d / M) * (d / M)) / (D / (l / D)))));
	} else {
		tmp = w0;
	}
	return tmp;
}
[M, D] = sort([M, D])
def code(w0, M, D, h, l, d):
	tmp = 0
	if M <= -2.55e+269:
		tmp = -0.125 * (h * (w0 / (((d / M) * (d / M)) / (D / (l / D)))))
	else:
		tmp = w0
	return tmp
M, D = sort([M, D])
function code(w0, M, D, h, l, d)
	tmp = 0.0
	if (M <= -2.55e+269)
		tmp = Float64(-0.125 * Float64(h * Float64(w0 / Float64(Float64(Float64(d / M) * Float64(d / M)) / Float64(D / Float64(l / D))))));
	else
		tmp = w0;
	end
	return tmp
end
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(w0, M, D, h, l, d)
	tmp = 0.0;
	if (M <= -2.55e+269)
		tmp = -0.125 * (h * (w0 / (((d / M) * (d / M)) / (D / (l / D)))));
	else
		tmp = w0;
	end
	tmp_2 = tmp;
end
NOTE: M and D should be sorted in increasing order before calling this function.
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[M, -2.55e+269], N[(-0.125 * N[(h * N[(w0 / N[(N[(N[(d / M), $MachinePrecision] * N[(d / M), $MachinePrecision]), $MachinePrecision] / N[(D / N[(l / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], w0]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;M \leq -2.55 \cdot 10^{+269}:\\
\;\;\;\;-0.125 \cdot \left(h \cdot \frac{w0}{\frac{\frac{d}{M} \cdot \frac{d}{M}}{\frac{D}{\frac{\ell}{D}}}}\right)\\

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


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

    1. Initial program 100.0%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Step-by-step derivation
      1. *-commutative100.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 \cdot \mathsf{fma}\left(\color{blue}{\frac{D}{\frac{\ell}{D}}} \cdot \frac{h \cdot {M}^{2}}{{d}^{2}}, -0.125, 1\right) \]
      10. associate-/l*100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -0.125 \cdot \left(h \cdot \frac{w0}{\frac{\color{blue}{\frac{d}{M} \cdot \frac{d}{M}}}{\frac{D}{\frac{\ell}{D}}}}\right) \]
    14. Applied egg-rr100.0%

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

    if -2.55000000000000006e269 < M

    1. Initial program 82.3%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Step-by-step derivation
      1. *-commutative82.3%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq -2.55 \cdot 10^{+269}:\\ \;\;\;\;-0.125 \cdot \left(h \cdot \frac{w0}{\frac{\frac{d}{M} \cdot \frac{d}{M}}{\frac{D}{\frac{\ell}{D}}}}\right)\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]

Alternative 11: 67.9% accurate, 216.0× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ w0 \end{array} \]
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (w0 M D h l d) :precision binary64 w0)
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
	return w0;
}
NOTE: M and D should be sorted in increasing order before calling this function.
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
end function
assert M < D;
public static double code(double w0, double M, double D, double h, double l, double d) {
	return w0;
}
[M, D] = sort([M, D])
def code(w0, M, D, h, l, d):
	return w0
M, D = sort([M, D])
function code(w0, M, D, h, l, d)
	return w0
end
M, D = num2cell(sort([M, D])){:}
function tmp = code(w0, M, D, h, l, d)
	tmp = w0;
end
NOTE: M and D should be sorted in increasing order before calling this function.
code[w0_, M_, D_, h_, l_, d_] := w0
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
w0
\end{array}
Derivation
  1. Initial program 82.4%

    \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
  2. Step-by-step derivation
    1. *-commutative82.4%

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

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

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

    \[\leadsto \color{blue}{w0} \]
  5. Final simplification75.2%

    \[\leadsto w0 \]

Reproduce

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