Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 81.4% → 87.8%
Time: 15.4s
Alternatives: 14
Speedup: 1.8×

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.4% 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.8% accurate, 1.0× speedup?

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

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


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

    1. Initial program 84.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.00000000000000012e140 < (/.f64 (*.f64 M D) (*.f64 2 d))

    1. Initial program 52.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 87.2% accurate, 0.7× speedup?

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

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


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

    1. Initial program 88.0%

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

    if 1.99999999999999996e-12 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l))

    1. Initial program 0.0%

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

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

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

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

Alternative 3: 86.3% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 53.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 \cdot \sqrt{1 - 0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{\color{blue}{\ell \cdot {d}^{2}}}} \]
      2. times-frac53.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. unpow253.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-*l/53.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -inf.0 < (/.f64 h l) < -1e-224

    1. Initial program 83.9%

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

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

    if -1e-224 < (/.f64 h l)

    1. Initial program 83.7%

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

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

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

        \[\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. *-commutative58.0%

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

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

        \[\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) \]
    5. Simplified58.0%

      \[\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)} \]
    6. Taylor expanded in D around 0 51.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) \]
    7. Step-by-step derivation
      1. *-commutative51.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-frac58.0%

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

        \[\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/64.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. unpow264.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 86.3% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 55.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\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-*l/51.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1e308 < (/.f64 h l) < -1e-224

    1. Initial program 83.8%

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

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

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

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

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

    if -1e-224 < (/.f64 h l)

    1. Initial program 83.7%

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

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

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

        \[\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. *-commutative58.0%

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

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

        \[\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) \]
    5. Simplified58.0%

      \[\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)} \]
    6. Taylor expanded in D around 0 51.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) \]
    7. Step-by-step derivation
      1. *-commutative51.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-frac58.0%

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

        \[\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/64.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. unpow264.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 88.0% accurate, 1.0× speedup?

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

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


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

    1. Initial program 84.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.9999999999999996e130 < (/.f64 (*.f64 M D) (*.f64 2 d))

    1. Initial program 53.8%

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

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

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

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

        \[\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/50.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 82.9% accurate, 1.7× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < 7.19999999999999951e-116

    1. Initial program 81.3%

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

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

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

        \[\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. *-commutative48.4%

        \[\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/48.4%

        \[\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. *-commutative48.4%

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

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

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

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

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

        \[\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) \]
    5. Simplified52.7%

      \[\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)} \]
    6. Taylor expanded in D around 0 48.4%

      \[\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) \]
    7. Step-by-step derivation
      1. *-commutative48.4%

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

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

        \[\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/56.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 7.19999999999999951e-116 < d < 1.40000000000000007e119

    1. Initial program 76.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 \cdot \sqrt{1 - 0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{\color{blue}{\ell \cdot {d}^{2}}}} \]
      2. times-frac61.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. unpow261.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-*l/61.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.40000000000000007e119 < d

    1. Initial program 84.4%

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

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

      \[\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)} \]
    4. Step-by-step derivation
      1. associate-*r/52.3%

        \[\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. *-commutative52.3%

        \[\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/52.3%

        \[\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. *-commutative52.3%

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

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

        \[\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. *-commutative50.1%

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

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

        \[\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) \]
    5. Simplified50.1%

      \[\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)} \]
    6. Taylor expanded in D around 0 52.3%

      \[\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) \]
    7. Step-by-step derivation
      1. *-commutative52.3%

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

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

        \[\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/52.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 82.4% accurate, 1.8× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < 7.4999999999999999e-99

    1. Initial program 81.1%

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

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

      \[\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)} \]
    4. Step-by-step derivation
      1. associate-*r/48.1%

        \[\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. *-commutative48.1%

        \[\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/48.1%

        \[\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. *-commutative48.1%

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

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

        \[\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. *-commutative53.0%

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

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

        \[\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) \]
    5. Simplified53.0%

      \[\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)} \]
    6. Taylor expanded in D around 0 48.1%

      \[\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) \]
    7. Step-by-step derivation
      1. *-commutative48.1%

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

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

        \[\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/56.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 7.4999999999999999e-99 < d

    1. Initial program 81.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\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-*l/56.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 84.1% accurate, 1.8× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < 1.3999999999999999e-90

    1. Initial program 80.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.3999999999999999e-90 < d

    1. Initial program 82.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\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-*l/57.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 77.4% accurate, 9.4× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ d = |d|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;M \leq 1.25 \cdot 10^{-87}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \left(1 + -0.125 \cdot \left(D \cdot \left(\left(M \cdot \left(M \cdot \frac{h}{d \cdot d}\right)\right) \cdot \frac{D}{\ell}\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: 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.25e-87)
   w0
   (* w0 (+ 1.0 (* -0.125 (* D (* (* M (* M (/ h (* d d)))) (/ D l))))))))
M = abs(M);
D = abs(D);
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.25e-87) {
		tmp = w0;
	} else {
		tmp = w0 * (1.0 + (-0.125 * (D * ((M * (M * (h / (d * d)))) * (D / l)))));
	}
	return tmp;
}
NOTE: M should be positive before calling this function
NOTE: D 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.25d-87) then
        tmp = w0
    else
        tmp = w0 * (1.0d0 + ((-0.125d0) * (d * ((m * (m * (h / (d_1 * d_1)))) * (d / l)))))
    end if
    code = tmp
