Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 81.7% → 88.0%
Time: 16.3s
Alternatives: 5
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 5 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.7% accurate, 1.0× speedup?

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

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

Alternative 1: 88.0% accurate, 0.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}\;h \leq -5 \cdot 10^{-310}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h \cdot {\left(M \cdot \left(0.5 \cdot \frac{D\_m}{d}\right)\right)}^{2}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{{\left(\left(0.5 \cdot \left(D\_m \cdot \frac{M}{d}\right)\right) \cdot \sqrt{h}\right)}^{2}}{\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
 (if (<= h -5e-310)
   (* w0 (sqrt (- 1.0 (/ (* h (pow (* M (* 0.5 (/ D_m d))) 2.0)) l))))
   (* w0 (sqrt (- 1.0 (/ (pow (* (* 0.5 (* D_m (/ M d))) (sqrt h)) 2.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 tmp;
	if (h <= -5e-310) {
		tmp = w0 * sqrt((1.0 - ((h * pow((M * (0.5 * (D_m / d))), 2.0)) / l)));
	} else {
		tmp = w0 * sqrt((1.0 - (pow(((0.5 * (D_m * (M / d))) * sqrt(h)), 2.0) / l)));
	}
	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 (h <= (-5d-310)) then
        tmp = w0 * sqrt((1.0d0 - ((h * ((m * (0.5d0 * (d_m / d))) ** 2.0d0)) / l)))
    else
        tmp = w0 * sqrt((1.0d0 - ((((0.5d0 * (d_m * (m / d))) * sqrt(h)) ** 2.0d0) / l)))
    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 (h <= -5e-310) {
		tmp = w0 * Math.sqrt((1.0 - ((h * Math.pow((M * (0.5 * (D_m / d))), 2.0)) / l)));
	} else {
		tmp = w0 * Math.sqrt((1.0 - (Math.pow(((0.5 * (D_m * (M / d))) * Math.sqrt(h)), 2.0) / l)));
	}
	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 h <= -5e-310:
		tmp = w0 * math.sqrt((1.0 - ((h * math.pow((M * (0.5 * (D_m / d))), 2.0)) / l)))
	else:
		tmp = w0 * math.sqrt((1.0 - (math.pow(((0.5 * (D_m * (M / d))) * math.sqrt(h)), 2.0) / l)))
	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 (h <= -5e-310)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h * (Float64(M * Float64(0.5 * Float64(D_m / d))) ^ 2.0)) / l))));
	else
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64((Float64(Float64(0.5 * Float64(D_m * Float64(M / d))) * sqrt(h)) ^ 2.0) / l))));
	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 (h <= -5e-310)
		tmp = w0 * sqrt((1.0 - ((h * ((M * (0.5 * (D_m / d))) ^ 2.0)) / l)));
	else
		tmp = w0 * sqrt((1.0 - ((((0.5 * (D_m * (M / d))) * sqrt(h)) ^ 2.0) / l)));
	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[h, -5e-310], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h * N[Power[N[(M * N[(0.5 * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(0.5 * N[(D$95$m * N[(M / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $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}\;h \leq -5 \cdot 10^{-310}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h \cdot {\left(M \cdot \left(0.5 \cdot \frac{D\_m}{d}\right)\right)}^{2}}{\ell}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if h < -4.999999999999985e-310

    1. Initial program 79.5%

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < h

    1. Initial program 79.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 87.0% accurate, 0.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}\;{\left(\frac{M \cdot D\_m}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell} \leq -200:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(\frac{M}{d} \cdot \left(0.5 \cdot D\_m\right)\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \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 (<= (* (pow (/ (* M D_m) (* d 2.0)) 2.0) (/ h l)) -200.0)
   (* w0 (sqrt (- 1.0 (* (/ h l) (pow (* (/ M d) (* 0.5 D_m)) 2.0)))))
   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) {
	double tmp;
	if ((pow(((M * D_m) / (d * 2.0)), 2.0) * (h / l)) <= -200.0) {
		tmp = w0 * sqrt((1.0 - ((h / l) * pow(((M / d) * (0.5 * D_m)), 2.0))));
	} else {
		tmp = w0;
	}
	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 (((((m * d_m) / (d * 2.0d0)) ** 2.0d0) * (h / l)) <= (-200.0d0)) then
        tmp = w0 * sqrt((1.0d0 - ((h / l) * (((m / d) * (0.5d0 * d_m)) ** 2.0d0))))
    else
        tmp = w0
    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 ((Math.pow(((M * D_m) / (d * 2.0)), 2.0) * (h / l)) <= -200.0) {
		tmp = w0 * Math.sqrt((1.0 - ((h / l) * Math.pow(((M / d) * (0.5 * D_m)), 2.0))));
	} else {
		tmp = w0;
	}
	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 (math.pow(((M * D_m) / (d * 2.0)), 2.0) * (h / l)) <= -200.0:
		tmp = w0 * math.sqrt((1.0 - ((h / l) * math.pow(((M / d) * (0.5 * D_m)), 2.0))))
	else:
		tmp = w0
	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 (Float64((Float64(Float64(M * D_m) / Float64(d * 2.0)) ^ 2.0) * Float64(h / l)) <= -200.0)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h / l) * (Float64(Float64(M / d) * Float64(0.5 * D_m)) ^ 2.0)))));
	else
		tmp = w0;
	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 (((((M * D_m) / (d * 2.0)) ^ 2.0) * (h / l)) <= -200.0)
		tmp = w0 * sqrt((1.0 - ((h / l) * (((M / d) * (0.5 * D_m)) ^ 2.0))));
	else
		tmp = w0;
	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[N[(N[Power[N[(N[(M * D$95$m), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -200.0], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(M / d), $MachinePrecision] * N[(0.5 * D$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 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])\\
\\
\begin{array}{l}
\mathbf{if}\;{\left(\frac{M \cdot D\_m}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell} \leq -200:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(\frac{M}{d} \cdot \left(0.5 \cdot D\_m\right)\right)}^{2}}\\

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


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

    1. Initial program 65.6%

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

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

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

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

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

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

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

    1. Initial program 85.8%

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

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

      \[\leadsto \color{blue}{w0} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification86.6%

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

Alternative 3: 83.9% accurate, 1.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])\\ \\ \begin{array}{l} \mathbf{if}\;\frac{h}{\ell} \leq -5 \cdot 10^{-198}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(M \cdot \frac{D\_m}{d \cdot 2}\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \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 (<= (/ h l) -5e-198)
   (* w0 (sqrt (- 1.0 (* (/ h l) (pow (* M (/ D_m (* d 2.0))) 2.0)))))
   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) {
	double tmp;
	if ((h / l) <= -5e-198) {
		tmp = w0 * sqrt((1.0 - ((h / l) * pow((M * (D_m / (d * 2.0))), 2.0))));
	} else {
		tmp = w0;
	}
	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 ((h / l) <= (-5d-198)) then
        tmp = w0 * sqrt((1.0d0 - ((h / l) * ((m * (d_m / (d * 2.0d0))) ** 2.0d0))))
    else
        tmp = w0
    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 ((h / l) <= -5e-198) {
		tmp = w0 * Math.sqrt((1.0 - ((h / l) * Math.pow((M * (D_m / (d * 2.0))), 2.0))));
	} else {
		tmp = w0;
	}
	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 (h / l) <= -5e-198:
		tmp = w0 * math.sqrt((1.0 - ((h / l) * math.pow((M * (D_m / (d * 2.0))), 2.0))))
	else:
		tmp = w0
	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 (Float64(h / l) <= -5e-198)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h / l) * (Float64(M * Float64(D_m / Float64(d * 2.0))) ^ 2.0)))));
	else
		tmp = w0;
	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 ((h / l) <= -5e-198)
		tmp = w0 * sqrt((1.0 - ((h / l) * ((M * (D_m / (d * 2.0))) ^ 2.0))));
	else
		tmp = w0;
	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[N[(h / l), $MachinePrecision], -5e-198], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[Power[N[(M * N[(D$95$m / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 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])\\
\\
\begin{array}{l}
\mathbf{if}\;\frac{h}{\ell} \leq -5 \cdot 10^{-198}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(M \cdot \frac{D\_m}{d \cdot 2}\right)}^{2}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 h l) < -4.9999999999999999e-198

    1. Initial program 76.8%

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

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

    if -4.9999999999999999e-198 < (/.f64 h l)

    1. Initial program 82.3%

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

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

      \[\leadsto \color{blue}{w0} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification83.9%

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

Alternative 4: 71.9% 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 1.02 \cdot 10^{-84}:\\ \;\;\;\;w0 \cdot \left(1 + \left({D\_m}^{2} \cdot \left(h \cdot \left(\frac{M}{d} \cdot \frac{\frac{M}{d}}{\ell}\right)\right)\right) \cdot -0.125\right)\\ \mathbf{else}:\\ \;\;\;\;w0\\ \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 1.02e-84)
   (* w0 (+ 1.0 (* (* (pow D_m 2.0) (* h (* (/ M d) (/ (/ M d) l)))) -0.125)))
   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) {
	double tmp;
	if (d <= 1.02e-84) {
		tmp = w0 * (1.0 + ((pow(D_m, 2.0) * (h * ((M / d) * ((M / d) / l)))) * -0.125));
	} else {
		tmp = w0;
	}
	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 <= 1.02d-84) then
        tmp = w0 * (1.0d0 + (((d_m ** 2.0d0) * (h * ((m / d) * ((m / d) / l)))) * (-0.125d0)))
    else
        tmp = w0
    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 <= 1.02e-84) {
		tmp = w0 * (1.0 + ((Math.pow(D_m, 2.0) * (h * ((M / d) * ((M / d) / l)))) * -0.125));
	} else {
		tmp = w0;
	}
	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 <= 1.02e-84:
		tmp = w0 * (1.0 + ((math.pow(D_m, 2.0) * (h * ((M / d) * ((M / d) / l)))) * -0.125))
	else:
		tmp = w0
	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 <= 1.02e-84)
		tmp = Float64(w0 * Float64(1.0 + Float64(Float64((D_m ^ 2.0) * Float64(h * Float64(Float64(M / d) * Float64(Float64(M / d) / l)))) * -0.125)));
	else
		tmp = w0;
	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 <= 1.02e-84)
		tmp = w0 * (1.0 + (((D_m ^ 2.0) * (h * ((M / d) * ((M / d) / l)))) * -0.125));
	else
		tmp = w0;
	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, 1.02e-84], N[(w0 * N[(1.0 + N[(N[(N[Power[D$95$m, 2.0], $MachinePrecision] * N[(h * N[(N[(M / d), $MachinePrecision] * N[(N[(M / d), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq 1.02 \cdot 10^{-84}:\\
\;\;\;\;w0 \cdot \left(1 + \left({D\_m}^{2} \cdot \left(h \cdot \left(\frac{M}{d} \cdot \frac{\frac{M}{d}}{\ell}\right)\right)\right) \cdot -0.125\right)\\

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


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

    1. Initial program 79.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.02000000000000004e-84 < d

    1. Initial program 78.9%

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

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

      \[\leadsto \color{blue}{w0} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification68.8%

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

Alternative 5: 68.5% 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.2%

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

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

    \[\leadsto w0 \]
  6. Add Preprocessing

Reproduce

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