Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 80.8% → 85.8%
Time: 12.6s
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: 80.8% 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: 85.8% 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])\\ \\ w0 \cdot \sqrt{1 - h \cdot \frac{{\left(D_m \cdot \left(M \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}} \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 (* h (/ (pow (* D_m (* M (/ 0.5 d))) 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) {
	return w0 * sqrt((1.0 - (h * (pow((D_m * (M * (0.5 / d))), 2.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
    code = w0 * sqrt((1.0d0 - (h * (((d_m * (m * (0.5d0 / d))) ** 2.0d0) / 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 - (h * (Math.pow((D_m * (M * (0.5 / d))), 2.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):
	return w0 * math.sqrt((1.0 - (h * (math.pow((D_m * (M * (0.5 / d))), 2.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)
	return Float64(w0 * sqrt(Float64(1.0 - Float64(h * Float64((Float64(D_m * Float64(M * Float64(0.5 / d))) ^ 2.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)
	tmp = w0 * sqrt((1.0 - (h * (((D_m * (M * (0.5 / d))) ^ 2.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_] := N[(w0 * N[Sqrt[N[(1.0 - N[(h * N[(N[Power[N[(D$95$m * N[(M * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.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])\\
\\
w0 \cdot \sqrt{1 - h \cdot \frac{{\left(D_m \cdot \left(M \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}}
\end{array}
Derivation
  1. Initial program 80.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 81.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 := \frac{D_m \cdot M}{d}\\ w0 \cdot \mathsf{fma}\left(-0.125, h \cdot \left(t_0 \cdot \frac{t_0}{\ell}\right), 1\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) d)))
   (* w0 (fma -0.125 (* h (* t_0 (/ t_0 l))) 1.0))))
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) / d;
	return w0 * fma(-0.125, (h * (t_0 * (t_0 / l))), 1.0);
}
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(Float64(D_m * M) / d)
	return Float64(w0 * fma(-0.125, Float64(h * Float64(t_0 * Float64(t_0 / l))), 1.0))
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[(N[(D$95$m * M), $MachinePrecision] / d), $MachinePrecision]}, N[(w0 * N[(-0.125 * N[(h * N[(t$95$0 * N[(t$95$0 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $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 := \frac{D_m \cdot M}{d}\\
w0 \cdot \mathsf{fma}\left(-0.125, h \cdot \left(t_0 \cdot \frac{t_0}{\ell}\right), 1\right)
\end{array}
\end{array}
Derivation
  1. Initial program 80.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 69.9% accurate, 1.9× 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}\;M \leq 29500:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \left(\frac{h}{\ell} \cdot \left(-0.125 \cdot {\left(D_m \cdot \frac{M}{d}\right)}^{2}\right)\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 (<= M 29500.0)
   w0
   (* w0 (* (/ h l) (* -0.125 (pow (* D_m (/ M d)) 2.0))))))
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 (M <= 29500.0) {
		tmp = w0;
	} else {
		tmp = w0 * ((h / l) * (-0.125 * pow((D_m * (M / d)), 2.0)));
	}
	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 <= 29500.0d0) then
        tmp = w0
    else
        tmp = w0 * ((h / l) * ((-0.125d0) * ((d_m * (m / d)) ** 2.0d0)))
    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 (M <= 29500.0) {
		tmp = w0;
	} else {
		tmp = w0 * ((h / l) * (-0.125 * Math.pow((D_m * (M / d)), 2.0)));
	}
	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 M <= 29500.0:
		tmp = w0
	else:
		tmp = w0 * ((h / l) * (-0.125 * math.pow((D_m * (M / d)), 2.0)))
	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 (M <= 29500.0)
		tmp = w0;
	else
		tmp = Float64(w0 * Float64(Float64(h / l) * Float64(-0.125 * (Float64(D_m * Float64(M / d)) ^ 2.0))));
	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 <= 29500.0)
		tmp = w0;
	else
		tmp = w0 * ((h / l) * (-0.125 * ((D_m * (M / d)) ^ 2.0)));
	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[M, 29500.0], w0, N[(w0 * N[(N[(h / l), $MachinePrecision] * N[(-0.125 * N[Power[N[(D$95$m * N[(M / d), $MachinePrecision]), $MachinePrecision], 2.0], $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}\;M \leq 29500:\\
\;\;\;\;w0\\

\mathbf{else}:\\
\;\;\;\;w0 \cdot \left(\frac{h}{\ell} \cdot \left(-0.125 \cdot {\left(D_m \cdot \frac{M}{d}\right)}^{2}\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if M < 29500

    1. Initial program 82.1%

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

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

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

    if 29500 < M

    1. Initial program 73.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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)} \]
    11. Step-by-step derivation
      1. +-commutative41.5%

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

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

      \[\leadsto w0 \cdot \color{blue}{\mathsf{fma}\left(-0.125, h \cdot \frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{\ell}, 1\right)} \]
    13. Taylor expanded in h around inf 23.4%

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

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

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

Alternative 4: 80.7% accurate, 1.9× 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 + w0 \cdot \left(-0.125 \cdot \frac{h \cdot {\left(\frac{D_m \cdot M}{d}\right)}^{2}}{\ell}\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 (* w0 (* -0.125 (/ (* h (pow (/ (* D_m M) d) 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) {
	return w0 + (w0 * (-0.125 * ((h * pow(((D_m * M) / d), 2.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
    code = w0 + (w0 * ((-0.125d0) * ((h * (((d_m * m) / d) ** 2.0d0)) / 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 + (w0 * (-0.125 * ((h * Math.pow(((D_m * M) / d), 2.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):
	return w0 + (w0 * (-0.125 * ((h * math.pow(((D_m * M) / d), 2.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)
	return Float64(w0 + Float64(w0 * Float64(-0.125 * Float64(Float64(h * (Float64(Float64(D_m * M) / d) ^ 2.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)
	tmp = w0 + (w0 * (-0.125 * ((h * (((D_m * M) / d) ^ 2.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_] := N[(w0 + N[(w0 * N[(-0.125 * N[(N[(h * N[Power[N[(N[(D$95$m * M), $MachinePrecision] / d), $MachinePrecision], 2.0], $MachinePrecision]), $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])\\
\\
w0 + w0 \cdot \left(-0.125 \cdot \frac{h \cdot {\left(\frac{D_m \cdot M}{d}\right)}^{2}}{\ell}\right)
\end{array}
Derivation
  1. Initial program 80.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 67.2% accurate, 2.1× 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}\;M \leq 7.1 \cdot 10^{-6}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;\sqrt{w0 \cdot 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 (<= M 7.1e-6) w0 (sqrt (* w0 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 (M <= 7.1e-6) {
		tmp = w0;
	} else {
		tmp = sqrt((w0 * 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 <= 7.1d-6) then
        tmp = w0
    else
        tmp = sqrt((w0 * 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 (M <= 7.1e-6) {
		tmp = w0;
	} else {
		tmp = Math.sqrt((w0 * 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 M <= 7.1e-6:
		tmp = w0
	else:
		tmp = math.sqrt((w0 * 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 (M <= 7.1e-6)
		tmp = w0;
	else
		tmp = sqrt(Float64(w0 * 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 <= 7.1e-6)
		tmp = w0;
	else
		tmp = sqrt((w0 * 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[M, 7.1e-6], w0, N[Sqrt[N[(w0 * w0), $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}\;M \leq 7.1 \cdot 10^{-6}:\\
\;\;\;\;w0\\

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


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

    1. Initial program 81.8%

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

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

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

    if 7.0999999999999998e-6 < M

    1. Initial program 75.0%

      \[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{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Step-by-step derivation
      1. add-sqr-sqrt37.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{\color{blue}{{w0}^{2}}} \]
    8. Step-by-step derivation
      1. unpow215.4%

        \[\leadsto \sqrt{\color{blue}{w0 \cdot w0}} \]
    9. Applied egg-rr15.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 7.1 \cdot 10^{-6}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;\sqrt{w0 \cdot w0}\\ \end{array} \]

Alternative 6: 68.1% 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 80.2%

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

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

    \[\leadsto \color{blue}{w0} \]
  4. Final simplification66.9%

    \[\leadsto w0 \]

Reproduce

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