end function
M = Math.abs(M);
D = Math.abs(D);
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.25e-87) {
		tmp = w0;
	} else {
		tmp = w0 * (1.0 + (-0.125 * (D * ((M * (M * (h / (d * d)))) * (D / l)))));
	}
	return tmp;
}
M = abs(M)
D = abs(D)
d = abs(d)
[M, D] = sort([M, D])
def code(w0, M, D, h, l, d):
	tmp = 0
	if M <= 1.25e-87:
		tmp = w0
	else:
		tmp = w0 * (1.0 + (-0.125 * (D * ((M * (M * (h / (d * d)))) * (D / l)))))
	return tmp
M = abs(M)
D = abs(D)
d = abs(d)
M, D = sort([M, D])
function code(w0, M, D, h, l, d)
	tmp = 0.0
	if (M <= 1.25e-87)
		tmp = w0;
	else
		tmp = Float64(w0 * Float64(1.0 + Float64(-0.125 * Float64(D * Float64(Float64(M * Float64(M * Float64(h / Float64(d * d)))) * Float64(D / l))))));
	end
	return tmp
end
M = abs(M)
D = abs(D)
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.25e-87)
		tmp = w0;
	else
		tmp = w0 * (1.0 + (-0.125 * (D * ((M * (M * (h / (d * d)))) * (D / 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: 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.25e-87], w0, N[(w0 * N[(1.0 + N[(-0.125 * N[(D * N[(N[(M * N[(M * N[(h / N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(D / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M = |M|\\
D = |D|\\
d = |d|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;M \leq 1.25 \cdot 10^{-87}:\\
\;\;\;\;w0\\

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


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

    1. Initial program 82.7%

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

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

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

    if 1.25000000000000011e-87 < M

    1. Initial program 77.6%

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

      \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Taylor expanded in D around 0 44.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)} \]
    4. Step-by-step derivation
      1. associate-*r/44.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. *-commutative44.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/44.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. *-commutative44.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-frac46.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. unpow246.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. *-commutative46.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. unpow246.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. unpow246.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) \]
    5. Simplified46.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)} \]
    6. Taylor expanded in D around 0 44.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) \]
    7. Step-by-step derivation
      1. *-commutative44.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-frac46.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. unpow246.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/50.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 77.5% accurate, 9.4× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ d = |d|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;d \leq 8 \cdot 10^{+125}:\\ \;\;\;\;w0 \cdot \left(1 + -0.125 \cdot \left(D \cdot \left(\frac{D}{\ell} \cdot \left(M \cdot \left(\frac{M}{d} \cdot \frac{h}{d}\right)\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: 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 8e+125)
   (* w0 (+ 1.0 (* -0.125 (* D (* (/ D l) (* M (* (/ M d) (/ h d))))))))
   w0))
M = abs(M);
D = abs(D);
d = abs(d);
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if (d <= 8e+125) {
		tmp = w0 * (1.0 + (-0.125 * (D * ((D / l) * (M * ((M / d) * (h / 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: 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 <= 8d+125) then
        tmp = w0 * (1.0d0 + ((-0.125d0) * (d * ((d / l) * (m * ((m / d_1) * (h / d_1)))))))
    else
        tmp = w0
    end if
    code = tmp
end function
M = Math.abs(M);
D = Math.abs(D);
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 <= 8e+125) {
		tmp = w0 * (1.0 + (-0.125 * (D * ((D / l) * (M * ((M / d) * (h / d)))))));
	} else {
		tmp = w0;
	}
	return tmp;
}
M = abs(M)
D = abs(D)
d = abs(d)
[M, D] = sort([M, D])
def code(w0, M, D, h, l, d):
	tmp = 0
	if d <= 8e+125:
		tmp = w0 * (1.0 + (-0.125 * (D * ((D / l) * (M * ((M / d) * (h / d)))))))
	else:
		tmp = w0
	return tmp
M = abs(M)
D = abs(D)
d = abs(d)
M, D = sort([M, D])
function code(w0, M, D, h, l, d)
	tmp = 0.0
	if (d <= 8e+125)
		tmp = Float64(w0 * Float64(1.0 + Float64(-0.125 * Float64(D * Float64(Float64(D / l) * Float64(M * Float64(Float64(M / d) * Float64(h / d))))))));
	else
		tmp = w0;
	end
	return tmp
end
M = abs(M)
D = abs(D)
d = abs(d)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(w0, M, D, h, l, d)
	tmp = 0.0;
	if (d <= 8e+125)
		tmp = w0 * (1.0 + (-0.125 * (D * ((D / l) * (M * ((M / d) * (h / 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: 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, 8e+125], N[(w0 * N[(1.0 + N[(-0.125 * N[(D * N[(N[(D / l), $MachinePrecision] * N[(M * N[(N[(M / d), $MachinePrecision] * N[(h / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], w0]
\begin{array}{l}
M = |M|\\
D = |D|\\
d = |d|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq 8 \cdot 10^{+125}:\\
\;\;\;\;w0 \cdot \left(1 + -0.125 \cdot \left(D \cdot \left(\frac{D}{\ell} \cdot \left(M \cdot \left(\frac{M}{d} \cdot \frac{h}{d}\right)\right)\right)\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < 7.9999999999999994e125

    1. Initial program 80.3%

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

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

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

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

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

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

        \[\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) \]
    5. Simplified54.1%

      \[\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)} \]
    6. Taylor expanded in D around 0 49.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) \]
    7. Step-by-step derivation
      1. *-commutative49.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.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 7.9999999999999994e125 < d

    1. Initial program 84.4%

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

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

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

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

Alternative 11: 78.7% accurate, 9.4× speedup?

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

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


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

    1. Initial program 81.7%

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

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

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

    if 3.5000000000000003e-141 < M

    1. Initial program 80.1%

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

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

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

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

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

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

        \[\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) \]
    5. Simplified50.2%

      \[\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)} \]
    6. Taylor expanded in D around 0 48.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) \]
    7. Step-by-step derivation
      1. *-commutative48.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-frac50.2%

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

        \[\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/53.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 72.9% accurate, 10.3× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ d = |d|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;M \leq 9 \cdot 10^{+51}:\\ \;\;\;\;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: 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 9e+51)
   w0
   (* -0.125 (* (/ (* D D) (* d d)) (/ (* w0 (* h (* M M))) l)))))
M = abs(M);
D = abs(D);
d = abs(d);
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if (M <= 9e+51) {
		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: 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 <= 9d+51) 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);
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 <= 9e+51) {
		tmp = w0;
	} else {
		tmp = -0.125 * (((D * D) / (d * d)) * ((w0 * (h * (M * M))) / l));
	}
	return tmp;
}
M = abs(M)
D = abs(D)
d = abs(d)
[M, D] = sort([M, D])
def code(w0, M, D, h, l, d):
	tmp = 0
	if M <= 9e+51:
		tmp = w0
	else:
		tmp = -0.125 * (((D * D) / (d * d)) * ((w0 * (h * (M * M))) / l))
	return tmp
M = abs(M)
D = abs(D)
d = abs(d)
M, D = sort([M, D])
function code(w0, M, D, h, l, d)
	tmp = 0.0
	if (M <= 9e+51)
		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)
d = abs(d)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(w0, M, D, h, l, d)
	tmp = 0.0;
	if (M <= 9e+51)
		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: 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, 9e+51], 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|\\
d = |d|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;M \leq 9 \cdot 10^{+51}:\\
\;\;\;\;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 < 8.9999999999999999e51

    1. Initial program 82.9%

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

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

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

    if 8.9999999999999999e51 < M

    1. Initial program 73.7%

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

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

      \[\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)} \]
    4. Step-by-step derivation
      1. associate-*r/34.1%

        \[\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. *-commutative34.1%

        \[\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/34.1%

        \[\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. *-commutative34.1%

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

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

        \[\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. *-commutative34.1%

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

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

        \[\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) \]
    5. Simplified34.1%

      \[\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)} \]
    6. Taylor expanded in D around 0 34.1%

      \[\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) \]
    7. Step-by-step derivation
      1. *-commutative34.1%

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

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

        \[\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/36.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 9 \cdot 10^{+51}:\\ \;\;\;\;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 13: 79.6% accurate, 10.3× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ d = |d|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ w0 \cdot \left(1 + \left(D \cdot \frac{D \cdot \left(M \cdot \frac{M \cdot \frac{h}{d}}{d}\right)}{\ell}\right) \cdot -0.125\right) \end{array} \]
NOTE: M should be positive before calling this function
NOTE: D 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 (+ 1.0 (* (* D (/ (* D (* M (/ (* M (/ h d)) d))) l)) -0.125))))
M = abs(M);
D = abs(D);
d = abs(d);
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
	return w0 * (1.0 + ((D * ((D * (M * ((M * (h / d)) / d))) / l)) * -0.125));
}
NOTE: M should be positive before calling this function
NOTE: D 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 * (1.0d0 + ((d * ((d * (m * ((m * (h / d_1)) / d_1))) / l)) * (-0.125d0)))
end function
M = Math.abs(M);
D = Math.abs(D);
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 * (1.0 + ((D * ((D * (M * ((M * (h / d)) / d))) / l)) * -0.125));
}
M = abs(M)
D = abs(D)
d = abs(d)
[M, D] = sort([M, D])
def code(w0, M, D, h, l, d):
	return w0 * (1.0 + ((D * ((D * (M * ((M * (h / d)) / d))) / l)) * -0.125))
M = abs(M)
D = abs(D)
d = abs(d)
M, D = sort([M, D])
function code(w0, M, D, h, l, d)
	return Float64(w0 * Float64(1.0 + Float64(Float64(D * Float64(Float64(D * Float64(M * Float64(Float64(M * Float64(h / d)) / d))) / l)) * -0.125)))
end
M = abs(M)
D = abs(D)
d = abs(d)
M, D = num2cell(sort([M, D])){:}
function tmp = code(w0, M, D, h, l, d)
	tmp = w0 * (1.0 + ((D * ((D * (M * ((M * (h / d)) / d))) / l)) * -0.125));
end
NOTE: M should be positive before calling this function
NOTE: D 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_] := N[(w0 * N[(1.0 + N[(N[(D * N[(N[(D * N[(M * N[(N[(M * N[(h / d), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M = |M|\\
D = |D|\\
d = |d|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
w0 \cdot \left(1 + \left(D \cdot \frac{D \cdot \left(M \cdot \frac{M \cdot \frac{h}{d}}{d}\right)}{\ell}\right) \cdot -0.125\right)
\end{array}
Derivation
  1. Initial program 81.1%

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

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

    \[\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)} \]
  4. Step-by-step derivation
    1. associate-*r/50.3%

      \[\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. *-commutative50.3%

      \[\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/50.3%

      \[\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. *-commutative50.3%

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

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

      \[\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. *-commutative53.3%

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

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

      \[\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) \]
  5. Simplified53.3%

    \[\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)} \]
  6. Taylor expanded in D around 0 50.3%

    \[\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) \]
  7. Step-by-step derivation
    1. *-commutative50.3%

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

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

      \[\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/56.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 14: 70.1% accurate, 216.0× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ 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: 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);
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: 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);
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)
d = abs(d)
[M, D] = sort([M, D])
def code(w0, M, D, h, l, d):
	return w0
M = abs(M)
D = abs(D)
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)
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: 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|\\
d = |d|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
w0
\end{array}
Derivation
  1. Initial program 81.1%

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

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

    \[\leadsto \color{blue}{w0} \]
  4. Final simplification67.6%

    \[\leadsto w0 \]

Reproduce

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