Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 81.6% → 90.1%
Time: 21.0s
Alternatives: 4
Speedup: 1.8×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 4 alternatives:

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

Initial Program: 81.6% accurate, 1.0× speedup?

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

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

Alternative 1: 90.1% accurate, 1.8× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{\frac{\frac{D}{d} \cdot M}{2}}{\ell} \cdot \frac{\frac{\frac{D}{d} \cdot M}{2}}{\frac{1}{h}}}} \]
  10. Step-by-step derivation
    1. associate-*l/89.5%

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

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

      \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{D}{2} \cdot \frac{M}{d}}}{\ell} \cdot \frac{\frac{\frac{D}{d} \cdot M}{2}}{\frac{1}{h}}} \]
    4. *-commutative88.1%

      \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{M}{d} \cdot \frac{D}{2}}}{\ell} \cdot \frac{\frac{\frac{D}{d} \cdot M}{2}}{\frac{1}{h}}} \]
    5. associate-/r/88.1%

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

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

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

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

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

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

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

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

Alternative 2: 87.5% accurate, 1.7× speedup?

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

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


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

    1. Initial program 78.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{\frac{\frac{D}{d} \cdot M}{2}}{\ell} \cdot \frac{\frac{\frac{D}{d} \cdot M}{2}}{\frac{1}{h}}}} \]
    10. Step-by-step derivation
      1. associate-*l/87.5%

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

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

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

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{M}{d} \cdot \frac{D}{2}}}{\ell} \cdot \frac{\frac{\frac{D}{d} \cdot M}{2}}{\frac{1}{h}}} \]
      5. associate-/r/85.7%

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

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

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

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

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

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

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

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

    if 1.2999999999999999e-183 < d

    1. Initial program 81.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{\frac{\frac{D}{d} \cdot M}{2}}{\ell} \cdot \frac{\frac{\frac{D}{d} \cdot M}{2}}{\frac{1}{h}}}} \]
    10. Step-by-step derivation
      1. associate-*l/92.6%

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

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

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{D}{2} \cdot \frac{M}{d}}}{\ell} \cdot \frac{\frac{\frac{D}{d} \cdot M}{2}}{\frac{1}{h}}} \]
      4. *-commutative91.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{M}{d} \cdot \frac{D}{2}}}{\ell} \cdot \frac{\frac{\frac{D}{d} \cdot M}{2}}{\frac{1}{h}}} \]
      5. associate-/r/91.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 87.4% accurate, 1.8× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{\frac{\frac{D}{d} \cdot M}{2}}{\ell} \cdot \frac{\frac{\frac{D}{d} \cdot M}{2}}{\frac{1}{h}}}} \]
  10. Step-by-step derivation
    1. associate-*l/89.5%

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

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

      \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{D}{2} \cdot \frac{M}{d}}}{\ell} \cdot \frac{\frac{\frac{D}{d} \cdot M}{2}}{\frac{1}{h}}} \]
    4. *-commutative88.1%

      \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{M}{d} \cdot \frac{D}{2}}}{\ell} \cdot \frac{\frac{\frac{D}{d} \cdot M}{2}}{\frac{1}{h}}} \]
    5. associate-/r/88.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 68.7% accurate, 216.0× speedup?

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

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

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

    \[\leadsto \color{blue}{w0} \]
  5. Final simplification68.8%

    \[\leadsto w0 \]
  6. Add Preprocessing

Reproduce

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