Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 81.8% → 87.7%
Time: 16.9s
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.8% accurate, 1.0× speedup?

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

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

Alternative 1: 87.7% accurate, 0.2× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ [w0, M, D, h, l, d_m] = \mathsf{sort}([w0, M, D, h, l, d_m])\\ \\ \begin{array}{l} \mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d_m}\right)}^{2} \leq 5 \cdot 10^{+220}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{{\left(0.5 \cdot \frac{D}{\frac{d_m}{M}}\right)}^{2} \cdot h}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;{\left(\sqrt[3]{w0} \cdot {\left(e^{0.16666666666666666}\right)}^{\left(\mathsf{fma}\left(-2, \log d_m, \log \left(-0.25 \cdot \frac{h \cdot {\left(M \cdot D\right)}^{2}}{\ell}\right)\right)\right)}\right)}^{3}\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
NOTE: w0, M, D, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0 M D h l d_m)
 :precision binary64
 (if (<= (pow (/ (* M D) (* 2.0 d_m)) 2.0) 5e+220)
   (* w0 (sqrt (- 1.0 (/ (* (pow (* 0.5 (/ D (/ d_m M))) 2.0) h) l))))
   (pow
    (*
     (cbrt w0)
     (pow
      (exp 0.16666666666666666)
      (fma -2.0 (log d_m) (log (* -0.25 (/ (* h (pow (* M D) 2.0)) l))))))
    3.0)))
d_m = fabs(d);
assert(w0 < M && M < D && D < h && h < l && l < d_m);
double code(double w0, double M, double D, double h, double l, double d_m) {
	double tmp;
	if (pow(((M * D) / (2.0 * d_m)), 2.0) <= 5e+220) {
		tmp = w0 * sqrt((1.0 - ((pow((0.5 * (D / (d_m / M))), 2.0) * h) / l)));
	} else {
		tmp = pow((cbrt(w0) * pow(exp(0.16666666666666666), fma(-2.0, log(d_m), log((-0.25 * ((h * pow((M * D), 2.0)) / l)))))), 3.0);
	}
	return tmp;
}
d_m = abs(d)
w0, M, D, h, l, d_m = sort([w0, M, D, h, l, d_m])
function code(w0, M, D, h, l, d_m)
	tmp = 0.0
	if ((Float64(Float64(M * D) / Float64(2.0 * d_m)) ^ 2.0) <= 5e+220)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64((Float64(0.5 * Float64(D / Float64(d_m / M))) ^ 2.0) * h) / l))));
	else
		tmp = Float64(cbrt(w0) * (exp(0.16666666666666666) ^ fma(-2.0, log(d_m), log(Float64(-0.25 * Float64(Float64(h * (Float64(M * D) ^ 2.0)) / l)))))) ^ 3.0;
	end
	return tmp
