Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 80.5% → 89.1%
Time: 13.3s
Alternatives: 11
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 11 alternatives:

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

Initial Program: 80.5% 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: 89.1% accurate, 1.0× speedup?

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

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


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

    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-frac83.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 70.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. *-commutative70.2%

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

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{M}{d} \cdot \frac{D}{2}\right)}}^{2} \cdot \frac{h}{\ell}} \]
    3. Simplified70.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 w0 around 0 50.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 86.3% accurate, 0.9× speedup?

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

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


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

    1. Initial program 64.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. *-commutative64.3%

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

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{M}{d} \cdot \frac{D}{2}\right)}}^{2} \cdot \frac{h}{\ell}} \]
    3. Simplified65.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 w0 around 0 44.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 88.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. *-commutative88.0%

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

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{M}{d} \cdot \frac{D}{2}\right)}}^{2} \cdot \frac{h}{\ell}} \]
    3. Simplified87.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 98.5%

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

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

Alternative 3: 89.1% accurate, 1.0× speedup?

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

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


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

    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-frac83.4%

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 70.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. *-commutative70.2%

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

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{M}{d} \cdot \frac{D}{2}\right)}}^{2} \cdot \frac{h}{\ell}} \]
    3. Simplified70.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 w0 around 0 50.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 82.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}\;M \leq 1.6 \cdot 10^{-206}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 + -0.25 \cdot \left(\frac{D}{\ell} \cdot \left(\frac{h}{\frac{d}{M}} \cdot \left(M \cdot \frac{D}{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.6e-206)
   w0
   (*
    w0
    (sqrt (+ 1.0 (* -0.25 (* (/ D l) (* (/ h (/ d M)) (* M (/ D 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.6e-206) {
		tmp = w0;
	} else {
		tmp = w0 * sqrt((1.0 + (-0.25 * ((D / l) * ((h / (d / M)) * (M * (D / 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.6d-206) then
        tmp = w0
    else
        tmp = w0 * sqrt((1.0d0 + ((-0.25d0) * ((d / l) * ((h / (d_1 / m)) * (m * (d / 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.6e-206) {
		tmp = w0;
	} else {
		tmp = w0 * Math.sqrt((1.0 + (-0.25 * ((D / l) * ((h / (d / M)) * (M * (D / 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.6e-206:
		tmp = w0
	else:
		tmp = w0 * math.sqrt((1.0 + (-0.25 * ((D / l) * ((h / (d / M)) * (M * (D / 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.6e-206)
		tmp = w0;
	else
		tmp = Float64(w0 * sqrt(Float64(1.0 + Float64(-0.25 * Float64(Float64(D / l) * Float64(Float64(h / Float64(d / M)) * Float64(M * Float64(D / 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.6e-206)
		tmp = w0;
	else
		tmp = w0 * sqrt((1.0 + (-0.25 * ((D / l) * ((h / (d / M)) * (M * (D / d)))))));
	end
	tmp_2 = tmp;
end
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: 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.6e-206], w0, N[(w0 * N[Sqrt[N[(1.0 + N[(-0.25 * N[(N[(D / l), $MachinePrecision] * N[(N[(h / N[(d / M), $MachinePrecision]), $MachinePrecision] * N[(M * N[(D / d), $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}\;M \leq 1.6 \cdot 10^{-206}:\\
\;\;\;\;w0\\

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


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

    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-frac80.5%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{M}{d} \cdot \frac{D}{2}\right)}}^{2} \cdot \frac{h}{\ell}} \]
    3. Simplified80.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 79.1%

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

    if 1.59999999999999988e-206 < M

    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-frac81.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 80.5% 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 3.8 \cdot 10^{-8}:\\ \;\;\;\;w0 \cdot \mathsf{fma}\left(\frac{h}{\frac{\ell}{D}} \cdot \frac{D}{\frac{d}{M} \cdot \frac{d}{M}}, -0.125, 1\right)\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \left(1 + -0.125 \cdot \left(\frac{D}{d} \cdot \left(\frac{D}{d} \cdot \frac{M \cdot h}{\frac{\ell}{M}}\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 (<= d 3.8e-8)
   (* w0 (fma (* (/ h (/ l D)) (/ D (* (/ d M) (/ d M)))) -0.125 1.0))
   (* w0 (+ 1.0 (* -0.125 (* (/ D d) (* (/ D d) (/ (* M h) (/ l 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 <= 3.8e-8) {
		tmp = w0 * fma(((h / (l / D)) * (D / ((d / M) * (d / M)))), -0.125, 1.0);
	} else {
		tmp = w0 * (1.0 + (-0.125 * ((D / d) * ((D / d) * ((M * h) / (l / 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 <= 3.8e-8)
		tmp = Float64(w0 * fma(Float64(Float64(h / Float64(l / D)) * Float64(D / Float64(Float64(d / M) * Float64(d / M)))), -0.125, 1.0));
	else
		tmp = Float64(w0 * Float64(1.0 + Float64(-0.125 * Float64(Float64(D / d) * Float64(Float64(D / d) * Float64(Float64(M * h) / Float64(l / M)))))));
	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[d, 3.8e-8], N[(w0 * N[(N[(N[(h / N[(l / D), $MachinePrecision]), $MachinePrecision] * N[(D / N[(N[(d / M), $MachinePrecision] * N[(d / M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision]), $MachinePrecision], N[(w0 * N[(1.0 + N[(-0.125 * N[(N[(D / d), $MachinePrecision] * N[(N[(D / d), $MachinePrecision] * N[(N[(M * h), $MachinePrecision] / N[(l / M), $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 3.8 \cdot 10^{-8}:\\
\;\;\;\;w0 \cdot \mathsf{fma}\left(\frac{h}{\frac{\ell}{D}} \cdot \frac{D}{\frac{d}{M} \cdot \frac{d}{M}}, -0.125, 1\right)\\

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


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

    1. Initial program 82.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.80000000000000028e-8 < d

    1. Initial program 79.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. *-commutative79.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 69.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 80.6% 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 \cdot 10^{-18}:\\ \;\;\;\;w0 \cdot \mathsf{fma}\left(\frac{D \cdot \frac{h}{\frac{d}{M} \cdot \frac{d}{M}}}{\frac{\ell}{D}}, -0.125, 1\right)\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \left(1 + -0.125 \cdot \left(\frac{D}{d} \cdot \left(\frac{D}{d} \cdot \frac{M \cdot h}{\frac{\ell}{M}}\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 (<= d 4e-18)
   (* w0 (fma (/ (* D (/ h (* (/ d M) (/ d M)))) (/ l D)) -0.125 1.0))
   (* w0 (+ 1.0 (* -0.125 (* (/ D d) (* (/ D d) (/ (* M h) (/ l 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 <= 4e-18) {
		tmp = w0 * fma(((D * (h / ((d / M) * (d / M)))) / (l / D)), -0.125, 1.0);
	} else {
		tmp = w0 * (1.0 + (-0.125 * ((D / d) * ((D / d) * ((M * h) / (l / 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 <= 4e-18)
		tmp = Float64(w0 * fma(Float64(Float64(D * Float64(h / Float64(Float64(d / M) * Float64(d / M)))) / Float64(l / D)), -0.125, 1.0));
	else
		tmp = Float64(w0 * Float64(1.0 + Float64(-0.125 * Float64(Float64(D / d) * Float64(Float64(D / d) * Float64(Float64(M * h) / Float64(l / M)))))));
	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[d, 4e-18], N[(w0 * N[(N[(N[(D * N[(h / N[(N[(d / M), $MachinePrecision] * N[(d / M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(l / D), $MachinePrecision]), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision]), $MachinePrecision], N[(w0 * N[(1.0 + N[(-0.125 * N[(N[(D / d), $MachinePrecision] * N[(N[(D / d), $MachinePrecision] * N[(N[(M * h), $MachinePrecision] / N[(l / M), $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 \cdot 10^{-18}:\\
\;\;\;\;w0 \cdot \mathsf{fma}\left(\frac{D \cdot \frac{h}{\frac{d}{M} \cdot \frac{d}{M}}}{\frac{\ell}{D}}, -0.125, 1\right)\\

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


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

    1. Initial program 82.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.0000000000000003e-18 < d

    1. Initial program 79.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. *-commutative79.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 69.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 79.3% accurate, 8.6× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if M < 4.35000000000000005e-156

    1. Initial program 80.7%

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

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

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

    if 4.35000000000000005e-156 < M < 1.00000000000000005e-4

    1. Initial program 80.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. *-commutative80.3%

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

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{M}{d} \cdot \frac{D}{2}\right)}}^{2} \cdot \frac{h}{\ell}} \]
    3. Simplified80.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 66.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. *-commutative66.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.00000000000000005e-4 < M

    1. Initial program 83.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 78.4% accurate, 9.4× speedup?

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

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


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

    1. Initial program 80.7%

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

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

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

    if 4.35000000000000005e-156 < M

    1. Initial program 82.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 78.6% 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 5.8 \cdot 10^{-155}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \left(1 + -0.125 \cdot \left(\frac{D}{d} \cdot \left(\frac{D}{d} \cdot \frac{M \cdot h}{\frac{\ell}{M}}\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 5.8e-155)
   w0
   (* w0 (+ 1.0 (* -0.125 (* (/ D d) (* (/ D d) (/ (* M h) (/ l M)))))))))
M = abs(M);
D = abs(D);
d = abs(d);
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if (M <= 5.8e-155) {
		tmp = w0;
	} else {
		tmp = w0 * (1.0 + (-0.125 * ((D / d) * ((D / d) * ((M * h) / (l / M))))));
	}
	return tmp;
}
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: d should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
real(8) function code(w0, m, d, h, l, d_1)
    real(8), intent (in) :: w0
    real(8), intent (in) :: m
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d_1
    real(8) :: tmp
    if (m <= 5.8d-155) then
        tmp = w0
    else
        tmp = w0 * (1.0d0 + ((-0.125d0) * ((d / d_1) * ((d / d_1) * ((m * h) / (l / m))))))
    end if
    code = tmp
end function
M = Math.abs(M);
D = Math.abs(D);
d = Math.abs(d);
assert M < D;
public static double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if (M <= 5.8e-155) {
		tmp = w0;
	} else {
		tmp = w0 * (1.0 + (-0.125 * ((D / d) * ((D / d) * ((M * h) / (l / M))))));
	}
	return tmp;
}
M = abs(M)
D = abs(D)
d = abs(d)
[M, D] = sort([M, D])
def code(w0, M, D, h, l, d):
	tmp = 0
	if M <= 5.8e-155:
		tmp = w0
	else:
		tmp = w0 * (1.0 + (-0.125 * ((D / d) * ((D / d) * ((M * h) / (l / 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 (M <= 5.8e-155)
		tmp = w0;
	else
		tmp = Float64(w0 * Float64(1.0 + Float64(-0.125 * Float64(Float64(D / d) * Float64(Float64(D / d) * Float64(Float64(M * h) / Float64(l / M)))))));
	end
	return tmp
end
M = abs(M)
D = abs(D)
d = abs(d)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(w0, M, D, h, l, d)
	tmp = 0.0;
	if (M <= 5.8e-155)
		tmp = w0;
	else
		tmp = w0 * (1.0 + (-0.125 * ((D / d) * ((D / d) * ((M * h) / (l / M))))));
	end
	tmp_2 = tmp;
end
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: 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, 5.8e-155], w0, N[(w0 * N[(1.0 + N[(-0.125 * N[(N[(D / d), $MachinePrecision] * N[(N[(D / d), $MachinePrecision] * N[(N[(M * h), $MachinePrecision] / N[(l / M), $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}\;M \leq 5.8 \cdot 10^{-155}:\\
\;\;\;\;w0\\

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


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

    1. Initial program 80.7%

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

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

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

    if 5.80000000000000021e-155 < M

    1. Initial program 82.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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

    1. Initial program 80.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. *-commutative80.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.7%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{M}{d} \cdot \frac{D}{2}\right)}}^{2} \cdot \frac{h}{\ell}} \]
    3. Simplified79.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 79.7%

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

    if 2.30000000000000015e56 < M

    1. Initial program 86.0%

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

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

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{M}{d} \cdot \frac{D}{2}\right)}}^{2} \cdot \frac{h}{\ell}} \]
    3. Simplified85.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 49.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 67.6% accurate, 216.0× speedup?

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

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

    \[\leadsto w0 \]

Reproduce

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