Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 81.0% → 88.9%
Time: 19.8s
Alternatives: 10
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 10 alternatives:

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

Initial Program: 81.0% 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: 88.9% accurate, 0.3× speedup?

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

\mathbf{elif}\;t\_0 \leq -4 \cdot 10^{+44}:\\
\;\;\;\;w0\_m \cdot \sqrt{1 - t\_0}\\

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


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

    1. Initial program 60.6%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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} \]

    if -inf.0 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < -4.0000000000000004e44

    1. Initial program 99.3%

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

    if -4.0000000000000004e44 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l))

    1. Initial program 89.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 88.0% accurate, 0.3× speedup?

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

\mathbf{elif}\;t\_0 \leq -4 \cdot 10^{+44}:\\
\;\;\;\;w0\_m \cdot \sqrt{1 - t\_0}\\

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


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

    1. Initial program 60.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -inf.0 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < -4.0000000000000004e44

    1. Initial program 99.3%

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

    if -4.0000000000000004e44 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l))

    1. Initial program 89.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 87.3% accurate, 0.3× speedup?

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

\mathbf{elif}\;t\_0 \leq -4 \cdot 10^{+44}:\\
\;\;\;\;w0\_m \cdot \sqrt{1 - t\_0}\\

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


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

    1. Initial program 60.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -inf.0 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < -4.0000000000000004e44

    1. Initial program 99.3%

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

    if -4.0000000000000004e44 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l))

    1. Initial program 89.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 88.2% accurate, 0.3× speedup?

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

\mathbf{elif}\;t\_0 \leq -4 \cdot 10^{+44}:\\
\;\;\;\;w0\_m \cdot \sqrt{1 - t\_0}\\

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


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

    1. Initial program 60.6%

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

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

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

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

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

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

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

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

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

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

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

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

    if -inf.0 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < -4.0000000000000004e44

    1. Initial program 99.3%

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

    if -4.0000000000000004e44 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l))

    1. Initial program 89.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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

    1. Initial program 98.8%

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

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

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

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

    if 5.0000000000000004e283 < (-.f64 #s(literal 1 binary64) (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)))

    1. Initial program 48.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 67.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_m, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0_m, M_m, D_m, h, l, d_m])\\ \\ w0\_s \cdot \begin{array}{l} \mathbf{if}\;d\_m \leq 2.3 \cdot 10^{-222}:\\ \;\;\;\;\log \left(e^{w0\_m}\right)\\ \mathbf{else}:\\ \;\;\;\;w0\_m\\ \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 #s(literal 1 binary64) w0)
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0_s w0_m M_m D_m h l d_m)
 :precision binary64
 (* w0_s (if (<= d_m 2.3e-222) (log (exp w0_m)) w0_m)))
M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
w0\_m = fabs(w0);
w0\_s = copysign(1.0, w0);
assert(w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
	double tmp;
	if (d_m <= 2.3e-222) {
		tmp = log(exp(w0_m));
	} else {
		tmp = w0_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)
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
real(8) function code(w0_s, w0_m, m_m, d_m, h, l, d_m_1)
    real(8), intent (in) :: w0_s
    real(8), intent (in) :: w0_m
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d_m_1
    real(8) :: tmp
    if (d_m_1 <= 2.3d-222) then
        tmp = log(exp(w0_m))
    else
        tmp = w0_m
    end if
    code = w0_s * tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
d_m = Math.abs(d);
w0\_m = Math.abs(w0);
w0\_s = Math.copySign(1.0, w0);
assert w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
	double tmp;
	if (d_m <= 2.3e-222) {
		tmp = Math.log(Math.exp(w0_m));
	} else {
		tmp = w0_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)
[w0_m, M_m, D_m, h, l, d_m] = sort([w0_m, M_m, D_m, h, l, d_m])
def code(w0_s, w0_m, M_m, D_m, h, l, d_m):
	tmp = 0
	if d_m <= 2.3e-222:
		tmp = math.log(math.exp(w0_m))
	else:
		tmp = w0_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)
w0_m, M_m, D_m, h, l, d_m = sort([w0_m, M_m, D_m, h, l, d_m])
function code(w0_s, w0_m, M_m, D_m, h, l, d_m)
	tmp = 0.0
	if (d_m <= 2.3e-222)
		tmp = log(exp(w0_m));
	else
		tmp = w0_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);
w0_m, M_m, D_m, h, l, d_m = num2cell(sort([w0_m, M_m, D_m, h, l, d_m])){:}
function tmp_2 = code(w0_s, w0_m, M_m, D_m, h, l, d_m)
	tmp = 0.0;
	if (d_m <= 2.3e-222)
		tmp = log(exp(w0_m));
	else
		tmp = w0_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]
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0$95$s_, w0$95$m_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := N[(w0$95$s * If[LessEqual[d$95$m, 2.3e-222], N[Log[N[Exp[w0$95$m], $MachinePrecision]], $MachinePrecision], w0$95$m]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
w0\_m = \left|w0\right|
\\
w0\_s = \mathsf{copysign}\left(1, w0\right)
\\
[w0_m, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0_m, M_m, D_m, h, l, d_m])\\
\\
w0\_s \cdot \begin{array}{l}
\mathbf{if}\;d\_m \leq 2.3 \cdot 10^{-222}:\\
\;\;\;\;\log \left(e^{w0\_m}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < 2.3000000000000001e-222

    1. Initial program 83.8%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto {\color{blue}{\left(\sqrt{w0}\right)}}^{2} \]
    7. Step-by-step derivation
      1. unpow224.5%

        \[\leadsto \color{blue}{\sqrt{w0} \cdot \sqrt{w0}} \]
      2. add-sqr-sqrt54.3%

        \[\leadsto \color{blue}{w0} \]
      3. add-log-exp21.4%

        \[\leadsto \color{blue}{\log \left(e^{w0}\right)} \]
    8. Applied egg-rr21.4%

      \[\leadsto \color{blue}{\log \left(e^{w0}\right)} \]

    if 2.3000000000000001e-222 < d

    1. Initial program 83.4%

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

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

      \[\leadsto \color{blue}{w0} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 10: 67.2% accurate, 216.0× speedup?

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

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

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

    \[\leadsto \color{blue}{w0} \]
  5. Add Preprocessing

Reproduce

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