end
d_m = N[Abs[d], $MachinePrecision]
NOTE: w0, M, D, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0_, M_, D_, h_, l_, d$95$m_] := If[LessEqual[N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], 5e+220], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[Power[N[(0.5 * N[(D / N[(d$95$m / M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Power[N[(N[Power[w0, 1/3], $MachinePrecision] * N[Power[N[Exp[0.16666666666666666], $MachinePrecision], N[(-2.0 * N[Log[d$95$m], $MachinePrecision] + N[Log[N[(-0.25 * N[(N[(h * N[Power[N[(M * D), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision]]
\begin{array}{l}
d_m = \left|d\right|
\\
[w0, M, D, h, l, d_m] = \mathsf{sort}([w0, M, D, h, l, d_m])\\
\\
\begin{array}{l}
\mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d_m}\right)}^{2} \leq 5 \cdot 10^{+220}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{{\left(0.5 \cdot \frac{D}{\frac{d_m}{M}}\right)}^{2} \cdot h}{\ell}}\\

\mathbf{else}:\\
\;\;\;\;{\left(\sqrt[3]{w0} \cdot {\left(e^{0.16666666666666666}\right)}^{\left(\mathsf{fma}\left(-2, \log d_m, \log \left(-0.25 \cdot \frac{h \cdot {\left(M \cdot D\right)}^{2}}{\ell}\right)\right)\right)}\right)}^{3}\\


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

    1. Initial program 91.5%

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.0000000000000002e220 < (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)

    1. Initial program 50.3%

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

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

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

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

        \[\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*55.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*55.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-eval55.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}} \]
    4. Applied egg-rr55.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}}} \]
    5. Step-by-step derivation
      1. add-sqr-sqrt24.4%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto {\color{blue}{\left({\left(1 \cdot w0\right)}^{0.3333333333333333} \cdot e^{0.16666666666666666 \cdot \left(\log \left(-0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{\ell}\right) + -2 \cdot \log d\right)}\right)}}^{3} \]
    10. Step-by-step derivation
      1. unpow1/331.3%

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

        \[\leadsto {\left(\sqrt[3]{\color{blue}{w0}} \cdot e^{0.16666666666666666 \cdot \left(\log \left(-0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{\ell}\right) + -2 \cdot \log d\right)}\right)}^{3} \]
      3. exp-prod31.0%

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

        \[\leadsto {\left(\sqrt[3]{w0} \cdot {\left(e^{0.16666666666666666}\right)}^{\color{blue}{\left(-2 \cdot \log d + \log \left(-0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{\ell}\right)\right)}}\right)}^{3} \]
      5. fma-def31.0%

        \[\leadsto {\left(\sqrt[3]{w0} \cdot {\left(e^{0.16666666666666666}\right)}^{\color{blue}{\left(\mathsf{fma}\left(-2, \log d, \log \left(-0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{\ell}\right)\right)\right)}}\right)}^{3} \]
      6. distribute-lft-neg-in31.0%

        \[\leadsto {\left(\sqrt[3]{w0} \cdot {\left(e^{0.16666666666666666}\right)}^{\left(\mathsf{fma}\left(-2, \log d, \log \color{blue}{\left(\left(-0.25\right) \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{\ell}\right)}\right)\right)}\right)}^{3} \]
      7. metadata-eval31.0%

        \[\leadsto {\left(\sqrt[3]{w0} \cdot {\left(e^{0.16666666666666666}\right)}^{\left(\mathsf{fma}\left(-2, \log d, \log \left(\color{blue}{-0.25} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{\ell}\right)\right)\right)}\right)}^{3} \]
      8. associate-*r*29.8%

        \[\leadsto {\left(\sqrt[3]{w0} \cdot {\left(e^{0.16666666666666666}\right)}^{\left(\mathsf{fma}\left(-2, \log d, \log \left(-0.25 \cdot \frac{\color{blue}{\left({D}^{2} \cdot {M}^{2}\right) \cdot h}}{\ell}\right)\right)\right)}\right)}^{3} \]
      9. *-commutative29.8%

        \[\leadsto {\left(\sqrt[3]{w0} \cdot {\left(e^{0.16666666666666666}\right)}^{\left(\mathsf{fma}\left(-2, \log d, \log \left(-0.25 \cdot \frac{\color{blue}{\left({M}^{2} \cdot {D}^{2}\right)} \cdot h}{\ell}\right)\right)\right)}\right)}^{3} \]
      10. unpow229.8%

        \[\leadsto {\left(\sqrt[3]{w0} \cdot {\left(e^{0.16666666666666666}\right)}^{\left(\mathsf{fma}\left(-2, \log d, \log \left(-0.25 \cdot \frac{\left(\color{blue}{\left(M \cdot M\right)} \cdot {D}^{2}\right) \cdot h}{\ell}\right)\right)\right)}\right)}^{3} \]
      11. unpow229.8%

        \[\leadsto {\left(\sqrt[3]{w0} \cdot {\left(e^{0.16666666666666666}\right)}^{\left(\mathsf{fma}\left(-2, \log d, \log \left(-0.25 \cdot \frac{\left(\left(M \cdot M\right) \cdot \color{blue}{\left(D \cdot D\right)}\right) \cdot h}{\ell}\right)\right)\right)}\right)}^{3} \]
      12. swap-sqr38.3%

        \[\leadsto {\left(\sqrt[3]{w0} \cdot {\left(e^{0.16666666666666666}\right)}^{\left(\mathsf{fma}\left(-2, \log d, \log \left(-0.25 \cdot \frac{\color{blue}{\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right)} \cdot h}{\ell}\right)\right)\right)}\right)}^{3} \]
      13. unpow238.3%

        \[\leadsto {\left(\sqrt[3]{w0} \cdot {\left(e^{0.16666666666666666}\right)}^{\left(\mathsf{fma}\left(-2, \log d, \log \left(-0.25 \cdot \frac{\color{blue}{{\left(M \cdot D\right)}^{2}} \cdot h}{\ell}\right)\right)\right)}\right)}^{3} \]
      14. *-commutative38.3%

        \[\leadsto {\left(\sqrt[3]{w0} \cdot {\left(e^{0.16666666666666666}\right)}^{\left(\mathsf{fma}\left(-2, \log d, \log \left(-0.25 \cdot \frac{{\color{blue}{\left(D \cdot M\right)}}^{2} \cdot h}{\ell}\right)\right)\right)}\right)}^{3} \]
    11. Simplified38.3%

      \[\leadsto {\color{blue}{\left(\sqrt[3]{w0} \cdot {\left(e^{0.16666666666666666}\right)}^{\left(\mathsf{fma}\left(-2, \log d, \log \left(-0.25 \cdot \frac{{\left(D \cdot M\right)}^{2} \cdot h}{\ell}\right)\right)\right)}\right)}}^{3} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification80.9%

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

Alternative 2: 86.8% accurate, 1.0× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ [w0, M, D, h, l, d_m] = \mathsf{sort}([w0, M, D, h, l, d_m])\\ \\ w0 \cdot \sqrt{1 - h \cdot \frac{0.25}{\frac{\ell}{{\left(\frac{D}{\frac{d_m}{M}}\right)}^{2}}}} \end{array} \]
d_m = (fabs.f64 d)
NOTE: w0, M, D, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0 M D h l d_m)
 :precision binary64
 (* w0 (sqrt (- 1.0 (* h (/ 0.25 (/ l (pow (/ D (/ d_m M)) 2.0))))))))
d_m = fabs(d);
assert(w0 < M && M < D && D < h && h < l && l < d_m);
double code(double w0, double M, double D, double h, double l, double d_m) {
	return w0 * sqrt((1.0 - (h * (0.25 / (l / pow((D / (d_m / M)), 2.0))))));
}
d_m = abs(d)
NOTE: w0, M, D, h, l, and d_m should be sorted in increasing order before calling this function.
real(8) function code(w0, m, d, h, l, d_m)
    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_m
    code = w0 * sqrt((1.0d0 - (h * (0.25d0 / (l / ((d / (d_m / m)) ** 2.0d0))))))
end function
d_m = Math.abs(d);
assert w0 < M && M < D && D < h && h < l && l < d_m;
public static double code(double w0, double M, double D, double h, double l, double d_m) {
	return w0 * Math.sqrt((1.0 - (h * (0.25 / (l / Math.pow((D / (d_m / M)), 2.0))))));
}
d_m = math.fabs(d)
[w0, M, D, h, l, d_m] = sort([w0, M, D, h, l, d_m])
def code(w0, M, D, h, l, d_m):
	return w0 * math.sqrt((1.0 - (h * (0.25 / (l / math.pow((D / (d_m / M)), 2.0))))))
d_m = abs(d)
w0, M, D, h, l, d_m = sort([w0, M, D, h, l, d_m])
function code(w0, M, D, h, l, d_m)
	return Float64(w0 * sqrt(Float64(1.0 - Float64(h * Float64(0.25 / Float64(l / (Float64(D / Float64(d_m / M)) ^ 2.0)))))))
end
d_m = abs(d);
w0, M, D, h, l, d_m = num2cell(sort([w0, M, D, h, l, d_m])){:}
function tmp = code(w0, M, D, h, l, d_m)
	tmp = w0 * sqrt((1.0 - (h * (0.25 / (l / ((D / (d_m / M)) ^ 2.0))))));
end
d_m = N[Abs[d], $MachinePrecision]
NOTE: w0, M, D, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0_, M_, D_, h_, l_, d$95$m_] := N[(w0 * N[Sqrt[N[(1.0 - N[(h * N[(0.25 / N[(l / N[Power[N[(D / N[(d$95$m / M), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
d_m = \left|d\right|
\\
[w0, M, D, h, l, d_m] = \mathsf{sort}([w0, M, D, h, l, d_m])\\
\\
w0 \cdot \sqrt{1 - h \cdot \frac{0.25}{\frac{\ell}{{\left(\frac{D}{\frac{d_m}{M}}\right)}^{2}}}}
\end{array}
Derivation
  1. Initial program 80.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto w0 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\sqrt{1 - h \cdot \frac{{\left(0.5 \cdot \left(D \cdot \frac{M}{d}\right)\right)}^{2}}{\ell}}\right)} - 1\right)} \]
    3. unpow-prod-down84.0%

      \[\leadsto w0 \cdot \left(e^{\mathsf{log1p}\left(\sqrt{1 - h \cdot \frac{\color{blue}{{0.5}^{2} \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}}}{\ell}}\right)} - 1\right) \]
    4. metadata-eval84.0%

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

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

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

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

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

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

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

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

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

Alternative 3: 86.8% accurate, 1.0× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ [w0, M, D, h, l, d_m] = \mathsf{sort}([w0, M, D, h, l, d_m])\\ \\ w0 \cdot \sqrt{1 - \frac{{\left(0.5 \cdot \frac{D}{\frac{d_m}{M}}\right)}^{2} \cdot h}{\ell}} \end{array} \]
d_m = (fabs.f64 d)
NOTE: w0, M, D, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0 M D h l d_m)
 :precision binary64
 (* w0 (sqrt (- 1.0 (/ (* (pow (* 0.5 (/ D (/ d_m M))) 2.0) h) l)))))
d_m = fabs(d);
assert(w0 < M && M < D && D < h && h < l && l < d_m);
double code(double w0, double M, double D, double h, double l, double d_m) {
	return w0 * sqrt((1.0 - ((pow((0.5 * (D / (d_m / M))), 2.0) * h) / l)));
}
d_m = abs(d)
NOTE: w0, M, D, h, l, and d_m should be sorted in increasing order before calling this function.
real(8) function code(w0, m, d, h, l, d_m)
    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_m
    code = w0 * sqrt((1.0d0 - ((((0.5d0 * (d / (d_m / m))) ** 2.0d0) * h) / l)))
end function
d_m = Math.abs(d);
assert w0 < M && M < D && D < h && h < l && l < d_m;
public static double code(double w0, double M, double D, double h, double l, double d_m) {
	return w0 * Math.sqrt((1.0 - ((Math.pow((0.5 * (D / (d_m / M))), 2.0) * h) / l)));
}
d_m = math.fabs(d)
[w0, M, D, h, l, d_m] = sort([w0, M, D, h, l, d_m])
def code(w0, M, D, h, l, d_m):
	return w0 * math.sqrt((1.0 - ((math.pow((0.5 * (D / (d_m / M))), 2.0) * h) / l)))
d_m = abs(d)
w0, M, D, h, l, d_m = sort([w0, M, D, h, l, d_m])
function code(w0, M, D, h, l, d_m)
	return Float64(w0 * sqrt(Float64(1.0 - Float64(Float64((Float64(0.5 * Float64(D / Float64(d_m / M))) ^ 2.0) * h) / l))))
end
d_m = abs(d);
w0, M, D, h, l, d_m = num2cell(sort([w0, M, D, h, l, d_m])){:}
function tmp = code(w0, M, D, h, l, d_m)
	tmp = w0 * sqrt((1.0 - ((((0.5 * (D / (d_m / M))) ^ 2.0) * h) / l)));
end
d_m = N[Abs[d], $MachinePrecision]
NOTE: w0, M, D, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0_, M_, D_, h_, l_, d$95$m_] := N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[Power[N[(0.5 * N[(D / N[(d$95$m / M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
d_m = \left|d\right|
\\
[w0, M, D, h, l, d_m] = \mathsf{sort}([w0, M, D, h, l, d_m])\\
\\
w0 \cdot \sqrt{1 - \frac{{\left(0.5 \cdot \frac{D}{\frac{d_m}{M}}\right)}^{2} \cdot h}{\ell}}
\end{array}
Derivation
  1. Initial program 80.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 77.2% accurate, 1.8× speedup?

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

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


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

    1. Initial program 76.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 + -0.125 \cdot \left(e^{\mathsf{log1p}\left({\left(M \cdot \frac{D}{d}\right)}^{2} \cdot \color{blue}{\frac{h}{\frac{\ell}{w0}}}\right)} - 1\right) \]
    10. Applied egg-rr53.4%

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

        \[\leadsto w0 + -0.125 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(M \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\frac{\ell}{w0}}\right)\right)} \]
      2. expm1-log1p65.2%

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

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

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

    if -9.99999999999948e-312 < (/.f64 h l)

    1. Initial program 86.0%

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

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

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

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

Alternative 5: 78.3% accurate, 1.8× speedup?

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

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


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

    1. Initial program 75.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.94066e-324 < (/.f64 h l)

    1. Initial program 86.7%

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

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

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

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

Alternative 6: 73.4% accurate, 1.8× speedup?

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

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


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

    1. Initial program 81.5%

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

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

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

    if 2.60000000000000007e122 < D

    1. Initial program 70.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 70.4% accurate, 9.4× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ [w0, M, D, h, l, d_m] = \mathsf{sort}([w0, M, D, h, l, d_m])\\ \\ \begin{array}{l} t_0 := M \cdot \frac{D}{d_m}\\ \mathbf{if}\;M \leq 1.8 \cdot 10^{-94}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;w0 + -0.125 \cdot \left(\frac{w0 \cdot h}{\ell} \cdot \left(t_0 \cdot t_0\right)\right)\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
NOTE: w0, M, D, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0 M D h l d_m)
 :precision binary64
 (let* ((t_0 (* M (/ D d_m))))
   (if (<= M 1.8e-94) w0 (+ w0 (* -0.125 (* (/ (* w0 h) l) (* t_0 t_0)))))))
d_m = fabs(d);
assert(w0 < M && M < D && D < h && h < l && l < d_m);
double code(double w0, double M, double D, double h, double l, double d_m) {
	double t_0 = M * (D / d_m);
	double tmp;
	if (M <= 1.8e-94) {
		tmp = w0;
	} else {
		tmp = w0 + (-0.125 * (((w0 * h) / l) * (t_0 * t_0)));
	}
	return tmp;
}
d_m = abs(d)
NOTE: w0, M, D, h, l, and d_m should be sorted in increasing order before calling this function.
real(8) function code(w0, m, d, h, l, d_m)
    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_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = m * (d / d_m)
    if (m <= 1.8d-94) then
        tmp = w0
    else
        tmp = w0 + ((-0.125d0) * (((w0 * h) / l) * (t_0 * t_0)))
    end if
    code = tmp
end function
d_m = Math.abs(d);
assert w0 < M && M < D && D < h && h < l && l < d_m;
public static double code(double w0, double M, double D, double h, double l, double d_m) {
	double t_0 = M * (D / d_m);
	double tmp;
	if (M <= 1.8e-94) {
		tmp = w0;
	} else {
		tmp = w0 + (-0.125 * (((w0 * h) / l) * (t_0 * t_0)));
	}
	return tmp;
}
d_m = math.fabs(d)
[w0, M, D, h, l, d_m] = sort([w0, M, D, h, l, d_m])
def code(w0, M, D, h, l, d_m):
	t_0 = M * (D / d_m)
	tmp = 0
	if M <= 1.8e-94:
		tmp = w0
	else:
		tmp = w0 + (-0.125 * (((w0 * h) / l) * (t_0 * t_0)))
	return tmp
d_m = abs(d)
w0, M, D, h, l, d_m = sort([w0, M, D, h, l, d_m])
function code(w0, M, D, h, l, d_m)
	t_0 = Float64(M * Float64(D / d_m))
	tmp = 0.0
	if (M <= 1.8e-94)
		tmp = w0;
	else
		tmp = Float64(w0 + Float64(-0.125 * Float64(Float64(Float64(w0 * h) / l) * Float64(t_0 * t_0))));
	end
	return tmp
end
d_m = abs(d);
w0, M, D, h, l, d_m = num2cell(sort([w0, M, D, h, l, d_m])){:}
function tmp_2 = code(w0, M, D, h, l, d_m)
	t_0 = M * (D / d_m);
	tmp = 0.0;
	if (M <= 1.8e-94)
		tmp = w0;
	else
		tmp = w0 + (-0.125 * (((w0 * h) / l) * (t_0 * t_0)));
	end
	tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
NOTE: w0, M, D, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0_, M_, D_, h_, l_, d$95$m_] := Block[{t$95$0 = N[(M * N[(D / d$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[M, 1.8e-94], w0, N[(w0 + N[(-0.125 * N[(N[(N[(w0 * h), $MachinePrecision] / l), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
d_m = \left|d\right|
\\
[w0, M, D, h, l, d_m] = \mathsf{sort}([w0, M, D, h, l, d_m])\\
\\
\begin{array}{l}
t_0 := M \cdot \frac{D}{d_m}\\
\mathbf{if}\;M \leq 1.8 \cdot 10^{-94}:\\
\;\;\;\;w0\\

\mathbf{else}:\\
\;\;\;\;w0 + -0.125 \cdot \left(\frac{w0 \cdot h}{\ell} \cdot \left(t_0 \cdot t_0\right)\right)\\


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

    1. Initial program 82.0%

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

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

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

    if 1.8e-94 < M

    1. Initial program 76.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 68.2% accurate, 216.0× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ [w0, M, D, h, l, d_m] = \mathsf{sort}([w0, M, D, h, l, d_m])\\ \\ w0 \end{array} \]
d_m = (fabs.f64 d)
NOTE: w0, M, D, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0 M D h l d_m) :precision binary64 w0)
d_m = fabs(d);
assert(w0 < M && M < D && D < h && h < l && l < d_m);
double code(double w0, double M, double D, double h, double l, double d_m) {
	return w0;
}
d_m = abs(d)
NOTE: w0, M, D, h, l, and d_m should be sorted in increasing order before calling this function.
real(8) function code(w0, m, d, h, l, d_m)
    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_m
    code = w0
end function
d_m = Math.abs(d);
assert w0 < M && M < D && D < h && h < l && l < d_m;
public static double code(double w0, double M, double D, double h, double l, double d_m) {
	return w0;
}
d_m = math.fabs(d)
[w0, M, D, h, l, d_m] = sort([w0, M, D, h, l, d_m])
def code(w0, M, D, h, l, d_m):
	return w0
d_m = abs(d)
w0, M, D, h, l, d_m = sort([w0, M, D, h, l, d_m])
function code(w0, M, D, h, l, d_m)
	return w0
end
d_m = abs(d);
w0, M, D, h, l, d_m = num2cell(sort([w0, M, D, h, l, d_m])){:}
function tmp = code(w0, M, D, h, l, d_m)
	tmp = w0;
end
d_m = N[Abs[d], $MachinePrecision]
NOTE: w0, M, D, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0_, M_, D_, h_, l_, d$95$m_] := w0
\begin{array}{l}
d_m = \left|d\right|
\\
[w0, M, D, h, l, d_m] = \mathsf{sort}([w0, M, D, h, l, d_m])\\
\\
w0
\end{array}
Derivation
  1. Initial program 80.2%

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

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

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

    \[\leadsto w0 \]

Reproduce

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