Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 80.4% → 86.8%
Time: 18.4s
Alternatives: 12
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 12 alternatives:

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

Initial Program: 80.4% 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: 86.8% accurate, 0.6× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 (*.f64 M D) (*.f64 2 d)) < 1.00000000000000005e-4

    1. Initial program 82.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.00000000000000005e-4 < (/.f64 (*.f64 M D) (*.f64 2 d)) < 4e153

    1. Initial program 85.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4e153 < (/.f64 (*.f64 M D) (*.f64 2 d))

    1. Initial program 36.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 87.2% accurate, 0.5× speedup?

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

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


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

    1. Initial program 92.8%

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

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

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

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

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

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

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

    1. Initial program 28.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 87.2% accurate, 0.6× speedup?

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

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


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

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

    1. Initial program 37.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 85.6% accurate, 1.0× speedup?

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

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


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

    1. Initial program 76.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.4500000000000001e-124 < d

    1. Initial program 83.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 85.7% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 79.7% accurate, 1.0× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ d_m = \left|d\right| \\ [w0, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0, M_m, D_m, h, l, d_m])\\ \\ w0 \cdot \mathsf{fma}\left(-0.125, \frac{h}{\ell \cdot {\left(M_m \cdot \frac{D_m}{d_m}\right)}^{-2}}, 1\right) \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d_m)
 :precision binary64
 (* w0 (fma -0.125 (/ h (* l (pow (* M_m (/ D_m d_m)) -2.0))) 1.0)))
