Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 81.1% → 87.9%
Time: 16.5s
Alternatives: 14
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 14 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.1% 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: 87.9% accurate, 1.0× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;\frac{h}{\ell} \leq -\infty:\\ \;\;\;\;w0 \cdot \sqrt{1 - 0.25 \cdot \left(\frac{D \cdot D}{\ell} \cdot \left(\frac{M}{d} \cdot \frac{h \cdot M}{d}\right)\right)}\\ \mathbf{elif}\;\frac{h}{\ell} \leq -1 \cdot 10^{-110}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}\\ \mathbf{elif}\;\frac{h}{\ell} \leq 0:\\ \;\;\;\;w0 \cdot \sqrt{1 - 0.25 \cdot \left(D \cdot \left(\frac{D}{\ell} \cdot \left(h \cdot \left(\frac{M}{d} \cdot \frac{M}{d}\right)\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \end{array} \]
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
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) l) (* (/ M d) (/ (* h M) d)))))))
   (if (<= (/ h l) -1e-110)
     (* w0 (sqrt (- 1.0 (* (/ h l) (pow (* (/ D d) (/ M 2.0)) 2.0)))))
     (if (<= (/ h l) 0.0)
       (*
        w0
        (sqrt (- 1.0 (* 0.25 (* D (* (/ D l) (* h (* (/ M d) (/ M d)))))))))
       w0))))
M = abs(M);
D = abs(D);
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) / l) * ((M / d) * ((h * M) / d))))));
	} else if ((h / l) <= -1e-110) {
		tmp = w0 * sqrt((1.0 - ((h / l) * pow(((D / d) * (M / 2.0)), 2.0))));
	} else if ((h / l) <= 0.0) {
		tmp = w0 * sqrt((1.0 - (0.25 * (D * ((D / l) * (h * ((M / d) * (M / d))))))));
	} else {
		tmp = w0;
	}
	return tmp;
}
M = Math.abs(M);
D = Math.abs(D);
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) / l) * ((M / d) * ((h * M) / d))))));
	} else if ((h / l) <= -1e-110) {
		tmp = w0 * Math.sqrt((1.0 - ((h / l) * Math.pow(((D / d) * (M / 2.0)), 2.0))));
	} else if ((h / l) <= 0.0) {
		tmp = w0 * Math.sqrt((1.0 - (0.25 * (D * ((D / l) * (h * ((M / d) * (M / d))))))));
	} else {
		tmp = w0;
	}
	return tmp;
}
M = abs(M)
D = abs(D)
[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) / l) * ((M / d) * ((h * M) / d))))))
	elif (h / l) <= -1e-110:
		tmp = w0 * math.sqrt((1.0 - ((h / l) * math.pow(((D / d) * (M / 2.0)), 2.0))))
	elif (h / l) <= 0.0:
		tmp = w0 * math.sqrt((1.0 - (0.25 * (D * ((D / l) * (h * ((M / d) * (M / d))))))))
	else:
		tmp = w0
	return tmp
M = abs(M)
D = abs(D)
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(Float64(Float64(D * D) / l) * Float64(Float64(M / d) * Float64(Float64(h * M) / d)))))));
	elseif (Float64(h / l) <= -1e-110)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h / l) * (Float64(Float64(D / d) * Float64(M / 2.0)) ^ 2.0)))));
	elseif (Float64(h / l) <= 0.0)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(0.25 * Float64(D * Float64(Float64(D / l) * Float64(h * Float64(Float64(M / d) * Float64(M / d)))))))));
	else
		tmp = w0;
	end
	return tmp
end
M = abs(M)
D = abs(D)
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) / l) * ((M / d) * ((h * M) / d))))));
	elseif ((h / l) <= -1e-110)
		tmp = w0 * sqrt((1.0 - ((h / l) * (((D / d) * (M / 2.0)) ^ 2.0))));
	elseif ((h / l) <= 0.0)
		tmp = w0 * sqrt((1.0 - (0.25 * (D * ((D / l) * (h * ((M / d) * (M / d))))))));
	else
		tmp = w0;
	end
	tmp_2 = tmp;
