Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 81.6% → 94.9%
Time: 24.3s
Alternatives: 9
Speedup: 1.8×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 9 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.6% accurate, 1.0× speedup?

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

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

Alternative 1: 94.9% accurate, 0.3× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ d_m = \left|d\right| \\ w0_m = \left|w0\right| \\ w0_s = \mathsf{copysign}\left(1, w0\right) \\ [w0_m, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0_m, M_m, D_m, h, l, d_m])\\ \\ \begin{array}{l} t_0 := \frac{M_m \cdot D_m}{\frac{d_m}{0.5}}\\ w0_s \cdot \begin{array}{l} \mathbf{if}\;{\left(\frac{M_m \cdot D_m}{2 \cdot d_m}\right)}^{2} \cdot \frac{h}{\ell} \leq -\infty:\\ \;\;\;\;{\left(\sqrt{w0_m} \cdot e^{0.25 \cdot \left(\log \left(\frac{h}{\ell} \cdot -0.25\right) + \left(2 \cdot \log D_m + \left(2 \cdot \log M_m + 2 \cdot \log \left(\frac{1}{d_m}\right)\right)\right)\right)}\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;w0_m \cdot \sqrt{1 - \frac{t_0}{\frac{\ell}{h \cdot t_0}}}\\ \end{array} \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
w0_m = (fabs.f64 w0)
w0_s = (copysign.f64 1 w0)
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0_s w0_m M_m D_m h l d_m)
 :precision binary64
 (let* ((t_0 (/ (* M_m D_m) (/ d_m 0.5))))
   (*
    w0_s
    (if (<= (* (pow (/ (* M_m D_m) (* 2.0 d_m)) 2.0) (/ h l)) (- INFINITY))
      (pow
       (*
        (sqrt w0_m)
        (exp
         (*
          0.25
          (+
           (log (* (/ h l) -0.25))
           (+
            (* 2.0 (log D_m))
            (+ (* 2.0 (log M_m)) (* 2.0 (log (/ 1.0 d_m)))))))))
       2.0)
      (* w0_m (sqrt (- 1.0 (/ t_0 (/ l (* h t_0))))))))))
M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
w0_m = fabs(w0);
w0_s = copysign(1.0, w0);
assert(w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
	double t_0 = (M_m * D_m) / (d_m / 0.5);
	double tmp;
	if ((pow(((M_m * D_m) / (2.0 * d_m)), 2.0) * (h / l)) <= -((double) INFINITY)) {
		tmp = pow((sqrt(w0_m) * exp((0.25 * (log(((h / l) * -0.25)) + ((2.0 * log(D_m)) + ((2.0 * log(M_m)) + (2.0 * log((1.0 / d_m))))))))), 2.0);
	} else {
		tmp = w0_m * sqrt((1.0 - (t_0 / (l / (h * t_0)))));
	}
	return w0_s * tmp;
}
M_m = Math.abs(M);
D_m = Math.abs(D);
d_m = Math.abs(d);
w0_m = Math.abs(w0);
w0_s = Math.copySign(1.0, w0);
assert w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
	double t_0 = (M_m * D_m) / (d_m / 0.5);
	double tmp;
	if ((Math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0) * (h / l)) <= -Double.POSITIVE_INFINITY) {
		tmp = Math.pow((Math.sqrt(w0_m) * Math.exp((0.25 * (Math.log(((h / l) * -0.25)) + ((2.0 * Math.log(D_m)) + ((2.0 * Math.log(M_m)) + (2.0 * Math.log((1.0 / d_m))))))))), 2.0);
	} else {
		tmp = w0_m * Math.sqrt((1.0 - (t_0 / (l / (h * t_0)))));
	}
	return w0_s * tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
d_m = math.fabs(d)
w0_m = math.fabs(w0)
w0_s = math.copysign(1.0, w0)
[w0_m, M_m, D_m, h, l, d_m] = sort([w0_m, M_m, D_m, h, l, d_m])
def code(w0_s, w0_m, M_m, D_m, h, l, d_m):
	t_0 = (M_m * D_m) / (d_m / 0.5)
	tmp = 0
	if (math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0) * (h / l)) <= -math.inf:
		tmp = math.pow((math.sqrt(w0_m) * math.exp((0.25 * (math.log(((h / l) * -0.25)) + ((2.0 * math.log(D_m)) + ((2.0 * math.log(M_m)) + (2.0 * math.log((1.0 / d_m))))))))), 2.0)
	else:
		tmp = w0_m * math.sqrt((1.0 - (t_0 / (l / (h * t_0)))))
	return w0_s * tmp
M_m = abs(M)
D_m = abs(D)
d_m = abs(d)
w0_m = abs(w0)
w0_s = copysign(1.0, w0)
w0_m, M_m, D_m, h, l, d_m = sort([w0_m, M_m, D_m, h, l, d_m])
function code(w0_s, w0_m, M_m, D_m, h, l, d_m)
	t_0 = Float64(Float64(M_m * D_m) / Float64(d_m / 0.5))
	tmp = 0.0
	if (Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d_m)) ^ 2.0) * Float64(h / l)) <= Float64(-Inf))
		tmp = Float64(sqrt(w0_m) * exp(Float64(0.25 * Float64(log(Float64(Float64(h / l) * -0.25)) + Float64(Float64(2.0 * log(D_m)) + Float64(Float64(2.0 * log(M_m)) + Float64(2.0 * log(Float64(1.0 / d_m))))))))) ^ 2.0;
	else
		tmp = Float64(w0_m * sqrt(Float64(1.0 - Float64(t_0 / Float64(l / Float64(h * t_0))))));
	end
	return Float64(w0_s * tmp)
end
M_m = abs(M);
D_m = abs(D);
d_m = abs(d);
w0_m = abs(w0);
w0_s = sign(w0) * abs(1.0);
w0_m, M_m, D_m, h, l, d_m = num2cell(sort([w0_m, M_m, D_m, h, l, d_m])){:}
function tmp_2 = code(w0_s, w0_m, M_m, D_m, h, l, d_m)
	t_0 = (M_m * D_m) / (d_m / 0.5);
	tmp = 0.0;
	if (((((M_m * D_m) / (2.0 * d_m)) ^ 2.0) * (h / l)) <= -Inf)
		tmp = (sqrt(w0_m) * exp((0.25 * (log(((h / l) * -0.25)) + ((2.0 * log(D_m)) + ((2.0 * log(M_m)) + (2.0 * log((1.0 / d_m))))))))) ^ 2.0;
	else
		tmp = w0_m * sqrt((1.0 - (t_0 / (l / (h * t_0)))));
	end
	tmp_2 = w0_s * tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