M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
	return w0 * fma(-0.125, (h / (l * pow((M_m * (D_m / d_m)), -2.0))), 1.0);
}
M_m = abs(M)
D_m = abs(D)
d_m = abs(d)
w0, M_m, D_m, h, l, d_m = sort([w0, M_m, D_m, h, l, d_m])
function code(w0, M_m, D_m, h, l, d_m)
	return Float64(w0 * fma(-0.125, Float64(h / Float64(l * (Float64(M_m * Float64(D_m / d_m)) ^ -2.0))), 1.0))
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := N[(w0 * N[(-0.125 * N[(h / N[(l * N[Power[N[(M$95$m * N[(D$95$m / d$95$m), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
[w0, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0, M_m, D_m, h, l, d_m])\\
\\
w0 \cdot \mathsf{fma}\left(-0.125, \frac{h}{\ell \cdot {\left(M_m \cdot \frac{D_m}{d_m}\right)}^{-2}}, 1\right)
\end{array}
Derivation
  1. Initial program 79.0%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto w0 \cdot \color{blue}{\mathsf{fma}\left(-0.125, \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}, 1\right)} \]
  7. Simplified77.7%

    \[\leadsto w0 \cdot \color{blue}{\mathsf{fma}\left(-0.125, \frac{h}{\frac{\ell}{{\left(\frac{D}{d} \cdot M\right)}^{2}}}, 1\right)} \]
  8. Step-by-step derivation
    1. div-inv77.7%

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

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

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

      \[\leadsto w0 \cdot \mathsf{fma}\left(-0.125, \frac{h}{\ell \cdot \color{blue}{{\left(\frac{M \cdot D}{d}\right)}^{\left(-2\right)}}}, 1\right) \]
    5. *-commutative77.4%

      \[\leadsto w0 \cdot \mathsf{fma}\left(-0.125, \frac{h}{\ell \cdot {\left(\frac{\color{blue}{D \cdot M}}{d}\right)}^{\left(-2\right)}}, 1\right) \]
    6. associate-*l/77.7%

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

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

      \[\leadsto w0 \cdot \mathsf{fma}\left(-0.125, \frac{h}{\ell \cdot {\left(M \cdot \frac{D}{d}\right)}^{\color{blue}{-2}}}, 1\right) \]
  9. Applied egg-rr77.7%

    \[\leadsto w0 \cdot \mathsf{fma}\left(-0.125, \frac{h}{\color{blue}{\ell \cdot {\left(M \cdot \frac{D}{d}\right)}^{-2}}}, 1\right) \]
  10. Final simplification77.7%

    \[\leadsto w0 \cdot \mathsf{fma}\left(-0.125, \frac{h}{\ell \cdot {\left(M \cdot \frac{D}{d}\right)}^{-2}}, 1\right) \]

Alternative 7: 79.9% accurate, 1.0× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ d_m = \left|d\right| \\ [w0, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0, M_m, D_m, h, l, d_m])\\ \\ w0 \cdot \mathsf{fma}\left(-0.125, \frac{h}{\frac{\ell}{{\left(\frac{M_m}{\frac{d_m}{D_m}}\right)}^{2}}}, 1\right) \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d_m)
 :precision binary64
 (* w0 (fma -0.125 (/ h (/ l (pow (/ M_m (/ d_m D_m)) 2.0))) 1.0)))
M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
	return w0 * fma(-0.125, (h / (l / pow((M_m / (d_m / D_m)), 2.0))), 1.0);
}
M_m = abs(M)
D_m = abs(D)
d_m = abs(d)
w0, M_m, D_m, h, l, d_m = sort([w0, M_m, D_m, h, l, d_m])
function code(w0, M_m, D_m, h, l, d_m)
	return Float64(w0 * fma(-0.125, Float64(h / Float64(l / (Float64(M_m / Float64(d_m / D_m)) ^ 2.0))), 1.0))
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := N[(w0 * N[(-0.125 * N[(h / N[(l / N[Power[N[(M$95$m / N[(d$95$m / D$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
[w0, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0, M_m, D_m, h, l, d_m])\\
\\
w0 \cdot \mathsf{fma}\left(-0.125, \frac{h}{\frac{\ell}{{\left(\frac{M_m}{\frac{d_m}{D_m}}\right)}^{2}}}, 1\right)
\end{array}
Derivation
  1. Initial program 79.0%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto w0 \cdot \color{blue}{\mathsf{fma}\left(-0.125, \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}, 1\right)} \]
  7. Simplified77.7%

    \[\leadsto w0 \cdot \color{blue}{\mathsf{fma}\left(-0.125, \frac{h}{\frac{\ell}{{\left(\frac{D}{d} \cdot M\right)}^{2}}}, 1\right)} \]
  8. Step-by-step derivation
    1. associate-*l/77.3%

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

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

      \[\leadsto w0 \cdot \mathsf{fma}\left(-0.125, \frac{h}{\frac{\ell}{{\color{blue}{\left(\frac{M}{\frac{d}{D}}\right)}}^{2}}}, 1\right) \]
  9. Applied egg-rr77.7%

    \[\leadsto w0 \cdot \mathsf{fma}\left(-0.125, \frac{h}{\frac{\ell}{{\color{blue}{\left(\frac{M}{\frac{d}{D}}\right)}}^{2}}}, 1\right) \]
  10. Final simplification77.7%

    \[\leadsto w0 \cdot \mathsf{fma}\left(-0.125, \frac{h}{\frac{\ell}{{\left(\frac{M}{\frac{d}{D}}\right)}^{2}}}, 1\right) \]

Alternative 8: 80.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_m, D_m, h, l, d_m] = \mathsf{sort}([w0, M_m, D_m, h, l, d_m])\\ \\ w0 \cdot \mathsf{fma}\left(-0.125, \frac{h}{\frac{\ell}{{\left(\frac{M_m \cdot D_m}{d_m}\right)}^{2}}}, 1\right) \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d_m)
 :precision binary64
 (* w0 (fma -0.125 (/ h (/ l (pow (/ (* M_m D_m) d_m) 2.0))) 1.0)))
M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
	return w0 * fma(-0.125, (h / (l / pow(((M_m * D_m) / d_m), 2.0))), 1.0);
}
M_m = abs(M)
D_m = abs(D)
d_m = abs(d)
w0, M_m, D_m, h, l, d_m = sort([w0, M_m, D_m, h, l, d_m])
function code(w0, M_m, D_m, h, l, d_m)
	return Float64(w0 * fma(-0.125, Float64(h / Float64(l / (Float64(Float64(M_m * D_m) / d_m) ^ 2.0))), 1.0))
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := N[(w0 * N[(-0.125 * N[(h / N[(l / N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / d$95$m), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
[w0, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0, M_m, D_m, h, l, d_m])\\
\\
w0 \cdot \mathsf{fma}\left(-0.125, \frac{h}{\frac{\ell}{{\left(\frac{M_m \cdot D_m}{d_m}\right)}^{2}}}, 1\right)
\end{array}
Derivation
  1. Initial program 79.0%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto w0 \cdot \color{blue}{\mathsf{fma}\left(-0.125, \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}, 1\right)} \]
  7. Simplified77.7%

    \[\leadsto w0 \cdot \color{blue}{\mathsf{fma}\left(-0.125, \frac{h}{\frac{\ell}{{\left(\frac{D}{d} \cdot M\right)}^{2}}}, 1\right)} \]
  8. Step-by-step derivation
    1. associate-*l/77.3%

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

      \[\leadsto w0 \cdot \mathsf{fma}\left(-0.125, \frac{h}{\frac{\ell}{{\left(\frac{\color{blue}{M \cdot D}}{d}\right)}^{2}}}, 1\right) \]
  9. Applied egg-rr77.3%

    \[\leadsto w0 \cdot \mathsf{fma}\left(-0.125, \frac{h}{\frac{\ell}{{\color{blue}{\left(\frac{M \cdot D}{d}\right)}}^{2}}}, 1\right) \]
  10. Final simplification77.3%

    \[\leadsto w0 \cdot \mathsf{fma}\left(-0.125, \frac{h}{\frac{\ell}{{\left(\frac{M \cdot D}{d}\right)}^{2}}}, 1\right) \]

Alternative 9: 76.6% accurate, 1.8× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ d_m = \left|d\right| \\ [w0, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0, M_m, D_m, h, l, d_m])\\ \\ \begin{array}{l} \mathbf{if}\;M_m \cdot D_m \leq 2 \cdot 10^{-42}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-0.125, \frac{w0 \cdot h}{\ell} \cdot \left(\frac{M_m \cdot D_m}{d_m} \cdot \left(D_m \cdot \frac{M_m}{d_m}\right)\right), w0\right)\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d_m)
 :precision binary64
 (if (<= (* M_m D_m) 2e-42)
   w0
   (fma
    -0.125
    (* (/ (* w0 h) l) (* (/ (* M_m D_m) d_m) (* D_m (/ M_m d_m))))
    w0)))
M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
	double tmp;
	if ((M_m * D_m) <= 2e-42) {
		tmp = w0;
	} else {
		tmp = fma(-0.125, (((w0 * h) / l) * (((M_m * D_m) / d_m) * (D_m * (M_m / d_m)))), w0);
	}
	return tmp;
}
M_m = abs(M)
D_m = abs(D)
d_m = abs(d)
w0, M_m, D_m, h, l, d_m = sort([w0, M_m, D_m, h, l, d_m])
function code(w0, M_m, D_m, h, l, d_m)
	tmp = 0.0
	if (Float64(M_m * D_m) <= 2e-42)
		tmp = w0;
	else
		tmp = fma(-0.125, Float64(Float64(Float64(w0 * h) / l) * Float64(Float64(Float64(M_m * D_m) / d_m) * Float64(D_m * Float64(M_m / d_m)))), w0);
	end
	return tmp
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 2e-42], w0, N[(-0.125 * N[(N[(N[(w0 * h), $MachinePrecision] / l), $MachinePrecision] * N[(N[(N[(M$95$m * D$95$m), $MachinePrecision] / d$95$m), $MachinePrecision] * N[(D$95$m * N[(M$95$m / d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + w0), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
[w0, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0, M_m, D_m, h, l, d_m])\\
\\
\begin{array}{l}
\mathbf{if}\;M_m \cdot D_m \leq 2 \cdot 10^{-42}:\\
\;\;\;\;w0\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.125, \frac{w0 \cdot h}{\ell} \cdot \left(\frac{M_m \cdot D_m}{d_m} \cdot \left(D_m \cdot \frac{M_m}{d_m}\right)\right), w0\right)\\


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

    1. Initial program 81.5%

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

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

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

    if 2.00000000000000008e-42 < (*.f64 M D)

    1. Initial program 70.0%

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(-0.125, \frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(h \cdot w0\right)\right)}{{d}^{2} \cdot \ell}, w0\right)} \]
      3. associate-*r*39.2%

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

        \[\leadsto \mathsf{fma}\left(-0.125, \color{blue}{\frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}} \cdot \frac{h \cdot w0}{\ell}}, w0\right) \]
      5. *-commutative40.9%

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

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

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

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

        \[\leadsto \mathsf{fma}\left(-0.125, \frac{\color{blue}{{\left(M \cdot D\right)}^{2}}}{{d}^{2}} \cdot \frac{h \cdot w0}{\ell}, w0\right) \]
      10. *-commutative52.4%

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(-0.125, \left(\frac{M \cdot D}{\color{blue}{\sqrt{d} \cdot \sqrt{d}}} \cdot \sqrt{\frac{{\left(D \cdot M\right)}^{2}}{{d}^{2}}}\right) \cdot \frac{h \cdot w0}{\ell}, w0\right) \]
      9. add-sqr-sqrt35.3%

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

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

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

        \[\leadsto \mathsf{fma}\left(-0.125, \left(\frac{M \cdot D}{d} \cdot \frac{\color{blue}{\sqrt{D \cdot M} \cdot \sqrt{D \cdot M}}}{\sqrt{{d}^{2}}}\right) \cdot \frac{h \cdot w0}{\ell}, w0\right) \]
      13. add-sqr-sqrt39.0%

        \[\leadsto \mathsf{fma}\left(-0.125, \left(\frac{M \cdot D}{d} \cdot \frac{\color{blue}{D \cdot M}}{\sqrt{{d}^{2}}}\right) \cdot \frac{h \cdot w0}{\ell}, w0\right) \]
      14. *-commutative39.0%

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

        \[\leadsto \mathsf{fma}\left(-0.125, \left(\frac{M \cdot D}{d} \cdot \frac{M \cdot D}{\sqrt{\color{blue}{d \cdot d}}}\right) \cdot \frac{h \cdot w0}{\ell}, w0\right) \]
      16. sqrt-prod33.6%

        \[\leadsto \mathsf{fma}\left(-0.125, \left(\frac{M \cdot D}{d} \cdot \frac{M \cdot D}{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}\right) \cdot \frac{h \cdot w0}{\ell}, w0\right) \]
      17. add-sqr-sqrt56.5%

        \[\leadsto \mathsf{fma}\left(-0.125, \left(\frac{M \cdot D}{d} \cdot \frac{M \cdot D}{\color{blue}{d}}\right) \cdot \frac{h \cdot w0}{\ell}, w0\right) \]
    7. Applied egg-rr56.5%

      \[\leadsto \mathsf{fma}\left(-0.125, \color{blue}{\left(\frac{M \cdot D}{d} \cdot \frac{M \cdot D}{d}\right)} \cdot \frac{h \cdot w0}{\ell}, w0\right) \]
    8. Taylor expanded in M around 0 56.5%

      \[\leadsto \mathsf{fma}\left(-0.125, \left(\frac{M \cdot D}{d} \cdot \color{blue}{\frac{D \cdot M}{d}}\right) \cdot \frac{h \cdot w0}{\ell}, w0\right) \]
    9. Step-by-step derivation
      1. associate-/l*56.4%

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

      \[\leadsto \mathsf{fma}\left(-0.125, \left(\frac{M \cdot D}{d} \cdot \color{blue}{\frac{D}{\frac{d}{M}}}\right) \cdot \frac{h \cdot w0}{\ell}, w0\right) \]
    11. Step-by-step derivation
      1. associate-/r/56.5%

        \[\leadsto \mathsf{fma}\left(-0.125, \left(\frac{M \cdot D}{d} \cdot \color{blue}{\left(\frac{D}{d} \cdot M\right)}\right) \cdot \frac{h \cdot w0}{\ell}, w0\right) \]
      2. associate-*l/56.5%

        \[\leadsto \mathsf{fma}\left(-0.125, \left(\frac{M \cdot D}{d} \cdot \color{blue}{\frac{D \cdot M}{d}}\right) \cdot \frac{h \cdot w0}{\ell}, w0\right) \]
      3. *-commutative56.5%

        \[\leadsto \mathsf{fma}\left(-0.125, \left(\frac{M \cdot D}{d} \cdot \frac{\color{blue}{M \cdot D}}{d}\right) \cdot \frac{h \cdot w0}{\ell}, w0\right) \]
      4. associate-/l*56.5%

        \[\leadsto \mathsf{fma}\left(-0.125, \left(\frac{M \cdot D}{d} \cdot \color{blue}{\frac{M}{\frac{d}{D}}}\right) \cdot \frac{h \cdot w0}{\ell}, w0\right) \]
      5. associate-/r/56.3%

        \[\leadsto \mathsf{fma}\left(-0.125, \left(\frac{M \cdot D}{d} \cdot \color{blue}{\left(\frac{M}{d} \cdot D\right)}\right) \cdot \frac{h \cdot w0}{\ell}, w0\right) \]
    12. Applied egg-rr56.3%

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

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

Alternative 10: 76.6% accurate, 1.8× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ d_m = \left|d\right| \\ [w0, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0, M_m, D_m, h, l, d_m])\\ \\ \begin{array}{l} t_0 := \frac{M_m \cdot D_m}{d_m}\\ \mathbf{if}\;M_m \cdot D_m \leq 2 \cdot 10^{-42}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-0.125, \left(t_0 \cdot t_0\right) \cdot \frac{w0 \cdot h}{\ell}, w0\right)\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d_m)
 :precision binary64
 (let* ((t_0 (/ (* M_m D_m) d_m)))
   (if (<= (* M_m D_m) 2e-42)
     w0
     (fma -0.125 (* (* t_0 t_0) (/ (* w0 h) l)) w0))))
M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
	double t_0 = (M_m * D_m) / d_m;
	double tmp;
	if ((M_m * D_m) <= 2e-42) {
		tmp = w0;
	} else {
		tmp = fma(-0.125, ((t_0 * t_0) * ((w0 * h) / l)), w0);
	}
	return tmp;
}
M_m = abs(M)
D_m = abs(D)
d_m = abs(d)
w0, M_m, D_m, h, l, d_m = sort([w0, M_m, D_m, h, l, d_m])
function code(w0, M_m, D_m, h, l, d_m)
	t_0 = Float64(Float64(M_m * D_m) / d_m)
	tmp = 0.0
	if (Float64(M_m * D_m) <= 2e-42)
		tmp = w0;
	else
		tmp = fma(-0.125, Float64(Float64(t_0 * t_0) * Float64(Float64(w0 * h) / l)), w0);
	end
	return tmp
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := Block[{t$95$0 = N[(N[(M$95$m * D$95$m), $MachinePrecision] / d$95$m), $MachinePrecision]}, If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 2e-42], w0, N[(-0.125 * N[(N[(t$95$0 * t$95$0), $MachinePrecision] * N[(N[(w0 * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] + w0), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
[w0, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0, M_m, D_m, h, l, d_m])\\
\\
\begin{array}{l}
t_0 := \frac{M_m \cdot D_m}{d_m}\\
\mathbf{if}\;M_m \cdot D_m \leq 2 \cdot 10^{-42}:\\
\;\;\;\;w0\\

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


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

    1. Initial program 81.5%

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

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

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

    if 2.00000000000000008e-42 < (*.f64 M D)

    1. Initial program 70.0%

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(-0.125, \frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(h \cdot w0\right)\right)}{{d}^{2} \cdot \ell}, w0\right)} \]
      3. associate-*r*39.2%

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

        \[\leadsto \mathsf{fma}\left(-0.125, \color{blue}{\frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}} \cdot \frac{h \cdot w0}{\ell}}, w0\right) \]
      5. *-commutative40.9%

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

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

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

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

        \[\leadsto \mathsf{fma}\left(-0.125, \frac{\color{blue}{{\left(M \cdot D\right)}^{2}}}{{d}^{2}} \cdot \frac{h \cdot w0}{\ell}, w0\right) \]
      10. *-commutative52.4%

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(-0.125, \left(\frac{M \cdot D}{\color{blue}{\sqrt{d} \cdot \sqrt{d}}} \cdot \sqrt{\frac{{\left(D \cdot M\right)}^{2}}{{d}^{2}}}\right) \cdot \frac{h \cdot w0}{\ell}, w0\right) \]
      9. add-sqr-sqrt35.3%

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

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

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

        \[\leadsto \mathsf{fma}\left(-0.125, \left(\frac{M \cdot D}{d} \cdot \frac{\color{blue}{\sqrt{D \cdot M} \cdot \sqrt{D \cdot M}}}{\sqrt{{d}^{2}}}\right) \cdot \frac{h \cdot w0}{\ell}, w0\right) \]
      13. add-sqr-sqrt39.0%

        \[\leadsto \mathsf{fma}\left(-0.125, \left(\frac{M \cdot D}{d} \cdot \frac{\color{blue}{D \cdot M}}{\sqrt{{d}^{2}}}\right) \cdot \frac{h \cdot w0}{\ell}, w0\right) \]
      14. *-commutative39.0%

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

        \[\leadsto \mathsf{fma}\left(-0.125, \left(\frac{M \cdot D}{d} \cdot \frac{M \cdot D}{\sqrt{\color{blue}{d \cdot d}}}\right) \cdot \frac{h \cdot w0}{\ell}, w0\right) \]
      16. sqrt-prod33.6%

        \[\leadsto \mathsf{fma}\left(-0.125, \left(\frac{M \cdot D}{d} \cdot \frac{M \cdot D}{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}\right) \cdot \frac{h \cdot w0}{\ell}, w0\right) \]
      17. add-sqr-sqrt56.5%

        \[\leadsto \mathsf{fma}\left(-0.125, \left(\frac{M \cdot D}{d} \cdot \frac{M \cdot D}{\color{blue}{d}}\right) \cdot \frac{h \cdot w0}{\ell}, w0\right) \]
    7. Applied egg-rr56.5%

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

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

Alternative 11: 75.5% accurate, 1.8× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ d_m = \left|d\right| \\ [w0, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0, M_m, D_m, h, l, d_m])\\ \\ \begin{array}{l} t_0 := \frac{D_m}{\frac{d_m}{M_m}}\\ \mathbf{if}\;M_m \leq 6.2 \cdot 10^{-171}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-0.125, \frac{w0 \cdot h}{\ell} \cdot \left(t_0 \cdot t_0\right), w0\right)\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d_m)
 :precision binary64
 (let* ((t_0 (/ D_m (/ d_m M_m))))
   (if (<= M_m 6.2e-171) w0 (fma -0.125 (* (/ (* w0 h) l) (* t_0 t_0)) w0))))
