Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 81.0% → 86.5%
Time: 15.8s
Alternatives: 7
Speedup: 0.9×

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: 81.0% 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: 86.5% accurate, 0.9× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ d_m = \left|d\right| \\ [w0, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0, M_m, D_m, h, l, d_m])\\ \\ \begin{array}{l} \mathbf{if}\;{\left(\frac{M\_m \cdot D\_m}{2 \cdot d\_m}\right)}^{2} \cdot \frac{h}{\ell} \leq -\infty:\\ \;\;\;\;\frac{\sqrt{-0.25 \cdot \frac{D\_m \cdot \left(\left(M\_m \cdot h\right) \cdot \left(M\_m \cdot D\_m\right)\right)}{\ell}}}{d\_m} \cdot w0\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 + h \cdot \frac{\frac{D\_m \cdot \frac{M\_m}{\frac{d\_m}{M\_m \cdot D\_m}}}{d\_m \cdot -4}}{\ell}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d_m)
 :precision binary64
 (if (<= (* (pow (/ (* M_m D_m) (* 2.0 d_m)) 2.0) (/ h l)) (- INFINITY))
   (* (/ (sqrt (* -0.25 (/ (* D_m (* (* M_m h) (* M_m D_m))) l))) d_m) w0)
   (*
    w0
    (sqrt
     (+
      1.0
      (* h (/ (/ (* D_m (/ M_m (/ d_m (* M_m D_m)))) (* d_m -4.0)) l)))))))
M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
	double tmp;
	if ((pow(((M_m * D_m) / (2.0 * d_m)), 2.0) * (h / l)) <= -((double) INFINITY)) {
		tmp = (sqrt((-0.25 * ((D_m * ((M_m * h) * (M_m * D_m))) / l))) / d_m) * w0;
	} else {
		tmp = w0 * sqrt((1.0 + (h * (((D_m * (M_m / (d_m / (M_m * D_m)))) / (d_m * -4.0)) / l))));
	}
	return tmp;
}
M_m = Math.abs(M);
D_m = Math.abs(D);
d_m = Math.abs(d);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
	double tmp;
	if ((Math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0) * (h / l)) <= -Double.POSITIVE_INFINITY) {
		tmp = (Math.sqrt((-0.25 * ((D_m * ((M_m * h) * (M_m * D_m))) / l))) / d_m) * w0;
	} else {
		tmp = w0 * Math.sqrt((1.0 + (h * (((D_m * (M_m / (d_m / (M_m * D_m)))) / (d_m * -4.0)) / l))));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
d_m = math.fabs(d)
[w0, M_m, D_m, h, l, d_m] = sort([w0, M_m, D_m, h, l, d_m])
def code(w0, M_m, D_m, h, l, d_m):
	tmp = 0
	if (math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0) * (h / l)) <= -math.inf:
		tmp = (math.sqrt((-0.25 * ((D_m * ((M_m * h) * (M_m * D_m))) / l))) / d_m) * w0
	else:
		tmp = w0 * math.sqrt((1.0 + (h * (((D_m * (M_m / (d_m / (M_m * D_m)))) / (d_m * -4.0)) / l))))
	return tmp
M_m = abs(M)
D_m = abs(D)
d_m = abs(d)
w0, M_m, D_m, h, l, d_m = sort([w0, M_m, D_m, h, l, d_m])
function code(w0, M_m, D_m, h, l, d_m)
	tmp = 0.0
	if (Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d_m)) ^ 2.0) * Float64(h / l)) <= Float64(-Inf))
		tmp = Float64(Float64(sqrt(Float64(-0.25 * Float64(Float64(D_m * Float64(Float64(M_m * h) * Float64(M_m * D_m))) / l))) / d_m) * w0);
	else
		tmp = Float64(w0 * sqrt(Float64(1.0 + Float64(h * Float64(Float64(Float64(D_m * Float64(M_m / Float64(d_m / Float64(M_m * D_m)))) / Float64(d_m * -4.0)) / l)))));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d_m = abs(d);
