Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 81.1% → 89.9%
Time: 19.1s
Alternatives: 7
Speedup: 1.7×

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 7 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.1% accurate, 1.0× speedup?

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

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

Alternative 1: 89.9% accurate, 0.2× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ d_m = \left|d\right| \\ [w0, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0, M_m, D_m, h, l, d_m])\\ \\ \begin{array}{l} t_0 := {\left(\frac{M_m \cdot D_m}{2 \cdot d_m}\right)}^{2} \cdot \frac{h}{\ell}\\ \mathbf{if}\;t_0 \leq -\infty:\\ \;\;\;\;{\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_m \cdot D_m\right)}^{2}}{\ell}\right)\right)\right)}\right)}^{3}\\ \mathbf{elif}\;t_0 \leq 2 \cdot 10^{-46}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(\frac{D_m}{2} \cdot \frac{M_m}{d_m}\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{M_m}{\frac{\ell}{\frac{D_m \cdot 0.5}{d_m}}} \cdot \frac{M_m}{\frac{\frac{1}{h}}{D_m \cdot \frac{0.5}{d_m}}}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d_m)
 :precision binary64
 (let* ((t_0 (* (pow (/ (* M_m D_m) (* 2.0 d_m)) 2.0) (/ h l))))
   (if (<= t_0 (- INFINITY))
     (pow
      (*
       (cbrt w0)
       (pow
        (exp 0.16666666666666666)
        (fma
         -2.0
         (log d_m)
         (log (* -0.25 (/ (* h (pow (* M_m D_m) 2.0)) l))))))
      3.0)
     (if (<= t_0 2e-46)
       (* w0 (sqrt (- 1.0 (* (/ h l) (pow (* (/ D_m 2.0) (/ M_m d_m)) 2.0)))))
       (*
        w0
        (sqrt
         (-
          1.0
          (*
           (/ M_m (/ l (/ (* D_m 0.5) d_m)))
           (/ M_m (/ (/ 1.0 h) (* D_m (/ 0.5 d_m))))))))))))
