Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 80.6% → 86.9%
Time: 12.7s
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.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \end{array} \]
(FPCore (w0 M D h l d)
 :precision binary64
 (* w0 (sqrt (- 1.0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l))))))
double code(double w0, double M, double D, double h, double l, double d) {
	return w0 * sqrt((1.0 - (pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
}
real(8) function code(w0, m, d, h, l, d_1)
    real(8), intent (in) :: w0
    real(8), intent (in) :: m
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d_1
    code = w0 * sqrt((1.0d0 - ((((m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l))))
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
	return w0 * Math.sqrt((1.0 - (Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
}
def code(w0, M, D, h, l, d):
	return w0 * math.sqrt((1.0 - (math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))))
function code(w0, M, D, h, l, d)
	return Float64(w0 * sqrt(Float64(1.0 - Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)))))
end
function tmp = code(w0, M, D, h, l, d)
	tmp = w0 * sqrt((1.0 - ((((M * D) / (2.0 * d)) ^ 2.0) * (h / l))));
end
code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Alternative 1: 86.9% accurate, 0.7× speedup?

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

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


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

    1. Initial program 99.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. *-commutative99.9%

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

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

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

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

    1. Initial program 42.5%

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{1 + -0.25 \cdot \frac{D \cdot \color{blue}{\frac{M \cdot \frac{h}{d}}{\frac{d}{M}}}}{\frac{\ell}{D}}} \cdot w0 \]
      6. Step-by-step derivation
        1. associate-/r/61.3%

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

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

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

    Alternative 2: 86.7% accurate, 1.0× speedup?

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

      1. Initial program 72.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      if -1.00000000000000001e-119 < (/.f64 h l)

      1. Initial program 84.5%

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

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

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

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

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

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

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

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

            \[\leadsto \sqrt{1 + -0.25 \cdot \frac{D \cdot \color{blue}{\frac{M \cdot \frac{h}{d}}{\frac{d}{M}}}}{\frac{\ell}{D}}} \cdot w0 \]
        5. Applied egg-rr85.0%

          \[\leadsto \sqrt{1 + -0.25 \cdot \frac{D \cdot \color{blue}{\frac{M \cdot \frac{h}{d}}{\frac{d}{M}}}}{\frac{\ell}{D}}} \cdot w0 \]
        6. Step-by-step derivation
          1. associate-/r/85.2%

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

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

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

      Alternative 3: 76.0% accurate, 1.8× speedup?

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

        1. Initial program 81.1%

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

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

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

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

        if 2.10000000000000001e-44 < M

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

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

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

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

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

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

        Alternative 4: 74.8% accurate, 1.8× speedup?

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

          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. times-frac78.7%

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

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

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

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

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

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

            if 6.09999999999999959e-149 < d < 2e27

            1. Initial program 88.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            if 2e27 < d

            1. Initial program 76.4%

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

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

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

              \[\leadsto \color{blue}{w0} \]
          6. Recombined 3 regimes into one program.
          7. Final simplification69.6%

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

          Alternative 5: 82.9% accurate, 1.8× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            Alternative 6: 83.5% accurate, 1.8× speedup?

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

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

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

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

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

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

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

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

                  \[\leadsto \sqrt{1 + -0.25 \cdot \frac{D \cdot \color{blue}{\frac{M \cdot \frac{h}{d}}{\frac{d}{M}}}}{\frac{\ell}{D}}} \cdot w0 \]
              5. Applied egg-rr77.9%

                \[\leadsto \sqrt{1 + -0.25 \cdot \frac{D \cdot \color{blue}{\frac{M \cdot \frac{h}{d}}{\frac{d}{M}}}}{\frac{\ell}{D}}} \cdot w0 \]
              6. Step-by-step derivation
                1. associate-/r/78.5%

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

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

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

              Alternative 7: 77.0% accurate, 1.8× speedup?

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

                1. Initial program 81.2%

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

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

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

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

                if 1.25000000000000011e-87 < M

                1. Initial program 75.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              Alternative 8: 74.5% accurate, 1.8× speedup?

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

                1. Initial program 80.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                if 2.04999999999999992e26 < d

                1. Initial program 76.4%

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

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

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

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

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

              Alternative 9: 67.9% accurate, 9.4× speedup?

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

                1. Initial program 80.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                if 3.2e5 < d

                1. Initial program 77.5%

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

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

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

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

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

              Alternative 10: 71.4% accurate, 10.3× speedup?

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

                1. Initial program 81.0%

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

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

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

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

                if 1.25 < M

                1. Initial program 74.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\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}} \]
                  3. associate-*r/24.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              Alternative 11: 67.6% accurate, 216.0× speedup?

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

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

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

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

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

                \[\leadsto w0 \]

              Reproduce

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