w0, M_m, D_m, h, l, d_m = num2cell(sort([w0, M_m, D_m, h, l, d_m])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d_m)
	tmp = 0.0;
	if (((((M_m * D_m) / (2.0 * d_m)) ^ 2.0) * (h / l)) <= -Inf)
		tmp = (sqrt((-0.25 * ((D_m * ((M_m * h) * (M_m * D_m))) / l))) / d_m) * w0;
	else
		tmp = w0 * sqrt((1.0 + (h * (((D_m * (M_m / (d_m / (M_m * D_m)))) / (d_m * -4.0)) / l))));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := If[LessEqual[N[(N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], (-Infinity)], N[(N[(N[Sqrt[N[(-0.25 * N[(N[(D$95$m * N[(N[(M$95$m * h), $MachinePrecision] * N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / d$95$m), $MachinePrecision] * w0), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 + N[(h * N[(N[(N[(D$95$m * N[(M$95$m / N[(d$95$m / N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d$95$m * -4.0), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
[w0, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0, M_m, D_m, h, l, d_m])\\
\\
\begin{array}{l}
\mathbf{if}\;{\left(\frac{M\_m \cdot D\_m}{2 \cdot d\_m}\right)}^{2} \cdot \frac{h}{\ell} \leq -\infty:\\
\;\;\;\;\frac{\sqrt{-0.25 \cdot \frac{D\_m \cdot \left(\left(M\_m \cdot h\right) \cdot \left(M\_m \cdot D\_m\right)\right)}{\ell}}}{d\_m} \cdot w0\\

\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 + h \cdot \frac{\frac{D\_m \cdot \frac{M\_m}{\frac{d\_m}{M\_m \cdot D\_m}}}{d\_m \cdot -4}}{\ell}}\\


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

    1. Initial program 44.2%

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

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

      \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{sqrt.f64}\left(\color{blue}{\left(\frac{-1}{4} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)}\right)\right) \]
    5. Step-by-step derivation
      1. associate-*r/N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{sqrt.f64}\left(\left(\frac{\frac{-1}{4} \cdot \left({D}^{2} \cdot \left({M}^{2} \cdot h\right)\right)}{{d}^{2} \cdot \ell}\right)\right)\right) \]
      2. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\left(\frac{-1}{4} \cdot \left({D}^{2} \cdot \left({M}^{2} \cdot h\right)\right)\right), \left({d}^{2} \cdot \ell\right)\right)\right)\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \left({D}^{2} \cdot \left({M}^{2} \cdot h\right)\right)\right), \left({d}^{2} \cdot \ell\right)\right)\right)\right) \]
      4. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \left(\left(D \cdot D\right) \cdot \left({M}^{2} \cdot h\right)\right)\right), \left({d}^{2} \cdot \ell\right)\right)\right)\right) \]
      5. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \left(D \cdot \left(D \cdot \left({M}^{2} \cdot h\right)\right)\right)\right), \left({d}^{2} \cdot \ell\right)\right)\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(D, \left(D \cdot \left({M}^{2} \cdot h\right)\right)\right)\right), \left({d}^{2} \cdot \ell\right)\right)\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(D, \mathsf{*.f64}\left(D, \left({M}^{2} \cdot h\right)\right)\right)\right), \left({d}^{2} \cdot \ell\right)\right)\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(D, \mathsf{*.f64}\left(D, \mathsf{*.f64}\left(\left({M}^{2}\right), h\right)\right)\right)\right), \left({d}^{2} \cdot \ell\right)\right)\right)\right) \]
      9. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(D, \mathsf{*.f64}\left(D, \mathsf{*.f64}\left(\left(M \cdot M\right), h\right)\right)\right)\right), \left({d}^{2} \cdot \ell\right)\right)\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(D, \mathsf{*.f64}\left(D, \mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), h\right)\right)\right)\right), \left({d}^{2} \cdot \ell\right)\right)\right)\right) \]
      11. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(D, \mathsf{*.f64}\left(D, \mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), h\right)\right)\right)\right), \mathsf{*.f64}\left(\left({d}^{2}\right), \ell\right)\right)\right)\right) \]
      12. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(D, \mathsf{*.f64}\left(D, \mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), h\right)\right)\right)\right), \mathsf{*.f64}\left(\left(d \cdot d\right), \ell\right)\right)\right)\right) \]
      13. *-lowering-*.f6439.8%

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(D, \mathsf{*.f64}\left(D, \mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), h\right)\right)\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(d, d\right), \ell\right)\right)\right)\right) \]
    6. Simplified39.8%

      \[\leadsto w0 \cdot \sqrt{\color{blue}{\frac{-0.25 \cdot \left(D \cdot \left(D \cdot \left(\left(M \cdot M\right) \cdot h\right)\right)\right)}{\left(d \cdot d\right) \cdot \ell}}} \]
    7. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \sqrt{\frac{\frac{-1}{4} \cdot \left(D \cdot \left(D \cdot \left(\left(M \cdot M\right) \cdot h\right)\right)\right)}{\left(d \cdot d\right) \cdot \ell}} \cdot \color{blue}{w0} \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\sqrt{\frac{\frac{-1}{4} \cdot \left(D \cdot \left(D \cdot \left(\left(M \cdot M\right) \cdot h\right)\right)\right)}{\left(d \cdot d\right) \cdot \ell}}\right), \color{blue}{w0}\right) \]
    8. Applied egg-rr19.3%

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{/.f64}\left(\mathsf{*.f64}\left(D, \left(\left(h \cdot \left(M \cdot M\right)\right) \cdot D\right)\right), \ell\right)\right)\right), d\right), w0\right) \]
      2. associate-*r*N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{/.f64}\left(\mathsf{*.f64}\left(D, \left(\left(\left(h \cdot M\right) \cdot M\right) \cdot D\right)\right), \ell\right)\right)\right), d\right), w0\right) \]
      3. associate-*r*N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{/.f64}\left(\mathsf{*.f64}\left(D, \left(\left(h \cdot M\right) \cdot \left(M \cdot D\right)\right)\right), \ell\right)\right)\right), d\right), w0\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{/.f64}\left(\mathsf{*.f64}\left(D, \left(\left(h \cdot M\right) \cdot \left(D \cdot M\right)\right)\right), \ell\right)\right)\right), d\right), w0\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{/.f64}\left(\mathsf{*.f64}\left(D, \mathsf{*.f64}\left(\left(h \cdot M\right), \left(D \cdot M\right)\right)\right), \ell\right)\right)\right), d\right), w0\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{/.f64}\left(\mathsf{*.f64}\left(D, \mathsf{*.f64}\left(\mathsf{*.f64}\left(h, M\right), \left(D \cdot M\right)\right)\right), \ell\right)\right)\right), d\right), w0\right) \]
      7. *-lowering-*.f6427.8%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{/.f64}\left(\mathsf{*.f64}\left(D, \mathsf{*.f64}\left(\mathsf{*.f64}\left(h, M\right), \mathsf{*.f64}\left(D, M\right)\right)\right), \ell\right)\right)\right), d\right), w0\right) \]
    10. Applied egg-rr27.8%

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

    if -inf.0 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l))

    1. Initial program 93.3%

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

      \[\leadsto \color{blue}{w0 \cdot \sqrt{1 + \frac{\frac{h \cdot \left(D \cdot \frac{M \cdot \frac{M \cdot D}{d}}{-4}\right)}{d}}{\ell}}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. associate-/l*N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \left(\frac{h \cdot \frac{D \cdot \frac{M \cdot \frac{M \cdot D}{d}}{-4}}{d}}{\ell}\right)\right)\right)\right) \]
      2. associate-/l*N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \left(h \cdot \frac{\frac{D \cdot \frac{M \cdot \frac{M \cdot D}{d}}{-4}}{d}}{\ell}\right)\right)\right)\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(h, \left(\frac{\frac{D \cdot \frac{M \cdot \frac{M \cdot D}{d}}{-4}}{d}}{\ell}\right)\right)\right)\right)\right) \]
      4. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(h, \mathsf{/.f64}\left(\left(\frac{D \cdot \frac{M \cdot \frac{M \cdot D}{d}}{-4}}{d}\right), \ell\right)\right)\right)\right)\right) \]
      5. associate-*r/N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(h, \mathsf{/.f64}\left(\left(\frac{\frac{D \cdot \left(M \cdot \frac{M \cdot D}{d}\right)}{-4}}{d}\right), \ell\right)\right)\right)\right)\right) \]
      6. associate-/l/N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(h, \mathsf{/.f64}\left(\left(\frac{D \cdot \left(M \cdot \frac{M \cdot D}{d}\right)}{d \cdot -4}\right), \ell\right)\right)\right)\right)\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(h, \mathsf{/.f64}\left(\mathsf{/.f64}\left(\left(D \cdot \left(M \cdot \frac{M \cdot D}{d}\right)\right), \left(d \cdot -4\right)\right), \ell\right)\right)\right)\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(h, \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(D, \left(M \cdot \frac{M \cdot D}{d}\right)\right), \left(d \cdot -4\right)\right), \ell\right)\right)\right)\right)\right) \]
      9. clear-numN/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(h, \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(D, \left(M \cdot \frac{1}{\frac{d}{M \cdot D}}\right)\right), \left(d \cdot -4\right)\right), \ell\right)\right)\right)\right)\right) \]
      10. un-div-invN/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(h, \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(D, \left(\frac{M}{\frac{d}{M \cdot D}}\right)\right), \left(d \cdot -4\right)\right), \ell\right)\right)\right)\right)\right) \]
      11. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(h, \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(D, \mathsf{/.f64}\left(M, \left(\frac{d}{M \cdot D}\right)\right)\right), \left(d \cdot -4\right)\right), \ell\right)\right)\right)\right)\right) \]
      12. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(h, \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(D, \mathsf{/.f64}\left(M, \mathsf{/.f64}\left(d, \left(M \cdot D\right)\right)\right)\right), \left(d \cdot -4\right)\right), \ell\right)\right)\right)\right)\right) \]
      13. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(h, \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(D, \mathsf{/.f64}\left(M, \mathsf{/.f64}\left(d, \left(D \cdot M\right)\right)\right)\right), \left(d \cdot -4\right)\right), \ell\right)\right)\right)\right)\right) \]
      14. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(h, \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(D, \mathsf{/.f64}\left(M, \mathsf{/.f64}\left(d, \mathsf{*.f64}\left(D, M\right)\right)\right)\right), \left(d \cdot -4\right)\right), \ell\right)\right)\right)\right)\right) \]
      15. *-lowering-*.f6497.5%

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(h, \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(D, \mathsf{/.f64}\left(M, \mathsf{/.f64}\left(d, \mathsf{*.f64}\left(D, M\right)\right)\right)\right), \mathsf{*.f64}\left(d, -4\right)\right), \ell\right)\right)\right)\right)\right) \]
    5. Applied egg-rr97.5%

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

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