M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
	double t_0 = pow(((M_m * D_m) / (2.0 * d_m)), 2.0) * (h / l);
	double tmp;
	if (t_0 <= -((double) INFINITY)) {
		tmp = pow((cbrt(w0) * pow(exp(0.16666666666666666), fma(-2.0, log(d_m), log((-0.25 * ((h * pow((M_m * D_m), 2.0)) / l)))))), 3.0);
	} else if (t_0 <= 2e-46) {
		tmp = w0 * sqrt((1.0 - ((h / l) * pow(((D_m / 2.0) * (M_m / d_m)), 2.0))));
	} else {
		tmp = w0 * sqrt((1.0 - ((M_m / (l / ((D_m * 0.5) / d_m))) * (M_m / ((1.0 / h) / (D_m * (0.5 / d_m)))))));
	}
	return tmp;
}
M_m = abs(M)
D_m = abs(D)
d_m = abs(d)
w0, M_m, D_m, h, l, d_m = sort([w0, M_m, D_m, h, l, d_m])
function code(w0, M_m, D_m, h, l, d_m)
	t_0 = Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d_m)) ^ 2.0) * Float64(h / l))
	tmp = 0.0
	if (t_0 <= Float64(-Inf))
		tmp = Float64(cbrt(w0) * (exp(0.16666666666666666) ^ fma(-2.0, log(d_m), log(Float64(-0.25 * Float64(Float64(h * (Float64(M_m * D_m) ^ 2.0)) / l)))))) ^ 3.0;
	elseif (t_0 <= 2e-46)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h / l) * (Float64(Float64(D_m / 2.0) * Float64(M_m / d_m)) ^ 2.0)))));
	else
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(M_m / Float64(l / Float64(Float64(D_m * 0.5) / d_m))) * Float64(M_m / Float64(Float64(1.0 / h) / Float64(D_m * Float64(0.5 / d_m))))))));
	end
	return tmp
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := Block[{t$95$0 = N[(N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], 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$95$m * D$95$m), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision], If[LessEqual[t$95$0, 2e-46], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D$95$m / 2.0), $MachinePrecision] * N[(M$95$m / d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(M$95$m / N[(l / N[(N[(D$95$m * 0.5), $MachinePrecision] / d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(M$95$m / N[(N[(1.0 / h), $MachinePrecision] / N[(D$95$m * N[(0.5 / d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
[w0, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0, M_m, D_m, h, l, d_m])\\
\\
\begin{array}{l}
t_0 := {\left(\frac{M_m \cdot D_m}{2 \cdot d_m}\right)}^{2} \cdot \frac{h}{\ell}\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;{\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_m \cdot D_m\right)}^{2}}{\ell}\right)\right)\right)}\right)}^{3}\\

\mathbf{elif}\;t_0 \leq 2 \cdot 10^{-46}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(\frac{D_m}{2} \cdot \frac{M_m}{d_m}\right)}^{2}}\\

\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{M_m}{\frac{\ell}{\frac{D_m \cdot 0.5}{d_m}}} \cdot \frac{M_m}{\frac{\frac{1}{h}}{D_m \cdot \frac{0.5}{d_m}}}}\\


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

    1. Initial program 55.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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} \]
    11. Step-by-step derivation
      1. unpow1/331.0%

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

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

        \[\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. +-commutative30.9%

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

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

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

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

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

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

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

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

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

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

        \[\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}{h \cdot {\left(M \cdot D\right)}^{2}}}{\ell}\right)\right)\right)}\right)}^{3} \]
      15. *-commutative35.5%

        \[\leadsto {\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 {\color{blue}{\left(D \cdot M\right)}}^{2}}{\ell}\right)\right)\right)}\right)}^{3} \]
    12. Simplified35.5%

      \[\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{h \cdot {\left(D \cdot M\right)}^{2}}{\ell}\right)\right)\right)}\right)}}^{3} \]

    if -inf.0 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)) < 2.00000000000000005e-46

    1. Initial program 99.4%

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

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

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

    1. Initial program 9.9%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\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)}}{\frac{\ell}{h}}} \]
      2. div-inv20.0%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\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)}{\color{blue}{\ell \cdot \frac{1}{h}}}} \]
      3. times-frac77.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M}{\frac{\ell}{\frac{D \cdot 0.5}{d}}} \cdot \frac{M \cdot \color{blue}{\frac{D \cdot 0.5}{d}}}{\frac{1}{h}}} \]
      8. associate-/l*80.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M}{\frac{\ell}{\frac{D \cdot 0.5}{d}}} \cdot \color{blue}{\frac{M}{\frac{\frac{1}{h}}{\frac{D \cdot 0.5}{d}}}}} \]
      9. associate-*r/80.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M}{\frac{\ell}{\frac{D \cdot 0.5}{d}}} \cdot \frac{M}{\frac{\frac{1}{h}}{\color{blue}{D \cdot \frac{0.5}{d}}}}} \]
    11. Applied egg-rr80.7%

      \[\leadsto w0 \cdot \sqrt{1 - \frac{M}{\frac{\ell}{\frac{D \cdot 0.5}{d}}} \cdot \color{blue}{\frac{M}{\frac{\frac{1}{h}}{D \cdot \frac{0.5}{d}}}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification81.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -\infty:\\ \;\;\;\;{\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}\\ \mathbf{elif}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq 2 \cdot 10^{-46}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{M}{\frac{\ell}{\frac{D \cdot 0.5}{d}}} \cdot \frac{M}{\frac{\frac{1}{h}}{D \cdot \frac{0.5}{d}}}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 89.1% accurate, 0.6× speedup?

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

\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{M_m \cdot \frac{D_m \cdot 0.5}{d_m}}{\ell} \cdot \frac{M_m \cdot \left(D_m \cdot \frac{0.5}{d_m}\right)}{\frac{1}{h}}}\\


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

    1. Initial program 99.4%

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

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

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

    1. Initial program 44.2%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\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)}}{\frac{\ell}{h}}} \]
      2. div-inv47.3%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\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)}{\color{blue}{\ell \cdot \frac{1}{h}}}} \]
      3. times-frac71.2%

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

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

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

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{e^{\mathsf{log1p}\left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)} - 1}}{\ell} \cdot \frac{M \cdot \left(D \cdot \frac{0.5}{d}\right)}{\frac{1}{h}}} \]
    9. Applied egg-rr43.1%

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

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

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

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

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

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

Alternative 3: 83.4% accurate, 1.7× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ d_m = \left|d\right| \\ [w0, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0, M_m, D_m, h, l, d_m])\\ \\ \begin{array}{l} \mathbf{if}\;M_m \leq 2.5 \cdot 10^{-172}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \left(h \cdot \left(M_m \cdot \frac{D_m \cdot 0.5}{d_m}\right)\right) \cdot \frac{M_m}{d_m \cdot \frac{\ell}{D_m \cdot 0.5}}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d_m)
 :precision binary64
 (if (<= M_m 2.5e-172)
   w0
   (*
    w0
    (sqrt
     (-
      1.0
      (*
       (* h (* M_m (/ (* D_m 0.5) d_m)))
       (/ M_m (* d_m (/ l (* D_m 0.5))))))))))
