Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 80.6% → 87.4%
Time: 15.7s
Alternatives: 13
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 13 alternatives:

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

Initial Program: 80.6% 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.4% 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 500:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot {\left(1 + -0.25 \cdot \frac{D}{\frac{\frac{d}{M}}{\frac{h \cdot \left(M \cdot D\right)}{d \cdot \ell}}}\right)}^{0.5}\\ \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)) 500.0)
   (* w0 (sqrt (- 1.0 (/ (* (pow (* M (* 0.5 (/ D d))) 2.0) h) l))))
   (*
    w0
    (pow (+ 1.0 (* -0.25 (/ D (/ (/ d M) (/ (* h (* M D)) (* d l)))))) 0.5))))
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)) <= 500.0) {
		tmp = w0 * sqrt((1.0 - ((pow((M * (0.5 * (D / d))), 2.0) * h) / l)));
	} else {
		tmp = w0 * pow((1.0 + (-0.25 * (D / ((d / M) / ((h * (M * D)) / (d * l)))))), 0.5);
	}
	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)) <= 500.0d0) then
        tmp = w0 * sqrt((1.0d0 - ((((m * (0.5d0 * (d / d_1))) ** 2.0d0) * h) / l)))
    else
        tmp = w0 * ((1.0d0 + ((-0.25d0) * (d / ((d_1 / m) / ((h * (m * d)) / (d_1 * l)))))) ** 0.5d0)
    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)) <= 500.0) {
		tmp = w0 * Math.sqrt((1.0 - ((Math.pow((M * (0.5 * (D / d))), 2.0) * h) / l)));
	} else {
		tmp = w0 * Math.pow((1.0 + (-0.25 * (D / ((d / M) / ((h * (M * D)) / (d * l)))))), 0.5);
	}
	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)) <= 500.0:
		tmp = w0 * math.sqrt((1.0 - ((math.pow((M * (0.5 * (D / d))), 2.0) * h) / l)))
	else:
		tmp = w0 * math.pow((1.0 + (-0.25 * (D / ((d / M) / ((h * (M * D)) / (d * l)))))), 0.5)
	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)) <= 500.0)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64((Float64(M * Float64(0.5 * Float64(D / d))) ^ 2.0) * h) / l))));
	else
		tmp = Float64(w0 * (Float64(1.0 + Float64(-0.25 * Float64(D / Float64(Float64(d / M) / Float64(Float64(h * Float64(M * D)) / Float64(d * l)))))) ^ 0.5));
	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)) <= 500.0)
		tmp = w0 * sqrt((1.0 - ((((M * (0.5 * (D / d))) ^ 2.0) * h) / l)));
	else
		tmp = w0 * ((1.0 + (-0.25 * (D / ((d / M) / ((h * (M * D)) / (d * l)))))) ^ 0.5);
	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], 500.0], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[Power[N[(M * N[(0.5 * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Power[N[(1.0 + N[(-0.25 * N[(D / N[(N[(d / M), $MachinePrecision] / N[(N[(h * N[(M * D), $MachinePrecision]), $MachinePrecision] / N[(d * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.5], $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 500:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}}\\

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


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

    1. Initial program 85.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 58.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto w0 \cdot \color{blue}{{\left(1 + -0.25 \cdot \frac{D}{\frac{\frac{d}{M} \cdot \frac{d \cdot \ell}{M \cdot h}}{D}}\right)}^{0.5}} \]
    9. Step-by-step derivation
      1. *-un-lft-identity52.4%

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

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

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

      \[\leadsto w0 \cdot {\left(1 + -0.25 \cdot \frac{D}{\color{blue}{1 \cdot \frac{\frac{d}{M}}{\frac{D}{\frac{d}{\frac{M \cdot h}{\ell}}}}}}\right)}^{0.5} \]
    11. Taylor expanded in D around 0 54.7%

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

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

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

        \[\leadsto w0 \cdot {\left(1 + -0.25 \cdot \frac{D}{1 \cdot \frac{\frac{d}{M}}{\frac{\left(D \cdot M\right) \cdot h}{\color{blue}{\ell \cdot d}}}}\right)}^{0.5} \]
    13. Simplified56.7%

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

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

Alternative 2: 86.8% accurate, 1.7× 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 500:\\ \;\;\;\;w0 \cdot \sqrt{1 + -0.25 \cdot \frac{\frac{D}{\frac{d}{M \cdot D}}}{\ell \cdot \frac{d}{M \cdot h}}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot {\left(1 + -0.25 \cdot \frac{D}{\frac{\frac{d}{M}}{\frac{h \cdot \left(M \cdot D\right)}{d \cdot \ell}}}\right)}^{0.5}\\ \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)) 500.0)
   (* w0 (sqrt (+ 1.0 (* -0.25 (/ (/ D (/ d (* M D))) (* l (/ d (* M h))))))))
   (*
    w0
    (pow (+ 1.0 (* -0.25 (/ D (/ (/ d M) (/ (* h (* M D)) (* d l)))))) 0.5))))
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)) <= 500.0) {
		tmp = w0 * sqrt((1.0 + (-0.25 * ((D / (d / (M * D))) / (l * (d / (M * h)))))));
	} else {
		tmp = w0 * pow((1.0 + (-0.25 * (D / ((d / M) / ((h * (M * D)) / (d * l)))))), 0.5);
	}
	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)) <= 500.0d0) then
        tmp = w0 * sqrt((1.0d0 + ((-0.25d0) * ((d / (d_1 / (m * d))) / (l * (d_1 / (m * h)))))))
    else
        tmp = w0 * ((1.0d0 + ((-0.25d0) * (d / ((d_1 / m) / ((h * (m * d)) / (d_1 * l)))))) ** 0.5d0)
    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)) <= 500.0) {
		tmp = w0 * Math.sqrt((1.0 + (-0.25 * ((D / (d / (M * D))) / (l * (d / (M * h)))))));
	} else {
		tmp = w0 * Math.pow((1.0 + (-0.25 * (D / ((d / M) / ((h * (M * D)) / (d * l)))))), 0.5);
	}
	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)) <= 500.0:
		tmp = w0 * math.sqrt((1.0 + (-0.25 * ((D / (d / (M * D))) / (l * (d / (M * h)))))))
	else:
		tmp = w0 * math.pow((1.0 + (-0.25 * (D / ((d / M) / ((h * (M * D)) / (d * l)))))), 0.5)
	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)) <= 500.0)
		tmp = Float64(w0 * sqrt(Float64(1.0 + Float64(-0.25 * Float64(Float64(D / Float64(d / Float64(M * D))) / Float64(l * Float64(d / Float64(M * h))))))));
	else
		tmp = Float64(w0 * (Float64(1.0 + Float64(-0.25 * Float64(D / Float64(Float64(d / M) / Float64(Float64(h * Float64(M * D)) / Float64(d * l)))))) ^ 0.5));
	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)) <= 500.0)
		tmp = w0 * sqrt((1.0 + (-0.25 * ((D / (d / (M * D))) / (l * (d / (M * h)))))));
	else
		tmp = w0 * ((1.0 + (-0.25 * (D / ((d / M) / ((h * (M * D)) / (d * l)))))) ^ 0.5);
	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], 500.0], N[(w0 * N[Sqrt[N[(1.0 + N[(-0.25 * N[(N[(D / N[(d / N[(M * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(l * N[(d / N[(M * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Power[N[(1.0 + N[(-0.25 * N[(D / N[(N[(d / M), $MachinePrecision] / N[(N[(h * N[(M * D), $MachinePrecision]), $MachinePrecision] / N[(d * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.5], $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 500:\\
\;\;\;\;w0 \cdot \sqrt{1 + -0.25 \cdot \frac{\frac{D}{\frac{d}{M \cdot D}}}{\ell \cdot \frac{d}{M \cdot h}}}\\

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


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

    1. Initial program 85.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto w0 \cdot \color{blue}{{\left(1 + -0.25 \cdot \frac{D}{\frac{\frac{d}{M} \cdot \frac{d \cdot \ell}{M \cdot h}}{D}}\right)}^{0.5}} \]
    9. Step-by-step derivation
      1. *-un-lft-identity87.1%

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

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

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

      \[\leadsto w0 \cdot {\left(1 + -0.25 \cdot \frac{D}{\color{blue}{1 \cdot \frac{\frac{d}{M}}{\frac{D}{\frac{d}{\frac{M \cdot h}{\ell}}}}}}\right)}^{0.5} \]
    11. Step-by-step derivation
      1. *-un-lft-identity87.1%

        \[\leadsto w0 \cdot \color{blue}{\left(1 \cdot {\left(1 + -0.25 \cdot \frac{D}{1 \cdot \frac{\frac{d}{M}}{\frac{D}{\frac{d}{\frac{M \cdot h}{\ell}}}}}\right)}^{0.5}\right)} \]
      2. unpow1/287.1%

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 \cdot \sqrt{1 + -0.25 \cdot \frac{\frac{D}{\frac{d}{D \cdot M}}}{\color{blue}{\ell \cdot \frac{\frac{d}{h}}{M}}}} \]
      5. associate-/l/87.4%

        \[\leadsto w0 \cdot \sqrt{1 + -0.25 \cdot \frac{\frac{D}{\frac{d}{D \cdot M}}}{\ell \cdot \color{blue}{\frac{d}{M \cdot h}}}} \]
    14. Simplified87.4%

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

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

    1. Initial program 58.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto w0 \cdot \color{blue}{{\left(1 + -0.25 \cdot \frac{D}{\frac{\frac{d}{M} \cdot \frac{d \cdot \ell}{M \cdot h}}{D}}\right)}^{0.5}} \]
    9. Step-by-step derivation
      1. *-un-lft-identity52.4%

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

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

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

      \[\leadsto w0 \cdot {\left(1 + -0.25 \cdot \frac{D}{\color{blue}{1 \cdot \frac{\frac{d}{M}}{\frac{D}{\frac{d}{\frac{M \cdot h}{\ell}}}}}}\right)}^{0.5} \]
    11. Taylor expanded in D around 0 54.7%

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

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

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

        \[\leadsto w0 \cdot {\left(1 + -0.25 \cdot \frac{D}{1 \cdot \frac{\frac{d}{M}}{\frac{\left(D \cdot M\right) \cdot h}{\color{blue}{\ell \cdot d}}}}\right)}^{0.5} \]
    13. Simplified56.7%

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

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

Alternative 3: 84.4% accurate, 1.7× 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 -4 \cdot 10^{+292}:\\ \;\;\;\;\mathsf{fma}\left(-0.125, \frac{D \cdot w0}{\frac{d}{M} \cdot \frac{\frac{d}{M}}{h}} \cdot \frac{D}{\ell}, w0\right)\\ \mathbf{elif}\;\frac{h}{\ell} \leq -2 \cdot 10^{-296}:\\ \;\;\;\;w0 \cdot \sqrt{1 + -0.25 \cdot \left(D \cdot \frac{D}{\frac{d}{M} \cdot \left(\frac{d}{M} \cdot \frac{\ell}{h}\right)}\right)}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \left(1 + -0.125 \cdot \frac{D}{\frac{\frac{d}{M} \cdot \frac{d \cdot \ell}{M \cdot h}}{D}}\right)\\ \end{array} \end{array} \]
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: 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) -4e+292)
   (fma -0.125 (* (/ (* D w0) (* (/ d M) (/ (/ d M) h))) (/ D l)) w0)
   (if (<= (/ h l) -2e-296)
     (*
      w0
      (sqrt (+ 1.0 (* -0.25 (* D (/ D (* (/ d M) (* (/ d M) (/ l h)))))))))
     (* w0 (+ 1.0 (* -0.125 (/ D (/ (* (/ d M) (/ (* d l) (* M h))) D))))))))
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) <= -4e+292) {
		tmp = fma(-0.125, (((D * w0) / ((d / M) * ((d / M) / h))) * (D / l)), w0);
	} else if ((h / l) <= -2e-296) {
		tmp = w0 * sqrt((1.0 + (-0.25 * (D * (D / ((d / M) * ((d / M) * (l / h))))))));
	} else {
		tmp = w0 * (1.0 + (-0.125 * (D / (((d / M) * ((d * l) / (M * h))) / D))));
	}
	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) <= -4e+292)
		tmp = fma(-0.125, Float64(Float64(Float64(D * w0) / Float64(Float64(d / M) * Float64(Float64(d / M) / h))) * Float64(D / l)), w0);
	elseif (Float64(h / l) <= -2e-296)
		tmp = Float64(w0 * sqrt(Float64(1.0 + Float64(-0.25 * Float64(D * Float64(D / Float64(Float64(d / M) * Float64(Float64(d / M) * Float64(l / h)))))))));
	else
		tmp = Float64(w0 * Float64(1.0 + Float64(-0.125 * Float64(D / Float64(Float64(Float64(d / M) * Float64(Float64(d * l) / Float64(M * h))) / D)))));
	end
	return 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], -4e+292], N[(-0.125 * N[(N[(N[(D * w0), $MachinePrecision] / N[(N[(d / M), $MachinePrecision] * N[(N[(d / M), $MachinePrecision] / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(D / l), $MachinePrecision]), $MachinePrecision] + w0), $MachinePrecision], If[LessEqual[N[(h / l), $MachinePrecision], -2e-296], N[(w0 * N[Sqrt[N[(1.0 + N[(-0.25 * N[(D * N[(D / N[(N[(d / M), $MachinePrecision] * N[(N[(d / M), $MachinePrecision] * N[(l / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[(1.0 + N[(-0.125 * N[(D / N[(N[(N[(d / M), $MachinePrecision] * N[(N[(d * l), $MachinePrecision] / N[(M * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / D), $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{h}{\ell} \leq -4 \cdot 10^{+292}:\\
\;\;\;\;\mathsf{fma}\left(-0.125, \frac{D \cdot w0}{\frac{d}{M} \cdot \frac{\frac{d}{M}}{h}} \cdot \frac{D}{\ell}, w0\right)\\

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

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


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

    1. Initial program 43.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(-0.125, \frac{D}{\frac{\ell}{D}} \cdot \left(\frac{\color{blue}{\left(M \cdot M\right)} \cdot h}{d} \cdot \frac{w0}{d}\right), w0\right) \]
      12. associate-*l*58.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.0000000000000001e292 < (/.f64 h l) < -2e-296

    1. Initial program 83.9%

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

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

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

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

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

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

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

        \[\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. associate-/l*53.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2e-296 < (/.f64 h l)

    1. Initial program 82.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 84.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}\;\frac{h}{\ell} \leq -5 \cdot 10^{-195}:\\ \;\;\;\;w0 \cdot {\left(1 + -0.25 \cdot \frac{D}{\frac{\frac{d}{M}}{\frac{D}{\frac{d}{\frac{M \cdot h}{\ell}}}}}\right)}^{0.5}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot {\left(1 + -0.25 \cdot \frac{D}{\frac{\frac{d}{M}}{\frac{D \cdot \left(M \cdot h\right)}{d \cdot \ell}}}\right)}^{0.5}\\ \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) -5e-195)
   (*
    w0
    (pow (+ 1.0 (* -0.25 (/ D (/ (/ d M) (/ D (/ d (/ (* M h) l))))))) 0.5))
   (*
    w0
    (pow (+ 1.0 (* -0.25 (/ D (/ (/ d M) (/ (* D (* M h)) (* d l)))))) 0.5))))
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) <= -5e-195) {
		tmp = w0 * pow((1.0 + (-0.25 * (D / ((d / M) / (D / (d / ((M * h) / l))))))), 0.5);
	} else {
		tmp = w0 * pow((1.0 + (-0.25 * (D / ((d / M) / ((D * (M * h)) / (d * l)))))), 0.5);
	}
	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) <= (-5d-195)) then
        tmp = w0 * ((1.0d0 + ((-0.25d0) * (d / ((d_1 / m) / (d / (d_1 / ((m * h) / l))))))) ** 0.5d0)
    else
        tmp = w0 * ((1.0d0 + ((-0.25d0) * (d / ((d_1 / m) / ((d * (m * h)) / (d_1 * l)))))) ** 0.5d0)
    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) <= -5e-195) {
		tmp = w0 * Math.pow((1.0 + (-0.25 * (D / ((d / M) / (D / (d / ((M * h) / l))))))), 0.5);
	} else {
		tmp = w0 * Math.pow((1.0 + (-0.25 * (D / ((d / M) / ((D * (M * h)) / (d * l)))))), 0.5);
	}
	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) <= -5e-195:
		tmp = w0 * math.pow((1.0 + (-0.25 * (D / ((d / M) / (D / (d / ((M * h) / l))))))), 0.5)
	else:
		tmp = w0 * math.pow((1.0 + (-0.25 * (D / ((d / M) / ((D * (M * h)) / (d * l)))))), 0.5)
	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) <= -5e-195)
		tmp = Float64(w0 * (Float64(1.0 + Float64(-0.25 * Float64(D / Float64(Float64(d / M) / Float64(D / Float64(d / Float64(Float64(M * h) / l))))))) ^ 0.5));
	else
		tmp = Float64(w0 * (Float64(1.0 + Float64(-0.25 * Float64(D / Float64(Float64(d / M) / Float64(Float64(D * Float64(M * h)) / Float64(d * l)))))) ^ 0.5));
	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) <= -5e-195)
		tmp = w0 * ((1.0 + (-0.25 * (D / ((d / M) / (D / (d / ((M * h) / l))))))) ^ 0.5);
	else
		tmp = w0 * ((1.0 + (-0.25 * (D / ((d / M) / ((D * (M * h)) / (d * l)))))) ^ 0.5);
	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], -5e-195], N[(w0 * N[Power[N[(1.0 + N[(-0.25 * N[(D / N[(N[(d / M), $MachinePrecision] / N[(D / N[(d / N[(N[(M * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Power[N[(1.0 + N[(-0.25 * N[(D / N[(N[(d / M), $MachinePrecision] / N[(N[(D * N[(M * h), $MachinePrecision]), $MachinePrecision] / N[(d * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.5], $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 -5 \cdot 10^{-195}:\\
\;\;\;\;w0 \cdot {\left(1 + -0.25 \cdot \frac{D}{\frac{\frac{d}{M}}{\frac{D}{\frac{d}{\frac{M \cdot h}{\ell}}}}}\right)}^{0.5}\\

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


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

    1. Initial program 79.0%

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

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

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

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

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{\ell \cdot {d}^{2}}}} \]
    5. Step-by-step derivation
      1. associate-*r/52.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. *-commutative52.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/52.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. associate-/l*52.9%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto w0 \cdot \color{blue}{{\left(1 + -0.25 \cdot \frac{D}{\frac{\frac{d}{M} \cdot \frac{d \cdot \ell}{M \cdot h}}{D}}\right)}^{0.5}} \]
    9. Step-by-step derivation
      1. *-un-lft-identity72.0%

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

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

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

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

    if -5.00000000000000009e-195 < (/.f64 h l)

    1. Initial program 81.4%

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

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

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

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

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{\ell \cdot {d}^{2}}}} \]
    5. Step-by-step derivation
      1. associate-*r/60.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. *-commutative60.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/60.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. associate-/l*60.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto w0 \cdot {\left(1 + -0.25 \cdot \frac{D}{\color{blue}{1 \cdot \frac{\frac{d}{M}}{\frac{D}{\frac{d}{\frac{M \cdot h}{\ell}}}}}}\right)}^{0.5} \]
    11. Taylor expanded in M around -inf 91.3%

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

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

Alternative 5: 86.3% accurate, 1.7× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ d = |d|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := \frac{d}{M \cdot D}\\ \mathbf{if}\;D \leq 4 \cdot 10^{+137}:\\ \;\;\;\;w0 \cdot \sqrt{1 + -0.25 \cdot \frac{\frac{D}{t_0}}{\ell \cdot \frac{d}{M \cdot h}}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot {\left(1 + -0.25 \cdot \frac{D}{t_0 \cdot \left(\ell \cdot \frac{\frac{d}{h}}{M}\right)}\right)}^{0.5}\\ \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 (/ d (* M D))))
   (if (<= D 4e+137)
     (* w0 (sqrt (+ 1.0 (* -0.25 (/ (/ D t_0) (* l (/ d (* M h))))))))
     (* w0 (pow (+ 1.0 (* -0.25 (/ D (* t_0 (* l (/ (/ d h) M)))))) 0.5)))))
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 = d / (M * D);
	double tmp;
	if (D <= 4e+137) {
		tmp = w0 * sqrt((1.0 + (-0.25 * ((D / t_0) / (l * (d / (M * h)))))));
	} else {
		tmp = w0 * pow((1.0 + (-0.25 * (D / (t_0 * (l * ((d / h) / M)))))), 0.5);
	}
	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 = d_1 / (m * d)
    if (d <= 4d+137) then
        tmp = w0 * sqrt((1.0d0 + ((-0.25d0) * ((d / t_0) / (l * (d_1 / (m * h)))))))
    else
        tmp = w0 * ((1.0d0 + ((-0.25d0) * (d / (t_0 * (l * ((d_1 / h) / m)))))) ** 0.5d0)
    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 = d / (M * D);
	double tmp;
	if (D <= 4e+137) {
		tmp = w0 * Math.sqrt((1.0 + (-0.25 * ((D / t_0) / (l * (d / (M * h)))))));
	} else {
		tmp = w0 * Math.pow((1.0 + (-0.25 * (D / (t_0 * (l * ((d / h) / M)))))), 0.5);
	}
	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 = d / (M * D)
	tmp = 0
	if D <= 4e+137:
		tmp = w0 * math.sqrt((1.0 + (-0.25 * ((D / t_0) / (l * (d / (M * h)))))))
	else:
		tmp = w0 * math.pow((1.0 + (-0.25 * (D / (t_0 * (l * ((d / h) / M)))))), 0.5)
	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(d / Float64(M * D))
	tmp = 0.0
	if (D <= 4e+137)
		tmp = Float64(w0 * sqrt(Float64(1.0 + Float64(-0.25 * Float64(Float64(D / t_0) / Float64(l * Float64(d / Float64(M * h))))))));
	else
		tmp = Float64(w0 * (Float64(1.0 + Float64(-0.25 * Float64(D / Float64(t_0 * Float64(l * Float64(Float64(d / h) / M)))))) ^ 0.5));
	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 = d / (M * D);
	tmp = 0.0;
	if (D <= 4e+137)
		tmp = w0 * sqrt((1.0 + (-0.25 * ((D / t_0) / (l * (d / (M * h)))))));
	else
		tmp = w0 * ((1.0 + (-0.25 * (D / (t_0 * (l * ((d / h) / M)))))) ^ 0.5);
	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[(d / N[(M * D), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[D, 4e+137], N[(w0 * N[Sqrt[N[(1.0 + N[(-0.25 * N[(N[(D / t$95$0), $MachinePrecision] / N[(l * N[(d / N[(M * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Power[N[(1.0 + N[(-0.25 * N[(D / N[(t$95$0 * N[(l * N[(N[(d / h), $MachinePrecision] / M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M = |M|\\
D = |D|\\
d = |d|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \frac{d}{M \cdot D}\\
\mathbf{if}\;D \leq 4 \cdot 10^{+137}:\\
\;\;\;\;w0 \cdot \sqrt{1 + -0.25 \cdot \frac{\frac{D}{t_0}}{\ell \cdot \frac{d}{M \cdot h}}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if D < 4.0000000000000001e137

    1. Initial program 81.5%

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

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

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

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

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

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

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

        \[\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. associate-/l*59.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 \cdot \color{blue}{\left(1 \cdot {\left(1 + -0.25 \cdot \frac{D}{1 \cdot \frac{\frac{d}{M}}{\frac{D}{\frac{d}{\frac{M \cdot h}{\ell}}}}}\right)}^{0.5}\right)} \]
      2. unpow1/282.7%

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

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

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

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

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

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

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

        \[\leadsto w0 \cdot \sqrt{1 + -0.25 \cdot \color{blue}{\frac{\frac{D}{\frac{\frac{d}{M}}{D}}}{\frac{\frac{d}{h}}{M} \cdot \ell}}} \]
      3. associate-/l/79.6%

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

        \[\leadsto w0 \cdot \sqrt{1 + -0.25 \cdot \frac{\frac{D}{\frac{d}{D \cdot M}}}{\color{blue}{\ell \cdot \frac{\frac{d}{h}}{M}}}} \]
      5. associate-/l/83.1%

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

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

    if 4.0000000000000001e137 < D

    1. Initial program 72.5%

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

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

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

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

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

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

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

        \[\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. associate-/l*39.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 85.9% 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 10^{+167}:\\ \;\;\;\;w0 \cdot \sqrt{1 + -0.25 \cdot \left(D \cdot \frac{D}{\frac{d}{M} \cdot \frac{d}{\frac{M \cdot h}{\ell}}}\right)}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 + -0.25 \cdot \frac{D}{\frac{\frac{d}{M}}{D} \cdot \left(\ell \cdot \frac{\frac{d}{h}}{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 (<= D 1e+167)
   (* w0 (sqrt (+ 1.0 (* -0.25 (* D (/ D (* (/ d M) (/ d (/ (* M h) l)))))))))
   (*
    w0
    (sqrt (+ 1.0 (* -0.25 (/ D (* (/ (/ d M) D) (* l (/ (/ d h) 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 (D <= 1e+167) {
		tmp = w0 * sqrt((1.0 + (-0.25 * (D * (D / ((d / M) * (d / ((M * h) / l))))))));
	} else {
		tmp = w0 * sqrt((1.0 + (-0.25 * (D / (((d / M) / D) * (l * ((d / h) / 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 (d <= 1d+167) then
        tmp = w0 * sqrt((1.0d0 + ((-0.25d0) * (d * (d / ((d_1 / m) * (d_1 / ((m * h) / l))))))))
    else
        tmp = w0 * sqrt((1.0d0 + ((-0.25d0) * (d / (((d_1 / m) / d) * (l * ((d_1 / h) / 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 (D <= 1e+167) {
		tmp = w0 * Math.sqrt((1.0 + (-0.25 * (D * (D / ((d / M) * (d / ((M * h) / l))))))));
	} else {
		tmp = w0 * Math.sqrt((1.0 + (-0.25 * (D / (((d / M) / D) * (l * ((d / h) / 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 D <= 1e+167:
		tmp = w0 * math.sqrt((1.0 + (-0.25 * (D * (D / ((d / M) * (d / ((M * h) / l))))))))
	else:
		tmp = w0 * math.sqrt((1.0 + (-0.25 * (D / (((d / M) / D) * (l * ((d / h) / 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 (D <= 1e+167)
		tmp = Float64(w0 * sqrt(Float64(1.0 + Float64(-0.25 * Float64(D * Float64(D / Float64(Float64(d / M) * Float64(d / Float64(Float64(M * h) / l)))))))));
	else
		tmp = Float64(w0 * sqrt(Float64(1.0 + Float64(-0.25 * Float64(D / Float64(Float64(Float64(d / M) / D) * Float64(l * Float64(Float64(d / h) / 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 (D <= 1e+167)
		tmp = w0 * sqrt((1.0 + (-0.25 * (D * (D / ((d / M) * (d / ((M * h) / l))))))));
	else
		tmp = w0 * sqrt((1.0 + (-0.25 * (D / (((d / M) / D) * (l * ((d / h) / 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[D, 1e+167], N[(w0 * N[Sqrt[N[(1.0 + N[(-0.25 * N[(D * N[(D / N[(N[(d / M), $MachinePrecision] * N[(d / N[(N[(M * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 + N[(-0.25 * N[(D / N[(N[(N[(d / M), $MachinePrecision] / D), $MachinePrecision] * N[(l * N[(N[(d / h), $MachinePrecision] / 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}\;D \leq 10^{+167}:\\
\;\;\;\;w0 \cdot \sqrt{1 + -0.25 \cdot \left(D \cdot \frac{D}{\frac{d}{M} \cdot \frac{d}{\frac{M \cdot h}{\ell}}}\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if D < 1e167

    1. Initial program 81.3%

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

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

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

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

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

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

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

        \[\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. associate-/l*59.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto w0 \cdot \color{blue}{{\left(1 + -0.25 \cdot \frac{D}{\frac{\frac{d}{M} \cdot \frac{d \cdot \ell}{M \cdot h}}{D}}\right)}^{0.5}} \]
    9. Step-by-step derivation
      1. unpow1/281.8%

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

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

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

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

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

    if 1e167 < D

    1. Initial program 72.5%

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

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

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

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

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

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

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

        \[\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. associate-/l*37.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto w0 \cdot {\left(1 + -0.25 \cdot \frac{D}{\color{blue}{1 \cdot \frac{\frac{d}{M}}{\frac{D}{\frac{d}{\frac{M \cdot h}{\ell}}}}}}\right)}^{0.5} \]
    11. Step-by-step derivation
      1. unpow1/273.9%

        \[\leadsto w0 \cdot \color{blue}{\sqrt{1 + -0.25 \cdot \frac{D}{1 \cdot \frac{\frac{d}{M}}{\frac{D}{\frac{d}{\frac{M \cdot h}{\ell}}}}}}} \]
      2. *-un-lft-identity73.9%

        \[\leadsto w0 \cdot \sqrt{1 + -0.25 \cdot \frac{D}{\color{blue}{\frac{\frac{d}{M}}{\frac{D}{\frac{d}{\frac{M \cdot h}{\ell}}}}}}} \]
      3. associate-/r/73.5%

        \[\leadsto w0 \cdot \sqrt{1 + -0.25 \cdot \frac{D}{\color{blue}{\frac{\frac{d}{M}}{D} \cdot \frac{d}{\frac{M \cdot h}{\ell}}}}} \]
      4. associate-/r/77.0%

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

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

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

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

Alternative 7: 86.7% 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 4.4 \cdot 10^{+139}:\\ \;\;\;\;w0 \cdot \sqrt{1 + -0.25 \cdot \frac{\frac{D}{\frac{d}{M \cdot D}}}{\ell \cdot \frac{d}{M \cdot h}}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 + -0.25 \cdot \frac{D}{\frac{\frac{d}{M}}{D} \cdot \left(\ell \cdot \frac{\frac{d}{h}}{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 (<= D 4.4e+139)
   (* w0 (sqrt (+ 1.0 (* -0.25 (/ (/ D (/ d (* M D))) (* l (/ d (* M h))))))))
   (*
    w0
    (sqrt (+ 1.0 (* -0.25 (/ D (* (/ (/ d M) D) (* l (/ (/ d h) 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 (D <= 4.4e+139) {
		tmp = w0 * sqrt((1.0 + (-0.25 * ((D / (d / (M * D))) / (l * (d / (M * h)))))));
	} else {
		tmp = w0 * sqrt((1.0 + (-0.25 * (D / (((d / M) / D) * (l * ((d / h) / 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 (d <= 4.4d+139) then
        tmp = w0 * sqrt((1.0d0 + ((-0.25d0) * ((d / (d_1 / (m * d))) / (l * (d_1 / (m * h)))))))
    else
        tmp = w0 * sqrt((1.0d0 + ((-0.25d0) * (d / (((d_1 / m) / d) * (l * ((d_1 / h) / 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 (D <= 4.4e+139) {
		tmp = w0 * Math.sqrt((1.0 + (-0.25 * ((D / (d / (M * D))) / (l * (d / (M * h)))))));
	} else {
		tmp = w0 * Math.sqrt((1.0 + (-0.25 * (D / (((d / M) / D) * (l * ((d / h) / 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 D <= 4.4e+139:
		tmp = w0 * math.sqrt((1.0 + (-0.25 * ((D / (d / (M * D))) / (l * (d / (M * h)))))))
	else:
		tmp = w0 * math.sqrt((1.0 + (-0.25 * (D / (((d / M) / D) * (l * ((d / h) / 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 (D <= 4.4e+139)
		tmp = Float64(w0 * sqrt(Float64(1.0 + Float64(-0.25 * Float64(Float64(D / Float64(d / Float64(M * D))) / Float64(l * Float64(d / Float64(M * h))))))));
	else
		tmp = Float64(w0 * sqrt(Float64(1.0 + Float64(-0.25 * Float64(D / Float64(Float64(Float64(d / M) / D) * Float64(l * Float64(Float64(d / h) / 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 (D <= 4.4e+139)
		tmp = w0 * sqrt((1.0 + (-0.25 * ((D / (d / (M * D))) / (l * (d / (M * h)))))));
	else
		tmp = w0 * sqrt((1.0 + (-0.25 * (D / (((d / M) / D) * (l * ((d / h) / 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[D, 4.4e+139], N[(w0 * N[Sqrt[N[(1.0 + N[(-0.25 * N[(N[(D / N[(d / N[(M * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(l * N[(d / N[(M * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 + N[(-0.25 * N[(D / N[(N[(N[(d / M), $MachinePrecision] / D), $MachinePrecision] * N[(l * N[(N[(d / h), $MachinePrecision] / 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}\;D \leq 4.4 \cdot 10^{+139}:\\
\;\;\;\;w0 \cdot \sqrt{1 + -0.25 \cdot \frac{\frac{D}{\frac{d}{M \cdot D}}}{\ell \cdot \frac{d}{M \cdot h}}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if D < 4.3999999999999999e139

    1. Initial program 81.5%

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

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

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

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

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

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

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

        \[\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. associate-/l*59.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 \cdot \color{blue}{\left(1 \cdot {\left(1 + -0.25 \cdot \frac{D}{1 \cdot \frac{\frac{d}{M}}{\frac{D}{\frac{d}{\frac{M \cdot h}{\ell}}}}}\right)}^{0.5}\right)} \]
      2. unpow1/282.7%

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

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

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

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

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

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

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

        \[\leadsto w0 \cdot \sqrt{1 + -0.25 \cdot \color{blue}{\frac{\frac{D}{\frac{\frac{d}{M}}{D}}}{\frac{\frac{d}{h}}{M} \cdot \ell}}} \]
      3. associate-/l/79.6%

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

        \[\leadsto w0 \cdot \sqrt{1 + -0.25 \cdot \frac{\frac{D}{\frac{d}{D \cdot M}}}{\color{blue}{\ell \cdot \frac{\frac{d}{h}}{M}}}} \]
      5. associate-/l/83.1%

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

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

    if 4.3999999999999999e139 < D

    1. Initial program 72.5%

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

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

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

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

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

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

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

        \[\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. associate-/l*39.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto w0 \cdot {\left(1 + -0.25 \cdot \frac{D}{\color{blue}{1 \cdot \frac{\frac{d}{M}}{\frac{D}{\frac{d}{\frac{M \cdot h}{\ell}}}}}}\right)}^{0.5} \]
    11. Step-by-step derivation
      1. unpow1/273.7%

        \[\leadsto w0 \cdot \color{blue}{\sqrt{1 + -0.25 \cdot \frac{D}{1 \cdot \frac{\frac{d}{M}}{\frac{D}{\frac{d}{\frac{M \cdot h}{\ell}}}}}}} \]
      2. *-un-lft-identity73.7%

        \[\leadsto w0 \cdot \sqrt{1 + -0.25 \cdot \frac{D}{\color{blue}{\frac{\frac{d}{M}}{\frac{D}{\frac{d}{\frac{M \cdot h}{\ell}}}}}}} \]
      3. associate-/r/73.4%

        \[\leadsto w0 \cdot \sqrt{1 + -0.25 \cdot \frac{D}{\color{blue}{\frac{\frac{d}{M}}{D} \cdot \frac{d}{\frac{M \cdot h}{\ell}}}}} \]
      4. associate-/r/76.2%

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

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

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

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

Alternative 8: 84.6% accurate, 1.8× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ d = |d|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ w0 \cdot \sqrt{1 + -0.25 \cdot \left(D \cdot \frac{D}{\frac{d}{M} \cdot \frac{d}{\frac{M \cdot h}{\ell}}}\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 (sqrt (+ 1.0 (* -0.25 (* D (/ D (* (/ d M) (/ d (/ (* M h) 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) {
	return w0 * sqrt((1.0 + (-0.25 * (D * (D / ((d / M) * (d / ((M * h) / l))))))));
}
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 * sqrt((1.0d0 + ((-0.25d0) * (d * (d / ((d_1 / m) * (d_1 / ((m * h) / l))))))))
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 * Math.sqrt((1.0 + (-0.25 * (D * (D / ((d / M) * (d / ((M * h) / l))))))));
}
M = abs(M)
D = abs(D)
d = abs(d)
[M, D] = sort([M, D])
def code(w0, M, D, h, l, d):
	return w0 * math.sqrt((1.0 + (-0.25 * (D * (D / ((d / M) * (d / ((M * h) / l))))))))
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 * sqrt(Float64(1.0 + Float64(-0.25 * Float64(D * Float64(D / Float64(Float64(d / M) * Float64(d / Float64(Float64(M * h) / l)))))))))
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 * sqrt((1.0 + (-0.25 * (D * (D / ((d / M) * (d / ((M * h) / l))))))));
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[Sqrt[N[(1.0 + N[(-0.25 * N[(D * N[(D / N[(N[(d / M), $MachinePrecision] * N[(d / N[(N[(M * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M = |M|\\
D = |D|\\
d = |d|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
w0 \cdot \sqrt{1 + -0.25 \cdot \left(D \cdot \frac{D}{\frac{d}{M} \cdot \frac{d}{\frac{M \cdot h}{\ell}}}\right)}
\end{array}
Derivation
  1. Initial program 80.2%

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

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

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

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

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

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

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

      \[\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. associate-/l*56.3%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto w0 \cdot \color{blue}{{\left(1 + -0.25 \cdot \frac{D}{\frac{\frac{d}{M} \cdot \frac{d \cdot \ell}{M \cdot h}}{D}}\right)}^{0.5}} \]
  9. Step-by-step derivation
    1. unpow1/280.5%

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

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

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

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

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

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

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

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


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

    1. Initial program 80.4%

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

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

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

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

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

    if 1.70000000000000011e-168 < M

    1. Initial program 79.6%

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

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

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

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

      \[\leadsto w0 \cdot \color{blue}{\left(1 + -0.125 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{\ell \cdot {d}^{2}}\right)} \]
    5. Step-by-step derivation
      1. associate-*r/60.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. *-commutative60.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/60.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. *-commutative60.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. associate-/l*60.1%

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

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

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

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

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

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

      \[\leadsto w0 \cdot \left(1 + \color{blue}{\frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}} \cdot -0.125\right) \]
    8. Step-by-step derivation
      1. *-commutative60.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-frac60.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. unpow260.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-*r/60.2%

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

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

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

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

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

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

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

Alternative 10: 77.8% 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 8.6 \cdot 10^{-180}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \left(1 + -0.125 \cdot \left(\left(\frac{D}{d} \cdot \frac{D}{d \cdot \ell}\right) \cdot \left(M \cdot \left(M \cdot h\right)\right)\right)\right)\\ \end{array} \end{array} \]
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: 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 8.6e-180)
   w0
   (* w0 (+ 1.0 (* -0.125 (* (* (/ D d) (/ D (* d l))) (* M (* M h))))))))
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 <= 8.6e-180) {
		tmp = w0;
	} else {
		tmp = w0 * (1.0 + (-0.125 * (((D / d) * (D / (d * l))) * (M * (M * h)))));
	}
	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 <= 8.6d-180) then
        tmp = w0
    else
        tmp = w0 * (1.0d0 + ((-0.125d0) * (((d / d_1) * (d / (d_1 * l))) * (m * (m * h)))))
    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 <= 8.6e-180) {
		tmp = w0;
	} else {
		tmp = w0 * (1.0 + (-0.125 * (((D / d) * (D / (d * l))) * (M * (M * h)))));
	}
	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 <= 8.6e-180:
		tmp = w0
	else:
		tmp = w0 * (1.0 + (-0.125 * (((D / d) * (D / (d * l))) * (M * (M * h)))))
	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 <= 8.6e-180)
		tmp = w0;
	else
		tmp = Float64(w0 * Float64(1.0 + Float64(-0.125 * Float64(Float64(Float64(D / d) * Float64(D / Float64(d * l))) * Float64(M * Float64(M * h))))));
	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 <= 8.6e-180)
		tmp = w0;
	else
		tmp = w0 * (1.0 + (-0.125 * (((D / d) * (D / (d * l))) * (M * (M * h)))));
	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, 8.6e-180], w0, N[(w0 * N[(1.0 + N[(-0.125 * N[(N[(N[(D / d), $MachinePrecision] * N[(D / N[(d * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(M * N[(M * h), $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 8.6 \cdot 10^{-180}:\\
\;\;\;\;w0\\

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


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

    1. Initial program 80.2%

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

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

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

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

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

    if 8.5999999999999991e-180 < 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. Step-by-step derivation
      1. *-commutative80.1%

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

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

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

      \[\leadsto w0 \cdot \color{blue}{\left(1 + -0.125 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{\ell \cdot {d}^{2}}\right)} \]
    5. Step-by-step derivation
      1. associate-*r/61.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. *-commutative61.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/61.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. *-commutative61.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. associate-/l*61.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 72.1% 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 23000000000:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;-0.125 \cdot \left(\left(D \cdot \frac{D}{\ell}\right) \cdot \left(\frac{w0 \cdot h}{d} \cdot \frac{M \cdot M}{d}\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 23000000000.0)
   w0
   (* -0.125 (* (* D (/ D l)) (* (/ (* w0 h) d) (/ (* M M) d))))))
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 <= 23000000000.0) {
		tmp = w0;
	} else {
		tmp = -0.125 * ((D * (D / l)) * (((w0 * h) / d) * ((M * M) / d)));
	}
	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 <= 23000000000.0d0) then
        tmp = w0
    else
        tmp = (-0.125d0) * ((d * (d / l)) * (((w0 * h) / d_1) * ((m * m) / d_1)))
    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 <= 23000000000.0) {
		tmp = w0;
	} else {
		tmp = -0.125 * ((D * (D / l)) * (((w0 * h) / d) * ((M * M) / d)));
	}
	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 <= 23000000000.0:
		tmp = w0
	else:
		tmp = -0.125 * ((D * (D / l)) * (((w0 * h) / d) * ((M * M) / d)))
	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 <= 23000000000.0)
		tmp = w0;
	else
		tmp = Float64(-0.125 * Float64(Float64(D * Float64(D / l)) * Float64(Float64(Float64(w0 * h) / d) * Float64(Float64(M * M) / d))));
	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 <= 23000000000.0)
		tmp = w0;
	else
		tmp = -0.125 * ((D * (D / l)) * (((w0 * h) / d) * ((M * M) / d)));
	end
	tmp_2 = tmp;
end
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: 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, 23000000000.0], w0, N[(-0.125 * N[(N[(D * N[(D / l), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(w0 * h), $MachinePrecision] / d), $MachinePrecision] * N[(N[(M * M), $MachinePrecision] / d), $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 23000000000:\\
\;\;\;\;w0\\

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


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

    1. Initial program 81.0%

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

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

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

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

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

    if 2.3e10 < M

    1. Initial program 76.2%

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

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

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

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

      \[\leadsto w0 \cdot \color{blue}{\left(1 + -0.125 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{\ell \cdot {d}^{2}}\right)} \]
    5. Step-by-step derivation
      1. associate-*r/51.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. *-commutative51.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/51.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. *-commutative51.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. associate-/l*51.8%

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

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

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

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

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

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

      \[\leadsto w0 \cdot \left(1 + \color{blue}{\frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}} \cdot -0.125\right) \]
    8. Step-by-step derivation
      1. *-commutative51.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-frac51.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 78.4% accurate, 10.3× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ d = |d|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ w0 \cdot \left(1 + -0.125 \cdot \frac{D}{\frac{\frac{d}{M} \cdot \frac{d \cdot \ell}{M \cdot h}}{D}}\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 (* -0.125 (/ D (/ (* (/ d M) (/ (* d l) (* M h))) D))))))
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 + (-0.125 * (D / (((d / M) * ((d * l) / (M * h))) / D))));
}
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 + ((-0.125d0) * (d / (((d_1 / m) * ((d_1 * l) / (m * h))) / d))))
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 + (-0.125 * (D / (((d / M) * ((d * l) / (M * h))) / D))));
}
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 + (-0.125 * (D / (((d / M) * ((d * l) / (M * h))) / D))))
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(-0.125 * Float64(D / Float64(Float64(Float64(d / M) * Float64(Float64(d * l) / Float64(M * h))) / D)))))
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 + (-0.125 * (D / (((d / M) * ((d * l) / (M * h))) / D))));
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[(-0.125 * N[(D / N[(N[(N[(d / M), $MachinePrecision] * N[(N[(d * l), $MachinePrecision] / N[(M * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M = |M|\\
D = |D|\\
d = |d|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
w0 \cdot \left(1 + -0.125 \cdot \frac{D}{\frac{\frac{d}{M} \cdot \frac{d \cdot \ell}{M \cdot h}}{D}}\right)
\end{array}
Derivation
  1. Initial program 80.2%

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

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

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

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

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

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

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

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

      \[\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. associate-/l*54.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 67.8% 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 80.2%

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

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

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

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

    \[\leadsto \color{blue}{w0} \]
  5. Final simplification61.0%

    \[\leadsto w0 \]

Reproduce

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