Alternative 2: 79.4% accurate, 8.3× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if D < 4.9999999999999999e-13

    1. Initial program 84.6%

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

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

      \[\leadsto \mathsf{*.f64}\left(w0, \color{blue}{\left(1 + \frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)}\right) \]
    5. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)}\right)\right) \]
      2. associate-*r/N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \left(\frac{\frac{-1}{8} \cdot \left({D}^{2} \cdot \left({M}^{2} \cdot h\right)\right)}{\color{blue}{{d}^{2} \cdot \ell}}\right)\right)\right) \]
      3. times-fracN/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \left(\frac{\frac{-1}{8}}{{d}^{2}} \cdot \color{blue}{\frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{\ell}}\right)\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left(\frac{\frac{-1}{8}}{{d}^{2}}\right), \color{blue}{\left(\frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{\ell}\right)}\right)\right)\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \left({d}^{2}\right)\right), \left(\frac{\color{blue}{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}}{\ell}\right)\right)\right)\right) \]
      6. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \left(d \cdot d\right)\right), \left(\frac{{D}^{2} \cdot \color{blue}{\left({M}^{2} \cdot h\right)}}{\ell}\right)\right)\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \left(\frac{{D}^{2} \cdot \color{blue}{\left({M}^{2} \cdot h\right)}}{\ell}\right)\right)\right)\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \mathsf{/.f64}\left(\left({D}^{2} \cdot \left({M}^{2} \cdot h\right)\right), \color{blue}{\ell}\right)\right)\right)\right) \]
      9. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \mathsf{/.f64}\left(\left(\left(D \cdot D\right) \cdot \left({M}^{2} \cdot h\right)\right), \ell\right)\right)\right)\right) \]
      10. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \mathsf{/.f64}\left(\left(D \cdot \left(D \cdot \left({M}^{2} \cdot h\right)\right)\right), \ell\right)\right)\right)\right) \]
      11. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(D, \left(D \cdot \left({M}^{2} \cdot h\right)\right)\right), \ell\right)\right)\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(D, \mathsf{*.f64}\left(D, \left({M}^{2} \cdot h\right)\right)\right), \ell\right)\right)\right)\right) \]
      13. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(D, \mathsf{*.f64}\left(D, \mathsf{*.f64}\left(\left({M}^{2}\right), h\right)\right)\right), \ell\right)\right)\right)\right) \]
      14. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(D, \mathsf{*.f64}\left(D, \mathsf{*.f64}\left(\left(M \cdot M\right), h\right)\right)\right), \ell\right)\right)\right)\right) \]
      15. *-lowering-*.f6461.1%

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(D, \mathsf{*.f64}\left(D, \mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), h\right)\right)\right), \ell\right)\right)\right)\right) \]
    6. Simplified61.1%

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

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \left(\frac{\frac{-1}{8} \cdot \frac{D \cdot \left(D \cdot \left(\left(M \cdot M\right) \cdot h\right)\right)}{\ell}}{\color{blue}{d \cdot d}}\right)\right)\right) \]
      2. associate-/r*N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \left(\frac{\frac{\frac{-1}{8} \cdot \frac{D \cdot \left(D \cdot \left(\left(M \cdot M\right) \cdot h\right)\right)}{\ell}}{d}}{\color{blue}{d}}\right)\right)\right) \]
      3. /-lowering-/.f64N/A

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

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

    if 4.9999999999999999e-13 < D

    1. Initial program 72.8%

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

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

      \[\leadsto \mathsf{*.f64}\left(w0, \color{blue}{\left(1 + \frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)}\right) \]
    5. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)}\right)\right) \]
      2. associate-*r/N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \left(\frac{\frac{-1}{8} \cdot \left({D}^{2} \cdot \left({M}^{2} \cdot h\right)\right)}{\color{blue}{{d}^{2} \cdot \ell}}\right)\right)\right) \]
      3. times-fracN/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \left(\frac{\frac{-1}{8}}{{d}^{2}} \cdot \color{blue}{\frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{\ell}}\right)\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left(\frac{\frac{-1}{8}}{{d}^{2}}\right), \color{blue}{\left(\frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{\ell}\right)}\right)\right)\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \left({d}^{2}\right)\right), \left(\frac{\color{blue}{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}}{\ell}\right)\right)\right)\right) \]
      6. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \left(d \cdot d\right)\right), \left(\frac{{D}^{2} \cdot \color{blue}{\left({M}^{2} \cdot h\right)}}{\ell}\right)\right)\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \left(\frac{{D}^{2} \cdot \color{blue}{\left({M}^{2} \cdot h\right)}}{\ell}\right)\right)\right)\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \mathsf{/.f64}\left(\left({D}^{2} \cdot \left({M}^{2} \cdot h\right)\right), \color{blue}{\ell}\right)\right)\right)\right) \]
      9. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \mathsf{/.f64}\left(\left(\left(D \cdot D\right) \cdot \left({M}^{2} \cdot h\right)\right), \ell\right)\right)\right)\right) \]
      10. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \mathsf{/.f64}\left(\left(D \cdot \left(D \cdot \left({M}^{2} \cdot h\right)\right)\right), \ell\right)\right)\right)\right) \]
      11. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(D, \left(D \cdot \left({M}^{2} \cdot h\right)\right)\right), \ell\right)\right)\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(D, \mathsf{*.f64}\left(D, \left({M}^{2} \cdot h\right)\right)\right), \ell\right)\right)\right)\right) \]
      13. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(D, \mathsf{*.f64}\left(D, \mathsf{*.f64}\left(\left({M}^{2}\right), h\right)\right)\right), \ell\right)\right)\right)\right) \]
      14. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(D, \mathsf{*.f64}\left(D, \mathsf{*.f64}\left(\left(M \cdot M\right), h\right)\right)\right), \ell\right)\right)\right)\right) \]
      15. *-lowering-*.f6458.4%

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(D, \mathsf{*.f64}\left(D, \mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), h\right)\right)\right), \ell\right)\right)\right)\right) \]
    6. Simplified58.4%

      \[\leadsto w0 \cdot \color{blue}{\left(1 + \frac{-0.125}{d \cdot d} \cdot \frac{D \cdot \left(D \cdot \left(\left(M \cdot M\right) \cdot h\right)\right)}{\ell}\right)} \]
    7. Step-by-step derivation
      1. frac-timesN/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \left(\frac{\frac{-1}{8} \cdot \left(D \cdot \left(D \cdot \left(\left(M \cdot M\right) \cdot h\right)\right)\right)}{\color{blue}{\left(d \cdot d\right) \cdot \ell}}\right)\right)\right) \]
      2. associate-*r*N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \left(\frac{\frac{-1}{8} \cdot \left(\left(D \cdot D\right) \cdot \left(\left(M \cdot M\right) \cdot h\right)\right)}{\left(d \cdot \color{blue}{d}\right) \cdot \ell}\right)\right)\right) \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \left(\frac{\frac{-1}{8} \cdot \left(\left(D \cdot D\right) \cdot \left(h \cdot \left(M \cdot M\right)\right)\right)}{\left(d \cdot d\right) \cdot \ell}\right)\right)\right) \]
      4. associate-*r*N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \left(\frac{\frac{-1}{8} \cdot \left(D \cdot \left(D \cdot \left(h \cdot \left(M \cdot M\right)\right)\right)\right)}{\left(d \cdot \color{blue}{d}\right) \cdot \ell}\right)\right)\right) \]
      5. associate-/l*N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \left(\frac{-1}{8} \cdot \color{blue}{\frac{D \cdot \left(D \cdot \left(h \cdot \left(M \cdot M\right)\right)\right)}{\left(d \cdot d\right) \cdot \ell}}\right)\right)\right) \]
      6. associate-*r*N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \left(\frac{-1}{8} \cdot \frac{D \cdot \left(D \cdot \left(\left(h \cdot M\right) \cdot M\right)\right)}{\left(d \cdot d\right) \cdot \ell}\right)\right)\right) \]
      7. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \left(\frac{-1}{8} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot \left(h \cdot M\right)\right)\right)}{\left(d \cdot d\right) \cdot \ell}\right)\right)\right) \]
      8. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \left(\frac{-1}{8} \cdot \frac{D \cdot \left(\left(D \cdot M\right) \cdot \left(h \cdot M\right)\right)}{\left(d \cdot \color{blue}{d}\right) \cdot \ell}\right)\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{8}, \color{blue}{\left(\frac{D \cdot \left(\left(D \cdot M\right) \cdot \left(h \cdot M\right)\right)}{\left(d \cdot d\right) \cdot \ell}\right)}\right)\right)\right) \]
      10. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{8}, \left(\frac{D \cdot \left(D \cdot \left(M \cdot \left(h \cdot M\right)\right)\right)}{\left(d \cdot \color{blue}{d}\right) \cdot \ell}\right)\right)\right)\right) \]
      11. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{8}, \left(\frac{D \cdot \left(D \cdot \left(\left(h \cdot M\right) \cdot M\right)\right)}{\left(d \cdot d\right) \cdot \ell}\right)\right)\right)\right) \]
      12. associate-*r*N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{8}, \left(\frac{D \cdot \left(D \cdot \left(h \cdot \left(M \cdot M\right)\right)\right)}{\left(d \cdot d\right) \cdot \ell}\right)\right)\right)\right) \]
      13. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{8}, \left(\frac{D \cdot \left(D \cdot \left(h \cdot \left(M \cdot M\right)\right)\right)}{d \cdot \color{blue}{\left(d \cdot \ell\right)}}\right)\right)\right)\right) \]
      14. associate-/r*N/A

        \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{8}, \left(\frac{\frac{D \cdot \left(D \cdot \left(h \cdot \left(M \cdot M\right)\right)\right)}{d}}{\color{blue}{d \cdot \ell}}\right)\right)\right)\right) \]
    8. Applied egg-rr67.6%

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

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