M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
	double tmp;
	if (M_m <= 2.5e-172) {
		tmp = w0;
	} else {
		tmp = w0 * sqrt((1.0 - ((h * (M_m * ((D_m * 0.5) / d_m))) * (M_m / (d_m * (l / (D_m * 0.5)))))));
	}
	return tmp;
}
M_m = abs(M)
D_m = abs(D)
d_m = abs(d)
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d_m_1)
    real(8), intent (in) :: w0
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d_m_1
    real(8) :: tmp
    if (m_m <= 2.5d-172) then
        tmp = w0
    else
        tmp = w0 * sqrt((1.0d0 - ((h * (m_m * ((d_m * 0.5d0) / d_m_1))) * (m_m / (d_m_1 * (l / (d_m * 0.5d0)))))))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
d_m = Math.abs(d);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
	double tmp;
	if (M_m <= 2.5e-172) {
		tmp = w0;
	} else {
		tmp = w0 * Math.sqrt((1.0 - ((h * (M_m * ((D_m * 0.5) / d_m))) * (M_m / (d_m * (l / (D_m * 0.5)))))));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
d_m = math.fabs(d)
[w0, M_m, D_m, h, l, d_m] = sort([w0, M_m, D_m, h, l, d_m])
def code(w0, M_m, D_m, h, l, d_m):
	tmp = 0
	if M_m <= 2.5e-172:
		tmp = w0
	else:
		tmp = w0 * math.sqrt((1.0 - ((h * (M_m * ((D_m * 0.5) / d_m))) * (M_m / (d_m * (l / (D_m * 0.5)))))))
	return tmp
M_m = abs(M)
D_m = abs(D)
d_m = abs(d)
w0, M_m, D_m, h, l, d_m = sort([w0, M_m, D_m, h, l, d_m])
function code(w0, M_m, D_m, h, l, d_m)
	tmp = 0.0
	if (M_m <= 2.5e-172)
		tmp = w0;
	else
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h * Float64(M_m * Float64(Float64(D_m * 0.5) / d_m))) * Float64(M_m / Float64(d_m * Float64(l / Float64(D_m * 0.5))))))));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d_m = abs(d);
w0, M_m, D_m, h, l, d_m = num2cell(sort([w0, M_m, D_m, h, l, d_m])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d_m)
	tmp = 0.0;
	if (M_m <= 2.5e-172)
		tmp = w0;
	else
		tmp = w0 * sqrt((1.0 - ((h * (M_m * ((D_m * 0.5) / d_m))) * (M_m / (d_m * (l / (D_m * 0.5)))))));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := If[LessEqual[M$95$m, 2.5e-172], w0, N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h * N[(M$95$m * N[(N[(D$95$m * 0.5), $MachinePrecision] / d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(M$95$m / N[(d$95$m * N[(l / N[(D$95$m * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
[w0, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0, M_m, D_m, h, l, d_m])\\
\\
\begin{array}{l}
\mathbf{if}\;M_m \leq 2.5 \cdot 10^{-172}:\\
\;\;\;\;w0\\

\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \left(h \cdot \left(M_m \cdot \frac{D_m \cdot 0.5}{d_m}\right)\right) \cdot \frac{M_m}{d_m \cdot \frac{\ell}{D_m \cdot 0.5}}}\\


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

    1. Initial program 83.8%

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

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

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

    if 2.5e-172 < M

    1. Initial program 67.9%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\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)}}{\frac{\ell}{h}}} \]
      2. div-inv69.0%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\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)}{\color{blue}{\ell \cdot \frac{1}{h}}}} \]
      3. times-frac82.4%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 2.5 \cdot 10^{-172}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \left(h \cdot \left(M \cdot \frac{D \cdot 0.5}{d}\right)\right) \cdot \frac{M}{d \cdot \frac{\ell}{D \cdot 0.5}}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 86.2% accurate, 1.7× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ d_m = \left|d\right| \\ [w0, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0, M_m, D_m, h, l, d_m])\\ \\ \begin{array}{l} t_0 := \frac{D_m \cdot 0.5}{d_m}\\ \mathbf{if}\;M_m \leq 3.3 \cdot 10^{-211}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{M_m}{\frac{\ell}{t_0}} \cdot \left(h \cdot \left(M_m \cdot t_0\right)\right)}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d_m)
 :precision binary64
 (let* ((t_0 (/ (* D_m 0.5) d_m)))
   (if (<= M_m 3.3e-211)
     w0
     (* w0 (sqrt (- 1.0 (* (/ M_m (/ l t_0)) (* h (* M_m t_0)))))))))
