Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 80.9% → 86.7%
Time: 12.5s
Alternatives: 14
Speedup: 1.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 14 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 80.9% 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.7% accurate, 0.7× speedup?

\[\begin{array}{l} D_m = \left|D\right| \\ [w0, M, D_m, h, l, d] = \mathsf{sort}([w0, M, D_m, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;\frac{h}{\ell} \cdot {\left(\frac{D\_m \cdot M}{2 \cdot d}\right)}^{2} \leq 2 \cdot 10^{-9}:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(\frac{-0.5 \cdot \left(D\_m \cdot M\right)}{d} \cdot \frac{h}{\ell}, D\_m \cdot \left(M \cdot \frac{0.5}{d}\right), 1\right)} \cdot w0\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-0.125 \cdot w0, \frac{D\_m}{\ell \cdot d} \cdot \frac{\left(\left(M \cdot M\right) \cdot h\right) \cdot D\_m}{d}, w0\right)\\ \end{array} \end{array} \]
D_m = (fabs.f64 D)
NOTE: w0, M, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M D_m h l d)
 :precision binary64
 (if (<= (* (/ h l) (pow (/ (* D_m M) (* 2.0 d)) 2.0)) 2e-9)
   (*
    (sqrt
     (fma (* (/ (* -0.5 (* D_m M)) d) (/ h l)) (* D_m (* M (/ 0.5 d))) 1.0))
    w0)
   (fma (* -0.125 w0) (* (/ D_m (* l d)) (/ (* (* (* M M) h) D_m) d)) w0)))
