Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 80.6% → 88.6%
Time: 15.4s
Alternatives: 7
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 7 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.6% accurate, 1.0× speedup?

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

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

Alternative 1: 88.6% accurate, 0.5× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 w0 (sqrt.f64 (-.f64 #s(literal 1 binary64) (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l))))) < 2.0000000000000001e221

    1. Initial program 93.2%

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

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

    if 2.0000000000000001e221 < (*.f64 w0 (sqrt.f64 (-.f64 #s(literal 1 binary64) (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)))))

    1. Initial program 46.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 88.1% accurate, 1.8× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 76.6% accurate, 1.8× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if D < 3.2000000000000001e93

    1. Initial program 79.5%

      \[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(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Add Preprocessing
    4. Taylor expanded in D around 0 68.6%

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

    if 3.2000000000000001e93 < D

    1. Initial program 82.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto w0 + -0.125 \cdot \left({D}^{2} \cdot \left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(\frac{M}{d}\right)}^{2}\right)\right)} \cdot \frac{w0 \cdot h}{\ell}\right)\right) \]
    11. Step-by-step derivation
      1. pow-to-exp44.4%

        \[\leadsto w0 + -0.125 \cdot \left(\color{blue}{e^{\log D \cdot 2}} \cdot \left(\mathsf{expm1}\left(\mathsf{log1p}\left({\left(\frac{M}{d}\right)}^{2}\right)\right) \cdot \frac{w0 \cdot h}{\ell}\right)\right) \]
      2. *-commutative44.4%

        \[\leadsto w0 + -0.125 \cdot \left(e^{\color{blue}{2 \cdot \log D}} \cdot \left(\mathsf{expm1}\left(\mathsf{log1p}\left({\left(\frac{M}{d}\right)}^{2}\right)\right) \cdot \frac{w0 \cdot h}{\ell}\right)\right) \]
      3. expm1-log1p-u44.4%

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

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

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

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

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

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

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

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

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

Alternative 4: 73.2% accurate, 8.3× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ w0\_m = \left|w0\right| \\ w0\_s = \mathsf{copysign}\left(1, w0\right) \\ [w0_m, M_m, D_m, h, l, d] = \mathsf{sort}([w0_m, M_m, D_m, h, l, d])\\ \\ w0\_s \cdot \begin{array}{l} \mathbf{if}\;M\_m \leq 118000:\\ \;\;\;\;w0\_m\\ \mathbf{else}:\\ \;\;\;\;w0\_m + -0.125 \cdot \left(\left(D\_m \cdot D\_m\right) \cdot \frac{\left(M\_m \cdot \frac{M\_m}{d}\right) \cdot \left(w0\_m \cdot h\right)}{d \cdot \ell}\right)\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
w0\_m = (fabs.f64 w0)
w0\_s = (copysign.f64 #s(literal 1 binary64) w0)
NOTE: w0_m, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0_s w0_m M_m D_m h l d)
 :precision binary64
 (*
  w0_s
  (if (<= M_m 118000.0)
    w0_m
    (+
     w0_m
     (*
      -0.125
      (* (* D_m D_m) (/ (* (* M_m (/ M_m d)) (* w0_m h)) (* d l))))))))
M_m = fabs(M);
D_m = fabs(D);
w0\_m = fabs(w0);
w0\_s = copysign(1.0, w0);
assert(w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d) {
	double tmp;
	if (M_m <= 118000.0) {
		tmp = w0_m;
	} else {
		tmp = w0_m + (-0.125 * ((D_m * D_m) * (((M_m * (M_m / d)) * (w0_m * h)) / (d * l))));
	}
	return w0_s * tmp;
}
M_m = abs(m)
D_m = abs(d)
w0\_m = abs(w0)
w0\_s = copysign(1.0d0, w0)
NOTE: w0_m, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0_s, w0_m, m_m, d_m, h, l, d)
    real(8), intent (in) :: w0_s
    real(8), intent (in) :: w0_m
    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 <= 118000.0d0) then
        tmp = w0_m
    else
        tmp = w0_m + ((-0.125d0) * ((d_m * d_m) * (((m_m * (m_m / d)) * (w0_m * h)) / (d * l))))
    end if
    code = w0_s * tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