end
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
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[(N[(N[(D * D), $MachinePrecision] / l), $MachinePrecision] * N[(N[(M / d), $MachinePrecision] * N[(N[(h * M), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(h / l), $MachinePrecision], -1e-110], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D / d), $MachinePrecision] * N[(M / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(h / l), $MachinePrecision], 0.0], N[(w0 * N[Sqrt[N[(1.0 - N[(0.25 * N[(D * N[(N[(D / l), $MachinePrecision] * N[(h * N[(N[(M / d), $MachinePrecision] * N[(M / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0]]]
\begin{array}{l}
M = |M|\\
D = |D|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\frac{h}{\ell} \leq -\infty:\\
\;\;\;\;w0 \cdot \sqrt{1 - 0.25 \cdot \left(\frac{D \cdot D}{\ell} \cdot \left(\frac{M}{d} \cdot \frac{h \cdot M}{d}\right)\right)}\\

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

\mathbf{elif}\;\frac{h}{\ell} \leq 0:\\
\;\;\;\;w0 \cdot \sqrt{1 - 0.25 \cdot \left(D \cdot \left(\frac{D}{\ell} \cdot \left(h \cdot \left(\frac{M}{d} \cdot \frac{M}{d}\right)\right)\right)\right)}\\

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


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

    1. Initial program 48.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. times-frac48.1%

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

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

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

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

        \[\leadsto w0 \cdot \sqrt{1 - \frac{0.25 \cdot \left({D}^{2} \cdot \color{blue}{\left(h \cdot {M}^{2}\right)}\right)}{\ell \cdot {d}^{2}}} \]
      3. associate-*r/63.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}}}} \]
      4. times-frac63.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -inf.0 < (/.f64 h l) < -1.0000000000000001e-110

    1. Initial program 84.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. times-frac83.5%

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

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

    if -1.0000000000000001e-110 < (/.f64 h l) < -0.0

    1. Initial program 72.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. times-frac70.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -0.0 < (/.f64 h l)

    1. Initial program 95.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. times-frac95.4%

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

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

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

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

Alternative 2: 88.0% accurate, 0.7× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := 1 - {\left(\frac{D \cdot M}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\\ \mathbf{if}\;t_0 \leq 10^{+264}:\\ \;\;\;\;w0 \cdot \sqrt{t_0}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - 0.25 \cdot \left(D \cdot \left(\frac{D}{\ell} \cdot \left(h \cdot \left(\frac{M}{d} \cdot \frac{M}{d}\right)\right)\right)\right)}\\ \end{array} \end{array} \]
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
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 (/ (* D M) (* 2.0 d)) 2.0) (/ h l)))))
   (if (<= t_0 1e+264)
     (* w0 (sqrt t_0))
     (*
      w0
      (sqrt (- 1.0 (* 0.25 (* D (* (/ D l) (* h (* (/ M d) (/ M d))))))))))))
M = abs(M);
D = abs(D);
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
	double t_0 = 1.0 - (pow(((D * M) / (2.0 * d)), 2.0) * (h / l));
	double tmp;
	if (t_0 <= 1e+264) {
		tmp = w0 * sqrt(t_0);
	} else {
		tmp = w0 * sqrt((1.0 - (0.25 * (D * ((D / l) * (h * ((M / d) * (M / d))))))));
	}
	return tmp;
}
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
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 - ((((d * m) / (2.0d0 * d_1)) ** 2.0d0) * (h / l))
    if (t_0 <= 1d+264) then
        tmp = w0 * sqrt(t_0)
    else
        tmp = w0 * sqrt((1.0d0 - (0.25d0 * (d * ((d / l) * (h * ((m / d_1) * (m / d_1))))))))
    end if
    code = tmp
end function
M = Math.abs(M);
D = Math.abs(D);
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(((D * M) / (2.0 * d)), 2.0) * (h / l));
	double tmp;
	if (t_0 <= 1e+264) {
		tmp = w0 * Math.sqrt(t_0);
	} else {
		tmp = w0 * Math.sqrt((1.0 - (0.25 * (D * ((D / l) * (h * ((M / d) * (M / d))))))));
	}
	return tmp;
}
M = abs(M)
D = abs(D)
[M, D] = sort([M, D])
def code(w0, M, D, h, l, d):
	t_0 = 1.0 - (math.pow(((D * M) / (2.0 * d)), 2.0) * (h / l))
	tmp = 0
	if t_0 <= 1e+264:
		tmp = w0 * math.sqrt(t_0)
	else:
		tmp = w0 * math.sqrt((1.0 - (0.25 * (D * ((D / l) * (h * ((M / d) * (M / d))))))))
	return tmp
M = abs(M)
D = abs(D)
M, D = sort([M, D])
function code(w0, M, D, h, l, d)
	t_0 = Float64(1.0 - Float64((Float64(Float64(D * M) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)))
	tmp = 0.0
	if (t_0 <= 1e+264)
		tmp = Float64(w0 * sqrt(t_0));
	else
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(0.25 * Float64(D * Float64(Float64(D / l) * Float64(h * Float64(Float64(M / d) * Float64(M / d)))))))));
	end
	return tmp
end
M = abs(M)
D = abs(D)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(w0, M, D, h, l, d)
	t_0 = 1.0 - ((((D * M) / (2.0 * d)) ^ 2.0) * (h / l));
	tmp = 0.0;
	if (t_0 <= 1e+264)
		tmp = w0 * sqrt(t_0);
	else
		tmp = w0 * sqrt((1.0 - (0.25 * (D * ((D / l) * (h * ((M / d) * (M / d))))))));
	end
	tmp_2 = tmp;
end
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
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[(D * M), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 1e+264], N[(w0 * N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(0.25 * N[(D * N[(N[(D / l), $MachinePrecision] * N[(h * N[(N[(M / d), $MachinePrecision] * N[(M / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M = |M|\\
D = |D|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := 1 - {\left(\frac{D \cdot M}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\\
\mathbf{if}\;t_0 \leq 10^{+264}:\\
\;\;\;\;w0 \cdot \sqrt{t_0}\\

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


\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))) < 1.00000000000000004e264

    1. Initial program 99.9%

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

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

    1. Initial program 46.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. times-frac47.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{0.25}{d \cdot d} \cdot \frac{h \cdot \left(D \cdot \left(M \cdot \left(D \cdot M\right)\right)\right)}{\ell}}} \]
    7. Taylor expanded in d around 0 44.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}}}} \]
    8. Step-by-step derivation
      1. *-commutative44.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 87.9% accurate, 1.0× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;\frac{h}{\ell} \leq -\infty:\\ \;\;\;\;w0 \cdot \sqrt{1 - 0.25 \cdot \left(\frac{D \cdot D}{\ell} \cdot \left(\frac{M}{d} \cdot \frac{h \cdot M}{d}\right)\right)}\\ \mathbf{elif}\;\frac{h}{\ell} \leq -1 \cdot 10^{-110}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}^{2}}\\ \mathbf{elif}\;\frac{h}{\ell} \leq 0:\\ \;\;\;\;w0 \cdot \sqrt{1 - 0.25 \cdot \left(D \cdot \left(\frac{D}{\ell} \cdot \left(h \cdot \left(\frac{M}{d} \cdot \frac{M}{d}\right)\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \end{array} \]
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
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) l) (* (/ M d) (/ (* h M) d)))))))
   (if (<= (/ h l) -1e-110)
     (* w0 (sqrt (- 1.0 (* (/ h l) (pow (* M (* D (/ 0.5 d))) 2.0)))))
     (if (<= (/ h l) 0.0)
       (*
        w0
        (sqrt (- 1.0 (* 0.25 (* D (* (/ D l) (* h (* (/ M d) (/ M d)))))))))
       w0))))