M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
	double t_0 = D_m / (d_m / M_m);
	double tmp;
	if (M_m <= 6.2e-171) {
		tmp = w0;
	} else {
		tmp = fma(-0.125, (((w0 * h) / l) * (t_0 * t_0)), w0);
	}
	return tmp;
}
M_m = abs(M)
D_m = abs(D)
d_m = abs(d)
w0, M_m, D_m, h, l, d_m = sort([w0, M_m, D_m, h, l, d_m])
function code(w0, M_m, D_m, h, l, d_m)
	t_0 = Float64(D_m / Float64(d_m / M_m))
	tmp = 0.0
	if (M_m <= 6.2e-171)
		tmp = w0;
	else
		tmp = fma(-0.125, Float64(Float64(Float64(w0 * h) / l) * Float64(t_0 * t_0)), w0);
	end
	return tmp
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := Block[{t$95$0 = N[(D$95$m / N[(d$95$m / M$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[M$95$m, 6.2e-171], w0, N[(-0.125 * N[(N[(N[(w0 * h), $MachinePrecision] / l), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] + w0), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
[w0, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0, M_m, D_m, h, l, d_m])\\
\\
\begin{array}{l}
t_0 := \frac{D_m}{\frac{d_m}{M_m}}\\
\mathbf{if}\;M_m \leq 6.2 \cdot 10^{-171}:\\
\;\;\;\;w0\\

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


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

    1. Initial program 79.0%

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

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

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

    if 6.2000000000000001e-171 < M

    1. Initial program 79.1%

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(-0.125, \frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(h \cdot w0\right)\right)}{{d}^{2} \cdot \ell}, w0\right)} \]
      3. associate-*r*50.2%

        \[\leadsto \mathsf{fma}\left(-0.125, \frac{\color{blue}{\left({D}^{2} \cdot {M}^{2}\right) \cdot \left(h \cdot w0\right)}}{{d}^{2} \cdot \ell}, w0\right) \]
      4. times-frac54.4%

        \[\leadsto \mathsf{fma}\left(-0.125, \color{blue}{\frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}} \cdot \frac{h \cdot w0}{\ell}}, w0\right) \]
      5. *-commutative54.4%

        \[\leadsto \mathsf{fma}\left(-0.125, \frac{\color{blue}{{M}^{2} \cdot {D}^{2}}}{{d}^{2}} \cdot \frac{h \cdot w0}{\ell}, w0\right) \]
      6. unpow254.4%

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

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

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

        \[\leadsto \mathsf{fma}\left(-0.125, \frac{\color{blue}{{\left(M \cdot D\right)}^{2}}}{{d}^{2}} \cdot \frac{h \cdot w0}{\ell}, w0\right) \]
      10. *-commutative63.7%

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(-0.125, \left(\frac{\color{blue}{\sqrt{D \cdot M} \cdot \sqrt{D \cdot M}}}{\sqrt{{d}^{2}}} \cdot \sqrt{\frac{{\left(D \cdot M\right)}^{2}}{{d}^{2}}}\right) \cdot \frac{h \cdot w0}{\ell}, w0\right) \]
      5. add-sqr-sqrt56.7%

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

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

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

        \[\leadsto \mathsf{fma}\left(-0.125, \left(\frac{M \cdot D}{\color{blue}{\sqrt{d} \cdot \sqrt{d}}} \cdot \sqrt{\frac{{\left(D \cdot M\right)}^{2}}{{d}^{2}}}\right) \cdot \frac{h \cdot w0}{\ell}, w0\right) \]
      9. add-sqr-sqrt49.9%

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

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

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

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

        \[\leadsto \mathsf{fma}\left(-0.125, \left(\frac{M \cdot D}{d} \cdot \frac{\color{blue}{D \cdot M}}{\sqrt{{d}^{2}}}\right) \cdot \frac{h \cdot w0}{\ell}, w0\right) \]
      14. *-commutative54.6%

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

        \[\leadsto \mathsf{fma}\left(-0.125, \left(\frac{M \cdot D}{d} \cdot \frac{M \cdot D}{\sqrt{\color{blue}{d \cdot d}}}\right) \cdot \frac{h \cdot w0}{\ell}, w0\right) \]
      16. sqrt-prod39.8%

        \[\leadsto \mathsf{fma}\left(-0.125, \left(\frac{M \cdot D}{d} \cdot \frac{M \cdot D}{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}\right) \cdot \frac{h \cdot w0}{\ell}, w0\right) \]
      17. add-sqr-sqrt69.6%

        \[\leadsto \mathsf{fma}\left(-0.125, \left(\frac{M \cdot D}{d} \cdot \frac{M \cdot D}{\color{blue}{d}}\right) \cdot \frac{h \cdot w0}{\ell}, w0\right) \]
    7. Applied egg-rr69.6%

      \[\leadsto \mathsf{fma}\left(-0.125, \color{blue}{\left(\frac{M \cdot D}{d} \cdot \frac{M \cdot D}{d}\right)} \cdot \frac{h \cdot w0}{\ell}, w0\right) \]
    8. Taylor expanded in M around 0 69.6%

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

        \[\leadsto \mathsf{fma}\left(-0.125, \left(\frac{M \cdot D}{d} \cdot \color{blue}{\frac{D}{\frac{d}{M}}}\right) \cdot \frac{h \cdot w0}{\ell}, w0\right) \]
    10. Simplified69.6%

      \[\leadsto \mathsf{fma}\left(-0.125, \left(\frac{M \cdot D}{d} \cdot \color{blue}{\frac{D}{\frac{d}{M}}}\right) \cdot \frac{h \cdot w0}{\ell}, w0\right) \]
    11. Taylor expanded in M around 0 69.6%

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

        \[\leadsto \mathsf{fma}\left(-0.125, \left(\frac{M \cdot D}{d} \cdot \color{blue}{\frac{D}{\frac{d}{M}}}\right) \cdot \frac{h \cdot w0}{\ell}, w0\right) \]
    13. Simplified69.6%

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

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

Alternative 12: 67.6% accurate, 216.0× speedup?

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

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

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

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

    \[\leadsto w0 \]

Reproduce

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