Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 80.8% → 91.4%
Time: 17.2s
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: 80.8% accurate, 1.0× speedup?

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

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

Alternative 1: 91.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_s \cdot \begin{array}{l} \mathbf{if}\;{\left(\frac{M_m \cdot D_m}{2 \cdot d_m}\right)}^{2} \leq 4 \cdot 10^{+253}:\\ \;\;\;\;w0_m \cdot {\left(1 - \frac{h \cdot {\left(\left(M_m \cdot D_m\right) \cdot \frac{0.5}{d_m}\right)}^{2}}{\ell}\right)}^{0.5}\\ \mathbf{else}:\\ \;\;\;\;{\left(\sqrt{w0_m} \cdot e^{0.25 \cdot \left(\left(\left(2 \cdot \log M_m + \log \left(-0.25 \cdot \frac{h}{\ell}\right)\right) + -2 \cdot \log d_m\right) + -2 \cdot \log \left(\frac{1}{D_m}\right)\right)}\right)}^{2}\\ \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)
(FPCore (w0_s w0_m M_m D_m h l d_m)
 :precision binary64
 (*
  w0_s
  (if (<= (pow (/ (* M_m D_m) (* 2.0 d_m)) 2.0) 4e+253)
    (*
     w0_m
     (pow (- 1.0 (/ (* h (pow (* (* M_m D_m) (/ 0.5 d_m)) 2.0)) l)) 0.5))
    (pow
     (*
      (sqrt w0_m)
      (exp
       (*
        0.25
        (+
         (+ (+ (* 2.0 (log M_m)) (log (* -0.25 (/ h l)))) (* -2.0 (log d_m)))
         (* -2.0 (log (/ 1.0 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);
double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
	double tmp;
	if (pow(((M_m * D_m) / (2.0 * d_m)), 2.0) <= 4e+253) {
		tmp = w0_m * pow((1.0 - ((h * pow(((M_m * D_m) * (0.5 / d_m)), 2.0)) / l)), 0.5);
	} else {
		tmp = pow((sqrt(w0_m) * exp((0.25 * ((((2.0 * log(M_m)) + log((-0.25 * (h / l)))) + (-2.0 * log(d_m))) + (-2.0 * log((1.0 / 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)
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) :: tmp
    if ((((m_m * d_m) / (2.0d0 * d_m_1)) ** 2.0d0) <= 4d+253) then
        tmp = w0_m * ((1.0d0 - ((h * (((m_m * d_m) * (0.5d0 / d_m_1)) ** 2.0d0)) / l)) ** 0.5d0)
    else
        tmp = (sqrt(w0_m) * exp((0.25d0 * ((((2.0d0 * log(m_m)) + log(((-0.25d0) * (h / l)))) + ((-2.0d0) * log(d_m_1))) + ((-2.0d0) * log((1.0d0 / d_m))))))) ** 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);
public static double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
	double tmp;
	if (Math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0) <= 4e+253) {
		tmp = w0_m * Math.pow((1.0 - ((h * Math.pow(((M_m * D_m) * (0.5 / d_m)), 2.0)) / l)), 0.5);
	} else {
		tmp = Math.pow((Math.sqrt(w0_m) * Math.exp((0.25 * ((((2.0 * Math.log(M_m)) + Math.log((-0.25 * (h / l)))) + (-2.0 * Math.log(d_m))) + (-2.0 * Math.log((1.0 / 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)
def code(w0_s, w0_m, M_m, D_m, h, l, d_m):
	tmp = 0
	if math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0) <= 4e+253:
		tmp = w0_m * math.pow((1.0 - ((h * math.pow(((M_m * D_m) * (0.5 / d_m)), 2.0)) / l)), 0.5)
	else:
		tmp = math.pow((math.sqrt(w0_m) * math.exp((0.25 * ((((2.0 * math.log(M_m)) + math.log((-0.25 * (h / l)))) + (-2.0 * math.log(d_m))) + (-2.0 * math.log((1.0 / 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)
function code(w0_s, w0_m, M_m, D_m, h, l, d_m)
	tmp = 0.0
	if ((Float64(Float64(M_m * D_m) / Float64(2.0 * d_m)) ^ 2.0) <= 4e+253)
		tmp = Float64(w0_m * (Float64(1.0 - Float64(Float64(h * (Float64(Float64(M_m * D_m) * Float64(0.5 / d_m)) ^ 2.0)) / l)) ^ 0.5));
	else
		tmp = Float64(sqrt(w0_m) * exp(Float64(0.25 * Float64(Float64(Float64(Float64(2.0 * log(M_m)) + log(Float64(-0.25 * Float64(h / l)))) + Float64(-2.0 * log(d_m))) + Float64(-2.0 * log(Float64(1.0 / 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);
function tmp_2 = code(w0_s, w0_m, M_m, D_m, h, l, d_m)
	tmp = 0.0;
	if ((((M_m * D_m) / (2.0 * d_m)) ^ 2.0) <= 4e+253)
		tmp = w0_m * ((1.0 - ((h * (((M_m * D_m) * (0.5 / d_m)) ^ 2.0)) / l)) ^ 0.5);
	else
		tmp = (sqrt(w0_m) * exp((0.25 * ((((2.0 * log(M_m)) + log((-0.25 * (h / l)))) + (-2.0 * log(d_m))) + (-2.0 * log((1.0 / 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]
code[w0$95$s_, w0$95$m_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := N[(w0$95$s * If[LessEqual[N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], 4e+253], N[(w0$95$m * N[Power[N[(1.0 - N[(N[(h * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] * N[(0.5 / d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision], N[Power[N[(N[Sqrt[w0$95$m], $MachinePrecision] * N[Exp[N[(0.25 * N[(N[(N[(N[(2.0 * N[Log[M$95$m], $MachinePrecision]), $MachinePrecision] + N[Log[N[(-0.25 * N[(h / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(-2.0 * N[Log[d$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-2.0 * N[Log[N[(1.0 / 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_s \cdot \begin{array}{l}
\mathbf{if}\;{\left(\frac{M_m \cdot D_m}{2 \cdot d_m}\right)}^{2} \leq 4 \cdot 10^{+253}:\\
\;\;\;\;w0_m \cdot {\left(1 - \frac{h \cdot {\left(\left(M_m \cdot D_m\right) \cdot \frac{0.5}{d_m}\right)}^{2}}{\ell}\right)}^{0.5}\\

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


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

    1. Initial program 90.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.9999999999999997e253 < (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)

    1. Initial program 48.7%

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

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

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

      \[\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} \]
    5. Taylor expanded in d around 0 7.1%

      \[\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 \left(\frac{1}{D}\right)\right)}\right)}^{2} \]
    6. Step-by-step derivation
      1. distribute-lft-neg-in7.1%

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

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

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

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

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

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

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

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

Alternative 2: 86.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_s \cdot \begin{array}{l} \mathbf{if}\;{\left(\frac{M_m \cdot D_m}{2 \cdot d_m}\right)}^{2} \leq 4 \cdot 10^{+253}:\\ \;\;\;\;w0_m \cdot {\left(1 - \frac{h \cdot {\left(\left(M_m \cdot D_m\right) \cdot \frac{0.5}{d_m}\right)}^{2}}{\ell}\right)}^{0.5}\\ \mathbf{else}:\\ \;\;\;\;{\left(\sqrt{w0_m} \cdot e^{0.25 \cdot \left(-2 \cdot \log \left(\frac{1}{D_m}\right) + \left(-2 \cdot \log d_m + \log \left(-0.25 \cdot \frac{{M_m}^{2}}{\frac{\ell}{h}}\right)\right)\right)}\right)}^{2}\\ \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)
(FPCore (w0_s w0_m M_m D_m h l d_m)
 :precision binary64
 (*
  w0_s
  (if (<= (pow (/ (* M_m D_m) (* 2.0 d_m)) 2.0) 4e+253)
    (*
     w0_m
     (pow (- 1.0 (/ (* h (pow (* (* M_m D_m) (/ 0.5 d_m)) 2.0)) l)) 0.5))
    (pow
     (*
      (sqrt w0_m)
      (exp
       (*
        0.25
        (+
         (* -2.0 (log (/ 1.0 D_m)))
         (+ (* -2.0 (log d_m)) (log (* -0.25 (/ (pow M_m 2.0) (/ l h)))))))))
     2.0))))
M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
w0_m = fabs(w0);
w0_s = copysign(1.0, w0);
double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
	double tmp;
	if (pow(((M_m * D_m) / (2.0 * d_m)), 2.0) <= 4e+253) {
		tmp = w0_m * pow((1.0 - ((h * pow(((M_m * D_m) * (0.5 / d_m)), 2.0)) / l)), 0.5);
	} else {
		tmp = pow((sqrt(w0_m) * exp((0.25 * ((-2.0 * log((1.0 / D_m))) + ((-2.0 * log(d_m)) + log((-0.25 * (pow(M_m, 2.0) / (l / h))))))))), 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)
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) :: tmp
    if ((((m_m * d_m) / (2.0d0 * d_m_1)) ** 2.0d0) <= 4d+253) then
        tmp = w0_m * ((1.0d0 - ((h * (((m_m * d_m) * (0.5d0 / d_m_1)) ** 2.0d0)) / l)) ** 0.5d0)
    else
        tmp = (sqrt(w0_m) * exp((0.25d0 * (((-2.0d0) * log((1.0d0 / d_m))) + (((-2.0d0) * log(d_m_1)) + log(((-0.25d0) * ((m_m ** 2.0d0) / (l / h))))))))) ** 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);
public static double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
	double tmp;
	if (Math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0) <= 4e+253) {
		tmp = w0_m * Math.pow((1.0 - ((h * Math.pow(((M_m * D_m) * (0.5 / d_m)), 2.0)) / l)), 0.5);
	} else {
		tmp = Math.pow((Math.sqrt(w0_m) * Math.exp((0.25 * ((-2.0 * Math.log((1.0 / D_m))) + ((-2.0 * Math.log(d_m)) + Math.log((-0.25 * (Math.pow(M_m, 2.0) / (l / h))))))))), 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)
def code(w0_s, w0_m, M_m, D_m, h, l, d_m):
	tmp = 0
	if math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0) <= 4e+253:
		tmp = w0_m * math.pow((1.0 - ((h * math.pow(((M_m * D_m) * (0.5 / d_m)), 2.0)) / l)), 0.5)
	else:
		tmp = math.pow((math.sqrt(w0_m) * math.exp((0.25 * ((-2.0 * math.log((1.0 / D_m))) + ((-2.0 * math.log(d_m)) + math.log((-0.25 * (math.pow(M_m, 2.0) / (l / h))))))))), 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)
function code(w0_s, w0_m, M_m, D_m, h, l, d_m)
	tmp = 0.0
	if ((Float64(Float64(M_m * D_m) / Float64(2.0 * d_m)) ^ 2.0) <= 4e+253)
		tmp = Float64(w0_m * (Float64(1.0 - Float64(Float64(h * (Float64(Float64(M_m * D_m) * Float64(0.5 / d_m)) ^ 2.0)) / l)) ^ 0.5));
	else
		tmp = Float64(sqrt(w0_m) * exp(Float64(0.25 * Float64(Float64(-2.0 * log(Float64(1.0 / D_m))) + Float64(Float64(-2.0 * log(d_m)) + log(Float64(-0.25 * Float64((M_m ^ 2.0) / Float64(l / h))))))))) ^ 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);
function tmp_2 = code(w0_s, w0_m, M_m, D_m, h, l, d_m)
	tmp = 0.0;
	if ((((M_m * D_m) / (2.0 * d_m)) ^ 2.0) <= 4e+253)
		tmp = w0_m * ((1.0 - ((h * (((M_m * D_m) * (0.5 / d_m)) ^ 2.0)) / l)) ^ 0.5);
	else
		tmp = (sqrt(w0_m) * exp((0.25 * ((-2.0 * log((1.0 / D_m))) + ((-2.0 * log(d_m)) + log((-0.25 * ((M_m ^ 2.0) / (l / h))))))))) ^ 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]
code[w0$95$s_, w0$95$m_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := N[(w0$95$s * If[LessEqual[N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], 4e+253], N[(w0$95$m * N[Power[N[(1.0 - N[(N[(h * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] * N[(0.5 / d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision], N[Power[N[(N[Sqrt[w0$95$m], $MachinePrecision] * N[Exp[N[(0.25 * N[(N[(-2.0 * N[Log[N[(1.0 / D$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[(-2.0 * N[Log[d$95$m], $MachinePrecision]), $MachinePrecision] + N[Log[N[(-0.25 * N[(N[Power[M$95$m, 2.0], $MachinePrecision] / N[(l / h), $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_s \cdot \begin{array}{l}
\mathbf{if}\;{\left(\frac{M_m \cdot D_m}{2 \cdot d_m}\right)}^{2} \leq 4 \cdot 10^{+253}:\\
\;\;\;\;w0_m \cdot {\left(1 - \frac{h \cdot {\left(\left(M_m \cdot D_m\right) \cdot \frac{0.5}{d_m}\right)}^{2}}{\ell}\right)}^{0.5}\\

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


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

    1. Initial program 90.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.9999999999999997e253 < (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)

    1. Initial program 48.7%

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

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

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

      \[\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} \]
    5. Taylor expanded in d around 0 7.1%

      \[\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 \left(\frac{1}{D}\right)\right)}\right)}^{2} \]
    6. Step-by-step derivation
      1. distribute-lft-neg-in7.1%

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

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

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

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

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

Alternative 3: 86.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_s \cdot \begin{array}{l} \mathbf{if}\;\frac{M_m \cdot D_m}{2 \cdot d_m} \leq 5 \cdot 10^{+126}:\\ \;\;\;\;w0_m \cdot {\left(1 - \frac{h \cdot {\left(\left(M_m \cdot D_m\right) \cdot \frac{0.5}{d_m}\right)}^{2}}{\ell}\right)}^{0.5}\\ \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} \]
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)
(FPCore (w0_s w0_m M_m D_m h l d_m)
 :precision binary64
 (*
  w0_s
  (if (<= (/ (* M_m D_m) (* 2.0 d_m)) 5e+126)
    (*
     w0_m
     (pow (- 1.0 (/ (* h (pow (* (* M_m D_m) (/ 0.5 d_m)) 2.0)) l)) 0.5))
    (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);
double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
	double tmp;
	if (((M_m * D_m) / (2.0 * d_m)) <= 5e+126) {
		tmp = w0_m * pow((1.0 - ((h * pow(((M_m * D_m) * (0.5 / d_m)), 2.0)) / l)), 0.5);
	} 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)
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) :: tmp
    if (((m_m * d_m) / (2.0d0 * d_m_1)) <= 5d+126) then
        tmp = w0_m * ((1.0d0 - ((h * (((m_m * d_m) * (0.5d0 / d_m_1)) ** 2.0d0)) / l)) ** 0.5d0)
    else
        tmp = (sqrt(w0_m) * exp((0.25d0 * (log(((-0.25d0) * ((h * (m_m ** 2.0d0)) / l))) + (((-2.0d0) * log(d_m_1)) + (2.0d0 * log(d_m))))))) ** 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);
public static double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
	double tmp;
	if (((M_m * D_m) / (2.0 * d_m)) <= 5e+126) {
		tmp = w0_m * Math.pow((1.0 - ((h * Math.pow(((M_m * D_m) * (0.5 / d_m)), 2.0)) / l)), 0.5);
	} 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)
def code(w0_s, w0_m, M_m, D_m, h, l, d_m):
	tmp = 0
	if ((M_m * D_m) / (2.0 * d_m)) <= 5e+126:
		tmp = w0_m * math.pow((1.0 - ((h * math.pow(((M_m * D_m) * (0.5 / d_m)), 2.0)) / l)), 0.5)
	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)
function code(w0_s, w0_m, M_m, D_m, h, l, d_m)
	tmp = 0.0
	if (Float64(Float64(M_m * D_m) / Float64(2.0 * d_m)) <= 5e+126)
		tmp = Float64(w0_m * (Float64(1.0 - Float64(Float64(h * (Float64(Float64(M_m * D_m) * Float64(0.5 / d_m)) ^ 2.0)) / l)) ^ 0.5));
	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);
function tmp_2 = code(w0_s, w0_m, M_m, D_m, h, l, d_m)
	tmp = 0.0;
	if (((M_m * D_m) / (2.0 * d_m)) <= 5e+126)
		tmp = w0_m * ((1.0 - ((h * (((M_m * D_m) * (0.5 / d_m)) ^ 2.0)) / l)) ^ 0.5);
	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]
code[w0$95$s_, w0$95$m_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := N[(w0$95$s * If[LessEqual[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 5e+126], N[(w0$95$m * N[Power[N[(1.0 - N[(N[(h * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] * N[(0.5 / d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision], 0.5], $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_s \cdot \begin{array}{l}
\mathbf{if}\;\frac{M_m \cdot D_m}{2 \cdot d_m} \leq 5 \cdot 10^{+126}:\\
\;\;\;\;w0_m \cdot {\left(1 - \frac{h \cdot {\left(\left(M_m \cdot D_m\right) \cdot \frac{0.5}{d_m}\right)}^{2}}{\ell}\right)}^{0.5}\\

\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}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (*.f64 M D) (*.f64 2 d)) < 4.99999999999999977e126

    1. Initial program 84.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.99999999999999977e126 < (/.f64 (*.f64 M D) (*.f64 2 d))

    1. Initial program 45.2%

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

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

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

      \[\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} \]
    5. Taylor expanded in d around 0 8.4%

      \[\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 \left(\frac{1}{D}\right)\right)}\right)}^{2} \]
    6. Step-by-step derivation
      1. distribute-lft-neg-in8.4%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{M \cdot D}{2 \cdot d} \leq 5 \cdot 10^{+126}:\\ \;\;\;\;w0 \cdot {\left(1 - \frac{h \cdot {\left(\left(M \cdot D\right) \cdot \frac{0.5}{d}\right)}^{2}}{\ell}\right)}^{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} \]

Alternative 4: 86.4% accurate, 0.4× 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) \\ \begin{array}{l} t_0 := \sqrt[3]{1 - \left(\left(0.5 \cdot \frac{D_m}{d_m}\right) \cdot \frac{M_m}{\frac{\ell}{h}}\right) \cdot \left(M_m \cdot \frac{D_m}{2 \cdot d_m}\right)}\\ w0_s \cdot \begin{array}{l} \mathbf{if}\;M_m \cdot D_m \leq 4 \cdot 10^{+99}:\\ \;\;\;\;w0_m \cdot {\left(1 - \frac{h \cdot {\left(\left(M_m \cdot D_m\right) \cdot \frac{0.5}{d_m}\right)}^{2}}{\ell}\right)}^{0.5}\\ \mathbf{else}:\\ \;\;\;\;w0_m \cdot \left({\left({t_0}^{2}\right)}^{0.5} \cdot {t_0}^{0.5}\right)\\ \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)
(FPCore (w0_s w0_m M_m D_m h l d_m)
 :precision binary64
 (let* ((t_0
         (cbrt
          (-
           1.0
           (*
            (* (* 0.5 (/ D_m d_m)) (/ M_m (/ l h)))
            (* M_m (/ D_m (* 2.0 d_m))))))))
   (*
    w0_s
    (if (<= (* M_m D_m) 4e+99)
      (*
       w0_m
       (pow (- 1.0 (/ (* h (pow (* (* M_m D_m) (/ 0.5 d_m)) 2.0)) l)) 0.5))
      (* w0_m (* (pow (pow t_0 2.0) 0.5) (pow t_0 0.5)))))))
M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
w0_m = fabs(w0);
w0_s = copysign(1.0, w0);
double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
	double t_0 = cbrt((1.0 - (((0.5 * (D_m / d_m)) * (M_m / (l / h))) * (M_m * (D_m / (2.0 * d_m))))));
	double tmp;
	if ((M_m * D_m) <= 4e+99) {
		tmp = w0_m * pow((1.0 - ((h * pow(((M_m * D_m) * (0.5 / d_m)), 2.0)) / l)), 0.5);
	} else {
		tmp = w0_m * (pow(pow(t_0, 2.0), 0.5) * pow(t_0, 0.5));
	}
	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);
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 = Math.cbrt((1.0 - (((0.5 * (D_m / d_m)) * (M_m / (l / h))) * (M_m * (D_m / (2.0 * d_m))))));
	double tmp;
	if ((M_m * D_m) <= 4e+99) {
		tmp = w0_m * Math.pow((1.0 - ((h * Math.pow(((M_m * D_m) * (0.5 / d_m)), 2.0)) / l)), 0.5);
	} else {
		tmp = w0_m * (Math.pow(Math.pow(t_0, 2.0), 0.5) * Math.pow(t_0, 0.5));
	}
	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)
function code(w0_s, w0_m, M_m, D_m, h, l, d_m)
	t_0 = cbrt(Float64(1.0 - Float64(Float64(Float64(0.5 * Float64(D_m / d_m)) * Float64(M_m / Float64(l / h))) * Float64(M_m * Float64(D_m / Float64(2.0 * d_m))))))
	tmp = 0.0
	if (Float64(M_m * D_m) <= 4e+99)
		tmp = Float64(w0_m * (Float64(1.0 - Float64(Float64(h * (Float64(Float64(M_m * D_m) * Float64(0.5 / d_m)) ^ 2.0)) / l)) ^ 0.5));
	else
		tmp = Float64(w0_m * Float64(((t_0 ^ 2.0) ^ 0.5) * (t_0 ^ 0.5)));
	end
	return Float64(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]
code[w0$95$s_, w0$95$m_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := Block[{t$95$0 = N[Power[N[(1.0 - N[(N[(N[(0.5 * N[(D$95$m / d$95$m), $MachinePrecision]), $MachinePrecision] * N[(M$95$m / N[(l / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(M$95$m * N[(D$95$m / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]}, N[(w0$95$s * If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 4e+99], N[(w0$95$m * N[Power[N[(1.0 - N[(N[(h * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] * N[(0.5 / d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision], N[(w0$95$m * N[(N[Power[N[Power[t$95$0, 2.0], $MachinePrecision], 0.5], $MachinePrecision] * N[Power[t$95$0, 0.5], $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)

\\
\begin{array}{l}
t_0 := \sqrt[3]{1 - \left(\left(0.5 \cdot \frac{D_m}{d_m}\right) \cdot \frac{M_m}{\frac{\ell}{h}}\right) \cdot \left(M_m \cdot \frac{D_m}{2 \cdot d_m}\right)}\\
w0_s \cdot \begin{array}{l}
\mathbf{if}\;M_m \cdot D_m \leq 4 \cdot 10^{+99}:\\
\;\;\;\;w0_m \cdot {\left(1 - \frac{h \cdot {\left(\left(M_m \cdot D_m\right) \cdot \frac{0.5}{d_m}\right)}^{2}}{\ell}\right)}^{0.5}\\

\mathbf{else}:\\
\;\;\;\;w0_m \cdot \left({\left({t_0}^{2}\right)}^{0.5} \cdot {t_0}^{0.5}\right)\\


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 M D) < 3.9999999999999999e99

    1. Initial program 85.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.9999999999999999e99 < (*.f64 M D)

    1. Initial program 53.8%

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

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

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

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

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

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

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

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

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{{\left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}^{2} \cdot h}{\ell}}} \]
    5. Step-by-step derivation
      1. associate-*r/56.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}}} \]
      2. *-commutative56.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}}} \]
      3. unpow256.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 88.2% accurate, 0.7× 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_s \cdot \begin{array}{l} \mathbf{if}\;1 - {\left(\frac{M_m \cdot D_m}{2 \cdot d_m}\right)}^{2} \cdot \frac{h}{\ell} \leq 2 \cdot 10^{+239}:\\ \;\;\;\;w0_m \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(\frac{D_m}{2 \cdot \frac{d_m}{M_m}}\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;w0_m \cdot \sqrt{1 + \left(\frac{D_m}{d_m} \cdot -0.5\right) \cdot \left(\frac{M_m}{\ell} \cdot \left(h \cdot \left(M_m \cdot \frac{D_m}{2 \cdot d_m}\right)\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)
(FPCore (w0_s w0_m M_m D_m h l d_m)
 :precision binary64
 (*
  w0_s
  (if (<= (- 1.0 (* (pow (/ (* M_m D_m) (* 2.0 d_m)) 2.0) (/ h l))) 2e+239)
    (* w0_m (sqrt (- 1.0 (* (/ h l) (pow (/ D_m (* 2.0 (/ d_m M_m))) 2.0)))))
    (*
     w0_m
     (sqrt
      (+
       1.0
       (*
        (* (/ D_m d_m) -0.5)
        (* (/ M_m l) (* h (* M_m (/ D_m (* 2.0 d_m))))))))))))
M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
w0_m = fabs(w0);
w0_s = copysign(1.0, w0);
double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
	double tmp;
	if ((1.0 - (pow(((M_m * D_m) / (2.0 * d_m)), 2.0) * (h / l))) <= 2e+239) {
		tmp = w0_m * sqrt((1.0 - ((h / l) * pow((D_m / (2.0 * (d_m / M_m))), 2.0))));
	} else {
		tmp = w0_m * sqrt((1.0 + (((D_m / d_m) * -0.5) * ((M_m / l) * (h * (M_m * (D_m / (2.0 * d_m))))))));
	}
	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)
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) :: tmp
    if ((1.0d0 - ((((m_m * d_m) / (2.0d0 * d_m_1)) ** 2.0d0) * (h / l))) <= 2d+239) then
        tmp = w0_m * sqrt((1.0d0 - ((h / l) * ((d_m / (2.0d0 * (d_m_1 / m_m))) ** 2.0d0))))
    else
        tmp = w0_m * sqrt((1.0d0 + (((d_m / d_m_1) * (-0.5d0)) * ((m_m / l) * (h * (m_m * (d_m / (2.0d0 * d_m_1))))))))
    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);
public static double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
	double tmp;
	if ((1.0 - (Math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0) * (h / l))) <= 2e+239) {
		tmp = w0_m * Math.sqrt((1.0 - ((h / l) * Math.pow((D_m / (2.0 * (d_m / M_m))), 2.0))));
	} else {
		tmp = w0_m * Math.sqrt((1.0 + (((D_m / d_m) * -0.5) * ((M_m / l) * (h * (M_m * (D_m / (2.0 * d_m))))))));
	}
	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)
def code(w0_s, w0_m, M_m, D_m, h, l, d_m):
	tmp = 0
	if (1.0 - (math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0) * (h / l))) <= 2e+239:
		tmp = w0_m * math.sqrt((1.0 - ((h / l) * math.pow((D_m / (2.0 * (d_m / M_m))), 2.0))))
	else:
		tmp = w0_m * math.sqrt((1.0 + (((D_m / d_m) * -0.5) * ((M_m / l) * (h * (M_m * (D_m / (2.0 * d_m))))))))
	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)
function code(w0_s, w0_m, M_m, D_m, h, l, d_m)
	tmp = 0.0
	if (Float64(1.0 - Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d_m)) ^ 2.0) * Float64(h / l))) <= 2e+239)
		tmp = Float64(w0_m * sqrt(Float64(1.0 - Float64(Float64(h / l) * (Float64(D_m / Float64(2.0 * Float64(d_m / M_m))) ^ 2.0)))));
	else
		tmp = Float64(w0_m * sqrt(Float64(1.0 + Float64(Float64(Float64(D_m / d_m) * -0.5) * Float64(Float64(M_m / l) * Float64(h * Float64(M_m * Float64(D_m / Float64(2.0 * d_m)))))))));
	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);
function tmp_2 = code(w0_s, w0_m, M_m, D_m, h, l, d_m)
	tmp = 0.0;
	if ((1.0 - ((((M_m * D_m) / (2.0 * d_m)) ^ 2.0) * (h / l))) <= 2e+239)
		tmp = w0_m * sqrt((1.0 - ((h / l) * ((D_m / (2.0 * (d_m / M_m))) ^ 2.0))));
	else
		tmp = w0_m * sqrt((1.0 + (((D_m / d_m) * -0.5) * ((M_m / l) * (h * (M_m * (D_m / (2.0 * d_m))))))));
	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]
code[w0$95$s_, w0$95$m_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := N[(w0$95$s * If[LessEqual[N[(1.0 - N[(N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2e+239], N[(w0$95$m * N[Sqrt[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[Power[N[(D$95$m / N[(2.0 * N[(d$95$m / M$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0$95$m * N[Sqrt[N[(1.0 + N[(N[(N[(D$95$m / d$95$m), $MachinePrecision] * -0.5), $MachinePrecision] * N[(N[(M$95$m / l), $MachinePrecision] * N[(h * N[(M$95$m * N[(D$95$m / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision]), $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_s \cdot \begin{array}{l}
\mathbf{if}\;1 - {\left(\frac{M_m \cdot D_m}{2 \cdot d_m}\right)}^{2} \cdot \frac{h}{\ell} \leq 2 \cdot 10^{+239}:\\
\;\;\;\;w0_m \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(\frac{D_m}{2 \cdot \frac{d_m}{M_m}}\right)}^{2}}\\

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


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

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

    1. Initial program 42.5%

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

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

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

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

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

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

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

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

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{{\left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}^{2} \cdot h}{\ell}}} \]
    5. Step-by-step derivation
      1. associate-*r/44.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}}} \]
      2. *-commutative44.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}}} \]
      3. unpow244.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 87.1% accurate, 1.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) \\ \begin{array}{l} t_0 := M_m \cdot \frac{D_m}{2 \cdot d_m}\\ w0_s \cdot \begin{array}{l} \mathbf{if}\;M_m \cdot D_m \leq 2 \cdot 10^{+98}:\\ \;\;\;\;w0_m \cdot {\left(1 - \frac{h \cdot {\left(\left(M_m \cdot D_m\right) \cdot \frac{0.5}{d_m}\right)}^{2}}{\ell}\right)}^{0.5}\\ \mathbf{else}:\\ \;\;\;\;w0_m \cdot \sqrt{1 - t_0 \cdot \left(\frac{h}{\ell} \cdot t_0\right)}\\ \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)
(FPCore (w0_s w0_m M_m D_m h l d_m)
 :precision binary64
 (let* ((t_0 (* M_m (/ D_m (* 2.0 d_m)))))
   (*
    w0_s
    (if (<= (* M_m D_m) 2e+98)
      (*
       w0_m
       (pow (- 1.0 (/ (* h (pow (* (* M_m D_m) (/ 0.5 d_m)) 2.0)) l)) 0.5))
      (* w0_m (sqrt (- 1.0 (* t_0 (* (/ h l) t_0)))))))))
M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
w0_m = fabs(w0);
w0_s = copysign(1.0, w0);
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 / (2.0 * d_m));
	double tmp;
	if ((M_m * D_m) <= 2e+98) {
		tmp = w0_m * pow((1.0 - ((h * pow(((M_m * D_m) * (0.5 / d_m)), 2.0)) / l)), 0.5);
	} else {
		tmp = w0_m * sqrt((1.0 - (t_0 * ((h / l) * 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.0d0, w0)
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 / (2.0d0 * d_m_1))
    if ((m_m * d_m) <= 2d+98) then
        tmp = w0_m * ((1.0d0 - ((h * (((m_m * d_m) * (0.5d0 / d_m_1)) ** 2.0d0)) / l)) ** 0.5d0)
    else
        tmp = w0_m * sqrt((1.0d0 - (t_0 * ((h / l) * t_0))))
    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);
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 / (2.0 * d_m));
	double tmp;
	if ((M_m * D_m) <= 2e+98) {
		tmp = w0_m * Math.pow((1.0 - ((h * Math.pow(((M_m * D_m) * (0.5 / d_m)), 2.0)) / l)), 0.5);
	} else {
		tmp = w0_m * Math.sqrt((1.0 - (t_0 * ((h / l) * 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)
def code(w0_s, w0_m, M_m, D_m, h, l, d_m):
	t_0 = M_m * (D_m / (2.0 * d_m))
	tmp = 0
	if (M_m * D_m) <= 2e+98:
		tmp = w0_m * math.pow((1.0 - ((h * math.pow(((M_m * D_m) * (0.5 / d_m)), 2.0)) / l)), 0.5)
	else:
		tmp = w0_m * math.sqrt((1.0 - (t_0 * ((h / l) * 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)
function code(w0_s, w0_m, M_m, D_m, h, l, d_m)
	t_0 = Float64(M_m * Float64(D_m / Float64(2.0 * d_m)))
	tmp = 0.0
	if (Float64(M_m * D_m) <= 2e+98)
		tmp = Float64(w0_m * (Float64(1.0 - Float64(Float64(h * (Float64(Float64(M_m * D_m) * Float64(0.5 / d_m)) ^ 2.0)) / l)) ^ 0.5));
	else
		tmp = Float64(w0_m * sqrt(Float64(1.0 - Float64(t_0 * Float64(Float64(h / l) * 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);
function tmp_2 = code(w0_s, w0_m, M_m, D_m, h, l, d_m)
	t_0 = M_m * (D_m / (2.0 * d_m));
	tmp = 0.0;
	if ((M_m * D_m) <= 2e+98)
		tmp = w0_m * ((1.0 - ((h * (((M_m * D_m) * (0.5 / d_m)) ^ 2.0)) / l)) ^ 0.5);
	else
		tmp = w0_m * sqrt((1.0 - (t_0 * ((h / l) * 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]
code[w0$95$s_, w0$95$m_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := Block[{t$95$0 = N[(M$95$m * N[(D$95$m / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(w0$95$s * If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 2e+98], N[(w0$95$m * N[Power[N[(1.0 - N[(N[(h * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] * N[(0.5 / d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision], N[(w0$95$m * N[Sqrt[N[(1.0 - N[(t$95$0 * N[(N[(h / l), $MachinePrecision] * 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)

\\
\begin{array}{l}
t_0 := M_m \cdot \frac{D_m}{2 \cdot d_m}\\
w0_s \cdot \begin{array}{l}
\mathbf{if}\;M_m \cdot D_m \leq 2 \cdot 10^{+98}:\\
\;\;\;\;w0_m \cdot {\left(1 - \frac{h \cdot {\left(\left(M_m \cdot D_m\right) \cdot \frac{0.5}{d_m}\right)}^{2}}{\ell}\right)}^{0.5}\\

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


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

    1. Initial program 85.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2e98 < (*.f64 M D)

    1. Initial program 53.8%

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

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

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

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

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

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

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

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

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{{\left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}^{2} \cdot h}{\ell}}} \]
    5. Step-by-step derivation
      1. associate-*r/56.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}}} \]
      2. *-commutative56.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}}} \]
      3. unpow256.4%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 84.0% accurate, 1.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_s \cdot \begin{array}{l} \mathbf{if}\;\ell \leq -2 \cdot 10^{+43}:\\ \;\;\;\;w0_m \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(D_m \cdot \frac{M_m}{2 \cdot d_m}\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;w0_m \cdot \sqrt{1 + \left(\frac{D_m}{d_m} \cdot -0.5\right) \cdot \left(\frac{M_m}{\ell} \cdot \left(h \cdot \left(M_m \cdot \frac{D_m}{2 \cdot d_m}\right)\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)
(FPCore (w0_s w0_m M_m D_m h l d_m)
 :precision binary64
 (*
  w0_s
  (if (<= l -2e+43)
    (* w0_m (sqrt (- 1.0 (* (/ h l) (pow (* D_m (/ M_m (* 2.0 d_m))) 2.0)))))
    (*
     w0_m
     (sqrt
      (+
       1.0
       (*
        (* (/ D_m d_m) -0.5)
        (* (/ M_m l) (* h (* M_m (/ D_m (* 2.0 d_m))))))))))))
M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
w0_m = fabs(w0);
w0_s = copysign(1.0, w0);
double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
	double tmp;
	if (l <= -2e+43) {
		tmp = w0_m * sqrt((1.0 - ((h / l) * pow((D_m * (M_m / (2.0 * d_m))), 2.0))));
	} else {
		tmp = w0_m * sqrt((1.0 + (((D_m / d_m) * -0.5) * ((M_m / l) * (h * (M_m * (D_m / (2.0 * d_m))))))));
	}
	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)
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) :: tmp
    if (l <= (-2d+43)) then
        tmp = w0_m * sqrt((1.0d0 - ((h / l) * ((d_m * (m_m / (2.0d0 * d_m_1))) ** 2.0d0))))
    else
        tmp = w0_m * sqrt((1.0d0 + (((d_m / d_m_1) * (-0.5d0)) * ((m_m / l) * (h * (m_m * (d_m / (2.0d0 * d_m_1))))))))
    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);
public static double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
	double tmp;
	if (l <= -2e+43) {
		tmp = w0_m * Math.sqrt((1.0 - ((h / l) * Math.pow((D_m * (M_m / (2.0 * d_m))), 2.0))));
	} else {
		tmp = w0_m * Math.sqrt((1.0 + (((D_m / d_m) * -0.5) * ((M_m / l) * (h * (M_m * (D_m / (2.0 * d_m))))))));
	}
	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)
def code(w0_s, w0_m, M_m, D_m, h, l, d_m):
	tmp = 0
	if l <= -2e+43:
		tmp = w0_m * math.sqrt((1.0 - ((h / l) * math.pow((D_m * (M_m / (2.0 * d_m))), 2.0))))
	else:
		tmp = w0_m * math.sqrt((1.0 + (((D_m / d_m) * -0.5) * ((M_m / l) * (h * (M_m * (D_m / (2.0 * d_m))))))))
	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)
function code(w0_s, w0_m, M_m, D_m, h, l, d_m)
	tmp = 0.0
	if (l <= -2e+43)
		tmp = Float64(w0_m * sqrt(Float64(1.0 - Float64(Float64(h / l) * (Float64(D_m * Float64(M_m / Float64(2.0 * d_m))) ^ 2.0)))));
	else
		tmp = Float64(w0_m * sqrt(Float64(1.0 + Float64(Float64(Float64(D_m / d_m) * -0.5) * Float64(Float64(M_m / l) * Float64(h * Float64(M_m * Float64(D_m / Float64(2.0 * d_m)))))))));
	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);
function tmp_2 = code(w0_s, w0_m, M_m, D_m, h, l, d_m)
	tmp = 0.0;
	if (l <= -2e+43)
		tmp = w0_m * sqrt((1.0 - ((h / l) * ((D_m * (M_m / (2.0 * d_m))) ^ 2.0))));
	else
		tmp = w0_m * sqrt((1.0 + (((D_m / d_m) * -0.5) * ((M_m / l) * (h * (M_m * (D_m / (2.0 * d_m))))))));
	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]
code[w0$95$s_, w0$95$m_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := N[(w0$95$s * If[LessEqual[l, -2e+43], N[(w0$95$m * N[Sqrt[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[Power[N[(D$95$m * N[(M$95$m / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0$95$m * N[Sqrt[N[(1.0 + N[(N[(N[(D$95$m / d$95$m), $MachinePrecision] * -0.5), $MachinePrecision] * N[(N[(M$95$m / l), $MachinePrecision] * N[(h * N[(M$95$m * N[(D$95$m / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision]), $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_s \cdot \begin{array}{l}
\mathbf{if}\;\ell \leq -2 \cdot 10^{+43}:\\
\;\;\;\;w0_m \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(D_m \cdot \frac{M_m}{2 \cdot d_m}\right)}^{2}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -2.00000000000000003e43

    1. Initial program 91.0%

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

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

    if -2.00000000000000003e43 < l

    1. Initial program 77.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 \cdot \sqrt{\color{blue}{1 + \left(-0.5 \cdot \frac{D}{d}\right) \cdot \left(\frac{M}{\frac{\ell}{h}} \cdot \left(M \cdot \frac{D}{d \cdot 2}\right)\right)}} \]
      5. distribute-lft-neg-in76.0%

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

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

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

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

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

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

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

Alternative 8: 85.3% 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_s \cdot \left(w0_m \cdot \sqrt{1 + \left(\frac{D_m}{d_m} \cdot -0.5\right) \cdot \left(\frac{M_m}{\ell} \cdot \left(h \cdot \left(M_m \cdot \frac{D_m}{2 \cdot d_m}\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)
(FPCore (w0_s w0_m M_m D_m h l d_m)
 :precision binary64
 (*
  w0_s
  (*
   w0_m
   (sqrt
    (+
     1.0
     (*
      (* (/ D_m d_m) -0.5)
      (* (/ M_m l) (* h (* M_m (/ D_m (* 2.0 d_m)))))))))))
M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
w0_m = fabs(w0);
w0_s = copysign(1.0, w0);
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 / d_m) * -0.5) * ((M_m / l) * (h * (M_m * (D_m / (2.0 * d_m)))))))));
}
M_m = abs(M)
D_m = abs(D)
d_m = abs(d)
w0_m = abs(w0)
w0_s = copysign(1.0d0, w0)
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 / d_m_1) * (-0.5d0)) * ((m_m / l) * (h * (m_m * (d_m / (2.0d0 * d_m_1)))))))))
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);
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 / d_m) * -0.5) * ((M_m / l) * (h * (M_m * (D_m / (2.0 * d_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)
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 / d_m) * -0.5) * ((M_m / l) * (h * (M_m * (D_m / (2.0 * d_m)))))))))
M_m = abs(M)
D_m = abs(D)
d_m = abs(d)
w0_m = abs(w0)
w0_s = copysign(1.0, w0)
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 / d_m) * -0.5) * Float64(Float64(M_m / l) * Float64(h * Float64(M_m * Float64(D_m / Float64(2.0 * d_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);
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 / d_m) * -0.5) * ((M_m / l) * (h * (M_m * (D_m / (2.0 * d_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]
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 / d$95$m), $MachinePrecision] * -0.5), $MachinePrecision] * N[(N[(M$95$m / l), $MachinePrecision] * N[(h * N[(M$95$m * N[(D$95$m / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision]), $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_s \cdot \left(w0_m \cdot \sqrt{1 + \left(\frac{D_m}{d_m} \cdot -0.5\right) \cdot \left(\frac{M_m}{\ell} \cdot \left(h \cdot \left(M_m \cdot \frac{D_m}{2 \cdot d_m}\right)\right)\right)}\right)
\end{array}
Derivation
  1. Initial program 80.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto w0 \cdot \sqrt{\color{blue}{1 + \left(-0.5 \cdot \frac{D}{d}\right) \cdot \left(\frac{M}{\frac{\ell}{h}} \cdot \left(M \cdot \frac{D}{d \cdot 2}\right)\right)}} \]
    5. distribute-lft-neg-in77.8%

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

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

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

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

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

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

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

Alternative 9: 67.9% 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_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)
(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);
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)
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);
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)
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)
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);
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]
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_s \cdot w0_m
\end{array}
Derivation
  1. Initial program 80.7%

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

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

    \[\leadsto \color{blue}{w0} \]
  4. Final simplification65.5%

    \[\leadsto w0 \]

Reproduce

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