M = abs(M);
D = abs(D);
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) / l) * ((M / d) * ((h * M) / d))))));
	} else if ((h / l) <= -1e-110) {
		tmp = w0 * sqrt((1.0 - ((h / l) * pow((M * (D * (0.5 / d))), 2.0))));
	} else if ((h / l) <= 0.0) {
		tmp = w0 * sqrt((1.0 - (0.25 * (D * ((D / l) * (h * ((M / d) * (M / d))))))));
	} else {
		tmp = w0;
	}
	return tmp;
}
M = Math.abs(M);
D = Math.abs(D);
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) / l) * ((M / d) * ((h * M) / d))))));
	} else if ((h / l) <= -1e-110) {
		tmp = w0 * Math.sqrt((1.0 - ((h / l) * Math.pow((M * (D * (0.5 / d))), 2.0))));
	} else if ((h / l) <= 0.0) {
		tmp = w0 * Math.sqrt((1.0 - (0.25 * (D * ((D / l) * (h * ((M / d) * (M / d))))))));
	} else {
		tmp = w0;
	}
	return tmp;
}
M = abs(M)
D = abs(D)
[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) / l) * ((M / d) * ((h * M) / d))))))
	elif (h / l) <= -1e-110:
		tmp = w0 * math.sqrt((1.0 - ((h / l) * math.pow((M * (D * (0.5 / d))), 2.0))))
	elif (h / l) <= 0.0:
		tmp = w0 * math.sqrt((1.0 - (0.25 * (D * ((D / l) * (h * ((M / d) * (M / d))))))))
	else:
		tmp = w0
	return tmp
