Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 81.3% → 86.5%
Time: 13.3s
Alternatives: 8
Speedup: 1.0×

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 8 alternatives:

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

Initial Program: 81.3% 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.5% accurate, 0.7× speedup?

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

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


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

    1. Initial program 86.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-frac86.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.00000000000000008e201 < (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)

    1. Initial program 49.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 86.4% accurate, 0.7× speedup?

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

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


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

    1. Initial program 86.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-frac86.8%

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.00000000000000008e201 < (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)

    1. Initial program 49.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 85.9% accurate, 1.0× speedup?

\[\begin{array}{l} [M, D] = \mathsf{sort}([M, D])\\ \\ w0 \cdot \sqrt{1 - 0.25 \cdot \left(h \cdot \frac{{\left(M \cdot \frac{D}{d}\right)}^{2}}{\ell}\right)} \end{array} \]
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 (* h (/ (pow (* M (/ D d)) 2.0) l)))))))
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
	return w0 * sqrt((1.0 - (0.25 * (h * (pow((M * (D / d)), 2.0) / l)))));
}
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 * (h * (((m * (d / d_1)) ** 2.0d0) / l)))))
end function
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 * (h * (Math.pow((M * (D / d)), 2.0) / l)))));
}
[M, D] = sort([M, D])
def code(w0, M, D, h, l, d):
	return w0 * math.sqrt((1.0 - (0.25 * (h * (math.pow((M * (D / d)), 2.0) / l)))))
M, D = sort([M, D])
function code(w0, M, D, h, l, d)
	return Float64(w0 * sqrt(Float64(1.0 - Float64(0.25 * Float64(h * Float64((Float64(M * Float64(D / d)) ^ 2.0) / l))))))
end
M, D = num2cell(sort([M, D])){:}
function tmp = code(w0, M, D, h, l, d)
	tmp = w0 * sqrt((1.0 - (0.25 * (h * (((M * (D / d)) ^ 2.0) / l)))));
end
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[(h * N[(N[Power[N[(M * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
w0 \cdot \sqrt{1 - 0.25 \cdot \left(h \cdot \frac{{\left(M \cdot \frac{D}{d}\right)}^{2}}{\ell}\right)}
\end{array}
Derivation
  1. Initial program 78.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 80.4% accurate, 1.9× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 5: 75.9% accurate, 8.6× speedup?

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

      1. Initial program 81.5%

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

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

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

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

      if -5.79999999999999975e107 < d < 1.85000000000000005e99

      1. Initial program 76.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      Alternative 6: 69.5% accurate, 9.4× speedup?

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

        1. Initial program 68.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.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        if -1.90000000000000012e203 < M

        1. Initial program 79.6%

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

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

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

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

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

      Alternative 7: 69.9% accurate, 9.4× speedup?

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

        1. Initial program 68.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.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        if -2.4000000000000002e202 < M

        1. Initial program 79.6%

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

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

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

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

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

      Alternative 8: 67.5% accurate, 216.0× speedup?

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

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

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

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

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

        \[\leadsto w0 \]

      Reproduce

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