M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
	double t_0 = (D_m * 0.5) / d_m;
	double tmp;
	if (M_m <= 3.3e-211) {
		tmp = w0;
	} else {
		tmp = w0 * sqrt((1.0 - ((M_m / (l / t_0)) * (h * (M_m * t_0)))));
	}
	return tmp;
}
M_m = abs(M)
D_m = abs(D)
d_m = abs(d)
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d_m_1)
    real(8), intent (in) :: w0
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d_m_1
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (d_m * 0.5d0) / d_m_1
    if (m_m <= 3.3d-211) then
        tmp = w0
    else
        tmp = w0 * sqrt((1.0d0 - ((m_m / (l / t_0)) * (h * (m_m * t_0)))))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
d_m = Math.abs(d);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
	double t_0 = (D_m * 0.5) / d_m;
	double tmp;
	if (M_m <= 3.3e-211) {
		tmp = w0;
	} else {
		tmp = w0 * Math.sqrt((1.0 - ((M_m / (l / t_0)) * (h * (M_m * t_0)))));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
d_m = math.fabs(d)
[w0, M_m, D_m, h, l, d_m] = sort([w0, M_m, D_m, h, l, d_m])
def code(w0, M_m, D_m, h, l, d_m):
	t_0 = (D_m * 0.5) / d_m
	tmp = 0
	if M_m <= 3.3e-211:
		tmp = w0
	else:
		tmp = w0 * math.sqrt((1.0 - ((M_m / (l / t_0)) * (h * (M_m * t_0)))))
	return tmp
M_m = abs(M)
D_m = abs(D)
d_m = abs(d)
w0, M_m, D_m, h, l, d_m = sort([w0, M_m, D_m, h, l, d_m])
function code(w0, M_m, D_m, h, l, d_m)
	t_0 = Float64(Float64(D_m * 0.5) / d_m)
	tmp = 0.0
	if (M_m <= 3.3e-211)
		tmp = w0;
	else
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(M_m / Float64(l / t_0)) * Float64(h * Float64(M_m * t_0))))));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d_m = abs(d);
w0, M_m, D_m, h, l, d_m = num2cell(sort([w0, M_m, D_m, h, l, d_m])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d_m)
	t_0 = (D_m * 0.5) / d_m;
	tmp = 0.0;
	if (M_m <= 3.3e-211)
		tmp = w0;
	else
		tmp = w0 * sqrt((1.0 - ((M_m / (l / t_0)) * (h * (M_m * t_0)))));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := Block[{t$95$0 = N[(N[(D$95$m * 0.5), $MachinePrecision] / d$95$m), $MachinePrecision]}, If[LessEqual[M$95$m, 3.3e-211], w0, N[(w0 * N[Sqrt[N[(1.0 - N[(N[(M$95$m / N[(l / t$95$0), $MachinePrecision]), $MachinePrecision] * N[(h * N[(M$95$m * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
[w0, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0, M_m, D_m, h, l, d_m])\\
\\
\begin{array}{l}
t_0 := \frac{D_m \cdot 0.5}{d_m}\\
\mathbf{if}\;M_m \leq 3.3 \cdot 10^{-211}:\\
\;\;\;\;w0\\

\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{M_m}{\frac{\ell}{t_0}} \cdot \left(h \cdot \left(M_m \cdot t_0\right)\right)}\\


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

    1. Initial program 83.1%

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

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

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

    if 3.3000000000000002e-211 < M

    1. Initial program 71.3%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\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)}}{\frac{\ell}{h}}} \]
      2. div-inv72.3%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\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)}{\color{blue}{\ell \cdot \frac{1}{h}}}} \]
      3. times-frac84.8%

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

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

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

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

        \[\leadsto w0 \cdot \sqrt{1 - \frac{M}{\frac{\ell}{\frac{D \cdot 0.5}{d}}} \cdot \color{blue}{\left(\frac{M \cdot \left(D \cdot \frac{0.5}{d}\right)}{1} \cdot h\right)}} \]
      4. /-rgt-identity84.8%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 3.3 \cdot 10^{-211}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{M}{\frac{\ell}{\frac{D \cdot 0.5}{d}}} \cdot \left(h \cdot \left(M \cdot \frac{D \cdot 0.5}{d}\right)\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 88.4% accurate, 1.7× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ d_m = \left|d\right| \\ [w0, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0, M_m, D_m, h, l, d_m])\\ \\ \begin{array}{l} t_0 := M_m \cdot \left(D_m \cdot \frac{0.5}{d_m}\right)\\ w0 \cdot \sqrt{1 - \frac{t_0}{\frac{1}{h}} \cdot \frac{t_0}{\ell}} \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d_m)
 :precision binary64
 (let* ((t_0 (* M_m (* D_m (/ 0.5 d_m)))))
   (* w0 (sqrt (- 1.0 (* (/ t_0 (/ 1.0 h)) (/ t_0 l)))))))
M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
	double t_0 = M_m * (D_m * (0.5 / d_m));
	return w0 * sqrt((1.0 - ((t_0 / (1.0 / h)) * (t_0 / l))));
}
M_m = abs(M)
D_m = abs(D)
d_m = abs(d)
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d_m_1)
    real(8), intent (in) :: w0
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d_m_1
    real(8) :: t_0
    t_0 = m_m * (d_m * (0.5d0 / d_m_1))
    code = w0 * sqrt((1.0d0 - ((t_0 / (1.0d0 / h)) * (t_0 / l))))
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
d_m = Math.abs(d);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
	double t_0 = M_m * (D_m * (0.5 / d_m));
	return w0 * Math.sqrt((1.0 - ((t_0 / (1.0 / h)) * (t_0 / l))));
}
M_m = math.fabs(M)
D_m = math.fabs(D)
d_m = math.fabs(d)
[w0, M_m, D_m, h, l, d_m] = sort([w0, M_m, D_m, h, l, d_m])
def code(w0, M_m, D_m, h, l, d_m):
	t_0 = M_m * (D_m * (0.5 / d_m))
	return w0 * math.sqrt((1.0 - ((t_0 / (1.0 / h)) * (t_0 / l))))