M = abs(M)
D = abs(D)
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(Float64(Float64(D * D) / l) * Float64(Float64(M / d) * Float64(Float64(h * M) / d)))))));
	elseif (Float64(h / l) <= -1e-110)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h / l) * (Float64(M * Float64(D * Float64(0.5 / d))) ^ 2.0)))));
	elseif (Float64(h / l) <= 0.0)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(0.25 * Float64(D * Float64(Float64(D / l) * Float64(h * Float64(Float64(M / d) * Float64(M / d)))))))));
	else
		tmp = w0;
	end
	return tmp
end
M = abs(M)
D = abs(D)
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) / l) * ((M / d) * ((h * M) / d))))));
	elseif ((h / l) <= -1e-110)
		tmp = w0 * sqrt((1.0 - ((h / l) * ((M * (D * (0.5 / d))) ^ 2.0))));
	elseif ((h / l) <= 0.0)
		tmp = w0 * sqrt((1.0 - (0.25 * (D * ((D / l) * (h * ((M / d) * (M / d))))))));
	else
		tmp = w0;
	end
	tmp_2 = tmp;
end
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
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[(N[(N[(D * D), $MachinePrecision] / l), $MachinePrecision] * N[(N[(M / d), $MachinePrecision] * N[(N[(h * M), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(h / l), $MachinePrecision], -1e-110], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[Power[N[(M * N[(D * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(h / l), $MachinePrecision], 0.0], N[(w0 * N[Sqrt[N[(1.0 - N[(0.25 * N[(D * N[(N[(D / l), $MachinePrecision] * N[(h * N[(N[(M / d), $MachinePrecision] * N[(M / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0]]]
\begin{array}{l}
M = |M|\\
D = |D|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\frac{h}{\ell} \leq -\infty:\\
\;\;\;\;w0 \cdot \sqrt{1 - 0.25 \cdot \left(\frac{D \cdot D}{\ell} \cdot \left(\frac{M}{d} \cdot \frac{h \cdot M}{d}\right)\right)}\\

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

\mathbf{elif}\;\frac{h}{\ell} \leq 0:\\
\;\;\;\;w0 \cdot \sqrt{1 - 0.25 \cdot \left(D \cdot \left(\frac{D}{\ell} \cdot \left(h \cdot \left(\frac{M}{d} \cdot \frac{M}{d}\right)\right)\right)\right)}\\

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


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

    1. Initial program 48.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. times-frac48.1%

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

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

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

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

        \[\leadsto w0 \cdot \sqrt{1 - \frac{0.25 \cdot \left({D}^{2} \cdot \color{blue}{\left(h \cdot {M}^{2}\right)}\right)}{\ell \cdot {d}^{2}}} \]
      3. associate-*r/63.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}}}} \]
      4. times-frac63.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -inf.0 < (/.f64 h l) < -1.0000000000000001e-110

    1. Initial program 84.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. associate-/l*83.5%

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

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

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

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

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

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

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

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

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

    if -1.0000000000000001e-110 < (/.f64 h l) < -0.0

    1. Initial program 72.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. times-frac70.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -0.0 < (/.f64 h l)

    1. Initial program 95.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. times-frac95.4%

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

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

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

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

Alternative 4: 83.9% accurate, 1.0× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 2 d) < 4.9999999999999997e-113

    1. Initial program 80.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. times-frac79.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.9999999999999997e-113 < (*.f64 2 d)

    1. Initial program 84.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. times-frac85.0%

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 83.5% accurate, 1.7× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;\frac{h}{\ell} \leq 0:\\ \;\;\;\;w0 \cdot \sqrt{1 - 0.25 \cdot \left(D \cdot \left(\frac{D}{\ell} \cdot \left(h \cdot \left(\frac{M}{d} \cdot \frac{M}{d}\right)\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \end{array} \]
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
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) 0.0)
   (* w0 (sqrt (- 1.0 (* 0.25 (* D (* (/ D l) (* h (* (/ M d) (/ M d)))))))))
   w0))
M = abs(M);
D = abs(D);
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if ((h / l) <= 0.0) {
		tmp = w0 * sqrt((1.0 - (0.25 * (D * ((D / l) * (h * ((M / d) * (M / d))))))));
	} else {
		tmp = w0;
	}
	return tmp;
}
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
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 ((h / l) <= 0.0d0) then
        tmp = w0 * sqrt((1.0d0 - (0.25d0 * (d * ((d / l) * (h * ((m / d_1) * (m / d_1))))))))
    else
        tmp = w0
    end if
    code = tmp
end function
M = Math.abs(M);
D = Math.abs(D);
assert M < D;
public static double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if ((h / l) <= 0.0) {
		tmp = w0 * Math.sqrt((1.0 - (0.25 * (D * ((D / l) * (h * ((M / d) * (M / d))))))));
	} else {
		tmp = w0;
	}
	return tmp;
}
M = abs(M)
D = abs(D)
[M, D] = sort([M, D])
def code(w0, M, D, h, l, d):
	tmp = 0
	if (h / l) <= 0.0:
		tmp = w0 * math.sqrt((1.0 - (0.25 * (D * ((D / l) * (h * ((M / d) * (M / d))))))))
	else:
		tmp = w0
	return tmp
M = abs(M)
D = abs(D)
M, D = sort([M, D])
function code(w0, M, D, h, l, d)
	tmp = 0.0
	if (Float64(h / l) <= 0.0)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(0.25 * Float64(D * Float64(Float64(D / l) * Float64(h * Float64(Float64(M / d) * Float64(M / d)))))))));
	else
		tmp = w0;
	end
	return tmp
end
M = abs(M)
D = abs(D)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(w0, M, D, h, l, d)
	tmp = 0.0;
	if ((h / l) <= 0.0)
		tmp = w0 * sqrt((1.0 - (0.25 * (D * ((D / l) * (h * ((M / d) * (M / d))))))));
	else
		tmp = w0;
	end
	tmp_2 = tmp;
end
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
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], 0.0], N[(w0 * N[Sqrt[N[(1.0 - N[(0.25 * N[(D * N[(N[(D / l), $MachinePrecision] * N[(h * N[(N[(M / d), $MachinePrecision] * N[(M / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0]
\begin{array}{l}
M = |M|\\
D = |D|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\frac{h}{\ell} \leq 0:\\
\;\;\;\;w0 \cdot \sqrt{1 - 0.25 \cdot \left(D \cdot \left(\frac{D}{\ell} \cdot \left(h \cdot \left(\frac{M}{d} \cdot \frac{M}{d}\right)\right)\right)\right)}\\

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


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

    1. Initial program 75.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. times-frac74.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{0.25}{d \cdot d} \cdot \frac{h \cdot \left(D \cdot \left(M \cdot \left(D \cdot M\right)\right)\right)}{\ell}}} \]
    7. Taylor expanded in d around 0 51.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}}}} \]
    8. Step-by-step derivation
      1. *-commutative51.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -0.0 < (/.f64 h l)

    1. Initial program 95.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. times-frac95.4%

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

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

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

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

Alternative 6: 77.2% accurate, 9.4× speedup?

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

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


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

    1. Initial program 83.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. times-frac81.9%

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

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

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

    if 1.05000000000000006e-201 < M

    1. Initial program 81.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. times-frac81.4%

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

      \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    4. Taylor expanded in M around 0 56.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. associate-*r/56.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 77.3% accurate, 9.4× speedup?

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

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


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

    1. Initial program 83.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. times-frac81.9%

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

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

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

    if 1.29999999999999991e-201 < M

    1. Initial program 81.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. times-frac81.4%

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

      \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    4. Taylor expanded in M around 0 56.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. associate-*r/56.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 8: 75.7% accurate, 9.4× speedup?

    \[\begin{array}{l} M = |M|\\ D = |D|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;d \leq 1.26 \cdot 10^{+150}:\\ \;\;\;\;w0 \cdot \left(1 + \left(D \cdot \left(\frac{D}{\ell} \cdot \frac{h \cdot M}{d \cdot \frac{d}{M}}\right)\right) \cdot -0.125\right)\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \end{array} \]
    NOTE: M should be positive before calling this function
    NOTE: D should be positive before calling this function
    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.26e+150)
       (* w0 (+ 1.0 (* (* D (* (/ D l) (/ (* h M) (* d (/ d M))))) -0.125)))
       w0))
    M = abs(M);
    D = abs(D);
    assert(M < D);
    double code(double w0, double M, double D, double h, double l, double d) {
    	double tmp;
    	if (d <= 1.26e+150) {
    		tmp = w0 * (1.0 + ((D * ((D / l) * ((h * M) / (d * (d / M))))) * -0.125));
    	} else {
    		tmp = w0;
    	}
    	return tmp;
    }
    
    NOTE: M should be positive before calling this function
    NOTE: D should be positive before calling this function
    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 <= 1.26d+150) then
            tmp = w0 * (1.0d0 + ((d * ((d / l) * ((h * m) / (d_1 * (d_1 / m))))) * (-0.125d0)))
        else
            tmp = w0
        end if
        code = tmp
    end function
    
    M = Math.abs(M);
    D = Math.abs(D);
    assert M < D;
    public static double code(double w0, double M, double D, double h, double l, double d) {
    	double tmp;
    	if (d <= 1.26e+150) {
    		tmp = w0 * (1.0 + ((D * ((D / l) * ((h * M) / (d * (d / M))))) * -0.125));
    	} else {
    		tmp = w0;
    	}
    	return tmp;
    }
    
    M = abs(M)
    D = abs(D)
    [M, D] = sort([M, D])
    def code(w0, M, D, h, l, d):
    	tmp = 0
    	if d <= 1.26e+150:
    		tmp = w0 * (1.0 + ((D * ((D / l) * ((h * M) / (d * (d / M))))) * -0.125))
    	else:
    		tmp = w0
    	return tmp
    
    M = abs(M)
    D = abs(D)
    M, D = sort([M, D])
    function code(w0, M, D, h, l, d)
    	tmp = 0.0
    	if (d <= 1.26e+150)
    		tmp = Float64(w0 * Float64(1.0 + Float64(Float64(D * Float64(Float64(D / l) * Float64(Float64(h * M) / Float64(d * Float64(d / M))))) * -0.125)));
    	else
    		tmp = w0;
    	end
    	return tmp
    end
    
    M = abs(M)
    D = abs(D)
    M, D = num2cell(sort([M, D])){:}
    function tmp_2 = code(w0, M, D, h, l, d)
    	tmp = 0.0;
    	if (d <= 1.26e+150)
    		tmp = w0 * (1.0 + ((D * ((D / l) * ((h * M) / (d * (d / M))))) * -0.125));
    	else
    		tmp = w0;
    	end
    	tmp_2 = tmp;
    end
    
    NOTE: M should be positive before calling this function
    NOTE: D should be positive before calling this function
    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.26e+150], N[(w0 * N[(1.0 + N[(N[(D * N[(N[(D / l), $MachinePrecision] * N[(N[(h * M), $MachinePrecision] / N[(d * N[(d / M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], w0]
    
    \begin{array}{l}
    M = |M|\\
    D = |D|\\
    [M, D] = \mathsf{sort}([M, D])\\
    \\
    \begin{array}{l}
    \mathbf{if}\;d \leq 1.26 \cdot 10^{+150}:\\
    \;\;\;\;w0 \cdot \left(1 + \left(D \cdot \left(\frac{D}{\ell} \cdot \frac{h \cdot M}{d \cdot \frac{d}{M}}\right)\right) \cdot -0.125\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;w0\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if d < 1.26e150

      1. Initial program 82.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. times-frac81.6%

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

        \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
      4. Taylor expanded in M around 0 57.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. associate-*r/57.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt[3]{\left(\left(w0 \cdot \left(1 + \left(D \cdot \frac{D}{\ell}\right) \cdot \left(\left(\frac{M}{\frac{d}{h}} \cdot \frac{M}{d}\right) \cdot -0.125\right)\right)\right) \cdot \left(w0 \cdot \left(1 + \left(D \cdot \frac{D}{\ell}\right) \cdot \left(\left(\frac{M}{\frac{d}{h}} \cdot \frac{M}{d}\right) \cdot -0.125\right)\right)\right)\right) \cdot \left(w0 \cdot \left(1 + \left(D \cdot \frac{D}{\ell}\right) \cdot \left(\left(\frac{M}{\frac{d}{h}} \cdot \frac{M}{d}\right) \cdot -0.125\right)\right)\right)}} \]
      12. Step-by-step derivation
        1. associate-*l*33.5%

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

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

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

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

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

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

      if 1.26e150 < d

      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. times-frac82.3%

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

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

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

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

    Alternative 9: 71.7% accurate, 10.3× speedup?

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

      1. Initial program 83.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. times-frac82.9%

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

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

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

      if 9.8000000000000004e45 < M

      1. Initial program 76.7%

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

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

        \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
      4. Taylor expanded in M around 0 37.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. associate-*r/37.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 10: 71.7% accurate, 10.3× speedup?

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

      1. Initial program 83.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. times-frac82.9%

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

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

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

      if 1.04999999999999997e45 < M

      1. Initial program 76.7%

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

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

        \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
      4. Taylor expanded in M around 0 37.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. associate-*r/37.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 11: 71.5% accurate, 10.3× speedup?

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

      1. Initial program 83.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. times-frac82.9%

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

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

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

      if 9.9999999999999999e45 < M

      1. Initial program 76.7%

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

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

        \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
      4. Taylor expanded in M around 0 37.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. associate-*r/37.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 12: 72.0% accurate, 10.3× speedup?

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

      1. Initial program 84.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. times-frac83.1%

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

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

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

      if 6.5e15 < M

      1. Initial program 76.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. times-frac76.9%

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

        \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(\frac{M}{2} \cdot \frac{D}{d}\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. associate-*r/39.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 13: 72.4% accurate, 10.3× speedup?

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

      1. Initial program 84.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. times-frac83.1%

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

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

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

      if 6.5e15 < M

      1. Initial program 76.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. times-frac76.9%

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

        \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(\frac{M}{2} \cdot \frac{D}{d}\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. associate-*r/39.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 14: 68.2% accurate, 216.0× speedup?

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

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

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

      \[\leadsto \color{blue}{w0} \]
    5. Final simplification68.1%

      \[\leadsto w0 \]

    Reproduce

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