w0_m = N[Abs[w0], $MachinePrecision]
w0_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[w0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0$95$s_, w0$95$m_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := Block[{t$95$0 = N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(d$95$m / 0.5), $MachinePrecision]), $MachinePrecision]}, N[(w0$95$s * If[LessEqual[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], (-Infinity)], N[Power[N[(N[Sqrt[w0$95$m], $MachinePrecision] * N[Exp[N[(0.25 * N[(N[Log[N[(N[(h / l), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision] + N[(N[(2.0 * N[Log[D$95$m], $MachinePrecision]), $MachinePrecision] + N[(N[(2.0 * N[Log[M$95$m], $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[Log[N[(1.0 / d$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], N[(w0$95$m * N[Sqrt[N[(1.0 - N[(t$95$0 / N[(l / N[(h * t$95$0), $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 = \left|w0\right|
\\
w0_s = \mathsf{copysign}\left(1, w0\right)
\\
[w0_m, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0_m, M_m, D_m, h, l, d_m])\\
\\
\begin{array}{l}
t_0 := \frac{M_m \cdot D_m}{\frac{d_m}{0.5}}\\
w0_s \cdot \begin{array}{l}
\mathbf{if}\;{\left(\frac{M_m \cdot D_m}{2 \cdot d_m}\right)}^{2} \cdot \frac{h}{\ell} \leq -\infty:\\
\;\;\;\;{\left(\sqrt{w0_m} \cdot e^{0.25 \cdot \left(\log \left(\frac{h}{\ell} \cdot -0.25\right) + \left(2 \cdot \log D_m + \left(2 \cdot \log M_m + 2 \cdot \log \left(\frac{1}{d_m}\right)\right)\right)\right)}\right)}^{2}\\

\mathbf{else}:\\
\;\;\;\;w0_m \cdot \sqrt{1 - \frac{t_0}{\frac{\ell}{h \cdot t_0}}}\\


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

    1. Initial program 48.0%

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

      \[\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. Applied egg-rr24.6%

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

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

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

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

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

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

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

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

      \[\leadsto {\left(\sqrt{w0} \cdot \color{blue}{e^{0.25 \cdot \left(\log \left(-0.25 \cdot \frac{h}{{d}^{2} \cdot \ell}\right) + \left(2 \cdot \log D + 2 \cdot \log M\right)\right)}}\right)}^{2} \]
    9. Taylor expanded in d around inf 5.3%

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

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

    1. Initial program 91.2%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified91.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. *-commutative91.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{D \cdot \frac{M \cdot 0.5}{d}}{\ell} \cdot \frac{D \cdot \frac{M \cdot 0.5}{d}}{\frac{1}{h}}}} \]
    8. Taylor expanded in D around 0 91.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 \cdot \left(e^{\mathsf{log1p}\left(\sqrt{1 - \frac{\left(D \cdot \frac{M}{\frac{d}{0.5}}\right) \cdot \color{blue}{\left(\left(h \cdot D\right) \cdot \frac{M \cdot 0.5}{d}\right)}}{\ell}}\right)} - 1\right) \]
      6. associate-/l*91.6%

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

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

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

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

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

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

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

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{D \cdot M}{\frac{d}{0.5}}}{\frac{\ell}{h \cdot \color{blue}{\frac{D \cdot M}{\frac{d}{0.5}}}}}} \]
    14. Simplified98.9%

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

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

Alternative 2: 94.8% accurate, 0.3× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ d_m = \left|d\right| \\ w0_m = \left|w0\right| \\ w0_s = \mathsf{copysign}\left(1, w0\right) \\ [w0_m, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0_m, M_m, D_m, h, l, d_m])\\ \\ \begin{array}{l} t_0 := \frac{M_m \cdot D_m}{\frac{d_m}{0.5}}\\ w0_s \cdot \begin{array}{l} \mathbf{if}\;{\left(\frac{M_m \cdot D_m}{2 \cdot d_m}\right)}^{2} \cdot \frac{h}{\ell} \leq -\infty:\\ \;\;\;\;{\left(\sqrt{w0_m} \cdot e^{0.25 \cdot \left(\log \left(\frac{h}{\ell} \cdot -0.25\right) + \left(-2 \cdot \log d_m + \left(2 \cdot \log D_m + 2 \cdot \log M_m\right)\right)\right)}\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;w0_m \cdot \sqrt{1 - \frac{t_0}{\frac{\ell}{h \cdot t_0}}}\\ \end{array} \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
w0_m = (fabs.f64 w0)
w0_s = (copysign.f64 1 w0)
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0_s w0_m M_m D_m h l d_m)
 :precision binary64
 (let* ((t_0 (/ (* M_m D_m) (/ d_m 0.5))))
   (*
    w0_s
    (if (<= (* (pow (/ (* M_m D_m) (* 2.0 d_m)) 2.0) (/ h l)) (- INFINITY))
      (pow
       (*
        (sqrt w0_m)
        (exp
         (*
          0.25
          (+
           (log (* (/ h l) -0.25))
           (+ (* -2.0 (log d_m)) (+ (* 2.0 (log D_m)) (* 2.0 (log M_m))))))))
       2.0)
      (* w0_m (sqrt (- 1.0 (/ t_0 (/ l (* h t_0))))))))))
M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
w0_m = fabs(w0);
w0_s = copysign(1.0, w0);
assert(w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
	double t_0 = (M_m * D_m) / (d_m / 0.5);
	double tmp;
	if ((pow(((M_m * D_m) / (2.0 * d_m)), 2.0) * (h / l)) <= -((double) INFINITY)) {
		tmp = pow((sqrt(w0_m) * exp((0.25 * (log(((h / l) * -0.25)) + ((-2.0 * log(d_m)) + ((2.0 * log(D_m)) + (2.0 * log(M_m)))))))), 2.0);
	} else {
		tmp = w0_m * sqrt((1.0 - (t_0 / (l / (h * t_0)))));
	}
	return w0_s * tmp;
}
M_m = Math.abs(M);
D_m = Math.abs(D);
d_m = Math.abs(d);
w0_m = Math.abs(w0);
w0_s = Math.copySign(1.0, w0);
assert w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
	double t_0 = (M_m * D_m) / (d_m / 0.5);
	double tmp;
	if ((Math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0) * (h / l)) <= -Double.POSITIVE_INFINITY) {
		tmp = Math.pow((Math.sqrt(w0_m) * Math.exp((0.25 * (Math.log(((h / l) * -0.25)) + ((-2.0 * Math.log(d_m)) + ((2.0 * Math.log(D_m)) + (2.0 * Math.log(M_m)))))))), 2.0);
	} else {
		tmp = w0_m * Math.sqrt((1.0 - (t_0 / (l / (h * t_0)))));
	}
	return w0_s * tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
d_m = math.fabs(d)
w0_m = math.fabs(w0)
w0_s = math.copysign(1.0, w0)
[w0_m, M_m, D_m, h, l, d_m] = sort([w0_m, M_m, D_m, h, l, d_m])
def code(w0_s, w0_m, M_m, D_m, h, l, d_m):
	t_0 = (M_m * D_m) / (d_m / 0.5)
	tmp = 0
	if (math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0) * (h / l)) <= -math.inf:
		tmp = math.pow((math.sqrt(w0_m) * math.exp((0.25 * (math.log(((h / l) * -0.25)) + ((-2.0 * math.log(d_m)) + ((2.0 * math.log(D_m)) + (2.0 * math.log(M_m)))))))), 2.0)
	else:
		tmp = w0_m * math.sqrt((1.0 - (t_0 / (l / (h * t_0)))))
	return w0_s * tmp
M_m = abs(M)
D_m = abs(D)
d_m = abs(d)
w0_m = abs(w0)
w0_s = copysign(1.0, w0)
w0_m, M_m, D_m, h, l, d_m = sort([w0_m, M_m, D_m, h, l, d_m])
function code(w0_s, w0_m, M_m, D_m, h, l, d_m)
	t_0 = Float64(Float64(M_m * D_m) / Float64(d_m / 0.5))
	tmp = 0.0
	if (Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d_m)) ^ 2.0) * Float64(h / l)) <= Float64(-Inf))
		tmp = Float64(sqrt(w0_m) * exp(Float64(0.25 * Float64(log(Float64(Float64(h / l) * -0.25)) + Float64(Float64(-2.0 * log(d_m)) + Float64(Float64(2.0 * log(D_m)) + Float64(2.0 * log(M_m)))))))) ^ 2.0;
	else
		tmp = Float64(w0_m * sqrt(Float64(1.0 - Float64(t_0 / Float64(l / Float64(h * t_0))))));
	end
	return Float64(w0_s * tmp)
end
M_m = abs(M);
D_m = abs(D);
d_m = abs(d);
w0_m = abs(w0);
w0_s = sign(w0) * abs(1.0);
w0_m, M_m, D_m, h, l, d_m = num2cell(sort([w0_m, M_m, D_m, h, l, d_m])){:}
function tmp_2 = code(w0_s, w0_m, M_m, D_m, h, l, d_m)
	t_0 = (M_m * D_m) / (d_m / 0.5);
	tmp = 0.0;
	if (((((M_m * D_m) / (2.0 * d_m)) ^ 2.0) * (h / l)) <= -Inf)
		tmp = (sqrt(w0_m) * exp((0.25 * (log(((h / l) * -0.25)) + ((-2.0 * log(d_m)) + ((2.0 * log(D_m)) + (2.0 * log(M_m)))))))) ^ 2.0;
	else
		tmp = w0_m * sqrt((1.0 - (t_0 / (l / (h * t_0)))));
	end
	tmp_2 = w0_s * tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
w0_m = N[Abs[w0], $MachinePrecision]
w0_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[w0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0$95$s_, w0$95$m_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := Block[{t$95$0 = N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(d$95$m / 0.5), $MachinePrecision]), $MachinePrecision]}, N[(w0$95$s * If[LessEqual[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], (-Infinity)], N[Power[N[(N[Sqrt[w0$95$m], $MachinePrecision] * N[Exp[N[(0.25 * N[(N[Log[N[(N[(h / l), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision] + N[(N[(-2.0 * N[Log[d$95$m], $MachinePrecision]), $MachinePrecision] + N[(N[(2.0 * N[Log[D$95$m], $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[Log[M$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], N[(w0$95$m * N[Sqrt[N[(1.0 - N[(t$95$0 / N[(l / N[(h * t$95$0), $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 = \left|w0\right|
\\
w0_s = \mathsf{copysign}\left(1, w0\right)
\\
[w0_m, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0_m, M_m, D_m, h, l, d_m])\\
\\
\begin{array}{l}
t_0 := \frac{M_m \cdot D_m}{\frac{d_m}{0.5}}\\
w0_s \cdot \begin{array}{l}
\mathbf{if}\;{\left(\frac{M_m \cdot D_m}{2 \cdot d_m}\right)}^{2} \cdot \frac{h}{\ell} \leq -\infty:\\
\;\;\;\;{\left(\sqrt{w0_m} \cdot e^{0.25 \cdot \left(\log \left(\frac{h}{\ell} \cdot -0.25\right) + \left(-2 \cdot \log d_m + \left(2 \cdot \log D_m + 2 \cdot \log M_m\right)\right)\right)}\right)}^{2}\\

\mathbf{else}:\\
\;\;\;\;w0_m \cdot \sqrt{1 - \frac{t_0}{\frac{\ell}{h \cdot t_0}}}\\


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

    1. Initial program 48.0%

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

      \[\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. Applied egg-rr24.6%

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 91.2%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified91.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. *-commutative91.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{D \cdot \frac{M \cdot 0.5}{d}}{\ell} \cdot \frac{D \cdot \frac{M \cdot 0.5}{d}}{\frac{1}{h}}}} \]
    8. Taylor expanded in D around 0 91.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 \cdot \left(e^{\mathsf{log1p}\left(\sqrt{1 - \frac{\left(D \cdot \frac{M}{\frac{d}{0.5}}\right) \cdot \color{blue}{\left(\left(h \cdot D\right) \cdot \frac{M \cdot 0.5}{d}\right)}}{\ell}}\right)} - 1\right) \]
      6. associate-/l*91.6%

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

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

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

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

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

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

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

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{D \cdot M}{\frac{d}{0.5}}}{\frac{\ell}{h \cdot \color{blue}{\frac{D \cdot M}{\frac{d}{0.5}}}}}} \]
    14. Simplified98.9%

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

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

Alternative 3: 90.0% accurate, 0.3× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ d_m = \left|d\right| \\ w0_m = \left|w0\right| \\ w0_s = \mathsf{copysign}\left(1, w0\right) \\ [w0_m, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0_m, M_m, D_m, h, l, d_m])\\ \\ \begin{array}{l} t_0 := \frac{M_m \cdot D_m}{\frac{d_m}{0.5}}\\ w0_s \cdot \begin{array}{l} \mathbf{if}\;{\left(\frac{M_m \cdot D_m}{2 \cdot d_m}\right)}^{2} \cdot \frac{h}{\ell} \leq -\infty:\\ \;\;\;\;{\left(\sqrt{w0_m} \cdot e^{0.25 \cdot \left(-2 \cdot \log d_m + \log \left(-0.25 \cdot \frac{h \cdot {\left(M_m \cdot D_m\right)}^{2}}{\ell}\right)\right)}\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;w0_m \cdot \sqrt{1 - \frac{t_0}{\frac{\ell}{h \cdot t_0}}}\\ \end{array} \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
w0_m = (fabs.f64 w0)
w0_s = (copysign.f64 1 w0)
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0_s w0_m M_m D_m h l d_m)
 :precision binary64
 (let* ((t_0 (/ (* M_m D_m) (/ d_m 0.5))))
   (*
    w0_s
    (if (<= (* (pow (/ (* M_m D_m) (* 2.0 d_m)) 2.0) (/ h l)) (- INFINITY))
      (pow
       (*
        (sqrt w0_m)
        (exp
         (*
          0.25
          (+
           (* -2.0 (log d_m))
           (log (* -0.25 (/ (* h (pow (* M_m D_m) 2.0)) l)))))))
       2.0)
      (* w0_m (sqrt (- 1.0 (/ t_0 (/ l (* h t_0))))))))))
M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
w0_m = fabs(w0);
w0_s = copysign(1.0, w0);
assert(w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
	double t_0 = (M_m * D_m) / (d_m / 0.5);
	double tmp;
	if ((pow(((M_m * D_m) / (2.0 * d_m)), 2.0) * (h / l)) <= -((double) INFINITY)) {
		tmp = pow((sqrt(w0_m) * exp((0.25 * ((-2.0 * log(d_m)) + log((-0.25 * ((h * pow((M_m * D_m), 2.0)) / l))))))), 2.0);
	} else {
		tmp = w0_m * sqrt((1.0 - (t_0 / (l / (h * t_0)))));
	}
	return w0_s * tmp;
}
M_m = Math.abs(M);
D_m = Math.abs(D);
d_m = Math.abs(d);
w0_m = Math.abs(w0);
w0_s = Math.copySign(1.0, w0);
assert w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
	double t_0 = (M_m * D_m) / (d_m / 0.5);
	double tmp;
	if ((Math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0) * (h / l)) <= -Double.POSITIVE_INFINITY) {
		tmp = Math.pow((Math.sqrt(w0_m) * Math.exp((0.25 * ((-2.0 * Math.log(d_m)) + Math.log((-0.25 * ((h * Math.pow((M_m * D_m), 2.0)) / l))))))), 2.0);
	} else {
		tmp = w0_m * Math.sqrt((1.0 - (t_0 / (l / (h * t_0)))));
	}
	return w0_s * tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
d_m = math.fabs(d)
w0_m = math.fabs(w0)
w0_s = math.copysign(1.0, w0)
[w0_m, M_m, D_m, h, l, d_m] = sort([w0_m, M_m, D_m, h, l, d_m])
def code(w0_s, w0_m, M_m, D_m, h, l, d_m):
	t_0 = (M_m * D_m) / (d_m / 0.5)
	tmp = 0
	if (math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0) * (h / l)) <= -math.inf:
		tmp = math.pow((math.sqrt(w0_m) * math.exp((0.25 * ((-2.0 * math.log(d_m)) + math.log((-0.25 * ((h * math.pow((M_m * D_m), 2.0)) / l))))))), 2.0)
	else:
		tmp = w0_m * math.sqrt((1.0 - (t_0 / (l / (h * t_0)))))
	return w0_s * tmp
M_m = abs(M)
D_m = abs(D)
d_m = abs(d)
w0_m = abs(w0)
w0_s = copysign(1.0, w0)
w0_m, M_m, D_m, h, l, d_m = sort([w0_m, M_m, D_m, h, l, d_m])
function code(w0_s, w0_m, M_m, D_m, h, l, d_m)
	t_0 = Float64(Float64(M_m * D_m) / Float64(d_m / 0.5))
	tmp = 0.0
	if (Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d_m)) ^ 2.0) * Float64(h / l)) <= Float64(-Inf))
		tmp = Float64(sqrt(w0_m) * exp(Float64(0.25 * Float64(Float64(-2.0 * log(d_m)) + log(Float64(-0.25 * Float64(Float64(h * (Float64(M_m * D_m) ^ 2.0)) / l))))))) ^ 2.0;
	else
		tmp = Float64(w0_m * sqrt(Float64(1.0 - Float64(t_0 / Float64(l / Float64(h * t_0))))));
	end
	return Float64(w0_s * tmp)
end
M_m = abs(M);
D_m = abs(D);
d_m = abs(d);
w0_m = abs(w0);
w0_s = sign(w0) * abs(1.0);
w0_m, M_m, D_m, h, l, d_m = num2cell(sort([w0_m, M_m, D_m, h, l, d_m])){:}
function tmp_2 = code(w0_s, w0_m, M_m, D_m, h, l, d_m)
	t_0 = (M_m * D_m) / (d_m / 0.5);
	tmp = 0.0;
	if (((((M_m * D_m) / (2.0 * d_m)) ^ 2.0) * (h / l)) <= -Inf)
		tmp = (sqrt(w0_m) * exp((0.25 * ((-2.0 * log(d_m)) + log((-0.25 * ((h * ((M_m * D_m) ^ 2.0)) / l))))))) ^ 2.0;
	else
		tmp = w0_m * sqrt((1.0 - (t_0 / (l / (h * t_0)))));
	end
	tmp_2 = w0_s * tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
w0_m = N[Abs[w0], $MachinePrecision]
w0_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[w0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0$95$s_, w0$95$m_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := Block[{t$95$0 = N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(d$95$m / 0.5), $MachinePrecision]), $MachinePrecision]}, N[(w0$95$s * If[LessEqual[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], (-Infinity)], N[Power[N[(N[Sqrt[w0$95$m], $MachinePrecision] * N[Exp[N[(0.25 * N[(N[(-2.0 * N[Log[d$95$m], $MachinePrecision]), $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]), $MachinePrecision], 2.0], $MachinePrecision], N[(w0$95$m * N[Sqrt[N[(1.0 - N[(t$95$0 / N[(l / N[(h * t$95$0), $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 = \left|w0\right|
\\
w0_s = \mathsf{copysign}\left(1, w0\right)
\\
[w0_m, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0_m, M_m, D_m, h, l, d_m])\\
\\
\begin{array}{l}
t_0 := \frac{M_m \cdot D_m}{\frac{d_m}{0.5}}\\
w0_s \cdot \begin{array}{l}
\mathbf{if}\;{\left(\frac{M_m \cdot D_m}{2 \cdot d_m}\right)}^{2} \cdot \frac{h}{\ell} \leq -\infty:\\
\;\;\;\;{\left(\sqrt{w0_m} \cdot e^{0.25 \cdot \left(-2 \cdot \log d_m + \log \left(-0.25 \cdot \frac{h \cdot {\left(M_m \cdot D_m\right)}^{2}}{\ell}\right)\right)}\right)}^{2}\\

\mathbf{else}:\\
\;\;\;\;w0_m \cdot \sqrt{1 - \frac{t_0}{\frac{\ell}{h \cdot t_0}}}\\


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

    1. Initial program 48.0%

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

      \[\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. Applied egg-rr24.6%

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

      \[\leadsto {\color{blue}{\left(\sqrt{w0} \cdot e^{0.25 \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)}}^{2} \]
    6. Step-by-step derivation
      1. *-un-lft-identity10.1%

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

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

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

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

        \[\leadsto {\left(\sqrt{w0} \cdot e^{0.25 \cdot \left(\left(0 + \log \left(\color{blue}{-0.25} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{\ell}\right)\right) + -2 \cdot \log d\right)}\right)}^{2} \]
      6. associate-*r*11.3%

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

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

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

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

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

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

    1. Initial program 91.2%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified91.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. *-commutative91.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{D \cdot \frac{M \cdot 0.5}{d}}{\ell} \cdot \frac{D \cdot \frac{M \cdot 0.5}{d}}{\frac{1}{h}}}} \]
    8. Taylor expanded in D around 0 91.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 \cdot \left(e^{\mathsf{log1p}\left(\sqrt{1 - \frac{\left(D \cdot \frac{M}{\frac{d}{0.5}}\right) \cdot \color{blue}{\left(\left(h \cdot D\right) \cdot \frac{M \cdot 0.5}{d}\right)}}{\ell}}\right)} - 1\right) \]
      6. associate-/l*91.6%

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

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

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

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

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

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

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

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{D \cdot M}{\frac{d}{0.5}}}{\frac{\ell}{h \cdot \color{blue}{\frac{D \cdot M}{\frac{d}{0.5}}}}}} \]
    14. Simplified98.9%

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

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

Alternative 4: 90.2% accurate, 0.3× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ d_m = \left|d\right| \\ w0_m = \left|w0\right| \\ w0_s = \mathsf{copysign}\left(1, w0\right) \\ [w0_m, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0_m, M_m, D_m, h, l, d_m])\\ \\ \begin{array}{l} t_0 := \frac{M_m \cdot D_m}{\frac{d_m}{0.5}}\\ w0_s \cdot \begin{array}{l} \mathbf{if}\;\frac{M_m \cdot D_m}{2 \cdot d_m} \leq 5 \cdot 10^{+298}:\\ \;\;\;\;w0_m \cdot \sqrt{1 - \frac{t_0}{\frac{\ell}{h \cdot t_0}}}\\ \mathbf{else}:\\ \;\;\;\;{\left(\sqrt{w0_m} \cdot e^{0.25 \cdot \left(\log \left(-0.25 \cdot \frac{h \cdot {M_m}^{2}}{\ell}\right) + \left(2 \cdot \log D_m + -2 \cdot \log d_m\right)\right)}\right)}^{2}\\ \end{array} \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
w0_m = (fabs.f64 w0)
w0_s = (copysign.f64 1 w0)
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0_s w0_m M_m D_m h l d_m)
 :precision binary64
 (let* ((t_0 (/ (* M_m D_m) (/ d_m 0.5))))
   (*
    w0_s
    (if (<= (/ (* M_m D_m) (* 2.0 d_m)) 5e+298)
      (* w0_m (sqrt (- 1.0 (/ t_0 (/ l (* h t_0))))))
      (pow
       (*
        (sqrt w0_m)
        (exp
         (*
          0.25
          (+
           (log (* -0.25 (/ (* h (pow M_m 2.0)) l)))
           (+ (* 2.0 (log D_m)) (* -2.0 (log d_m)))))))
       2.0)))))
M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
w0_m = fabs(w0);
w0_s = copysign(1.0, w0);
assert(w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
	double t_0 = (M_m * D_m) / (d_m / 0.5);
	double tmp;
	if (((M_m * D_m) / (2.0 * d_m)) <= 5e+298) {
		tmp = w0_m * sqrt((1.0 - (t_0 / (l / (h * t_0)))));
	} else {
		tmp = pow((sqrt(w0_m) * exp((0.25 * (log((-0.25 * ((h * pow(M_m, 2.0)) / l))) + ((2.0 * log(D_m)) + (-2.0 * log(d_m))))))), 2.0);
	}
	return w0_s * tmp;
}
M_m = abs(M)
D_m = abs(D)
d_m = abs(d)
w0_m = abs(w0)
w0_s = copysign(1.0d0, w0)
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
real(8) function code(w0_s, w0_m, m_m, d_m, h, l, d_m_1)
    real(8), intent (in) :: w0_s
    real(8), intent (in) :: w0_m
    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 = (m_m * d_m) / (d_m_1 / 0.5d0)
    if (((m_m * d_m) / (2.0d0 * d_m_1)) <= 5d+298) then
        tmp = w0_m * sqrt((1.0d0 - (t_0 / (l / (h * t_0)))))
    else
        tmp = (sqrt(w0_m) * exp((0.25d0 * (log(((-0.25d0) * ((h * (m_m ** 2.0d0)) / l))) + ((2.0d0 * log(d_m)) + ((-2.0d0) * log(d_m_1))))))) ** 2.0d0
    end if
    code = w0_s * tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
d_m = Math.abs(d);
w0_m = Math.abs(w0);
w0_s = Math.copySign(1.0, w0);
assert w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
	double t_0 = (M_m * D_m) / (d_m / 0.5);
	double tmp;
	if (((M_m * D_m) / (2.0 * d_m)) <= 5e+298) {
		tmp = w0_m * Math.sqrt((1.0 - (t_0 / (l / (h * t_0)))));
	} else {
		tmp = Math.pow((Math.sqrt(w0_m) * Math.exp((0.25 * (Math.log((-0.25 * ((h * Math.pow(M_m, 2.0)) / l))) + ((2.0 * Math.log(D_m)) + (-2.0 * Math.log(d_m))))))), 2.0);
	}
	return w0_s * tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
d_m = math.fabs(d)
w0_m = math.fabs(w0)
w0_s = math.copysign(1.0, w0)
[w0_m, M_m, D_m, h, l, d_m] = sort([w0_m, M_m, D_m, h, l, d_m])
def code(w0_s, w0_m, M_m, D_m, h, l, d_m):
	t_0 = (M_m * D_m) / (d_m / 0.5)
	tmp = 0
	if ((M_m * D_m) / (2.0 * d_m)) <= 5e+298:
		tmp = w0_m * math.sqrt((1.0 - (t_0 / (l / (h * t_0)))))
	else:
		tmp = math.pow((math.sqrt(w0_m) * math.exp((0.25 * (math.log((-0.25 * ((h * math.pow(M_m, 2.0)) / l))) + ((2.0 * math.log(D_m)) + (-2.0 * math.log(d_m))))))), 2.0)
	return w0_s * tmp
M_m = abs(M)
D_m = abs(D)
d_m = abs(d)
w0_m = abs(w0)
w0_s = copysign(1.0, w0)
w0_m, M_m, D_m, h, l, d_m = sort([w0_m, M_m, D_m, h, l, d_m])
function code(w0_s, w0_m, M_m, D_m, h, l, d_m)
	t_0 = Float64(Float64(M_m * D_m) / Float64(d_m / 0.5))
	tmp = 0.0
	if (Float64(Float64(M_m * D_m) / Float64(2.0 * d_m)) <= 5e+298)
		tmp = Float64(w0_m * sqrt(Float64(1.0 - Float64(t_0 / Float64(l / Float64(h * t_0))))));
	else
		tmp = Float64(sqrt(w0_m) * exp(Float64(0.25 * Float64(log(Float64(-0.25 * Float64(Float64(h * (M_m ^ 2.0)) / l))) + Float64(Float64(2.0 * log(D_m)) + Float64(-2.0 * log(d_m))))))) ^ 2.0;
	end
	return Float64(w0_s * tmp)
end
M_m = abs(M);
D_m = abs(D);
d_m = abs(d);
w0_m = abs(w0);
w0_s = sign(w0) * abs(1.0);
w0_m, M_m, D_m, h, l, d_m = num2cell(sort([w0_m, M_m, D_m, h, l, d_m])){:}
function tmp_2 = code(w0_s, w0_m, M_m, D_m, h, l, d_m)
	t_0 = (M_m * D_m) / (d_m / 0.5);
	tmp = 0.0;
	if (((M_m * D_m) / (2.0 * d_m)) <= 5e+298)
		tmp = w0_m * sqrt((1.0 - (t_0 / (l / (h * t_0)))));
	else
		tmp = (sqrt(w0_m) * exp((0.25 * (log((-0.25 * ((h * (M_m ^ 2.0)) / l))) + ((2.0 * log(D_m)) + (-2.0 * log(d_m))))))) ^ 2.0;
	end
	tmp_2 = w0_s * tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
w0_m = N[Abs[w0], $MachinePrecision]
w0_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[w0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0$95$s_, w0$95$m_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := Block[{t$95$0 = N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(d$95$m / 0.5), $MachinePrecision]), $MachinePrecision]}, N[(w0$95$s * If[LessEqual[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 5e+298], N[(w0$95$m * N[Sqrt[N[(1.0 - N[(t$95$0 / N[(l / N[(h * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Power[N[(N[Sqrt[w0$95$m], $MachinePrecision] * N[Exp[N[(0.25 * N[(N[Log[N[(-0.25 * N[(N[(h * N[Power[M$95$m, 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(N[(2.0 * N[Log[D$95$m], $MachinePrecision]), $MachinePrecision] + N[(-2.0 * N[Log[d$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
w0_m = \left|w0\right|
\\
w0_s = \mathsf{copysign}\left(1, w0\right)
\\
[w0_m, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0_m, M_m, D_m, h, l, d_m])\\
\\
\begin{array}{l}
t_0 := \frac{M_m \cdot D_m}{\frac{d_m}{0.5}}\\
w0_s \cdot \begin{array}{l}
\mathbf{if}\;\frac{M_m \cdot D_m}{2 \cdot d_m} \leq 5 \cdot 10^{+298}:\\
\;\;\;\;w0_m \cdot \sqrt{1 - \frac{t_0}{\frac{\ell}{h \cdot t_0}}}\\

\mathbf{else}:\\
\;\;\;\;{\left(\sqrt{w0_m} \cdot e^{0.25 \cdot \left(\log \left(-0.25 \cdot \frac{h \cdot {M_m}^{2}}{\ell}\right) + \left(2 \cdot \log D_m + -2 \cdot \log d_m\right)\right)}\right)}^{2}\\


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

    1. Initial program 80.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right) \cdot \left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right)}}{1 \cdot \frac{\ell}{h}}} \]
      10. *-un-lft-identity80.8%

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

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

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

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

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

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{D \cdot \frac{M \cdot 0.5}{d}}{\ell} \cdot \frac{D \cdot \frac{M \cdot 0.5}{d}}{\frac{1}{h}}}} \]
    8. Taylor expanded in D around 0 80.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 \cdot \left(e^{\mathsf{log1p}\left(\sqrt{1 - \frac{\left(D \cdot \frac{M}{\frac{d}{0.5}}\right) \cdot \color{blue}{\left(\left(h \cdot D\right) \cdot \frac{M \cdot 0.5}{d}\right)}}{\ell}}\right)} - 1\right) \]
      6. associate-/l*80.6%

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

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

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

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

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

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

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

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{D \cdot M}{\frac{d}{0.5}}}{\frac{\ell}{h \cdot \color{blue}{\frac{D \cdot M}{\frac{d}{0.5}}}}}} \]
    14. Simplified88.0%

      \[\leadsto w0 \cdot \color{blue}{\sqrt{1 - \frac{\frac{D \cdot M}{\frac{d}{0.5}}}{\frac{\ell}{h \cdot \frac{D \cdot M}{\frac{d}{0.5}}}}}} \]

    if 5.0000000000000003e298 < (/.f64 (*.f64 M D) (*.f64 2 d))

    1. Initial program 62.9%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified67.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. Applied egg-rr22.6%

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

      \[\leadsto {\color{blue}{\left(\sqrt{w0} \cdot e^{0.25 \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)}}^{2} \]
    6. Step-by-step derivation
      1. exp-prod17.6%

        \[\leadsto {\left(\sqrt{w0} \cdot \color{blue}{{\left(e^{0.25}\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)}^{2} \]
      2. +-commutative17.6%

        \[\leadsto {\left(\sqrt{w0} \cdot {\left(e^{0.25}\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)}^{2} \]
      3. fma-def17.6%

        \[\leadsto {\left(\sqrt{w0} \cdot {\left(e^{0.25}\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)}^{2} \]
      4. distribute-lft-neg-in17.6%

        \[\leadsto {\left(\sqrt{w0} \cdot {\left(e^{0.25}\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)}^{2} \]
      5. metadata-eval17.6%

        \[\leadsto {\left(\sqrt{w0} \cdot {\left(e^{0.25}\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)}^{2} \]
      6. associate-*r*17.6%

        \[\leadsto {\left(\sqrt{w0} \cdot {\left(e^{0.25}\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)}^{2} \]
      7. *-commutative17.6%

        \[\leadsto {\left(\sqrt{w0} \cdot {\left(e^{0.25}\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)}^{2} \]
      8. unpow217.6%

        \[\leadsto {\left(\sqrt{w0} \cdot {\left(e^{0.25}\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)}^{2} \]
      9. unpow217.6%

        \[\leadsto {\left(\sqrt{w0} \cdot {\left(e^{0.25}\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)}^{2} \]
      10. swap-sqr17.6%

        \[\leadsto {\left(\sqrt{w0} \cdot {\left(e^{0.25}\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)}^{2} \]
      11. unpow217.6%

        \[\leadsto {\left(\sqrt{w0} \cdot {\left(e^{0.25}\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)}^{2} \]
      12. *-commutative17.6%

        \[\leadsto {\left(\sqrt{w0} \cdot {\left(e^{0.25}\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)}^{2} \]
    7. Simplified17.6%

      \[\leadsto {\color{blue}{\left(\sqrt{w0} \cdot {\left(e^{0.25}\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)}}^{2} \]
    8. Taylor expanded in D around 0 8.9%

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

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

Alternative 5: 89.4% accurate, 0.3× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ d_m = \left|d\right| \\ w0_m = \left|w0\right| \\ w0_s = \mathsf{copysign}\left(1, w0\right) \\ [w0_m, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0_m, M_m, D_m, h, l, d_m])\\ \\ \begin{array}{l} t_0 := \frac{M_m \cdot D_m}{\frac{d_m}{0.5}}\\ w0_s \cdot \begin{array}{l} \mathbf{if}\;\frac{M_m \cdot D_m}{2 \cdot d_m} \leq 10^{+198}:\\ \;\;\;\;w0_m \cdot \sqrt{1 - \frac{t_0}{\frac{\ell}{h \cdot t_0}}}\\ \mathbf{else}:\\ \;\;\;\;{\left(\sqrt{w0_m} \cdot e^{0.25 \cdot \left(-2 \cdot \log d_m + \left(2 \cdot \log D_m + \log \left(-0.25 \cdot \left(\frac{h}{\ell} \cdot {M_m}^{2}\right)\right)\right)\right)}\right)}^{2}\\ \end{array} \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
w0_m = (fabs.f64 w0)
w0_s = (copysign.f64 1 w0)
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0_s w0_m M_m D_m h l d_m)
 :precision binary64
 (let* ((t_0 (/ (* M_m D_m) (/ d_m 0.5))))
   (*
    w0_s
    (if (<= (/ (* M_m D_m) (* 2.0 d_m)) 1e+198)
      (* w0_m (sqrt (- 1.0 (/ t_0 (/ l (* h t_0))))))
      (pow
       (*
        (sqrt w0_m)
        (exp
         (*
          0.25
          (+
           (* -2.0 (log d_m))
           (+ (* 2.0 (log D_m)) (log (* -0.25 (* (/ h l) (pow M_m 2.0)))))))))
       2.0)))))
M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
w0_m = fabs(w0);
w0_s = copysign(1.0, w0);
assert(w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
	double t_0 = (M_m * D_m) / (d_m / 0.5);
	double tmp;
	if (((M_m * D_m) / (2.0 * d_m)) <= 1e+198) {
		tmp = w0_m * sqrt((1.0 - (t_0 / (l / (h * t_0)))));
	} else {
		tmp = pow((sqrt(w0_m) * exp((0.25 * ((-2.0 * log(d_m)) + ((2.0 * log(D_m)) + log((-0.25 * ((h / l) * pow(M_m, 2.0))))))))), 2.0);
	}
	return w0_s * tmp;
}
M_m = abs(M)
D_m = abs(D)
d_m = abs(d)
w0_m = abs(w0)
w0_s = copysign(1.0d0, w0)
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
real(8) function code(w0_s, w0_m, m_m, d_m, h, l, d_m_1)
    real(8), intent (in) :: w0_s
    real(8), intent (in) :: w0_m
    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 = (m_m * d_m) / (d_m_1 / 0.5d0)
    if (((m_m * d_m) / (2.0d0 * d_m_1)) <= 1d+198) then
        tmp = w0_m * sqrt((1.0d0 - (t_0 / (l / (h * t_0)))))
    else
        tmp = (sqrt(w0_m) * exp((0.25d0 * (((-2.0d0) * log(d_m_1)) + ((2.0d0 * log(d_m)) + log(((-0.25d0) * ((h / l) * (m_m ** 2.0d0))))))))) ** 2.0d0
    end if
    code = w0_s * tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
d_m = Math.abs(d);
w0_m = Math.abs(w0);
w0_s = Math.copySign(1.0, w0);
assert w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
	double t_0 = (M_m * D_m) / (d_m / 0.5);
	double tmp;
	if (((M_m * D_m) / (2.0 * d_m)) <= 1e+198) {
		tmp = w0_m * Math.sqrt((1.0 - (t_0 / (l / (h * t_0)))));
	} else {
		tmp = Math.pow((Math.sqrt(w0_m) * Math.exp((0.25 * ((-2.0 * Math.log(d_m)) + ((2.0 * Math.log(D_m)) + Math.log((-0.25 * ((h / l) * Math.pow(M_m, 2.0))))))))), 2.0);
	}
	return w0_s * tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
d_m = math.fabs(d)
w0_m = math.fabs(w0)
w0_s = math.copysign(1.0, w0)
[w0_m, M_m, D_m, h, l, d_m] = sort([w0_m, M_m, D_m, h, l, d_m])
def code(w0_s, w0_m, M_m, D_m, h, l, d_m):
	t_0 = (M_m * D_m) / (d_m / 0.5)
	tmp = 0
	if ((M_m * D_m) / (2.0 * d_m)) <= 1e+198:
		tmp = w0_m * math.sqrt((1.0 - (t_0 / (l / (h * t_0)))))
	else:
		tmp = math.pow((math.sqrt(w0_m) * math.exp((0.25 * ((-2.0 * math.log(d_m)) + ((2.0 * math.log(D_m)) + math.log((-0.25 * ((h / l) * math.pow(M_m, 2.0))))))))), 2.0)
	return w0_s * tmp
M_m = abs(M)
D_m = abs(D)
d_m = abs(d)
w0_m = abs(w0)
w0_s = copysign(1.0, w0)
w0_m, M_m, D_m, h, l, d_m = sort([w0_m, M_m, D_m, h, l, d_m])
function code(w0_s, w0_m, M_m, D_m, h, l, d_m)
	t_0 = Float64(Float64(M_m * D_m) / Float64(d_m / 0.5))
	tmp = 0.0
	if (Float64(Float64(M_m * D_m) / Float64(2.0 * d_m)) <= 1e+198)
		tmp = Float64(w0_m * sqrt(Float64(1.0 - Float64(t_0 / Float64(l / Float64(h * t_0))))));
	else
		tmp = Float64(sqrt(w0_m) * exp(Float64(0.25 * Float64(Float64(-2.0 * log(d_m)) + Float64(Float64(2.0 * log(D_m)) + log(Float64(-0.25 * Float64(Float64(h / l) * (M_m ^ 2.0))))))))) ^ 2.0;
	end
	return Float64(w0_s * tmp)
end
M_m = abs(M);
D_m = abs(D);
d_m = abs(d);
w0_m = abs(w0);
w0_s = sign(w0) * abs(1.0);
w0_m, M_m, D_m, h, l, d_m = num2cell(sort([w0_m, M_m, D_m, h, l, d_m])){:}
function tmp_2 = code(w0_s, w0_m, M_m, D_m, h, l, d_m)
	t_0 = (M_m * D_m) / (d_m / 0.5);
	tmp = 0.0;
	if (((M_m * D_m) / (2.0 * d_m)) <= 1e+198)
		tmp = w0_m * sqrt((1.0 - (t_0 / (l / (h * t_0)))));
	else
		tmp = (sqrt(w0_m) * exp((0.25 * ((-2.0 * log(d_m)) + ((2.0 * log(D_m)) + log((-0.25 * ((h / l) * (M_m ^ 2.0))))))))) ^ 2.0;
	end
	tmp_2 = w0_s * tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
w0_m = N[Abs[w0], $MachinePrecision]
w0_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[w0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0$95$s_, w0$95$m_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := Block[{t$95$0 = N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(d$95$m / 0.5), $MachinePrecision]), $MachinePrecision]}, N[(w0$95$s * If[LessEqual[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 1e+198], N[(w0$95$m * N[Sqrt[N[(1.0 - N[(t$95$0 / N[(l / N[(h * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Power[N[(N[Sqrt[w0$95$m], $MachinePrecision] * N[Exp[N[(0.25 * N[(N[(-2.0 * N[Log[d$95$m], $MachinePrecision]), $MachinePrecision] + N[(N[(2.0 * N[Log[D$95$m], $MachinePrecision]), $MachinePrecision] + N[Log[N[(-0.25 * N[(N[(h / l), $MachinePrecision] * N[Power[M$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
w0_m = \left|w0\right|
\\
w0_s = \mathsf{copysign}\left(1, w0\right)
\\
[w0_m, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0_m, M_m, D_m, h, l, d_m])\\
\\
\begin{array}{l}
t_0 := \frac{M_m \cdot D_m}{\frac{d_m}{0.5}}\\
w0_s \cdot \begin{array}{l}
\mathbf{if}\;\frac{M_m \cdot D_m}{2 \cdot d_m} \leq 10^{+198}:\\
\;\;\;\;w0_m \cdot \sqrt{1 - \frac{t_0}{\frac{\ell}{h \cdot t_0}}}\\

\mathbf{else}:\\
\;\;\;\;{\left(\sqrt{w0_m} \cdot e^{0.25 \cdot \left(-2 \cdot \log d_m + \left(2 \cdot \log D_m + \log \left(-0.25 \cdot \left(\frac{h}{\ell} \cdot {M_m}^{2}\right)\right)\right)\right)}\right)}^{2}\\


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

    1. Initial program 81.9%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified81.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. Step-by-step derivation
      1. *-commutative81.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{D \cdot \frac{M \cdot 0.5}{d}}{\ell} \cdot \frac{D \cdot \frac{M \cdot 0.5}{d}}{\frac{1}{h}}}} \]
    8. Taylor expanded in D around 0 81.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 \cdot \left(e^{\mathsf{log1p}\left(\sqrt{1 - \frac{\left(D \cdot \frac{M}{\frac{d}{0.5}}\right) \cdot \color{blue}{\left(\left(h \cdot D\right) \cdot \frac{M \cdot 0.5}{d}\right)}}{\ell}}\right)} - 1\right) \]
      6. associate-/l*82.1%

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

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

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

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

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

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

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

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{D \cdot M}{\frac{d}{0.5}}}{\frac{\ell}{h \cdot \color{blue}{\frac{D \cdot M}{\frac{d}{0.5}}}}}} \]
    14. Simplified88.8%

      \[\leadsto w0 \cdot \color{blue}{\sqrt{1 - \frac{\frac{D \cdot M}{\frac{d}{0.5}}}{\frac{\ell}{h \cdot \frac{D \cdot M}{\frac{d}{0.5}}}}}} \]

    if 1.00000000000000002e198 < (/.f64 (*.f64 M D) (*.f64 2 d))

    1. Initial program 57.2%

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

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

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

      \[\leadsto {\color{blue}{\left(\sqrt{w0} \cdot e^{0.25 \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)}}^{2} \]
    6. Taylor expanded in D around 0 6.6%

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

        \[\leadsto {\left(\sqrt{w0} \cdot e^{0.25 \cdot \left(\color{blue}{\left(2 \cdot \log D + \log \left(-0.25 \cdot \frac{{M}^{2} \cdot h}{\ell}\right)\right)} + -2 \cdot \log d\right)}\right)}^{2} \]
      2. distribute-lft-neg-in6.6%

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

        \[\leadsto {\left(\sqrt{w0} \cdot e^{0.25 \cdot \left(\left(2 \cdot \log D + \log \left(\color{blue}{-0.25} \cdot \frac{{M}^{2} \cdot h}{\ell}\right)\right) + -2 \cdot \log d\right)}\right)}^{2} \]
      4. associate-*r/6.6%

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

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

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

Alternative 6: 86.7% accurate, 1.8× speedup?

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

    \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
  2. Simplified78.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. *-commutative78.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right) \cdot \left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right)}}{1 \cdot \frac{\ell}{h}}} \]
    10. *-un-lft-identity79.6%

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

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

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

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

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

    \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{D \cdot \frac{M \cdot 0.5}{d}}{\ell} \cdot \frac{D \cdot \frac{M \cdot 0.5}{d}}{\frac{1}{h}}}} \]
  8. Taylor expanded in D around 0 79.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 90.1% accurate, 1.8× speedup?

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

    \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
  2. Simplified78.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. *-commutative78.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right) \cdot \left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right)}}{1 \cdot \frac{\ell}{h}}} \]
    10. *-un-lft-identity79.6%

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

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

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

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

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

    \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{D \cdot \frac{M \cdot 0.5}{d}}{\ell} \cdot \frac{D \cdot \frac{M \cdot 0.5}{d}}{\frac{1}{h}}}} \]
  8. Taylor expanded in D around 0 79.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 89.2% accurate, 1.8× speedup?

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

    \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
  2. Simplified78.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. *-commutative78.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right) \cdot \left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right)}}{1 \cdot \frac{\ell}{h}}} \]
    10. *-un-lft-identity79.6%

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

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

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

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

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

    \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{D \cdot \frac{M \cdot 0.5}{d}}{\ell} \cdot \frac{D \cdot \frac{M \cdot 0.5}{d}}{\frac{1}{h}}}} \]
  8. Taylor expanded in D around 0 79.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto w0 \cdot \left(e^{\mathsf{log1p}\left(\sqrt{1 - \frac{\left(D \cdot \frac{M}{\frac{d}{0.5}}\right) \cdot \color{blue}{\left(\left(h \cdot D\right) \cdot \frac{M \cdot 0.5}{d}\right)}}{\ell}}\right)} - 1\right) \]
    6. associate-/l*79.4%

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

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

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

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

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

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

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

      \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{D \cdot M}{\frac{d}{0.5}}}{\frac{\ell}{h \cdot \color{blue}{\frac{D \cdot M}{\frac{d}{0.5}}}}}} \]
  14. Simplified85.7%

    \[\leadsto w0 \cdot \color{blue}{\sqrt{1 - \frac{\frac{D \cdot M}{\frac{d}{0.5}}}{\frac{\ell}{h \cdot \frac{D \cdot M}{\frac{d}{0.5}}}}}} \]
  15. Final simplification85.7%

    \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{M \cdot D}{\frac{d}{0.5}}}{\frac{\ell}{h \cdot \frac{M \cdot D}{\frac{d}{0.5}}}}} \]
  16. Add Preprocessing

Alternative 9: 68.0% accurate, 216.0× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ d_m = \left|d\right| \\ w0_m = \left|w0\right| \\ w0_s = \mathsf{copysign}\left(1, w0\right) \\ [w0_m, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0_m, M_m, D_m, h, l, d_m])\\ \\ w0_s \cdot w0_m \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
w0_m = (fabs.f64 w0)
w0_s = (copysign.f64 1 w0)
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0_s w0_m M_m D_m h l d_m) :precision binary64 (* w0_s w0_m))
M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
w0_m = fabs(w0);
w0_s = copysign(1.0, w0);
assert(w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
	return w0_s * w0_m;
}
M_m = abs(M)
D_m = abs(D)
d_m = abs(d)
w0_m = abs(w0)
w0_s = copysign(1.0d0, w0)
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
real(8) function code(w0_s, w0_m, m_m, d_m, h, l, d_m_1)
    real(8), intent (in) :: w0_s
    real(8), intent (in) :: w0_m
    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_s * w0_m
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
d_m = Math.abs(d);
w0_m = Math.abs(w0);
w0_s = Math.copySign(1.0, w0);
assert w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
	return w0_s * w0_m;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
d_m = math.fabs(d)
w0_m = math.fabs(w0)
w0_s = math.copysign(1.0, w0)
[w0_m, M_m, D_m, h, l, d_m] = sort([w0_m, M_m, D_m, h, l, d_m])
def code(w0_s, w0_m, M_m, D_m, h, l, d_m):
	return w0_s * w0_m
M_m = abs(M)
D_m = abs(D)
d_m = abs(d)
w0_m = abs(w0)
w0_s = copysign(1.0, w0)
w0_m, M_m, D_m, h, l, d_m = sort([w0_m, M_m, D_m, h, l, d_m])
function code(w0_s, w0_m, M_m, D_m, h, l, d_m)
	return Float64(w0_s * w0_m)
end
M_m = abs(M);
D_m = abs(D);
d_m = abs(d);
w0_m = abs(w0);
w0_s = sign(w0) * abs(1.0);
w0_m, M_m, D_m, h, l, d_m = num2cell(sort([w0_m, M_m, D_m, h, l, d_m])){:}
function tmp = code(w0_s, w0_m, M_m, D_m, h, l, d_m)
	tmp = w0_s * w0_m;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
w0_m = N[Abs[w0], $MachinePrecision]
w0_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[w0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0$95$s_, w0$95$m_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := N[(w0$95$s * w0$95$m), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
w0_m = \left|w0\right|
\\
w0_s = \mathsf{copysign}\left(1, w0\right)
\\
[w0_m, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0_m, M_m, D_m, h, l, d_m])\\
\\
w0_s \cdot w0_m
\end{array}
Derivation
  1. Initial program 78.9%

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

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

    \[\leadsto w0 \]
  6. Add Preprocessing

Reproduce

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