w0\_m = Math.abs(w0);
w0\_s = Math.copySign(1.0, w0);
assert w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d) {
	double tmp;
	if (M_m <= 118000.0) {
		tmp = w0_m;
	} else {
		tmp = w0_m + (-0.125 * ((D_m * D_m) * (((M_m * (M_m / d)) * (w0_m * h)) / (d * l))));
	}
	return w0_s * tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
w0\_m = math.fabs(w0)
w0\_s = math.copysign(1.0, w0)
[w0_m, M_m, D_m, h, l, d] = sort([w0_m, M_m, D_m, h, l, d])
def code(w0_s, w0_m, M_m, D_m, h, l, d):
	tmp = 0
	if M_m <= 118000.0:
		tmp = w0_m
	else:
		tmp = w0_m + (-0.125 * ((D_m * D_m) * (((M_m * (M_m / d)) * (w0_m * h)) / (d * l))))
	return w0_s * tmp
M_m = abs(M)
D_m = abs(D)
w0\_m = abs(w0)
w0\_s = copysign(1.0, w0)
w0_m, M_m, D_m, h, l, d = sort([w0_m, M_m, D_m, h, l, d])
function code(w0_s, w0_m, M_m, D_m, h, l, d)
	tmp = 0.0
	if (M_m <= 118000.0)
		tmp = w0_m;
	else
		tmp = Float64(w0_m + Float64(-0.125 * Float64(Float64(D_m * D_m) * Float64(Float64(Float64(M_m * Float64(M_m / d)) * Float64(w0_m * h)) / Float64(d * l)))));
	end
	return Float64(w0_s * tmp)
end
M_m = abs(M);
D_m = abs(D);
w0\_m = abs(w0);
w0\_s = sign(w0) * abs(1.0);
w0_m, M_m, D_m, h, l, d = num2cell(sort([w0_m, M_m, D_m, h, l, d])){:}
function tmp_2 = code(w0_s, w0_m, M_m, D_m, h, l, d)
	tmp = 0.0;
	if (M_m <= 118000.0)
		tmp = w0_m;
	else
		tmp = w0_m + (-0.125 * ((D_m * D_m) * (((M_m * (M_m / d)) * (w0_m * h)) / (d * l))));
	end
	tmp_2 = w0_s * tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
w0\_m = N[Abs[w0], $MachinePrecision]
w0\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[w0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: w0_m, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0$95$s_, w0$95$m_, M$95$m_, D$95$m_, h_, l_, d_] := N[(w0$95$s * If[LessEqual[M$95$m, 118000.0], w0$95$m, N[(w0$95$m + N[(-0.125 * N[(N[(D$95$m * D$95$m), $MachinePrecision] * N[(N[(N[(M$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision] * N[(w0$95$m * h), $MachinePrecision]), $MachinePrecision] / N[(d * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
w0\_m = \left|w0\right|
\\
w0\_s = \mathsf{copysign}\left(1, w0\right)
\\
[w0_m, M_m, D_m, h, l, d] = \mathsf{sort}([w0_m, M_m, D_m, h, l, d])\\
\\
w0\_s \cdot \begin{array}{l}
\mathbf{if}\;M\_m \leq 118000:\\
\;\;\;\;w0\_m\\

\mathbf{else}:\\
\;\;\;\;w0\_m + -0.125 \cdot \left(\left(D\_m \cdot D\_m\right) \cdot \frac{\left(M\_m \cdot \frac{M\_m}{d}\right) \cdot \left(w0\_m \cdot h\right)}{d \cdot \ell}\right)\\


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

    1. Initial program 81.3%

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

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

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

    if 118000 < M

    1. Initial program 74.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 + -0.125 \cdot \left({D}^{2} \cdot \left(\left(e^{\mathsf{log1p}\left({\left(\frac{M}{\color{blue}{{d}^{\left(\frac{2}{2}\right)}}}\right)}^{2}\right)} - 1\right) \cdot \frac{w0 \cdot h}{\ell}\right)\right) \]
      10. metadata-eval59.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 73.2% accurate, 8.3× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ w0\_m = \left|w0\right| \\ w0\_s = \mathsf{copysign}\left(1, w0\right) \\ [w0_m, M_m, D_m, h, l, d] = \mathsf{sort}([w0_m, M_m, D_m, h, l, d])\\ \\ w0\_s \cdot \begin{array}{l} \mathbf{if}\;M\_m \leq 2050000:\\ \;\;\;\;w0\_m\\ \mathbf{else}:\\ \;\;\;\;w0\_m + -0.125 \cdot \left(\left(D\_m \cdot D\_m\right) \cdot \left(\left(\frac{M\_m}{d} \cdot \frac{M\_m}{d}\right) \cdot \frac{w0\_m \cdot h}{\ell}\right)\right)\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
w0\_m = (fabs.f64 w0)
w0\_s = (copysign.f64 #s(literal 1 binary64) w0)
NOTE: w0_m, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0_s w0_m M_m D_m h l d)
 :precision binary64
 (*
  w0_s
  (if (<= M_m 2050000.0)
    w0_m
    (+
     w0_m
     (*
      -0.125
      (* (* D_m D_m) (* (* (/ M_m d) (/ M_m d)) (/ (* w0_m h) l))))))))
M_m = fabs(M);
D_m = fabs(D);
w0\_m = fabs(w0);
w0\_s = copysign(1.0, w0);
assert(w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d) {
	double tmp;
	if (M_m <= 2050000.0) {
		tmp = w0_m;
	} else {
		tmp = w0_m + (-0.125 * ((D_m * D_m) * (((M_m / d) * (M_m / d)) * ((w0_m * h) / l))));
	}
	return w0_s * tmp;
}
M_m = abs(m)
D_m = abs(d)
w0\_m = abs(w0)
w0\_s = copysign(1.0d0, w0)
NOTE: w0_m, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0_s, w0_m, m_m, d_m, h, l, d)
    real(8), intent (in) :: w0_s
    real(8), intent (in) :: w0_m
    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 <= 2050000.0d0) then
        tmp = w0_m
    else
        tmp = w0_m + ((-0.125d0) * ((d_m * d_m) * (((m_m / d) * (m_m / d)) * ((w0_m * h) / l))))
    end if
    code = w0_s * tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
w0\_m = Math.abs(w0);
w0\_s = Math.copySign(1.0, w0);
assert w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d) {
	double tmp;
	if (M_m <= 2050000.0) {
		tmp = w0_m;
	} else {
		tmp = w0_m + (-0.125 * ((D_m * D_m) * (((M_m / d) * (M_m / d)) * ((w0_m * h) / l))));
	}
	return w0_s * tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
w0\_m = math.fabs(w0)
w0\_s = math.copysign(1.0, w0)
[w0_m, M_m, D_m, h, l, d] = sort([w0_m, M_m, D_m, h, l, d])
def code(w0_s, w0_m, M_m, D_m, h, l, d):
	tmp = 0
	if M_m <= 2050000.0:
		tmp = w0_m
	else:
		tmp = w0_m + (-0.125 * ((D_m * D_m) * (((M_m / d) * (M_m / d)) * ((w0_m * h) / l))))
	return w0_s * tmp
M_m = abs(M)
D_m = abs(D)
w0\_m = abs(w0)
w0\_s = copysign(1.0, w0)
w0_m, M_m, D_m, h, l, d = sort([w0_m, M_m, D_m, h, l, d])
function code(w0_s, w0_m, M_m, D_m, h, l, d)
	tmp = 0.0
	if (M_m <= 2050000.0)
		tmp = w0_m;
	else
		tmp = Float64(w0_m + Float64(-0.125 * Float64(Float64(D_m * D_m) * Float64(Float64(Float64(M_m / d) * Float64(M_m / d)) * Float64(Float64(w0_m * h) / l)))));
	end
	return Float64(w0_s * tmp)
end
M_m = abs(M);
D_m = abs(D);
w0\_m = abs(w0);
w0\_s = sign(w0) * abs(1.0);
w0_m, M_m, D_m, h, l, d = num2cell(sort([w0_m, M_m, D_m, h, l, d])){:}
function tmp_2 = code(w0_s, w0_m, M_m, D_m, h, l, d)
	tmp = 0.0;
	if (M_m <= 2050000.0)
		tmp = w0_m;
	else
		tmp = w0_m + (-0.125 * ((D_m * D_m) * (((M_m / d) * (M_m / d)) * ((w0_m * h) / l))));
	end
	tmp_2 = w0_s * tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
w0\_m = N[Abs[w0], $MachinePrecision]
w0\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[w0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: w0_m, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0$95$s_, w0$95$m_, M$95$m_, D$95$m_, h_, l_, d_] := N[(w0$95$s * If[LessEqual[M$95$m, 2050000.0], w0$95$m, N[(w0$95$m + N[(-0.125 * N[(N[(D$95$m * D$95$m), $MachinePrecision] * N[(N[(N[(M$95$m / d), $MachinePrecision] * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision] * N[(N[(w0$95$m * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
w0\_m = \left|w0\right|
\\
w0\_s = \mathsf{copysign}\left(1, w0\right)
\\
[w0_m, M_m, D_m, h, l, d] = \mathsf{sort}([w0_m, M_m, D_m, h, l, d])\\
\\
w0\_s \cdot \begin{array}{l}
\mathbf{if}\;M\_m \leq 2050000:\\
\;\;\;\;w0\_m\\

\mathbf{else}:\\
\;\;\;\;w0\_m + -0.125 \cdot \left(\left(D\_m \cdot D\_m\right) \cdot \left(\left(\frac{M\_m}{d} \cdot \frac{M\_m}{d}\right) \cdot \frac{w0\_m \cdot h}{\ell}\right)\right)\\


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

    1. Initial program 81.4%

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

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

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

    if 2.05e6 < M

    1. Initial program 74.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 72.9% accurate, 8.3× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ w0\_m = \left|w0\right| \\ w0\_s = \mathsf{copysign}\left(1, w0\right) \\ [w0_m, M_m, D_m, h, l, d] = \mathsf{sort}([w0_m, M_m, D_m, h, l, d])\\ \\ w0\_s \cdot \begin{array}{l} \mathbf{if}\;M\_m \leq 2500000:\\ \;\;\;\;w0\_m\\ \mathbf{else}:\\ \;\;\;\;w0\_m + -0.125 \cdot \left(\left(D\_m \cdot D\_m\right) \cdot \left(\left(w0\_m \cdot \frac{h}{\ell}\right) \cdot \left(\frac{M\_m}{d} \cdot \frac{M\_m}{d}\right)\right)\right)\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
w0\_m = (fabs.f64 w0)
w0\_s = (copysign.f64 #s(literal 1 binary64) w0)
NOTE: w0_m, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0_s w0_m M_m D_m h l d)
 :precision binary64
 (*
  w0_s
  (if (<= M_m 2500000.0)
    w0_m
    (+
     w0_m
     (*
      -0.125
      (* (* D_m D_m) (* (* w0_m (/ h l)) (* (/ M_m d) (/ M_m d)))))))))
M_m = fabs(M);
D_m = fabs(D);
w0\_m = fabs(w0);
w0\_s = copysign(1.0, w0);
assert(w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d) {
	double tmp;
	if (M_m <= 2500000.0) {
		tmp = w0_m;
	} else {
		tmp = w0_m + (-0.125 * ((D_m * D_m) * ((w0_m * (h / l)) * ((M_m / d) * (M_m / d)))));
	}
	return w0_s * tmp;
}
M_m = abs(m)
D_m = abs(d)
w0\_m = abs(w0)
w0\_s = copysign(1.0d0, w0)
NOTE: w0_m, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0_s, w0_m, m_m, d_m, h, l, d)
    real(8), intent (in) :: w0_s
    real(8), intent (in) :: w0_m
    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 <= 2500000.0d0) then
        tmp = w0_m
    else
        tmp = w0_m + ((-0.125d0) * ((d_m * d_m) * ((w0_m * (h / l)) * ((m_m / d) * (m_m / d)))))
    end if
    code = w0_s * tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
w0\_m = Math.abs(w0);
w0\_s = Math.copySign(1.0, w0);
assert w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d) {
	double tmp;
	if (M_m <= 2500000.0) {
		tmp = w0_m;
	} else {
		tmp = w0_m + (-0.125 * ((D_m * D_m) * ((w0_m * (h / l)) * ((M_m / d) * (M_m / d)))));
	}
	return w0_s * tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
w0\_m = math.fabs(w0)
w0\_s = math.copysign(1.0, w0)
[w0_m, M_m, D_m, h, l, d] = sort([w0_m, M_m, D_m, h, l, d])
def code(w0_s, w0_m, M_m, D_m, h, l, d):
	tmp = 0
	if M_m <= 2500000.0:
		tmp = w0_m
	else:
		tmp = w0_m + (-0.125 * ((D_m * D_m) * ((w0_m * (h / l)) * ((M_m / d) * (M_m / d)))))
	return w0_s * tmp
M_m = abs(M)
D_m = abs(D)
w0\_m = abs(w0)
w0\_s = copysign(1.0, w0)
w0_m, M_m, D_m, h, l, d = sort([w0_m, M_m, D_m, h, l, d])
function code(w0_s, w0_m, M_m, D_m, h, l, d)
	tmp = 0.0
	if (M_m <= 2500000.0)
		tmp = w0_m;
	else
		tmp = Float64(w0_m + Float64(-0.125 * Float64(Float64(D_m * D_m) * Float64(Float64(w0_m * Float64(h / l)) * Float64(Float64(M_m / d) * Float64(M_m / d))))));
	end
	return Float64(w0_s * tmp)
end
M_m = abs(M);
D_m = abs(D);
w0\_m = abs(w0);
w0\_s = sign(w0) * abs(1.0);
w0_m, M_m, D_m, h, l, d = num2cell(sort([w0_m, M_m, D_m, h, l, d])){:}
function tmp_2 = code(w0_s, w0_m, M_m, D_m, h, l, d)
	tmp = 0.0;
	if (M_m <= 2500000.0)
		tmp = w0_m;
	else
		tmp = w0_m + (-0.125 * ((D_m * D_m) * ((w0_m * (h / l)) * ((M_m / d) * (M_m / d)))));
	end
	tmp_2 = w0_s * tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
w0\_m = N[Abs[w0], $MachinePrecision]
w0\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[w0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: w0_m, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0$95$s_, w0$95$m_, M$95$m_, D$95$m_, h_, l_, d_] := N[(w0$95$s * If[LessEqual[M$95$m, 2500000.0], w0$95$m, N[(w0$95$m + N[(-0.125 * N[(N[(D$95$m * D$95$m), $MachinePrecision] * N[(N[(w0$95$m * N[(h / l), $MachinePrecision]), $MachinePrecision] * N[(N[(M$95$m / d), $MachinePrecision] * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
w0\_m = \left|w0\right|
\\
w0\_s = \mathsf{copysign}\left(1, w0\right)
\\
[w0_m, M_m, D_m, h, l, d] = \mathsf{sort}([w0_m, M_m, D_m, h, l, d])\\
\\
w0\_s \cdot \begin{array}{l}
\mathbf{if}\;M\_m \leq 2500000:\\
\;\;\;\;w0\_m\\

\mathbf{else}:\\
\;\;\;\;w0\_m + -0.125 \cdot \left(\left(D\_m \cdot D\_m\right) \cdot \left(\left(w0\_m \cdot \frac{h}{\ell}\right) \cdot \left(\frac{M\_m}{d} \cdot \frac{M\_m}{d}\right)\right)\right)\\


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

    1. Initial program 81.4%

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

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

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

    if 2.5e6 < M

    1. Initial program 74.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto w0 + -0.125 \cdot \left(\left(D \cdot D\right) \cdot \left(\left(\frac{M}{d} \cdot \frac{M}{d}\right) \cdot \color{blue}{\frac{h \cdot w0}{\ell}}\right)\right) \]
    12. Step-by-step derivation
      1. *-commutative62.6%

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

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

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

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

Alternative 7: 67.7% accurate, 216.0× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ w0\_m = \left|w0\right| \\ w0\_s = \mathsf{copysign}\left(1, w0\right) \\ [w0_m, M_m, D_m, h, l, d] = \mathsf{sort}([w0_m, M_m, D_m, h, l, d])\\ \\ w0\_s \cdot w0\_m \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
w0\_m = (fabs.f64 w0)
w0\_s = (copysign.f64 #s(literal 1 binary64) w0)
NOTE: w0_m, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0_s w0_m M_m D_m h l d) :precision binary64 (* w0_s w0_m))
M_m = fabs(M);
D_m = fabs(D);
w0\_m = fabs(w0);
w0\_s = copysign(1.0, w0);
assert(w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d) {
	return w0_s * w0_m;
}
M_m = abs(m)
D_m = abs(d)
w0\_m = abs(w0)
w0\_s = copysign(1.0d0, w0)
NOTE: w0_m, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0_s, w0_m, m_m, d_m, h, l, d)
    real(8), intent (in) :: w0_s
    real(8), intent (in) :: w0_m
    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_s * w0_m
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
w0\_m = Math.abs(w0);
w0\_s = Math.copySign(1.0, w0);
assert w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d) {
	return w0_s * w0_m;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
w0\_m = math.fabs(w0)
w0\_s = math.copysign(1.0, w0)
[w0_m, M_m, D_m, h, l, d] = sort([w0_m, M_m, D_m, h, l, d])
def code(w0_s, w0_m, M_m, D_m, h, l, d):
	return w0_s * w0_m
M_m = abs(M)
D_m = abs(D)
w0\_m = abs(w0)
w0\_s = copysign(1.0, w0)
w0_m, M_m, D_m, h, l, d = sort([w0_m, M_m, D_m, h, l, d])
function code(w0_s, w0_m, M_m, D_m, h, l, d)
	return Float64(w0_s * w0_m)
end
M_m = abs(M);
D_m = abs(D);
w0\_m = abs(w0);
w0\_s = sign(w0) * abs(1.0);
w0_m, M_m, D_m, h, l, d = num2cell(sort([w0_m, M_m, D_m, h, l, d])){:}
function tmp = code(w0_s, w0_m, M_m, D_m, h, l, d)
	tmp = w0_s * w0_m;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
w0\_m = N[Abs[w0], $MachinePrecision]
w0\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[w0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: w0_m, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0$95$s_, w0$95$m_, M$95$m_, D$95$m_, h_, l_, d_] := N[(w0$95$s * w0$95$m), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
w0\_m = \left|w0\right|
\\
w0\_s = \mathsf{copysign}\left(1, w0\right)
\\
[w0_m, M_m, D_m, h, l, d] = \mathsf{sort}([w0_m, M_m, D_m, h, l, d])\\
\\
w0\_s \cdot w0\_m
\end{array}
Derivation
  1. Initial program 80.0%

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

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

    \[\leadsto \color{blue}{w0} \]
  5. Add Preprocessing

Reproduce

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