Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 81.2% → 86.8%
Time: 15.0s
Alternatives: 13
Speedup: 0.8×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 13 alternatives:

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

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

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

\mathbf{else}:\\
\;\;\;\;w0 \cdot \mathsf{fma}\left(D\_m, \left(D\_m \cdot -0.125\right) \cdot \frac{\frac{M\_m \cdot \frac{M\_m \cdot h}{\ell}}{d}}{d}, 1\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)) < -2e-16

    1. Initial program 66.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-pow.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} \]
      6. unpow2N/A

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

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

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

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

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

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

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

    1. Initial program 89.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 M 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)} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 2: 81.1% accurate, 0.4× speedup?

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

      1. Initial program 55.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 M 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)} \]
      4. Step-by-step derivation
        1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          1. Initial program 99.5%

            \[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 M 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. lower-/.f64N/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}}} \]
            3. associate-*r*N/A

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

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

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

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

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

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

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

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

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

              \[\leadsto w0 \cdot \sqrt{\frac{\left(\frac{-1}{4} \cdot \left(D \cdot D\right)\right) \cdot \left(\left(M \cdot M\right) \cdot h\right)}{\color{blue}{\left(d \cdot d\right)} \cdot \ell}} \]
            13. lower-*.f6438.7

              \[\leadsto w0 \cdot \sqrt{\frac{\left(-0.25 \cdot \left(D \cdot D\right)\right) \cdot \left(\left(M \cdot M\right) \cdot h\right)}{\color{blue}{\left(d \cdot d\right)} \cdot \ell}} \]
          5. Applied rewrites38.7%

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

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

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

            1. Initial program 89.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 M around 0

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

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

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

            Alternative 3: 81.1% accurate, 0.4× speedup?

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

              1. Initial program 58.2%

                \[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 M 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)} \]
              4. Step-by-step derivation
                1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  1. Initial program 99.3%

                    \[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 M 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. lower-/.f64N/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}}} \]
                    3. associate-*r*N/A

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

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

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

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

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

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

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

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

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

                      \[\leadsto w0 \cdot \sqrt{\frac{\left(\frac{-1}{4} \cdot \left(D \cdot D\right)\right) \cdot \left(\left(M \cdot M\right) \cdot h\right)}{\color{blue}{\left(d \cdot d\right)} \cdot \ell}} \]
                    13. lower-*.f6444.5

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

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

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

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

                    1. Initial program 89.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 M around 0

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

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

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

                    Alternative 4: 84.3% accurate, 0.7× speedup?

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

                      1. Initial program 66.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-pow.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} \]
                        6. unpow2N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                      1. Initial program 89.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 M 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)} \]
                      4. Step-by-step derivation
                        1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                          \[\leadsto \mathsf{fma}\left(D, \left(D \cdot -0.125\right) \cdot \frac{\frac{M \cdot \frac{M \cdot h}{\ell}}{d}}{\color{blue}{d}}, 1\right) \cdot w0 \]
                      9. Recombined 2 regimes into one program.
                      10. Final simplification81.7%

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

                      Alternative 5: 83.6% accurate, 0.7× speedup?

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

                        1. Initial program 63.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 M 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. lower-/.f64N/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}}} \]
                          3. associate-*r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                            1. Initial program 89.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 M 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)} \]
                            4. Step-by-step derivation
                              1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                \[\leadsto w0 \cdot \mathsf{fma}\left(D \cdot D, \frac{\frac{-1}{8} \cdot \left(\left(M \cdot M\right) \cdot h\right)}{\color{blue}{\left(d \cdot d\right)} \cdot \ell}, 1\right) \]
                              17. lower-*.f6457.0

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

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

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

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

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

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

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

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

                            Alternative 6: 82.9% accurate, 0.8× speedup?

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

                              1. Initial program 65.7%

                                \[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-pow.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} \]
                                6. unpow2N/A

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

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

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

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

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

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

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

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

                              1. Initial program 89.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 M 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)} \]
                              4. Step-by-step derivation
                                1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                  \[\leadsto w0 \cdot \mathsf{fma}\left(D \cdot D, \frac{\frac{-1}{8} \cdot \left(\left(M \cdot M\right) \cdot h\right)}{\color{blue}{\left(d \cdot d\right)} \cdot \ell}, 1\right) \]
                                17. lower-*.f6459.0

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

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

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

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

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

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

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

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

                              Alternative 7: 81.8% accurate, 0.8× speedup?

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

                                1. Initial program 65.7%

                                  \[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-pow.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

                                    \[\leadsto w0 \cdot \sqrt{1 - \left(\left(M \cdot D\right) \cdot \frac{M \cdot D}{\left(d \cdot d\right) \cdot \color{blue}{4}}\right) \cdot \frac{h}{\ell}} \]
                                  15. metadata-evalN/A

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

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

                                    \[\leadsto w0 \cdot \sqrt{1 - \left(\left(M \cdot D\right) \cdot \frac{M \cdot D}{\color{blue}{\left(d \cdot d\right)} \cdot \left(2 + 2\right)}\right) \cdot \frac{h}{\ell}} \]
                                  18. metadata-eval54.0

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

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

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

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

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

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

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

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

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

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

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

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

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

                                    \[\leadsto w0 \cdot \sqrt{1 - M \cdot \left(D \cdot \frac{\color{blue}{\left(M \cdot D\right) \cdot h}}{\left(\left(d \cdot d\right) \cdot 4\right) \cdot \ell}\right)} \]
                                  13. lower-*.f6452.6

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

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

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

                                1. Initial program 89.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 M 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)} \]
                                4. Step-by-step derivation
                                  1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                    \[\leadsto w0 \cdot \mathsf{fma}\left(D \cdot D, \frac{\frac{-1}{8} \cdot \left(\left(M \cdot M\right) \cdot h\right)}{\color{blue}{\left(d \cdot d\right)} \cdot \ell}, 1\right) \]
                                  17. lower-*.f6459.0

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

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

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

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

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

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

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

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

                                Alternative 8: 82.0% accurate, 0.8× speedup?

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

                                  1. Initial program 65.7%

                                    \[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-pow.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

                                      \[\leadsto w0 \cdot \sqrt{1 - \left(\left(M \cdot D\right) \cdot \frac{M \cdot D}{\left(d \cdot d\right) \cdot \color{blue}{4}}\right) \cdot \frac{h}{\ell}} \]
                                    15. metadata-evalN/A

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

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

                                      \[\leadsto w0 \cdot \sqrt{1 - \left(\left(M \cdot D\right) \cdot \frac{M \cdot D}{\color{blue}{\left(d \cdot d\right)} \cdot \left(2 + 2\right)}\right) \cdot \frac{h}{\ell}} \]
                                    18. metadata-eval54.0

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

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

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

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

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

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

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

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

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

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

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

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

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

                                      \[\leadsto w0 \cdot \sqrt{1 - M \cdot \left(D \cdot \frac{\color{blue}{\left(M \cdot D\right) \cdot h}}{\left(\left(d \cdot d\right) \cdot 4\right) \cdot \ell}\right)} \]
                                    13. lower-*.f6452.6

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

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

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

                                  1. Initial program 89.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 M around 0

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

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

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

                                  Alternative 9: 80.9% accurate, 0.8× speedup?

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

                                    1. Initial program 62.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 M 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. lower-/.f64N/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}}} \]
                                      3. associate-*r*N/A

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

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

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

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

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

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

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

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

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

                                        \[\leadsto w0 \cdot \sqrt{\frac{\left(\frac{-1}{4} \cdot \left(D \cdot D\right)\right) \cdot \left(\left(M \cdot M\right) \cdot h\right)}{\color{blue}{\left(d \cdot d\right)} \cdot \ell}} \]
                                      13. lower-*.f6439.7

                                        \[\leadsto w0 \cdot \sqrt{\frac{\left(-0.25 \cdot \left(D \cdot D\right)\right) \cdot \left(\left(M \cdot M\right) \cdot h\right)}{\color{blue}{\left(d \cdot d\right)} \cdot \ell}} \]
                                    5. Applied rewrites39.7%

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

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

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

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

                                        1. Initial program 89.5%

                                          \[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 M around 0

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

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

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

                                        Alternative 10: 80.3% accurate, 0.8× speedup?

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

                                          1. Initial program 65.7%

                                            \[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 M 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)} \]
                                          4. Step-by-step derivation
                                            1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                              \[\leadsto w0 \cdot \mathsf{fma}\left(D \cdot D, \frac{\frac{-1}{8} \cdot \left(\left(M \cdot M\right) \cdot h\right)}{\color{blue}{\left(d \cdot d\right)} \cdot \ell}, 1\right) \]
                                            17. lower-*.f6431.5

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

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

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

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

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

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

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

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

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

                                              1. Initial program 89.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 M around 0

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

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

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

                                              Alternative 11: 79.8% accurate, 0.8× speedup?

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

                                                1. Initial program 55.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 M 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)} \]
                                                4. Step-by-step derivation
                                                  1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                      1. Initial program 90.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 M around 0

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

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

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

                                                      Alternative 12: 79.0% accurate, 0.8× speedup?

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

                                                        1. Initial program 55.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 M 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)} \]
                                                        4. Step-by-step derivation
                                                          1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                              1. Initial program 90.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 M around 0

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

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

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

                                                              Alternative 13: 67.9% accurate, 26.2× speedup?

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

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

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

                                                                Reproduce

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