M_m = abs(M)
D_m = abs(D)
d_m = abs(d)
w0, M_m, D_m, h, l, d_m = sort([w0, M_m, D_m, h, l, d_m])
function code(w0, M_m, D_m, h, l, d_m)
	t_0 = Float64(M_m * Float64(D_m * Float64(0.5 / d_m)))
	return Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(t_0 / Float64(1.0 / h)) * Float64(t_0 / l)))))
end
M_m = abs(M);
D_m = abs(D);
d_m = abs(d);
w0, M_m, D_m, h, l, d_m = num2cell(sort([w0, M_m, D_m, h, l, d_m])){:}
function tmp = code(w0, M_m, D_m, h, l, d_m)
	t_0 = M_m * (D_m * (0.5 / d_m));
	tmp = w0 * sqrt((1.0 - ((t_0 / (1.0 / h)) * (t_0 / l))));
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := Block[{t$95$0 = N[(M$95$m * N[(D$95$m * N[(0.5 / d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(w0 * N[Sqrt[N[(1.0 - N[(N[(t$95$0 / N[(1.0 / h), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
[w0, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0, M_m, D_m, h, l, d_m])\\
\\
\begin{array}{l}
t_0 := M_m \cdot \left(D_m \cdot \frac{0.5}{d_m}\right)\\
w0 \cdot \sqrt{1 - \frac{t_0}{\frac{1}{h}} \cdot \frac{t_0}{\ell}}
\end{array}
\end{array}
Derivation
  1. Initial program 78.7%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto w0 \cdot \sqrt{1 - \frac{\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)}}{\frac{\ell}{h}}} \]
    2. div-inv79.0%

      \[\leadsto w0 \cdot \sqrt{1 - \frac{\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)}{\color{blue}{\ell \cdot \frac{1}{h}}}} \]
    3. times-frac88.0%

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

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

    \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \left(D \cdot \frac{0.5}{d}\right)}{\frac{1}{h}} \cdot \frac{M \cdot \left(D \cdot \frac{0.5}{d}\right)}{\ell}} \]
  9. Add Preprocessing

Alternative 6: 88.4% accurate, 1.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto w0 \cdot \sqrt{1 - \frac{\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)}}{\frac{\ell}{h}}} \]
    2. div-inv79.0%

      \[\leadsto w0 \cdot \sqrt{1 - \frac{\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)}{\color{blue}{\ell \cdot \frac{1}{h}}}} \]
    3. times-frac88.0%

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

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

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

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

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

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

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

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

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

    \[\leadsto w0 \cdot \sqrt{1 - \frac{M \cdot \frac{D \cdot 0.5}{d}}{\ell} \cdot \frac{M \cdot \left(D \cdot \frac{0.5}{d}\right)}{\frac{1}{h}}} \]
  13. Add Preprocessing

Alternative 7: 68.4% accurate, 216.0× speedup?

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

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

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

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

    \[\leadsto w0 \]
  6. Add Preprocessing

Reproduce

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