Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 81.4% → 89.0%
Time: 14.4s
Alternatives: 8
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 8 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.0% accurate, 1.8× speedup?

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

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

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

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

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

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

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

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

      \[\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-inv78.3%

      \[\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*78.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*78.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-eval78.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-rr78.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+78.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-eval78.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-identity78.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/85.4%

      \[\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/86.9%

      \[\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. *-commutative86.9%

      \[\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*86.9%

      \[\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. *-commutative86.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 87.3% accurate, 1.8× speedup?

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

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

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

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

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

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

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

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

      \[\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-inv78.3%

      \[\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*78.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*78.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-eval78.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-rr78.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+78.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-eval78.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-identity78.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/85.4%

      \[\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/86.9%

      \[\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. *-commutative86.9%

      \[\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*86.9%

      \[\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. *-commutative86.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 82.1% accurate, 1.8× speedup?

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

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

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

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

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

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

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

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

      \[\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-inv78.3%

      \[\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*78.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*78.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-eval78.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-rr78.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+78.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-eval78.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-identity78.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/85.4%

      \[\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/86.9%

      \[\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. *-commutative86.9%

      \[\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*86.9%

      \[\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. *-commutative86.9%

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

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

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

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

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

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

    \[\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)} \]
  8. Step-by-step derivation
    1. +-commutative54.2%

      \[\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. *-commutative54.2%

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 72.8% accurate, 1.9× speedup?

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

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


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

    1. Initial program 80.9%

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

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

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

    if 1.4199999999999999 < M

    1. Initial program 68.6%

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

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

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

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

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

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

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

        \[\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-inv68.6%

        \[\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*70.3%

        \[\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*70.3%

        \[\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-eval70.3%

        \[\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-rr70.3%

      \[\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+70.3%

        \[\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-eval70.3%

        \[\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-identity70.3%

        \[\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/70.5%

        \[\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/75.7%

        \[\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. *-commutative75.7%

        \[\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*74.0%

        \[\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. *-commutative74.0%

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

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

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

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

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

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

      \[\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)} \]
    8. Step-by-step derivation
      1. +-commutative44.6%

        \[\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. *-commutative44.6%

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

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

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

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

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

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

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

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

        \[\leadsto -0.125 \cdot \left(\frac{\left(D \cdot D\right) \cdot \color{blue}{\left(M \cdot M\right)}}{d \cdot d} \cdot \frac{h \cdot w0}{\ell}\right) \]
      6. swap-sqr27.5%

        \[\leadsto -0.125 \cdot \left(\frac{\color{blue}{\left(D \cdot M\right) \cdot \left(D \cdot M\right)}}{d \cdot d} \cdot \frac{h \cdot w0}{\ell}\right) \]
      7. times-frac30.0%

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

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

        \[\leadsto -0.125 \cdot \left(\left(\left(D \cdot \frac{M}{d}\right) \cdot \color{blue}{\left(D \cdot \frac{M}{d}\right)}\right) \cdot \frac{h \cdot w0}{\ell}\right) \]
      10. unpow230.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\left(h \cdot \frac{w0}{\ell}\right) \cdot {\color{blue}{\left(\frac{M \cdot D}{d}\right)}}^{2}\right)} - 1\right) \]
      5. *-commutative14.8%

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

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

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

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

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

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

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

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

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

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

Alternative 5: 72.6% accurate, 1.9× speedup?

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

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


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

    1. Initial program 80.9%

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

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

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

    if 0.82999999999999996 < M

    1. Initial program 68.6%

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

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

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

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

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

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

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

        \[\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-inv68.6%

        \[\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*70.3%

        \[\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*70.3%

        \[\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-eval70.3%

        \[\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-rr70.3%

      \[\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+70.3%

        \[\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-eval70.3%

        \[\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-identity70.3%

        \[\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/70.5%

        \[\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/75.7%

        \[\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. *-commutative75.7%

        \[\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*74.0%

        \[\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. *-commutative74.0%

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

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

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

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

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

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

      \[\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)} \]
    8. Step-by-step derivation
      1. +-commutative44.6%

        \[\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. *-commutative44.6%

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

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

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

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

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

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

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

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

        \[\leadsto -0.125 \cdot \left(\frac{\left(D \cdot D\right) \cdot \color{blue}{\left(M \cdot M\right)}}{d \cdot d} \cdot \frac{h \cdot w0}{\ell}\right) \]
      6. swap-sqr27.5%

        \[\leadsto -0.125 \cdot \left(\frac{\color{blue}{\left(D \cdot M\right) \cdot \left(D \cdot M\right)}}{d \cdot d} \cdot \frac{h \cdot w0}{\ell}\right) \]
      7. times-frac30.0%

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

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

        \[\leadsto -0.125 \cdot \left(\left(\left(D \cdot \frac{M}{d}\right) \cdot \color{blue}{\left(D \cdot \frac{M}{d}\right)}\right) \cdot \frac{h \cdot w0}{\ell}\right) \]
      10. unpow230.0%

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

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

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

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

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

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

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

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

Alternative 6: 81.3% accurate, 1.9× speedup?

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

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

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

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

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

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

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

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

      \[\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-inv78.3%

      \[\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*78.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*78.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-eval78.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-rr78.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+78.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-eval78.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-identity78.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/85.4%

      \[\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/86.9%

      \[\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. *-commutative86.9%

      \[\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*86.9%

      \[\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. *-commutative86.9%

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

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

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

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

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

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

    \[\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)} \]
  8. Step-by-step derivation
    1. +-commutative54.2%

      \[\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. *-commutative54.2%

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

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

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

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

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

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

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

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

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

Alternative 7: 72.6% accurate, 10.3× speedup?

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

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


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

    1. Initial program 80.9%

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

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

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

    if 1.55000000000000004 < M

    1. Initial program 68.6%

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

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

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

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

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

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

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

        \[\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-inv68.6%

        \[\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*70.3%

        \[\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*70.3%

        \[\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-eval70.3%

        \[\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-rr70.3%

      \[\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+70.3%

        \[\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-eval70.3%

        \[\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-identity70.3%

        \[\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/70.5%

        \[\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/75.7%

        \[\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. *-commutative75.7%

        \[\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*74.0%

        \[\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. *-commutative74.0%

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

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

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

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

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

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

      \[\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)} \]
    8. Step-by-step derivation
      1. +-commutative44.6%

        \[\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. *-commutative44.6%

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

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

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

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

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

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

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

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

        \[\leadsto -0.125 \cdot \left(\frac{\left(D \cdot D\right) \cdot \color{blue}{\left(M \cdot M\right)}}{d \cdot d} \cdot \frac{h \cdot w0}{\ell}\right) \]
      6. swap-sqr27.5%

        \[\leadsto -0.125 \cdot \left(\frac{\color{blue}{\left(D \cdot M\right) \cdot \left(D \cdot M\right)}}{d \cdot d} \cdot \frac{h \cdot w0}{\ell}\right) \]
      7. times-frac30.0%

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

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

        \[\leadsto -0.125 \cdot \left(\left(\left(D \cdot \frac{M}{d}\right) \cdot \color{blue}{\left(D \cdot \frac{M}{d}\right)}\right) \cdot \frac{h \cdot w0}{\ell}\right) \]
      10. unpow230.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto -0.125 \cdot \left(\color{blue}{\left(\left(D \cdot \frac{M}{d}\right) \cdot \left(D \cdot \frac{M}{d}\right)\right)} \cdot \left(h \cdot \frac{w0}{\ell}\right)\right) \]
    14. Applied egg-rr30.0%

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

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

Alternative 8: 68.1% accurate, 216.0× speedup?

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

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

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

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

    \[\leadsto w0 \]

Reproduce

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