Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 81.4% → 89.6%
Time: 16.4s
Alternatives: 6
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 6 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.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: 89.6% accurate, 1.8× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 84.7% accurate, 1.7× speedup?

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

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


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

    1. Initial program 76.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.9999999999999999e-143 < d

    1. Initial program 84.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 84.7% accurate, 1.7× speedup?

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

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


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

    1. Initial program 76.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.9999999999999995e-144 < d

    1. Initial program 84.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 83.6% accurate, 1.8× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 84.4% accurate, 1.8× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 68.7% accurate, 216.0× speedup?

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

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

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

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

    \[\leadsto w0 \]
  6. Add Preprocessing

Reproduce

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