D_m = fabs(D);
assert(w0 < M && M < D_m && D_m < h && h < l && l < d);
double code(double w0, double M, double D_m, double h, double l, double d) {
	double tmp;
	if (((h / l) * pow(((D_m * M) / (2.0 * d)), 2.0)) <= 2e-9) {
		tmp = sqrt(fma((((-0.5 * (D_m * M)) / d) * (h / l)), (D_m * (M * (0.5 / d))), 1.0)) * w0;
	} else {
		tmp = fma((-0.125 * w0), ((D_m / (l * d)) * ((((M * M) * h) * D_m) / d)), w0);
	}
	return tmp;
}
D_m = abs(D)
w0, M, D_m, h, l, d = sort([w0, M, D_m, h, l, d])
function code(w0, M, D_m, h, l, d)
	tmp = 0.0
	if (Float64(Float64(h / l) * (Float64(Float64(D_m * M) / Float64(2.0 * d)) ^ 2.0)) <= 2e-9)
		tmp = Float64(sqrt(fma(Float64(Float64(Float64(-0.5 * Float64(D_m * M)) / d) * Float64(h / l)), Float64(D_m * Float64(M * Float64(0.5 / d))), 1.0)) * w0);
	else
		tmp = fma(Float64(-0.125 * w0), Float64(Float64(D_m / Float64(l * d)) * Float64(Float64(Float64(Float64(M * M) * h) * D_m) / d)), w0);
	end
	return tmp
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: w0, M, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M_, D$95$m_, h_, l_, d_] := If[LessEqual[N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D$95$m * M), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], 2e-9], N[(N[Sqrt[N[(N[(N[(N[(-0.5 * N[(D$95$m * M), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision] * N[(D$95$m * N[(M * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision] * w0), $MachinePrecision], N[(N[(-0.125 * w0), $MachinePrecision] * N[(N[(D$95$m / N[(l * d), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(M * M), $MachinePrecision] * h), $MachinePrecision] * D$95$m), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] + w0), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
[w0, M, D_m, h, l, d] = \mathsf{sort}([w0, M, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;\frac{h}{\ell} \cdot {\left(\frac{D\_m \cdot M}{2 \cdot d}\right)}^{2} \leq 2 \cdot 10^{-9}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(\frac{-0.5 \cdot \left(D\_m \cdot M\right)}{d} \cdot \frac{h}{\ell}, D\_m \cdot \left(M \cdot \frac{0.5}{d}\right), 1\right)} \cdot w0\\

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


\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)) < 2.00000000000000012e-9

    1. Initial program 89.8%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift--.f64N/A

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

        \[\leadsto w0 \cdot \sqrt{\color{blue}{1 + \left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}} \]
      3. +-commutativeN/A

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

        \[\leadsto w0 \cdot \sqrt{\left(\mathsf{neg}\left(\color{blue}{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}\right)\right) + 1} \]
      5. *-commutativeN/A

        \[\leadsto w0 \cdot \sqrt{\left(\mathsf{neg}\left(\color{blue}{\frac{h}{\ell} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}}\right)\right) + 1} \]
      6. distribute-rgt-neg-inN/A

        \[\leadsto w0 \cdot \sqrt{\color{blue}{\frac{h}{\ell} \cdot \left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right)\right)} + 1} \]
      7. lift-pow.f64N/A

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

        \[\leadsto w0 \cdot \sqrt{\frac{h}{\ell} \cdot \left(\mathsf{neg}\left(\color{blue}{\frac{M \cdot D}{2 \cdot d} \cdot \frac{M \cdot D}{2 \cdot d}}\right)\right) + 1} \]
      9. distribute-lft-neg-inN/A

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

        \[\leadsto w0 \cdot \sqrt{\color{blue}{\left(\frac{h}{\ell} \cdot \left(\mathsf{neg}\left(\frac{M \cdot D}{2 \cdot d}\right)\right)\right) \cdot \frac{M \cdot D}{2 \cdot d}} + 1} \]
      11. lower-fma.f64N/A

        \[\leadsto w0 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\frac{h}{\ell} \cdot \left(\mathsf{neg}\left(\frac{M \cdot D}{2 \cdot d}\right)\right), \frac{M \cdot D}{2 \cdot d}, 1\right)}} \]
    4. Applied rewrites90.6%

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

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

    1. Initial program 0.0%

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

      \[\leadsto w0 \cdot \color{blue}{1} \]
    4. Step-by-step derivation
      1. Applied rewrites81.8%

        \[\leadsto w0 \cdot \color{blue}{1} \]
      2. Taylor expanded in h around 0

        \[\leadsto \color{blue}{w0 + \frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(h \cdot w0\right)\right)}{{d}^{2} \cdot \ell}} \]
      3. Step-by-step derivation
        1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

        Alternative 2: 85.5% accurate, 0.7× speedup?

        \[\begin{array}{l} D_m = \left|D\right| \\ [w0, M, D_m, h, l, d] = \mathsf{sort}([w0, M, D_m, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;\frac{h}{\ell} \cdot {\left(\frac{D\_m \cdot M}{2 \cdot d}\right)}^{2} \leq -200000000:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(\left(0.25 \cdot M\right) \cdot \left(\frac{D\_m}{d} \cdot M\right), \frac{D\_m}{-d} \cdot \frac{h}{\ell}, 1\right)} \cdot w0\\ \mathbf{else}:\\ \;\;\;\;1 \cdot w0\\ \end{array} \end{array} \]
        D_m = (fabs.f64 D)
        NOTE: w0, M, D_m, h, l, and d should be sorted in increasing order before calling this function.
        (FPCore (w0 M D_m h l d)
         :precision binary64
         (if (<= (* (/ h l) (pow (/ (* D_m M) (* 2.0 d)) 2.0)) -200000000.0)
           (*
            (sqrt (fma (* (* 0.25 M) (* (/ D_m d) M)) (* (/ D_m (- d)) (/ h l)) 1.0))
            w0)
           (* 1.0 w0)))
        D_m = fabs(D);
        assert(w0 < M && M < D_m && D_m < h && h < l && l < d);
        double code(double w0, double M, double D_m, double h, double l, double d) {
        	double tmp;
        	if (((h / l) * pow(((D_m * M) / (2.0 * d)), 2.0)) <= -200000000.0) {
        		tmp = sqrt(fma(((0.25 * M) * ((D_m / d) * M)), ((D_m / -d) * (h / l)), 1.0)) * w0;
        	} else {
        		tmp = 1.0 * w0;
        	}
        	return tmp;
        }
        
        D_m = abs(D)
        w0, M, D_m, h, l, d = sort([w0, M, D_m, h, l, d])
        function code(w0, M, D_m, h, l, d)
        	tmp = 0.0
        	if (Float64(Float64(h / l) * (Float64(Float64(D_m * M) / Float64(2.0 * d)) ^ 2.0)) <= -200000000.0)
        		tmp = Float64(sqrt(fma(Float64(Float64(0.25 * M) * Float64(Float64(D_m / d) * M)), Float64(Float64(D_m / Float64(-d)) * Float64(h / l)), 1.0)) * w0);
        	else
        		tmp = Float64(1.0 * w0);
        	end
        	return tmp
        end
        
        D_m = N[Abs[D], $MachinePrecision]
        NOTE: w0, M, D_m, h, l, and d should be sorted in increasing order before calling this function.
        code[w0_, M_, D$95$m_, h_, l_, d_] := If[LessEqual[N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D$95$m * M), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], -200000000.0], N[(N[Sqrt[N[(N[(N[(0.25 * M), $MachinePrecision] * N[(N[(D$95$m / d), $MachinePrecision] * M), $MachinePrecision]), $MachinePrecision] * N[(N[(D$95$m / (-d)), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision] * w0), $MachinePrecision], N[(1.0 * w0), $MachinePrecision]]
        
        \begin{array}{l}
        D_m = \left|D\right|
        \\
        [w0, M, D_m, h, l, d] = \mathsf{sort}([w0, M, D_m, h, l, d])\\
        \\
        \begin{array}{l}
        \mathbf{if}\;\frac{h}{\ell} \cdot {\left(\frac{D\_m \cdot M}{2 \cdot d}\right)}^{2} \leq -200000000:\\
        \;\;\;\;\sqrt{\mathsf{fma}\left(\left(0.25 \cdot M\right) \cdot \left(\frac{D\_m}{d} \cdot M\right), \frac{D\_m}{-d} \cdot \frac{h}{\ell}, 1\right)} \cdot w0\\
        
        \mathbf{else}:\\
        \;\;\;\;1 \cdot w0\\
        
        
        \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)) < -2e8

          1. Initial program 69.8%

            \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
          2. Add Preprocessing
          3. Step-by-step derivation
            1. lift--.f64N/A

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

              \[\leadsto w0 \cdot \sqrt{\color{blue}{1 + \left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}} \]
            3. +-commutativeN/A

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

              \[\leadsto w0 \cdot \sqrt{\left(\mathsf{neg}\left(\color{blue}{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}\right)\right) + 1} \]
            5. lift-/.f64N/A

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

              \[\leadsto w0 \cdot \sqrt{\left(\mathsf{neg}\left(\color{blue}{\frac{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot h}{\ell}}\right)\right) + 1} \]
            7. distribute-neg-frac2N/A

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

              \[\leadsto w0 \cdot \sqrt{\color{blue}{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\mathsf{neg}\left(\ell\right)}} + 1} \]
            9. lift-pow.f64N/A

              \[\leadsto w0 \cdot \sqrt{\color{blue}{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}} \cdot \frac{h}{\mathsf{neg}\left(\ell\right)} + 1} \]
            10. unpow2N/A

              \[\leadsto w0 \cdot \sqrt{\color{blue}{\left(\frac{M \cdot D}{2 \cdot d} \cdot \frac{M \cdot D}{2 \cdot d}\right)} \cdot \frac{h}{\mathsf{neg}\left(\ell\right)} + 1} \]
            11. lift-/.f64N/A

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

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

              \[\leadsto w0 \cdot \sqrt{\left(\frac{M \cdot D}{2 \cdot d} \cdot \frac{M \cdot D}{\color{blue}{2 \cdot d}}\right) \cdot \frac{h}{\mathsf{neg}\left(\ell\right)} + 1} \]
            14. times-fracN/A

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

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

              \[\leadsto w0 \cdot \sqrt{\color{blue}{\left(\frac{M \cdot D}{2 \cdot d} \cdot \frac{M}{2}\right) \cdot \left(\frac{D}{d} \cdot \frac{h}{\mathsf{neg}\left(\ell\right)}\right)} + 1} \]
          4. Applied rewrites67.0%

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

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

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

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

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

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

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

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

              \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\left(\frac{D}{d} \cdot M\right) \cdot \color{blue}{\left(\frac{1}{4} \cdot M\right)}, \frac{D}{d} \cdot \frac{-h}{\ell}, 1\right)} \]
            9. lower-*.f6473.4

              \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\left(\frac{D}{d} \cdot M\right) \cdot \color{blue}{\left(0.25 \cdot M\right)}, \frac{D}{d} \cdot \frac{-h}{\ell}, 1\right)} \]
          6. Applied rewrites73.4%

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

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

          1. Initial program 87.6%

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

            \[\leadsto w0 \cdot \color{blue}{1} \]
          4. Step-by-step derivation
            1. Applied rewrites97.4%

              \[\leadsto w0 \cdot \color{blue}{1} \]
          5. Recombined 2 regimes into one program.
          6. Final simplification90.0%

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

          Alternative 3: 85.9% accurate, 0.7× speedup?

          \[\begin{array}{l} D_m = \left|D\right| \\ [w0, M, D_m, h, l, d] = \mathsf{sort}([w0, M, D_m, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;1 - \frac{h}{\ell} \cdot {\left(\frac{D\_m \cdot M}{2 \cdot d}\right)}^{2} \leq 2:\\ \;\;\;\;1 \cdot w0\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(\frac{\left(\left(D\_m \cdot M\right) \cdot h\right) \cdot -0.5}{\ell \cdot d}, D\_m \cdot \left(M \cdot \frac{0.5}{d}\right), 1\right)} \cdot w0\\ \end{array} \end{array} \]
          D_m = (fabs.f64 D)
          NOTE: w0, M, D_m, h, l, and d should be sorted in increasing order before calling this function.
          (FPCore (w0 M D_m h l d)
           :precision binary64
           (if (<= (- 1.0 (* (/ h l) (pow (/ (* D_m M) (* 2.0 d)) 2.0))) 2.0)
             (* 1.0 w0)
             (*
              (sqrt
               (fma (/ (* (* (* D_m M) h) -0.5) (* l d)) (* D_m (* M (/ 0.5 d))) 1.0))
              w0)))
          D_m = fabs(D);
          assert(w0 < M && M < D_m && D_m < h && h < l && l < d);
          double code(double w0, double M, double D_m, double h, double l, double d) {
          	double tmp;
          	if ((1.0 - ((h / l) * pow(((D_m * M) / (2.0 * d)), 2.0))) <= 2.0) {
          		tmp = 1.0 * w0;
          	} else {
          		tmp = sqrt(fma(((((D_m * M) * h) * -0.5) / (l * d)), (D_m * (M * (0.5 / d))), 1.0)) * w0;
          	}
          	return tmp;
          }
          
          D_m = abs(D)
          w0, M, D_m, h, l, d = sort([w0, M, D_m, h, l, d])
          function code(w0, M, D_m, h, l, d)
          	tmp = 0.0
          	if (Float64(1.0 - Float64(Float64(h / l) * (Float64(Float64(D_m * M) / Float64(2.0 * d)) ^ 2.0))) <= 2.0)
          		tmp = Float64(1.0 * w0);
          	else
          		tmp = Float64(sqrt(fma(Float64(Float64(Float64(Float64(D_m * M) * h) * -0.5) / Float64(l * d)), Float64(D_m * Float64(M * Float64(0.5 / d))), 1.0)) * w0);
          	end
          	return tmp
          end
          
          D_m = N[Abs[D], $MachinePrecision]
          NOTE: w0, M, D_m, h, l, and d should be sorted in increasing order before calling this function.
          code[w0_, M_, D$95$m_, h_, l_, d_] := If[LessEqual[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D$95$m * M), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], N[(1.0 * w0), $MachinePrecision], N[(N[Sqrt[N[(N[(N[(N[(N[(D$95$m * M), $MachinePrecision] * h), $MachinePrecision] * -0.5), $MachinePrecision] / N[(l * d), $MachinePrecision]), $MachinePrecision] * N[(D$95$m * N[(M * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision] * w0), $MachinePrecision]]
          
          \begin{array}{l}
          D_m = \left|D\right|
          \\
          [w0, M, D_m, h, l, d] = \mathsf{sort}([w0, M, D_m, h, l, d])\\
          \\
          \begin{array}{l}
          \mathbf{if}\;1 - \frac{h}{\ell} \cdot {\left(\frac{D\_m \cdot M}{2 \cdot d}\right)}^{2} \leq 2:\\
          \;\;\;\;1 \cdot w0\\
          
          \mathbf{else}:\\
          \;\;\;\;\sqrt{\mathsf{fma}\left(\frac{\left(\left(D\_m \cdot M\right) \cdot h\right) \cdot -0.5}{\ell \cdot d}, D\_m \cdot \left(M \cdot \frac{0.5}{d}\right), 1\right)} \cdot w0\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if (-.f64 #s(literal 1 binary64) (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l))) < 2

            1. Initial program 99.4%

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

              \[\leadsto w0 \cdot \color{blue}{1} \]
            4. Step-by-step derivation
              1. Applied rewrites99.6%

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

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

              1. Initial program 55.1%

                \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
              2. Add Preprocessing
              3. Step-by-step derivation
                1. lift--.f64N/A

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

                  \[\leadsto w0 \cdot \sqrt{\color{blue}{1 + \left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}} \]
                3. +-commutativeN/A

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

                  \[\leadsto w0 \cdot \sqrt{\left(\mathsf{neg}\left(\color{blue}{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}\right)\right) + 1} \]
                5. *-commutativeN/A

                  \[\leadsto w0 \cdot \sqrt{\left(\mathsf{neg}\left(\color{blue}{\frac{h}{\ell} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}}\right)\right) + 1} \]
                6. distribute-rgt-neg-inN/A

                  \[\leadsto w0 \cdot \sqrt{\color{blue}{\frac{h}{\ell} \cdot \left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right)\right)} + 1} \]
                7. lift-pow.f64N/A

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

                  \[\leadsto w0 \cdot \sqrt{\frac{h}{\ell} \cdot \left(\mathsf{neg}\left(\color{blue}{\frac{M \cdot D}{2 \cdot d} \cdot \frac{M \cdot D}{2 \cdot d}}\right)\right) + 1} \]
                9. distribute-lft-neg-inN/A

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

                  \[\leadsto w0 \cdot \sqrt{\color{blue}{\left(\frac{h}{\ell} \cdot \left(\mathsf{neg}\left(\frac{M \cdot D}{2 \cdot d}\right)\right)\right) \cdot \frac{M \cdot D}{2 \cdot d}} + 1} \]
                11. lower-fma.f64N/A

                  \[\leadsto w0 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\frac{h}{\ell} \cdot \left(\mathsf{neg}\left(\frac{M \cdot D}{2 \cdot d}\right)\right), \frac{M \cdot D}{2 \cdot d}, 1\right)}} \]
              4. Applied rewrites64.0%

                \[\leadsto w0 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\frac{h}{\ell} \cdot \frac{\left(D \cdot M\right) \cdot -0.5}{d}, \left(\frac{0.5}{d} \cdot M\right) \cdot D, 1\right)}} \]
              5. Step-by-step derivation
                1. lift-*.f64N/A

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

                  \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\frac{h}{\ell}} \cdot \frac{\left(D \cdot M\right) \cdot \frac{-1}{2}}{d}, \left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D, 1\right)} \]
                3. lift-/.f64N/A

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

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

                  \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{h \cdot \left(\left(D \cdot M\right) \cdot \frac{-1}{2}\right)}{\color{blue}{\ell \cdot d}}, \left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D, 1\right)} \]
                6. lower-/.f64N/A

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

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

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

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

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

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

                  \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\color{blue}{\left(h \cdot \left(M \cdot D\right)\right) \cdot \frac{-1}{2}}}{\ell \cdot d}, \left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D, 1\right)} \]
                13. lower-*.f6474.3

                  \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\color{blue}{\left(h \cdot \left(M \cdot D\right)\right)} \cdot -0.5}{\ell \cdot d}, \left(\frac{0.5}{d} \cdot M\right) \cdot D, 1\right)} \]
                14. lift-*.f64N/A

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

                  \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\left(h \cdot \left(M \cdot D\right)\right) \cdot \frac{-1}{2}}{\color{blue}{d \cdot \ell}}, \left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D, 1\right)} \]
                16. lower-*.f6474.3

                  \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\left(h \cdot \left(M \cdot D\right)\right) \cdot -0.5}{\color{blue}{d \cdot \ell}}, \left(\frac{0.5}{d} \cdot M\right) \cdot D, 1\right)} \]
              6. Applied rewrites74.3%

                \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\frac{\left(h \cdot \left(M \cdot D\right)\right) \cdot -0.5}{d \cdot \ell}}, \left(\frac{0.5}{d} \cdot M\right) \cdot D, 1\right)} \]
            5. Recombined 2 regimes into one program.
            6. Final simplification89.7%

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

            Alternative 4: 85.8% accurate, 0.7× speedup?

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

              1. Initial program 69.8%

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto w0 \cdot \sqrt{\frac{\left(M \cdot D\right) \cdot \left(M \cdot D\right)}{\ell \cdot \left(d \cdot d\right)} \cdot \left(-0.25 \cdot h\right)} \]
                2. Step-by-step derivation
                  1. Applied rewrites70.5%

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

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

                  1. Initial program 87.6%

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

                    \[\leadsto w0 \cdot \color{blue}{1} \]
                  4. Step-by-step derivation
                    1. Applied rewrites97.4%

                      \[\leadsto w0 \cdot \color{blue}{1} \]
                  5. Recombined 2 regimes into one program.
                  6. Final simplification89.1%

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

                  Alternative 5: 84.1% accurate, 0.7× speedup?

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

                    1. Initial program 69.8%

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

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

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

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

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

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

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

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

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

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

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

                        \[\leadsto w0 \cdot \sqrt{\frac{\left(M \cdot D\right) \cdot \left(M \cdot D\right)}{\ell \cdot \left(d \cdot d\right)} \cdot \left(-0.25 \cdot h\right)} \]
                      2. Step-by-step derivation
                        1. Applied rewrites64.4%

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

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

                        1. Initial program 87.6%

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

                          \[\leadsto w0 \cdot \color{blue}{1} \]
                        4. Step-by-step derivation
                          1. Applied rewrites97.4%

                            \[\leadsto w0 \cdot \color{blue}{1} \]
                        5. Recombined 2 regimes into one program.
                        6. Final simplification87.2%

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

                        Alternative 6: 82.1% accurate, 0.8× speedup?

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

                          1. Initial program 69.4%

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

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

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

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

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

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

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

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

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

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

                            \[\leadsto w0 \cdot \sqrt{\color{blue}{\frac{\left(\left(M \cdot M\right) \cdot D\right) \cdot D}{\ell \cdot \left(d \cdot d\right)} \cdot \left(-0.25 \cdot h\right)}} \]
                          6. Step-by-step derivation
                            1. Applied rewrites54.1%

                              \[\leadsto w0 \cdot \sqrt{\frac{\left(M \cdot D\right) \cdot \left(M \cdot D\right)}{\ell \cdot \left(d \cdot d\right)} \cdot \left(-0.25 \cdot h\right)} \]
                            2. Step-by-step derivation
                              1. Applied rewrites54.1%

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

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

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

                                1. Initial program 87.6%

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

                                  \[\leadsto w0 \cdot \color{blue}{1} \]
                                4. Step-by-step derivation
                                  1. Applied rewrites96.9%

                                    \[\leadsto w0 \cdot \color{blue}{1} \]
                                5. Recombined 2 regimes into one program.
                                6. Final simplification83.9%

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

                                Alternative 7: 81.1% accurate, 0.8× speedup?

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

                                  1. Initial program 69.4%

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

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

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

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

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

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

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

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

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

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

                                    \[\leadsto w0 \cdot \sqrt{\color{blue}{\frac{\left(\left(M \cdot M\right) \cdot D\right) \cdot D}{\ell \cdot \left(d \cdot d\right)} \cdot \left(-0.25 \cdot h\right)}} \]
                                  6. Step-by-step derivation
                                    1. Applied rewrites54.1%

                                      \[\leadsto w0 \cdot \sqrt{\frac{\left(M \cdot D\right) \cdot \left(M \cdot D\right)}{\ell \cdot \left(d \cdot d\right)} \cdot \left(-0.25 \cdot h\right)} \]
                                    2. Step-by-step derivation
                                      1. Applied rewrites54.1%

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

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

                                      1. Initial program 87.6%

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

                                        \[\leadsto w0 \cdot \color{blue}{1} \]
                                      4. Step-by-step derivation
                                        1. Applied rewrites96.9%

                                          \[\leadsto w0 \cdot \color{blue}{1} \]
                                      5. Recombined 2 regimes into one program.
                                      6. Final simplification83.9%

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

                                      Alternative 8: 79.6% accurate, 0.8× speedup?

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

                                        1. Initial program 69.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

                                          1. Initial program 87.6%

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

                                            \[\leadsto w0 \cdot \color{blue}{1} \]
                                          4. Step-by-step derivation
                                            1. Applied rewrites96.9%

                                              \[\leadsto w0 \cdot \color{blue}{1} \]
                                          5. Recombined 2 regimes into one program.
                                          6. Final simplification83.1%

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

                                          Alternative 9: 78.7% accurate, 0.8× speedup?

                                          \[\begin{array}{l} D_m = \left|D\right| \\ [w0, M, D_m, h, l, d] = \mathsf{sort}([w0, M, D_m, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;\frac{h}{\ell} \cdot {\left(\frac{D\_m \cdot M}{2 \cdot d}\right)}^{2} \leq -1 \cdot 10^{+100}:\\ \;\;\;\;\mathsf{fma}\left(\left(D\_m \cdot D\_m\right) \cdot -0.125, \left(\frac{\frac{w0}{d \cdot d} \cdot M}{\ell} \cdot M\right) \cdot h, w0\right)\\ \mathbf{else}:\\ \;\;\;\;1 \cdot w0\\ \end{array} \end{array} \]
                                          D_m = (fabs.f64 D)
                                          NOTE: w0, M, D_m, h, l, and d should be sorted in increasing order before calling this function.
                                          (FPCore (w0 M D_m h l d)
                                           :precision binary64
                                           (if (<= (* (/ h l) (pow (/ (* D_m M) (* 2.0 d)) 2.0)) -1e+100)
                                             (fma (* (* D_m D_m) -0.125) (* (* (/ (* (/ w0 (* d d)) M) l) M) h) w0)
                                             (* 1.0 w0)))
                                          D_m = fabs(D);
                                          assert(w0 < M && M < D_m && D_m < h && h < l && l < d);
                                          double code(double w0, double M, double D_m, double h, double l, double d) {
                                          	double tmp;
                                          	if (((h / l) * pow(((D_m * M) / (2.0 * d)), 2.0)) <= -1e+100) {
                                          		tmp = fma(((D_m * D_m) * -0.125), (((((w0 / (d * d)) * M) / l) * M) * h), w0);
                                          	} else {
                                          		tmp = 1.0 * w0;
                                          	}
                                          	return tmp;
                                          }
                                          
                                          D_m = abs(D)
                                          w0, M, D_m, h, l, d = sort([w0, M, D_m, h, l, d])
                                          function code(w0, M, D_m, h, l, d)
                                          	tmp = 0.0
                                          	if (Float64(Float64(h / l) * (Float64(Float64(D_m * M) / Float64(2.0 * d)) ^ 2.0)) <= -1e+100)
                                          		tmp = fma(Float64(Float64(D_m * D_m) * -0.125), Float64(Float64(Float64(Float64(Float64(w0 / Float64(d * d)) * M) / l) * M) * h), w0);
                                          	else
                                          		tmp = Float64(1.0 * w0);
                                          	end
                                          	return tmp
                                          end
                                          
                                          D_m = N[Abs[D], $MachinePrecision]
                                          NOTE: w0, M, D_m, h, l, and d should be sorted in increasing order before calling this function.
                                          code[w0_, M_, D$95$m_, h_, l_, d_] := If[LessEqual[N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D$95$m * M), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], -1e+100], N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] * -0.125), $MachinePrecision] * N[(N[(N[(N[(N[(w0 / N[(d * d), $MachinePrecision]), $MachinePrecision] * M), $MachinePrecision] / l), $MachinePrecision] * M), $MachinePrecision] * h), $MachinePrecision] + w0), $MachinePrecision], N[(1.0 * w0), $MachinePrecision]]
                                          
                                          \begin{array}{l}
                                          D_m = \left|D\right|
                                          \\
                                          [w0, M, D_m, h, l, d] = \mathsf{sort}([w0, M, D_m, h, l, d])\\
                                          \\
                                          \begin{array}{l}
                                          \mathbf{if}\;\frac{h}{\ell} \cdot {\left(\frac{D\_m \cdot M}{2 \cdot d}\right)}^{2} \leq -1 \cdot 10^{+100}:\\
                                          \;\;\;\;\mathsf{fma}\left(\left(D\_m \cdot D\_m\right) \cdot -0.125, \left(\frac{\frac{w0}{d \cdot d} \cdot M}{\ell} \cdot M\right) \cdot h, w0\right)\\
                                          
                                          \mathbf{else}:\\
                                          \;\;\;\;1 \cdot w0\\
                                          
                                          
                                          \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)) < -1.00000000000000002e100

                                            1. Initial program 66.0%

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

                                              \[\leadsto w0 \cdot \color{blue}{1} \]
                                            4. Step-by-step derivation
                                              1. Applied rewrites5.0%

                                                \[\leadsto w0 \cdot \color{blue}{1} \]
                                              2. Taylor expanded in h around 0

                                                \[\leadsto \color{blue}{w0 + \frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(h \cdot w0\right)\right)}{{d}^{2} \cdot \ell}} \]
                                              3. Step-by-step derivation
                                                1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

                                                  1. Initial program 88.1%

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

                                                    \[\leadsto w0 \cdot \color{blue}{1} \]
                                                  4. Step-by-step derivation
                                                    1. Applied rewrites93.2%

                                                      \[\leadsto w0 \cdot \color{blue}{1} \]
                                                  5. Recombined 2 regimes into one program.
                                                  6. Final simplification80.8%

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

                                                  Alternative 10: 78.0% accurate, 0.8× speedup?

                                                  \[\begin{array}{l} D_m = \left|D\right| \\ [w0, M, D_m, h, l, d] = \mathsf{sort}([w0, M, D_m, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;\frac{h}{\ell} \cdot {\left(\frac{D\_m \cdot M}{2 \cdot d}\right)}^{2} \leq -1 \cdot 10^{+100}:\\ \;\;\;\;\mathsf{fma}\left(\left(D\_m \cdot D\_m\right) \cdot -0.125, \frac{\left(\left(h \cdot M\right) \cdot M\right) \cdot w0}{\left(\ell \cdot d\right) \cdot d}, w0\right)\\ \mathbf{else}:\\ \;\;\;\;1 \cdot w0\\ \end{array} \end{array} \]
                                                  D_m = (fabs.f64 D)
                                                  NOTE: w0, M, D_m, h, l, and d should be sorted in increasing order before calling this function.
                                                  (FPCore (w0 M D_m h l d)
                                                   :precision binary64
                                                   (if (<= (* (/ h l) (pow (/ (* D_m M) (* 2.0 d)) 2.0)) -1e+100)
                                                     (fma (* (* D_m D_m) -0.125) (/ (* (* (* h M) M) w0) (* (* l d) d)) w0)
                                                     (* 1.0 w0)))
                                                  D_m = fabs(D);
                                                  assert(w0 < M && M < D_m && D_m < h && h < l && l < d);
                                                  double code(double w0, double M, double D_m, double h, double l, double d) {
                                                  	double tmp;
                                                  	if (((h / l) * pow(((D_m * M) / (2.0 * d)), 2.0)) <= -1e+100) {
                                                  		tmp = fma(((D_m * D_m) * -0.125), ((((h * M) * M) * w0) / ((l * d) * d)), w0);
                                                  	} else {
                                                  		tmp = 1.0 * w0;
                                                  	}
                                                  	return tmp;
                                                  }
                                                  
                                                  D_m = abs(D)
                                                  w0, M, D_m, h, l, d = sort([w0, M, D_m, h, l, d])
                                                  function code(w0, M, D_m, h, l, d)
                                                  	tmp = 0.0
                                                  	if (Float64(Float64(h / l) * (Float64(Float64(D_m * M) / Float64(2.0 * d)) ^ 2.0)) <= -1e+100)
                                                  		tmp = fma(Float64(Float64(D_m * D_m) * -0.125), Float64(Float64(Float64(Float64(h * M) * M) * w0) / Float64(Float64(l * d) * d)), w0);
                                                  	else
                                                  		tmp = Float64(1.0 * w0);
                                                  	end
                                                  	return tmp
                                                  end
                                                  
                                                  D_m = N[Abs[D], $MachinePrecision]
                                                  NOTE: w0, M, D_m, h, l, and d should be sorted in increasing order before calling this function.
                                                  code[w0_, M_, D$95$m_, h_, l_, d_] := If[LessEqual[N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D$95$m * M), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], -1e+100], N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] * -0.125), $MachinePrecision] * N[(N[(N[(N[(h * M), $MachinePrecision] * M), $MachinePrecision] * w0), $MachinePrecision] / N[(N[(l * d), $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] + w0), $MachinePrecision], N[(1.0 * w0), $MachinePrecision]]
                                                  
                                                  \begin{array}{l}
                                                  D_m = \left|D\right|
                                                  \\
                                                  [w0, M, D_m, h, l, d] = \mathsf{sort}([w0, M, D_m, h, l, d])\\
                                                  \\
                                                  \begin{array}{l}
                                                  \mathbf{if}\;\frac{h}{\ell} \cdot {\left(\frac{D\_m \cdot M}{2 \cdot d}\right)}^{2} \leq -1 \cdot 10^{+100}:\\
                                                  \;\;\;\;\mathsf{fma}\left(\left(D\_m \cdot D\_m\right) \cdot -0.125, \frac{\left(\left(h \cdot M\right) \cdot M\right) \cdot w0}{\left(\ell \cdot d\right) \cdot d}, w0\right)\\
                                                  
                                                  \mathbf{else}:\\
                                                  \;\;\;\;1 \cdot w0\\
                                                  
                                                  
                                                  \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)) < -1.00000000000000002e100

                                                    1. Initial program 66.0%

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

                                                      \[\leadsto w0 \cdot \color{blue}{1} \]
                                                    4. Step-by-step derivation
                                                      1. Applied rewrites5.0%

                                                        \[\leadsto w0 \cdot \color{blue}{1} \]
                                                      2. Taylor expanded in h around 0

                                                        \[\leadsto \color{blue}{w0 + \frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(h \cdot w0\right)\right)}{{d}^{2} \cdot \ell}} \]
                                                      3. Step-by-step derivation
                                                        1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

                                                        1. Initial program 88.1%

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

                                                          \[\leadsto w0 \cdot \color{blue}{1} \]
                                                        4. Step-by-step derivation
                                                          1. Applied rewrites93.2%

                                                            \[\leadsto w0 \cdot \color{blue}{1} \]
                                                        5. Recombined 2 regimes into one program.
                                                        6. Final simplification80.7%

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

                                                        Alternative 11: 77.8% accurate, 0.8× speedup?

                                                        \[\begin{array}{l} D_m = \left|D\right| \\ [w0, M, D_m, h, l, d] = \mathsf{sort}([w0, M, D_m, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;\frac{h}{\ell} \cdot {\left(\frac{D\_m \cdot M}{2 \cdot d}\right)}^{2} \leq -1 \cdot 10^{+100}:\\ \;\;\;\;\mathsf{fma}\left(-0.125 \cdot w0, \frac{\left(\left(\left(h \cdot M\right) \cdot M\right) \cdot D\_m\right) \cdot D\_m}{\left(d \cdot d\right) \cdot \ell}, w0\right)\\ \mathbf{else}:\\ \;\;\;\;1 \cdot w0\\ \end{array} \end{array} \]
                                                        D_m = (fabs.f64 D)
                                                        NOTE: w0, M, D_m, h, l, and d should be sorted in increasing order before calling this function.
                                                        (FPCore (w0 M D_m h l d)
                                                         :precision binary64
                                                         (if (<= (* (/ h l) (pow (/ (* D_m M) (* 2.0 d)) 2.0)) -1e+100)
                                                           (fma (* -0.125 w0) (/ (* (* (* (* h M) M) D_m) D_m) (* (* d d) l)) w0)
                                                           (* 1.0 w0)))
                                                        D_m = fabs(D);
                                                        assert(w0 < M && M < D_m && D_m < h && h < l && l < d);
                                                        double code(double w0, double M, double D_m, double h, double l, double d) {
                                                        	double tmp;
                                                        	if (((h / l) * pow(((D_m * M) / (2.0 * d)), 2.0)) <= -1e+100) {
                                                        		tmp = fma((-0.125 * w0), (((((h * M) * M) * D_m) * D_m) / ((d * d) * l)), w0);
                                                        	} else {
                                                        		tmp = 1.0 * w0;
                                                        	}
                                                        	return tmp;
                                                        }
                                                        
                                                        D_m = abs(D)
                                                        w0, M, D_m, h, l, d = sort([w0, M, D_m, h, l, d])
                                                        function code(w0, M, D_m, h, l, d)
                                                        	tmp = 0.0
                                                        	if (Float64(Float64(h / l) * (Float64(Float64(D_m * M) / Float64(2.0 * d)) ^ 2.0)) <= -1e+100)
                                                        		tmp = fma(Float64(-0.125 * w0), Float64(Float64(Float64(Float64(Float64(h * M) * M) * D_m) * D_m) / Float64(Float64(d * d) * l)), w0);
                                                        	else
                                                        		tmp = Float64(1.0 * w0);
                                                        	end
                                                        	return tmp
                                                        end
                                                        
                                                        D_m = N[Abs[D], $MachinePrecision]
                                                        NOTE: w0, M, D_m, h, l, and d should be sorted in increasing order before calling this function.
                                                        code[w0_, M_, D$95$m_, h_, l_, d_] := If[LessEqual[N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D$95$m * M), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], -1e+100], N[(N[(-0.125 * w0), $MachinePrecision] * N[(N[(N[(N[(N[(h * M), $MachinePrecision] * M), $MachinePrecision] * D$95$m), $MachinePrecision] * D$95$m), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] + w0), $MachinePrecision], N[(1.0 * w0), $MachinePrecision]]
                                                        
                                                        \begin{array}{l}
                                                        D_m = \left|D\right|
                                                        \\
                                                        [w0, M, D_m, h, l, d] = \mathsf{sort}([w0, M, D_m, h, l, d])\\
                                                        \\
                                                        \begin{array}{l}
                                                        \mathbf{if}\;\frac{h}{\ell} \cdot {\left(\frac{D\_m \cdot M}{2 \cdot d}\right)}^{2} \leq -1 \cdot 10^{+100}:\\
                                                        \;\;\;\;\mathsf{fma}\left(-0.125 \cdot w0, \frac{\left(\left(\left(h \cdot M\right) \cdot M\right) \cdot D\_m\right) \cdot D\_m}{\left(d \cdot d\right) \cdot \ell}, w0\right)\\
                                                        
                                                        \mathbf{else}:\\
                                                        \;\;\;\;1 \cdot w0\\
                                                        
                                                        
                                                        \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)) < -1.00000000000000002e100

                                                          1. Initial program 66.0%

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

                                                            \[\leadsto w0 \cdot \color{blue}{1} \]
                                                          4. Step-by-step derivation
                                                            1. Applied rewrites5.0%

                                                              \[\leadsto w0 \cdot \color{blue}{1} \]
                                                            2. Taylor expanded in h around 0

                                                              \[\leadsto \color{blue}{w0 + \frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(h \cdot w0\right)\right)}{{d}^{2} \cdot \ell}} \]
                                                            3. Step-by-step derivation
                                                              1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

                                                                1. Initial program 88.1%

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

                                                                  \[\leadsto w0 \cdot \color{blue}{1} \]
                                                                4. Step-by-step derivation
                                                                  1. Applied rewrites93.2%

                                                                    \[\leadsto w0 \cdot \color{blue}{1} \]
                                                                5. Recombined 2 regimes into one program.
                                                                6. Final simplification81.1%

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

                                                                Alternative 12: 88.1% accurate, 1.9× speedup?

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

                                                                  \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
                                                                2. Add Preprocessing
                                                                3. Step-by-step derivation
                                                                  1. lift--.f64N/A

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

                                                                    \[\leadsto w0 \cdot \sqrt{\color{blue}{1 + \left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}} \]
                                                                  3. +-commutativeN/A

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

                                                                    \[\leadsto w0 \cdot \sqrt{\left(\mathsf{neg}\left(\color{blue}{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}\right)\right) + 1} \]
                                                                  5. lift-/.f64N/A

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

                                                                    \[\leadsto w0 \cdot \sqrt{\left(\mathsf{neg}\left(\color{blue}{\frac{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot h}{\ell}}\right)\right) + 1} \]
                                                                  7. distribute-neg-frac2N/A

                                                                    \[\leadsto w0 \cdot \sqrt{\color{blue}{\frac{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot h}{\mathsf{neg}\left(\ell\right)}} + 1} \]
                                                                  8. lift-pow.f64N/A

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

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

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

                                                                    \[\leadsto w0 \cdot \sqrt{\color{blue}{\frac{M \cdot D}{2 \cdot d} \cdot \frac{\frac{M \cdot D}{2 \cdot d} \cdot h}{\mathsf{neg}\left(\ell\right)}} + 1} \]
                                                                  12. lower-fma.f64N/A

                                                                    \[\leadsto w0 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\frac{M \cdot D}{2 \cdot d}, \frac{\frac{M \cdot D}{2 \cdot d} \cdot h}{\mathsf{neg}\left(\ell\right)}, 1\right)}} \]
                                                                4. Applied rewrites89.6%

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

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

                                                                Alternative 13: 72.1% accurate, 2.5× speedup?

                                                                \[\begin{array}{l} D_m = \left|D\right| \\ [w0, M, D_m, h, l, d] = \mathsf{sort}([w0, M, D_m, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;D\_m \cdot M \leq 5 \cdot 10^{+54}:\\ \;\;\;\;1 \cdot w0\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-0.125 \cdot w0, \left(\frac{D\_m}{\left(d \cdot d\right) \cdot \ell} \cdot \left(\left(M \cdot M\right) \cdot h\right)\right) \cdot D\_m, w0\right)\\ \end{array} \end{array} \]
                                                                D_m = (fabs.f64 D)
                                                                NOTE: w0, M, D_m, h, l, and d should be sorted in increasing order before calling this function.
                                                                (FPCore (w0 M D_m h l d)
                                                                 :precision binary64
                                                                 (if (<= (* D_m M) 5e+54)
                                                                   (* 1.0 w0)
                                                                   (fma (* -0.125 w0) (* (* (/ D_m (* (* d d) l)) (* (* M M) h)) D_m) w0)))
                                                                D_m = fabs(D);
                                                                assert(w0 < M && M < D_m && D_m < h && h < l && l < d);
                                                                double code(double w0, double M, double D_m, double h, double l, double d) {
                                                                	double tmp;
                                                                	if ((D_m * M) <= 5e+54) {
                                                                		tmp = 1.0 * w0;
                                                                	} else {
                                                                		tmp = fma((-0.125 * w0), (((D_m / ((d * d) * l)) * ((M * M) * h)) * D_m), w0);
                                                                	}
                                                                	return tmp;
                                                                }
                                                                
                                                                D_m = abs(D)
                                                                w0, M, D_m, h, l, d = sort([w0, M, D_m, h, l, d])
                                                                function code(w0, M, D_m, h, l, d)
                                                                	tmp = 0.0
                                                                	if (Float64(D_m * M) <= 5e+54)
                                                                		tmp = Float64(1.0 * w0);
                                                                	else
                                                                		tmp = fma(Float64(-0.125 * w0), Float64(Float64(Float64(D_m / Float64(Float64(d * d) * l)) * Float64(Float64(M * M) * h)) * D_m), w0);
                                                                	end
                                                                	return tmp
                                                                end
                                                                
                                                                D_m = N[Abs[D], $MachinePrecision]
                                                                NOTE: w0, M, D_m, h, l, and d should be sorted in increasing order before calling this function.
                                                                code[w0_, M_, D$95$m_, h_, l_, d_] := If[LessEqual[N[(D$95$m * M), $MachinePrecision], 5e+54], N[(1.0 * w0), $MachinePrecision], N[(N[(-0.125 * w0), $MachinePrecision] * N[(N[(N[(D$95$m / N[(N[(d * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * N[(N[(M * M), $MachinePrecision] * h), $MachinePrecision]), $MachinePrecision] * D$95$m), $MachinePrecision] + w0), $MachinePrecision]]
                                                                
                                                                \begin{array}{l}
                                                                D_m = \left|D\right|
                                                                \\
                                                                [w0, M, D_m, h, l, d] = \mathsf{sort}([w0, M, D_m, h, l, d])\\
                                                                \\
                                                                \begin{array}{l}
                                                                \mathbf{if}\;D\_m \cdot M \leq 5 \cdot 10^{+54}:\\
                                                                \;\;\;\;1 \cdot w0\\
                                                                
                                                                \mathbf{else}:\\
                                                                \;\;\;\;\mathsf{fma}\left(-0.125 \cdot w0, \left(\frac{D\_m}{\left(d \cdot d\right) \cdot \ell} \cdot \left(\left(M \cdot M\right) \cdot h\right)\right) \cdot D\_m, w0\right)\\
                                                                
                                                                
                                                                \end{array}
                                                                \end{array}
                                                                
                                                                Derivation
                                                                1. Split input into 2 regimes
                                                                2. if (*.f64 M D) < 5.00000000000000005e54

                                                                  1. Initial program 83.9%

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

                                                                    \[\leadsto w0 \cdot \color{blue}{1} \]
                                                                  4. Step-by-step derivation
                                                                    1. Applied rewrites77.1%

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

                                                                    if 5.00000000000000005e54 < (*.f64 M D)

                                                                    1. Initial program 73.1%

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

                                                                      \[\leadsto w0 \cdot \color{blue}{1} \]
                                                                    4. Step-by-step derivation
                                                                      1. Applied rewrites29.2%

                                                                        \[\leadsto w0 \cdot \color{blue}{1} \]
                                                                      2. Taylor expanded in h around 0

                                                                        \[\leadsto \color{blue}{w0 + \frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(h \cdot w0\right)\right)}{{d}^{2} \cdot \ell}} \]
                                                                      3. Step-by-step derivation
                                                                        1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

                                                                        Alternative 14: 67.6% accurate, 26.2× speedup?

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

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

                                                                          \[\leadsto w0 \cdot \color{blue}{1} \]
                                                                        4. Step-by-step derivation
                                                                          1. Applied rewrites69.1%

                                                                            \[\leadsto w0 \cdot \color{blue}{1} \]
                                                                          2. Final simplification69.1%

                                                                            \[\leadsto 1 \cdot w0 \]
                                                                          3. Add Preprocessing

                                                                          Reproduce

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