Alternative 3: 79.2% accurate, 8.3× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if D < 1.05000000000000006e-38

    1. Initial program 84.9%

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

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

      \[\leadsto \color{blue}{w0} \]
    5. Step-by-step derivation
      1. Simplified77.4%

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

      if 1.05000000000000006e-38 < D

      1. Initial program 73.5%

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

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

        \[\leadsto \mathsf{*.f64}\left(w0, \color{blue}{\left(1 + \frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)}\right) \]
      5. Step-by-step derivation
        1. +-lowering-+.f64N/A

          \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)}\right)\right) \]
        2. associate-*r/N/A

          \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \left(\frac{\frac{-1}{8} \cdot \left({D}^{2} \cdot \left({M}^{2} \cdot h\right)\right)}{\color{blue}{{d}^{2} \cdot \ell}}\right)\right)\right) \]
        3. times-fracN/A

          \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \left(\frac{\frac{-1}{8}}{{d}^{2}} \cdot \color{blue}{\frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{\ell}}\right)\right)\right) \]
        4. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left(\frac{\frac{-1}{8}}{{d}^{2}}\right), \color{blue}{\left(\frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{\ell}\right)}\right)\right)\right) \]
        5. /-lowering-/.f64N/A

          \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \left({d}^{2}\right)\right), \left(\frac{\color{blue}{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}}{\ell}\right)\right)\right)\right) \]
        6. unpow2N/A

          \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \left(d \cdot d\right)\right), \left(\frac{{D}^{2} \cdot \color{blue}{\left({M}^{2} \cdot h\right)}}{\ell}\right)\right)\right)\right) \]
        7. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \left(\frac{{D}^{2} \cdot \color{blue}{\left({M}^{2} \cdot h\right)}}{\ell}\right)\right)\right)\right) \]
        8. /-lowering-/.f64N/A

          \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \mathsf{/.f64}\left(\left({D}^{2} \cdot \left({M}^{2} \cdot h\right)\right), \color{blue}{\ell}\right)\right)\right)\right) \]
        9. unpow2N/A

          \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \mathsf{/.f64}\left(\left(\left(D \cdot D\right) \cdot \left({M}^{2} \cdot h\right)\right), \ell\right)\right)\right)\right) \]
        10. associate-*l*N/A

          \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \mathsf{/.f64}\left(\left(D \cdot \left(D \cdot \left({M}^{2} \cdot h\right)\right)\right), \ell\right)\right)\right)\right) \]
        11. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(D, \left(D \cdot \left({M}^{2} \cdot h\right)\right)\right), \ell\right)\right)\right)\right) \]
        12. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(D, \mathsf{*.f64}\left(D, \left({M}^{2} \cdot h\right)\right)\right), \ell\right)\right)\right)\right) \]
        13. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(D, \mathsf{*.f64}\left(D, \mathsf{*.f64}\left(\left({M}^{2}\right), h\right)\right)\right), \ell\right)\right)\right)\right) \]
        14. unpow2N/A

          \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(D, \mathsf{*.f64}\left(D, \mathsf{*.f64}\left(\left(M \cdot M\right), h\right)\right)\right), \ell\right)\right)\right)\right) \]
        15. *-lowering-*.f6458.2%

          \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(D, \mathsf{*.f64}\left(D, \mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), h\right)\right)\right), \ell\right)\right)\right)\right) \]
      6. Simplified58.2%

        \[\leadsto w0 \cdot \color{blue}{\left(1 + \frac{-0.125}{d \cdot d} \cdot \frac{D \cdot \left(D \cdot \left(\left(M \cdot M\right) \cdot h\right)\right)}{\ell}\right)} \]
      7. Step-by-step derivation
        1. frac-timesN/A

          \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \left(\frac{\frac{-1}{8} \cdot \left(D \cdot \left(D \cdot \left(\left(M \cdot M\right) \cdot h\right)\right)\right)}{\color{blue}{\left(d \cdot d\right) \cdot \ell}}\right)\right)\right) \]
        2. associate-*r*N/A

          \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \left(\frac{\frac{-1}{8} \cdot \left(\left(D \cdot D\right) \cdot \left(\left(M \cdot M\right) \cdot h\right)\right)}{\left(d \cdot \color{blue}{d}\right) \cdot \ell}\right)\right)\right) \]
        3. *-commutativeN/A

          \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \left(\frac{\frac{-1}{8} \cdot \left(\left(D \cdot D\right) \cdot \left(h \cdot \left(M \cdot M\right)\right)\right)}{\left(d \cdot d\right) \cdot \ell}\right)\right)\right) \]
        4. associate-*r*N/A

          \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \left(\frac{\frac{-1}{8} \cdot \left(D \cdot \left(D \cdot \left(h \cdot \left(M \cdot M\right)\right)\right)\right)}{\left(d \cdot \color{blue}{d}\right) \cdot \ell}\right)\right)\right) \]
        5. associate-/l*N/A

          \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \left(\frac{-1}{8} \cdot \color{blue}{\frac{D \cdot \left(D \cdot \left(h \cdot \left(M \cdot M\right)\right)\right)}{\left(d \cdot d\right) \cdot \ell}}\right)\right)\right) \]
        6. associate-*r*N/A

          \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \left(\frac{-1}{8} \cdot \frac{D \cdot \left(D \cdot \left(\left(h \cdot M\right) \cdot M\right)\right)}{\left(d \cdot d\right) \cdot \ell}\right)\right)\right) \]
        7. *-commutativeN/A

          \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \left(\frac{-1}{8} \cdot \frac{D \cdot \left(D \cdot \left(M \cdot \left(h \cdot M\right)\right)\right)}{\left(d \cdot d\right) \cdot \ell}\right)\right)\right) \]
        8. associate-*l*N/A

          \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \left(\frac{-1}{8} \cdot \frac{D \cdot \left(\left(D \cdot M\right) \cdot \left(h \cdot M\right)\right)}{\left(d \cdot \color{blue}{d}\right) \cdot \ell}\right)\right)\right) \]
        9. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{8}, \color{blue}{\left(\frac{D \cdot \left(\left(D \cdot M\right) \cdot \left(h \cdot M\right)\right)}{\left(d \cdot d\right) \cdot \ell}\right)}\right)\right)\right) \]
        10. associate-*l*N/A

          \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{8}, \left(\frac{D \cdot \left(D \cdot \left(M \cdot \left(h \cdot M\right)\right)\right)}{\left(d \cdot \color{blue}{d}\right) \cdot \ell}\right)\right)\right)\right) \]
        11. *-commutativeN/A

          \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{8}, \left(\frac{D \cdot \left(D \cdot \left(\left(h \cdot M\right) \cdot M\right)\right)}{\left(d \cdot d\right) \cdot \ell}\right)\right)\right)\right) \]
        12. associate-*r*N/A

          \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{8}, \left(\frac{D \cdot \left(D \cdot \left(h \cdot \left(M \cdot M\right)\right)\right)}{\left(d \cdot d\right) \cdot \ell}\right)\right)\right)\right) \]
        13. associate-*l*N/A

          \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{8}, \left(\frac{D \cdot \left(D \cdot \left(h \cdot \left(M \cdot M\right)\right)\right)}{d \cdot \color{blue}{\left(d \cdot \ell\right)}}\right)\right)\right)\right) \]
        14. associate-/r*N/A

          \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{8}, \left(\frac{\frac{D \cdot \left(D \cdot \left(h \cdot \left(M \cdot M\right)\right)\right)}{d}}{\color{blue}{d \cdot \ell}}\right)\right)\right)\right) \]
      8. Applied egg-rr69.0%

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

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

    Alternative 4: 71.5% accurate, 9.0× speedup?

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

      1. Initial program 82.8%

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

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

        \[\leadsto \color{blue}{w0} \]
      5. Step-by-step derivation
        1. Simplified78.1%

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

        if 4.00000000000000033e-5 < M

        1. Initial program 78.6%

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

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

          \[\leadsto \mathsf{*.f64}\left(w0, \color{blue}{\left(1 + \frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)}\right) \]
        5. Step-by-step derivation
          1. +-lowering-+.f64N/A

            \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)}\right)\right) \]
          2. associate-*r/N/A

            \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \left(\frac{\frac{-1}{8} \cdot \left({D}^{2} \cdot \left({M}^{2} \cdot h\right)\right)}{\color{blue}{{d}^{2} \cdot \ell}}\right)\right)\right) \]
          3. times-fracN/A

            \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \left(\frac{\frac{-1}{8}}{{d}^{2}} \cdot \color{blue}{\frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{\ell}}\right)\right)\right) \]
          4. *-lowering-*.f64N/A

            \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left(\frac{\frac{-1}{8}}{{d}^{2}}\right), \color{blue}{\left(\frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{\ell}\right)}\right)\right)\right) \]
          5. /-lowering-/.f64N/A

            \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \left({d}^{2}\right)\right), \left(\frac{\color{blue}{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}}{\ell}\right)\right)\right)\right) \]
          6. unpow2N/A

            \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \left(d \cdot d\right)\right), \left(\frac{{D}^{2} \cdot \color{blue}{\left({M}^{2} \cdot h\right)}}{\ell}\right)\right)\right)\right) \]
          7. *-lowering-*.f64N/A

            \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \left(\frac{{D}^{2} \cdot \color{blue}{\left({M}^{2} \cdot h\right)}}{\ell}\right)\right)\right)\right) \]
          8. /-lowering-/.f64N/A

            \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \mathsf{/.f64}\left(\left({D}^{2} \cdot \left({M}^{2} \cdot h\right)\right), \color{blue}{\ell}\right)\right)\right)\right) \]
          9. unpow2N/A

            \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \mathsf{/.f64}\left(\left(\left(D \cdot D\right) \cdot \left({M}^{2} \cdot h\right)\right), \ell\right)\right)\right)\right) \]
          10. associate-*l*N/A

            \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \mathsf{/.f64}\left(\left(D \cdot \left(D \cdot \left({M}^{2} \cdot h\right)\right)\right), \ell\right)\right)\right)\right) \]
          11. *-lowering-*.f64N/A

            \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(D, \left(D \cdot \left({M}^{2} \cdot h\right)\right)\right), \ell\right)\right)\right)\right) \]
          12. *-lowering-*.f64N/A

            \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(D, \mathsf{*.f64}\left(D, \left({M}^{2} \cdot h\right)\right)\right), \ell\right)\right)\right)\right) \]
          13. *-lowering-*.f64N/A

            \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(D, \mathsf{*.f64}\left(D, \mathsf{*.f64}\left(\left({M}^{2}\right), h\right)\right)\right), \ell\right)\right)\right)\right) \]
          14. unpow2N/A

            \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(D, \mathsf{*.f64}\left(D, \mathsf{*.f64}\left(\left(M \cdot M\right), h\right)\right)\right), \ell\right)\right)\right)\right) \]
          15. *-lowering-*.f6447.8%

            \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(D, \mathsf{*.f64}\left(D, \mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), h\right)\right)\right), \ell\right)\right)\right)\right) \]
        6. Simplified47.8%

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

          \[\leadsto \mathsf{*.f64}\left(w0, \color{blue}{\left(\frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)}\right) \]
        8. Step-by-step derivation
          1. associate-/r*N/A

            \[\leadsto \mathsf{*.f64}\left(w0, \left(\frac{-1}{8} \cdot \frac{\frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}}{\color{blue}{\ell}}\right)\right) \]
          2. associate-*r/N/A

            \[\leadsto \mathsf{*.f64}\left(w0, \left(\frac{\frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}}{\color{blue}{\ell}}\right)\right) \]
          3. /-lowering-/.f64N/A

            \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{/.f64}\left(\left(\frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}\right), \color{blue}{\ell}\right)\right) \]
          4. associate-/l*N/A

            \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{/.f64}\left(\left(\frac{-1}{8} \cdot \left({D}^{2} \cdot \frac{{M}^{2} \cdot h}{{d}^{2}}\right)\right), \ell\right)\right) \]
          5. associate-*r*N/A

            \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{/.f64}\left(\left(\left(\frac{-1}{8} \cdot {D}^{2}\right) \cdot \frac{{M}^{2} \cdot h}{{d}^{2}}\right), \ell\right)\right) \]
          6. *-lowering-*.f64N/A

            \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\left(\frac{-1}{8} \cdot {D}^{2}\right), \left(\frac{{M}^{2} \cdot h}{{d}^{2}}\right)\right), \ell\right)\right) \]
          7. *-lowering-*.f64N/A

            \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \left({D}^{2}\right)\right), \left(\frac{{M}^{2} \cdot h}{{d}^{2}}\right)\right), \ell\right)\right) \]
          8. unpow2N/A

            \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \left(D \cdot D\right)\right), \left(\frac{{M}^{2} \cdot h}{{d}^{2}}\right)\right), \ell\right)\right) \]
          9. *-lowering-*.f64N/A

            \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(D, D\right)\right), \left(\frac{{M}^{2} \cdot h}{{d}^{2}}\right)\right), \ell\right)\right) \]
          10. /-lowering-/.f64N/A

            \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(D, D\right)\right), \mathsf{/.f64}\left(\left({M}^{2} \cdot h\right), \left({d}^{2}\right)\right)\right), \ell\right)\right) \]
          11. *-lowering-*.f64N/A

            \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(D, D\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(\left({M}^{2}\right), h\right), \left({d}^{2}\right)\right)\right), \ell\right)\right) \]
          12. unpow2N/A

            \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(D, D\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(\left(M \cdot M\right), h\right), \left({d}^{2}\right)\right)\right), \ell\right)\right) \]
          13. *-lowering-*.f64N/A

            \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(D, D\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), h\right), \left({d}^{2}\right)\right)\right), \ell\right)\right) \]
          14. unpow2N/A

            \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(D, D\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), h\right), \left(d \cdot d\right)\right)\right), \ell\right)\right) \]
          15. *-lowering-*.f6423.8%

            \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(D, D\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), h\right), \mathsf{*.f64}\left(d, d\right)\right)\right), \ell\right)\right) \]
        9. Simplified23.8%

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

            \[\leadsto \mathsf{*.f64}\left(w0, \left(\frac{\frac{\left(\frac{-1}{8} \cdot \left(D \cdot D\right)\right) \cdot \left(\left(M \cdot M\right) \cdot h\right)}{d \cdot d}}{\ell}\right)\right) \]
          2. associate-*r*N/A

            \[\leadsto \mathsf{*.f64}\left(w0, \left(\frac{\frac{\frac{-1}{8} \cdot \left(\left(D \cdot D\right) \cdot \left(\left(M \cdot M\right) \cdot h\right)\right)}{d \cdot d}}{\ell}\right)\right) \]
          3. associate-*l*N/A

            \[\leadsto \mathsf{*.f64}\left(w0, \left(\frac{\frac{\frac{-1}{8} \cdot \left(\left(\left(D \cdot D\right) \cdot \left(M \cdot M\right)\right) \cdot h\right)}{d \cdot d}}{\ell}\right)\right) \]
          4. associate-*l/N/A

            \[\leadsto \mathsf{*.f64}\left(w0, \left(\frac{\frac{\frac{-1}{8}}{d \cdot d} \cdot \left(\left(\left(D \cdot D\right) \cdot \left(M \cdot M\right)\right) \cdot h\right)}{\ell}\right)\right) \]
          5. associate-*r/N/A

            \[\leadsto \mathsf{*.f64}\left(w0, \left(\frac{\frac{-1}{8}}{d \cdot d} \cdot \color{blue}{\frac{\left(\left(D \cdot D\right) \cdot \left(M \cdot M\right)\right) \cdot h}{\ell}}\right)\right) \]
          6. associate-/r*N/A

            \[\leadsto \mathsf{*.f64}\left(w0, \left(\frac{\frac{\frac{-1}{8}}{d}}{d} \cdot \frac{\color{blue}{\left(\left(D \cdot D\right) \cdot \left(M \cdot M\right)\right) \cdot h}}{\ell}\right)\right) \]
          7. frac-timesN/A

            \[\leadsto \mathsf{*.f64}\left(w0, \left(\frac{\frac{\frac{-1}{8}}{d} \cdot \left(\left(\left(D \cdot D\right) \cdot \left(M \cdot M\right)\right) \cdot h\right)}{\color{blue}{d \cdot \ell}}\right)\right) \]
          8. /-lowering-/.f64N/A

            \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{/.f64}\left(\left(\frac{\frac{-1}{8}}{d} \cdot \left(\left(\left(D \cdot D\right) \cdot \left(M \cdot M\right)\right) \cdot h\right)\right), \color{blue}{\left(d \cdot \ell\right)}\right)\right) \]
        11. Applied egg-rr27.2%

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

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

      Alternative 5: 70.8% accurate, 9.0× speedup?

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

        1. Initial program 82.8%

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

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

          \[\leadsto \color{blue}{w0} \]
        5. Step-by-step derivation
          1. Simplified78.1%

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

          if 3.8000000000000002e-5 < M

          1. Initial program 78.6%

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

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

            \[\leadsto \mathsf{*.f64}\left(w0, \color{blue}{\left(1 + \frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)}\right) \]
          5. Step-by-step derivation
            1. +-lowering-+.f64N/A

              \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)}\right)\right) \]
            2. associate-*r/N/A

              \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \left(\frac{\frac{-1}{8} \cdot \left({D}^{2} \cdot \left({M}^{2} \cdot h\right)\right)}{\color{blue}{{d}^{2} \cdot \ell}}\right)\right)\right) \]
            3. times-fracN/A

              \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \left(\frac{\frac{-1}{8}}{{d}^{2}} \cdot \color{blue}{\frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{\ell}}\right)\right)\right) \]
            4. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left(\frac{\frac{-1}{8}}{{d}^{2}}\right), \color{blue}{\left(\frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{\ell}\right)}\right)\right)\right) \]
            5. /-lowering-/.f64N/A

              \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \left({d}^{2}\right)\right), \left(\frac{\color{blue}{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}}{\ell}\right)\right)\right)\right) \]
            6. unpow2N/A

              \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \left(d \cdot d\right)\right), \left(\frac{{D}^{2} \cdot \color{blue}{\left({M}^{2} \cdot h\right)}}{\ell}\right)\right)\right)\right) \]
            7. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \left(\frac{{D}^{2} \cdot \color{blue}{\left({M}^{2} \cdot h\right)}}{\ell}\right)\right)\right)\right) \]
            8. /-lowering-/.f64N/A

              \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \mathsf{/.f64}\left(\left({D}^{2} \cdot \left({M}^{2} \cdot h\right)\right), \color{blue}{\ell}\right)\right)\right)\right) \]
            9. unpow2N/A

              \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \mathsf{/.f64}\left(\left(\left(D \cdot D\right) \cdot \left({M}^{2} \cdot h\right)\right), \ell\right)\right)\right)\right) \]
            10. associate-*l*N/A

              \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \mathsf{/.f64}\left(\left(D \cdot \left(D \cdot \left({M}^{2} \cdot h\right)\right)\right), \ell\right)\right)\right)\right) \]
            11. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(D, \left(D \cdot \left({M}^{2} \cdot h\right)\right)\right), \ell\right)\right)\right)\right) \]
            12. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(D, \mathsf{*.f64}\left(D, \left({M}^{2} \cdot h\right)\right)\right), \ell\right)\right)\right)\right) \]
            13. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(D, \mathsf{*.f64}\left(D, \mathsf{*.f64}\left(\left({M}^{2}\right), h\right)\right)\right), \ell\right)\right)\right)\right) \]
            14. unpow2N/A

              \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(D, \mathsf{*.f64}\left(D, \mathsf{*.f64}\left(\left(M \cdot M\right), h\right)\right)\right), \ell\right)\right)\right)\right) \]
            15. *-lowering-*.f6447.8%

              \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(D, \mathsf{*.f64}\left(D, \mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), h\right)\right)\right), \ell\right)\right)\right)\right) \]
          6. Simplified47.8%

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

            \[\leadsto \mathsf{*.f64}\left(w0, \color{blue}{\left(\frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)}\right) \]
          8. Step-by-step derivation
            1. associate-/r*N/A

              \[\leadsto \mathsf{*.f64}\left(w0, \left(\frac{-1}{8} \cdot \frac{\frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}}{\color{blue}{\ell}}\right)\right) \]
            2. associate-*r/N/A

              \[\leadsto \mathsf{*.f64}\left(w0, \left(\frac{\frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}}{\color{blue}{\ell}}\right)\right) \]
            3. /-lowering-/.f64N/A

              \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{/.f64}\left(\left(\frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}\right), \color{blue}{\ell}\right)\right) \]
            4. associate-/l*N/A

              \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{/.f64}\left(\left(\frac{-1}{8} \cdot \left({D}^{2} \cdot \frac{{M}^{2} \cdot h}{{d}^{2}}\right)\right), \ell\right)\right) \]
            5. associate-*r*N/A

              \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{/.f64}\left(\left(\left(\frac{-1}{8} \cdot {D}^{2}\right) \cdot \frac{{M}^{2} \cdot h}{{d}^{2}}\right), \ell\right)\right) \]
            6. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\left(\frac{-1}{8} \cdot {D}^{2}\right), \left(\frac{{M}^{2} \cdot h}{{d}^{2}}\right)\right), \ell\right)\right) \]
            7. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \left({D}^{2}\right)\right), \left(\frac{{M}^{2} \cdot h}{{d}^{2}}\right)\right), \ell\right)\right) \]
            8. unpow2N/A

              \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \left(D \cdot D\right)\right), \left(\frac{{M}^{2} \cdot h}{{d}^{2}}\right)\right), \ell\right)\right) \]
            9. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(D, D\right)\right), \left(\frac{{M}^{2} \cdot h}{{d}^{2}}\right)\right), \ell\right)\right) \]
            10. /-lowering-/.f64N/A

              \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(D, D\right)\right), \mathsf{/.f64}\left(\left({M}^{2} \cdot h\right), \left({d}^{2}\right)\right)\right), \ell\right)\right) \]
            11. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(D, D\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(\left({M}^{2}\right), h\right), \left({d}^{2}\right)\right)\right), \ell\right)\right) \]
            12. unpow2N/A

              \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(D, D\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(\left(M \cdot M\right), h\right), \left({d}^{2}\right)\right)\right), \ell\right)\right) \]
            13. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(D, D\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), h\right), \left({d}^{2}\right)\right)\right), \ell\right)\right) \]
            14. unpow2N/A

              \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(D, D\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), h\right), \left(d \cdot d\right)\right)\right), \ell\right)\right) \]
            15. *-lowering-*.f6423.8%

              \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(D, D\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), h\right), \mathsf{*.f64}\left(d, d\right)\right)\right), \ell\right)\right) \]
          9. Simplified23.8%

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

              \[\leadsto \mathsf{*.f64}\left(w0, \left(\frac{\frac{\left(\frac{-1}{8} \cdot \left(D \cdot D\right)\right) \cdot \left(\left(M \cdot M\right) \cdot h\right)}{d \cdot d}}{\ell}\right)\right) \]
            2. associate-*r*N/A

              \[\leadsto \mathsf{*.f64}\left(w0, \left(\frac{\frac{\frac{-1}{8} \cdot \left(\left(D \cdot D\right) \cdot \left(\left(M \cdot M\right) \cdot h\right)\right)}{d \cdot d}}{\ell}\right)\right) \]
            3. associate-*l*N/A

              \[\leadsto \mathsf{*.f64}\left(w0, \left(\frac{\frac{\frac{-1}{8} \cdot \left(\left(\left(D \cdot D\right) \cdot \left(M \cdot M\right)\right) \cdot h\right)}{d \cdot d}}{\ell}\right)\right) \]
            4. associate-*l/N/A

              \[\leadsto \mathsf{*.f64}\left(w0, \left(\frac{\frac{\frac{-1}{8}}{d \cdot d} \cdot \left(\left(\left(D \cdot D\right) \cdot \left(M \cdot M\right)\right) \cdot h\right)}{\ell}\right)\right) \]
            5. *-commutativeN/A

              \[\leadsto \mathsf{*.f64}\left(w0, \left(\frac{\left(\left(\left(D \cdot D\right) \cdot \left(M \cdot M\right)\right) \cdot h\right) \cdot \frac{\frac{-1}{8}}{d \cdot d}}{\ell}\right)\right) \]
            6. associate-*l/N/A

              \[\leadsto \mathsf{*.f64}\left(w0, \left(\frac{\left(\left(D \cdot D\right) \cdot \left(M \cdot M\right)\right) \cdot h}{\ell} \cdot \color{blue}{\frac{\frac{-1}{8}}{d \cdot d}}\right)\right) \]
            7. clear-numN/A

              \[\leadsto \mathsf{*.f64}\left(w0, \left(\frac{1}{\frac{\ell}{\left(\left(D \cdot D\right) \cdot \left(M \cdot M\right)\right) \cdot h}} \cdot \frac{\color{blue}{\frac{-1}{8}}}{d \cdot d}\right)\right) \]
            8. frac-timesN/A

              \[\leadsto \mathsf{*.f64}\left(w0, \left(\frac{1 \cdot \frac{-1}{8}}{\color{blue}{\frac{\ell}{\left(\left(D \cdot D\right) \cdot \left(M \cdot M\right)\right) \cdot h} \cdot \left(d \cdot d\right)}}\right)\right) \]
            9. metadata-evalN/A

              \[\leadsto \mathsf{*.f64}\left(w0, \left(\frac{\frac{-1}{8}}{\color{blue}{\frac{\ell}{\left(\left(D \cdot D\right) \cdot \left(M \cdot M\right)\right) \cdot h}} \cdot \left(d \cdot d\right)}\right)\right) \]
            10. /-lowering-/.f64N/A

              \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{/.f64}\left(\frac{-1}{8}, \color{blue}{\left(\frac{\ell}{\left(\left(D \cdot D\right) \cdot \left(M \cdot M\right)\right) \cdot h} \cdot \left(d \cdot d\right)\right)}\right)\right) \]
            11. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(\left(\frac{\ell}{\left(\left(D \cdot D\right) \cdot \left(M \cdot M\right)\right) \cdot h}\right), \color{blue}{\left(d \cdot d\right)}\right)\right)\right) \]
          11. Applied egg-rr24.8%

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

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

        Alternative 6: 70.8% accurate, 9.0× speedup?

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

          1. Initial program 82.8%

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

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

            \[\leadsto \color{blue}{w0} \]
          5. Step-by-step derivation
            1. Simplified78.1%

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

            if 4.00000000000000033e-5 < M

            1. Initial program 78.6%

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

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

              \[\leadsto \mathsf{*.f64}\left(w0, \color{blue}{\left(1 + \frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)}\right) \]
            5. Step-by-step derivation
              1. +-lowering-+.f64N/A

                \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)}\right)\right) \]
              2. associate-*r/N/A

                \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \left(\frac{\frac{-1}{8} \cdot \left({D}^{2} \cdot \left({M}^{2} \cdot h\right)\right)}{\color{blue}{{d}^{2} \cdot \ell}}\right)\right)\right) \]
              3. times-fracN/A

                \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \left(\frac{\frac{-1}{8}}{{d}^{2}} \cdot \color{blue}{\frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{\ell}}\right)\right)\right) \]
              4. *-lowering-*.f64N/A

                \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left(\frac{\frac{-1}{8}}{{d}^{2}}\right), \color{blue}{\left(\frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{\ell}\right)}\right)\right)\right) \]
              5. /-lowering-/.f64N/A

                \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \left({d}^{2}\right)\right), \left(\frac{\color{blue}{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}}{\ell}\right)\right)\right)\right) \]
              6. unpow2N/A

                \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \left(d \cdot d\right)\right), \left(\frac{{D}^{2} \cdot \color{blue}{\left({M}^{2} \cdot h\right)}}{\ell}\right)\right)\right)\right) \]
              7. *-lowering-*.f64N/A

                \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \left(\frac{{D}^{2} \cdot \color{blue}{\left({M}^{2} \cdot h\right)}}{\ell}\right)\right)\right)\right) \]
              8. /-lowering-/.f64N/A

                \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \mathsf{/.f64}\left(\left({D}^{2} \cdot \left({M}^{2} \cdot h\right)\right), \color{blue}{\ell}\right)\right)\right)\right) \]
              9. unpow2N/A

                \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \mathsf{/.f64}\left(\left(\left(D \cdot D\right) \cdot \left({M}^{2} \cdot h\right)\right), \ell\right)\right)\right)\right) \]
              10. associate-*l*N/A

                \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \mathsf{/.f64}\left(\left(D \cdot \left(D \cdot \left({M}^{2} \cdot h\right)\right)\right), \ell\right)\right)\right)\right) \]
              11. *-lowering-*.f64N/A

                \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(D, \left(D \cdot \left({M}^{2} \cdot h\right)\right)\right), \ell\right)\right)\right)\right) \]
              12. *-lowering-*.f64N/A

                \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(D, \mathsf{*.f64}\left(D, \left({M}^{2} \cdot h\right)\right)\right), \ell\right)\right)\right)\right) \]
              13. *-lowering-*.f64N/A

                \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(D, \mathsf{*.f64}\left(D, \mathsf{*.f64}\left(\left({M}^{2}\right), h\right)\right)\right), \ell\right)\right)\right)\right) \]
              14. unpow2N/A

                \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(D, \mathsf{*.f64}\left(D, \mathsf{*.f64}\left(\left(M \cdot M\right), h\right)\right)\right), \ell\right)\right)\right)\right) \]
              15. *-lowering-*.f6447.8%

                \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(d, d\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(D, \mathsf{*.f64}\left(D, \mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), h\right)\right)\right), \ell\right)\right)\right)\right) \]
            6. Simplified47.8%

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

              \[\leadsto \mathsf{*.f64}\left(w0, \color{blue}{\left(\frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)}\right) \]
            8. Step-by-step derivation
              1. associate-/r*N/A

                \[\leadsto \mathsf{*.f64}\left(w0, \left(\frac{-1}{8} \cdot \frac{\frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}}{\color{blue}{\ell}}\right)\right) \]
              2. associate-*r/N/A

                \[\leadsto \mathsf{*.f64}\left(w0, \left(\frac{\frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}}{\color{blue}{\ell}}\right)\right) \]
              3. /-lowering-/.f64N/A

                \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{/.f64}\left(\left(\frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}\right), \color{blue}{\ell}\right)\right) \]
              4. associate-/l*N/A

                \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{/.f64}\left(\left(\frac{-1}{8} \cdot \left({D}^{2} \cdot \frac{{M}^{2} \cdot h}{{d}^{2}}\right)\right), \ell\right)\right) \]
              5. associate-*r*N/A

                \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{/.f64}\left(\left(\left(\frac{-1}{8} \cdot {D}^{2}\right) \cdot \frac{{M}^{2} \cdot h}{{d}^{2}}\right), \ell\right)\right) \]
              6. *-lowering-*.f64N/A

                \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\left(\frac{-1}{8} \cdot {D}^{2}\right), \left(\frac{{M}^{2} \cdot h}{{d}^{2}}\right)\right), \ell\right)\right) \]
              7. *-lowering-*.f64N/A

                \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \left({D}^{2}\right)\right), \left(\frac{{M}^{2} \cdot h}{{d}^{2}}\right)\right), \ell\right)\right) \]
              8. unpow2N/A

                \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \left(D \cdot D\right)\right), \left(\frac{{M}^{2} \cdot h}{{d}^{2}}\right)\right), \ell\right)\right) \]
              9. *-lowering-*.f64N/A

                \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(D, D\right)\right), \left(\frac{{M}^{2} \cdot h}{{d}^{2}}\right)\right), \ell\right)\right) \]
              10. /-lowering-/.f64N/A

                \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(D, D\right)\right), \mathsf{/.f64}\left(\left({M}^{2} \cdot h\right), \left({d}^{2}\right)\right)\right), \ell\right)\right) \]
              11. *-lowering-*.f64N/A

                \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(D, D\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(\left({M}^{2}\right), h\right), \left({d}^{2}\right)\right)\right), \ell\right)\right) \]
              12. unpow2N/A

                \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(D, D\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(\left(M \cdot M\right), h\right), \left({d}^{2}\right)\right)\right), \ell\right)\right) \]
              13. *-lowering-*.f64N/A

                \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(D, D\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), h\right), \left({d}^{2}\right)\right)\right), \ell\right)\right) \]
              14. unpow2N/A

                \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(D, D\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), h\right), \left(d \cdot d\right)\right)\right), \ell\right)\right) \]
              15. *-lowering-*.f6423.8%

                \[\leadsto \mathsf{*.f64}\left(w0, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(D, D\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), h\right), \mathsf{*.f64}\left(d, d\right)\right)\right), \ell\right)\right) \]
            9. Simplified23.8%

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

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

                \[\leadsto \frac{w0 \cdot \frac{\left(\frac{-1}{8} \cdot \left(D \cdot D\right)\right) \cdot \left(\left(M \cdot M\right) \cdot h\right)}{d \cdot d}}{\ell} \]
              3. associate-*r*N/A

                \[\leadsto \frac{w0 \cdot \frac{\frac{-1}{8} \cdot \left(\left(D \cdot D\right) \cdot \left(\left(M \cdot M\right) \cdot h\right)\right)}{d \cdot d}}{\ell} \]
              4. associate-*l*N/A

                \[\leadsto \frac{w0 \cdot \frac{\frac{-1}{8} \cdot \left(\left(\left(D \cdot D\right) \cdot \left(M \cdot M\right)\right) \cdot h\right)}{d \cdot d}}{\ell} \]
              5. associate-*l/N/A

                \[\leadsto \frac{w0 \cdot \left(\frac{\frac{-1}{8}}{d \cdot d} \cdot \left(\left(\left(D \cdot D\right) \cdot \left(M \cdot M\right)\right) \cdot h\right)\right)}{\ell} \]
              6. associate-*r/N/A

                \[\leadsto w0 \cdot \color{blue}{\frac{\frac{\frac{-1}{8}}{d \cdot d} \cdot \left(\left(\left(D \cdot D\right) \cdot \left(M \cdot M\right)\right) \cdot h\right)}{\ell}} \]
              7. associate-*r/N/A

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

                \[\leadsto \left(w0 \cdot \frac{\frac{-1}{8}}{d \cdot d}\right) \cdot \color{blue}{\frac{\left(\left(D \cdot D\right) \cdot \left(M \cdot M\right)\right) \cdot h}{\ell}} \]
              9. *-commutativeN/A

                \[\leadsto \left(\frac{\frac{-1}{8}}{d \cdot d} \cdot w0\right) \cdot \frac{\color{blue}{\left(\left(D \cdot D\right) \cdot \left(M \cdot M\right)\right) \cdot h}}{\ell} \]
              10. *-commutativeN/A

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

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

          Alternative 7: 67.5% accurate, 216.0× speedup?

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

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

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

            \[\leadsto \color{blue}{w0} \]
          5. Step-by-step derivation
            1. Simplified71.0%

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

            Reproduce

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