Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 80.6% → 88.8%
Time: 11.0s
Alternatives: 15
Speedup: 1.8×

Specification

?
\[\begin{array}{l} \\ w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \end{array} \]
(FPCore (w0 M D h l d)
 :precision binary64
 (* w0 (sqrt (- 1.0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l))))))
double code(double w0, double M, double D, double h, double l, double d) {
	return w0 * sqrt((1.0 - (pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(w0, m, d, h, l, d_1)
use fmin_fmax_functions
    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 15 alternatives:

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

Initial Program: 80.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \end{array} \]
(FPCore (w0 M D h l d)
 :precision binary64
 (* w0 (sqrt (- 1.0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l))))))
double code(double w0, double M, double D, double h, double l, double d) {
	return w0 * sqrt((1.0 - (pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

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

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

Alternative 1: 88.8% accurate, 1.6× 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}\;M\_m \cdot D\_m \leq 2 \cdot 10^{-171} \lor \neg \left(M\_m \cdot D\_m \leq 5 \cdot 10^{+180}\right):\\ \;\;\;\;w0 \cdot \sqrt{1 - \left(D\_m \cdot \frac{h \cdot M\_m}{4 \cdot d}\right) \cdot \frac{D\_m \cdot \frac{M\_m}{d}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{\left(M\_m \cdot D\_m\right) \cdot \frac{h}{4 \cdot d}}{\ell \cdot d} \cdot \left(M\_m \cdot D\_m\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 (or (<= (* M_m D_m) 2e-171) (not (<= (* M_m D_m) 5e+180)))
   (*
    w0
    (sqrt (- 1.0 (* (* D_m (/ (* h M_m) (* 4.0 d))) (/ (* D_m (/ M_m d)) l)))))
   (*
    w0
    (sqrt
     (- 1.0 (* (/ (* (* M_m D_m) (/ h (* 4.0 d))) (* l d)) (* M_m D_m)))))))
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 (((M_m * D_m) <= 2e-171) || !((M_m * D_m) <= 5e+180)) {
		tmp = w0 * sqrt((1.0 - ((D_m * ((h * M_m) / (4.0 * d))) * ((D_m * (M_m / d)) / l))));
	} else {
		tmp = w0 * sqrt((1.0 - ((((M_m * D_m) * (h / (4.0 * d))) / (l * d)) * (M_m * D_m))));
	}
	return tmp;
}
D_m =     private
M_m =     private
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(w0, m_m, d_m, h, l, d)
use fmin_fmax_functions
    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) <= 2d-171) .or. (.not. ((m_m * d_m) <= 5d+180))) then
        tmp = w0 * sqrt((1.0d0 - ((d_m * ((h * m_m) / (4.0d0 * d))) * ((d_m * (m_m / d)) / l))))
    else
        tmp = w0 * sqrt((1.0d0 - ((((m_m * d_m) * (h / (4.0d0 * d))) / (l * d)) * (m_m * d_m))))
    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 (((M_m * D_m) <= 2e-171) || !((M_m * D_m) <= 5e+180)) {
		tmp = w0 * Math.sqrt((1.0 - ((D_m * ((h * M_m) / (4.0 * d))) * ((D_m * (M_m / d)) / l))));
	} else {
		tmp = w0 * Math.sqrt((1.0 - ((((M_m * D_m) * (h / (4.0 * d))) / (l * d)) * (M_m * D_m))));
	}
	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 ((M_m * D_m) <= 2e-171) or not ((M_m * D_m) <= 5e+180):
		tmp = w0 * math.sqrt((1.0 - ((D_m * ((h * M_m) / (4.0 * d))) * ((D_m * (M_m / d)) / l))))
	else:
		tmp = w0 * math.sqrt((1.0 - ((((M_m * D_m) * (h / (4.0 * d))) / (l * d)) * (M_m * D_m))))
	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(M_m * D_m) <= 2e-171) || !(Float64(M_m * D_m) <= 5e+180))
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(D_m * Float64(Float64(h * M_m) / Float64(4.0 * d))) * Float64(Float64(D_m * Float64(M_m / d)) / l)))));
	else
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(Float64(M_m * D_m) * Float64(h / Float64(4.0 * d))) / Float64(l * d)) * Float64(M_m * D_m)))));
	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) <= 2e-171) || ~(((M_m * D_m) <= 5e+180)))
		tmp = w0 * sqrt((1.0 - ((D_m * ((h * M_m) / (4.0 * d))) * ((D_m * (M_m / d)) / l))));
	else
		tmp = w0 * sqrt((1.0 - ((((M_m * D_m) * (h / (4.0 * d))) / (l * d)) * (M_m * D_m))));
	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[Or[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 2e-171], N[Not[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 5e+180]], $MachinePrecision]], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(D$95$m * N[(N[(h * M$95$m), $MachinePrecision] / N[(4.0 * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(N[(M$95$m * D$95$m), $MachinePrecision] * N[(h / N[(4.0 * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(l * d), $MachinePrecision]), $MachinePrecision] * N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $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}\;M\_m \cdot D\_m \leq 2 \cdot 10^{-171} \lor \neg \left(M\_m \cdot D\_m \leq 5 \cdot 10^{+180}\right):\\
\;\;\;\;w0 \cdot \sqrt{1 - \left(D\_m \cdot \frac{h \cdot M\_m}{4 \cdot d}\right) \cdot \frac{D\_m \cdot \frac{M\_m}{d}}{\ell}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 M D) < 2e-171 or 4.9999999999999996e180 < (*.f64 M D)

    1. Initial program 82.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 \cdot \sqrt{1 - \left(D \cdot \frac{h \cdot M}{\color{blue}{\left(-2 \cdot -2\right) \cdot d}}\right) \cdot \frac{D \cdot \frac{M}{d}}{\ell}} \]
      16. metadata-eval86.7

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

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

    if 2e-171 < (*.f64 M D) < 4.9999999999999996e180

    1. Initial program 83.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 81.7% 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 -1 \cdot 10^{+304}:\\ \;\;\;\;\mathsf{fma}\left(w0 \cdot \left(M\_m \cdot \left(\left(h \cdot M\_m\right) \cdot \left(\frac{D\_m}{d} \cdot \frac{\frac{D\_m}{\ell}}{d}\right)\right)\right), -0.125, w0\right)\\ \mathbf{elif}\;t\_0 \leq -5 \cdot 10^{+49}:\\ \;\;\;\;w0 \cdot \sqrt{\left(\left(\left(\frac{h}{d \cdot d} \cdot M\_m\right) \cdot \frac{M\_m}{\ell}\right) \cdot \left(-0.25 \cdot D\_m\right)\right) \cdot D\_m}\\ \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 -1e+304)
     (fma (* w0 (* M_m (* (* h M_m) (* (/ D_m d) (/ (/ D_m l) d))))) -0.125 w0)
     (if (<= t_0 -5e+49)
       (*
        w0
        (sqrt (* (* (* (* (/ h (* d d)) M_m) (/ M_m l)) (* -0.25 D_m)) D_m)))
       (* 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 <= -1e+304) {
		tmp = fma((w0 * (M_m * ((h * M_m) * ((D_m / d) * ((D_m / l) / d))))), -0.125, w0);
	} else if (t_0 <= -5e+49) {
		tmp = w0 * sqrt((((((h / (d * d)) * M_m) * (M_m / l)) * (-0.25 * D_m)) * D_m));
	} 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 <= -1e+304)
		tmp = fma(Float64(w0 * Float64(M_m * Float64(Float64(h * M_m) * Float64(Float64(D_m / d) * Float64(Float64(D_m / l) / d))))), -0.125, w0);
	elseif (t_0 <= -5e+49)
		tmp = Float64(w0 * sqrt(Float64(Float64(Float64(Float64(Float64(h / Float64(d * d)) * M_m) * Float64(M_m / l)) * Float64(-0.25 * D_m)) * D_m)));
	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, -1e+304], N[(N[(w0 * N[(M$95$m * N[(N[(h * M$95$m), $MachinePrecision] * N[(N[(D$95$m / d), $MachinePrecision] * N[(N[(D$95$m / l), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125 + w0), $MachinePrecision], If[LessEqual[t$95$0, -5e+49], N[(w0 * N[Sqrt[N[(N[(N[(N[(N[(h / N[(d * d), $MachinePrecision]), $MachinePrecision] * M$95$m), $MachinePrecision] * N[(M$95$m / l), $MachinePrecision]), $MachinePrecision] * N[(-0.25 * D$95$m), $MachinePrecision]), $MachinePrecision] * D$95$m), $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 -1 \cdot 10^{+304}:\\
\;\;\;\;\mathsf{fma}\left(w0 \cdot \left(M\_m \cdot \left(\left(h \cdot M\_m\right) \cdot \left(\frac{D\_m}{d} \cdot \frac{\frac{D\_m}{\ell}}{d}\right)\right)\right), -0.125, w0\right)\\

\mathbf{elif}\;t\_0 \leq -5 \cdot 10^{+49}:\\
\;\;\;\;w0 \cdot \sqrt{\left(\left(\left(\frac{h}{d \cdot d} \cdot M\_m\right) \cdot \frac{M\_m}{\ell}\right) \cdot \left(-0.25 \cdot D\_m\right)\right) \cdot D\_m}\\

\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)) < -9.9999999999999994e303

    1. Initial program 67.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        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-/l*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          1. Initial program 85.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}{1} \]
          4. Step-by-step derivation
            1. Applied rewrites92.3%

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

          Alternative 3: 81.2% 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^{+280}:\\ \;\;\;\;\mathsf{fma}\left(w0 \cdot \left(M\_m \cdot \left(\left(h \cdot M\_m\right) \cdot \left(\frac{D\_m}{d} \cdot \frac{\frac{D\_m}{\ell}}{d}\right)\right)\right), -0.125, w0\right)\\ \mathbf{elif}\;t\_0 \leq -20:\\ \;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(h \cdot -0.25, \frac{\left(\left(M\_m \cdot M\_m\right) \cdot D\_m\right) \cdot D\_m}{\left(d \cdot d\right) \cdot \ell}, 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
           (let* ((t_0 (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ h l))))
             (if (<= t_0 -2e+280)
               (fma (* w0 (* M_m (* (* h M_m) (* (/ D_m d) (/ (/ D_m l) d))))) -0.125 w0)
               (if (<= t_0 -20.0)
                 (*
                  w0
                  (sqrt
                   (fma (* h -0.25) (/ (* (* (* M_m M_m) D_m) D_m) (* (* d 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 t_0 = pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l);
          	double tmp;
          	if (t_0 <= -2e+280) {
          		tmp = fma((w0 * (M_m * ((h * M_m) * ((D_m / d) * ((D_m / l) / d))))), -0.125, w0);
          	} else if (t_0 <= -20.0) {
          		tmp = w0 * sqrt(fma((h * -0.25), ((((M_m * M_m) * D_m) * D_m) / ((d * 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)
          	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+280)
          		tmp = fma(Float64(w0 * Float64(M_m * Float64(Float64(h * M_m) * Float64(Float64(D_m / d) * Float64(Float64(D_m / l) / d))))), -0.125, w0);
          	elseif (t_0 <= -20.0)
          		tmp = Float64(w0 * sqrt(fma(Float64(h * -0.25), Float64(Float64(Float64(Float64(M_m * M_m) * D_m) * D_m) / Float64(Float64(d * 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_] := 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+280], N[(N[(w0 * N[(M$95$m * N[(N[(h * M$95$m), $MachinePrecision] * N[(N[(D$95$m / d), $MachinePrecision] * N[(N[(D$95$m / l), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125 + w0), $MachinePrecision], If[LessEqual[t$95$0, -20.0], N[(w0 * N[Sqrt[N[(N[(h * -0.25), $MachinePrecision] * N[(N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] * D$95$m), $MachinePrecision] * D$95$m), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] + 1.0), $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^{+280}:\\
          \;\;\;\;\mathsf{fma}\left(w0 \cdot \left(M\_m \cdot \left(\left(h \cdot M\_m\right) \cdot \left(\frac{D\_m}{d} \cdot \frac{\frac{D\_m}{\ell}}{d}\right)\right)\right), -0.125, w0\right)\\
          
          \mathbf{elif}\;t\_0 \leq -20:\\
          \;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(h \cdot -0.25, \frac{\left(\left(M\_m \cdot M\_m\right) \cdot D\_m\right) \cdot D\_m}{\left(d \cdot d\right) \cdot \ell}, 1\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.0000000000000001e280

            1. Initial program 68.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                1. Initial program 99.4%

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

                  \[\leadsto w0 \cdot \sqrt{\color{blue}{h \cdot \left(\frac{1}{h} - \frac{1}{4} \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right)}} \]
                4. Step-by-step derivation
                  1. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

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

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

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

                1. Initial program 85.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 rewrites93.5%

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

                Alternative 4: 74.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^{+280}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{\left(\left(D\_m \cdot M\_m\right) \cdot h\right) \cdot \left(\left(-D\_m\right) \cdot M\_m\right)}{\left(-2 \cdot d\right) \cdot \ell}}\\ \mathbf{elif}\;t\_0 \leq -20:\\ \;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(h \cdot -0.25, \frac{\left(\left(M\_m \cdot M\_m\right) \cdot D\_m\right) \cdot D\_m}{\left(d \cdot d\right) \cdot \ell}, 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
                 (let* ((t_0 (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ h l))))
                   (if (<= t_0 -2e+280)
                     (*
                      w0
                      (sqrt
                       (- 1.0 (/ (* (* (* D_m M_m) h) (* (- D_m) M_m)) (* (* -2.0 d) l)))))
                     (if (<= t_0 -20.0)
                       (*
                        w0
                        (sqrt
                         (fma (* h -0.25) (/ (* (* (* M_m M_m) D_m) D_m) (* (* d 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 t_0 = pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l);
                	double tmp;
                	if (t_0 <= -2e+280) {
                		tmp = w0 * sqrt((1.0 - ((((D_m * M_m) * h) * (-D_m * M_m)) / ((-2.0 * d) * l))));
                	} else if (t_0 <= -20.0) {
                		tmp = w0 * sqrt(fma((h * -0.25), ((((M_m * M_m) * D_m) * D_m) / ((d * 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)
                	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+280)
                		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(Float64(D_m * M_m) * h) * Float64(Float64(-D_m) * M_m)) / Float64(Float64(-2.0 * d) * l)))));
                	elseif (t_0 <= -20.0)
                		tmp = Float64(w0 * sqrt(fma(Float64(h * -0.25), Float64(Float64(Float64(Float64(M_m * M_m) * D_m) * D_m) / Float64(Float64(d * 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_] := 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+280], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * h), $MachinePrecision] * N[((-D$95$m) * M$95$m), $MachinePrecision]), $MachinePrecision] / N[(N[(-2.0 * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -20.0], N[(w0 * N[Sqrt[N[(N[(h * -0.25), $MachinePrecision] * N[(N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] * D$95$m), $MachinePrecision] * D$95$m), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] + 1.0), $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^{+280}:\\
                \;\;\;\;w0 \cdot \sqrt{1 - \frac{\left(\left(D\_m \cdot M\_m\right) \cdot h\right) \cdot \left(\left(-D\_m\right) \cdot M\_m\right)}{\left(-2 \cdot d\right) \cdot \ell}}\\
                
                \mathbf{elif}\;t\_0 \leq -20:\\
                \;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(h \cdot -0.25, \frac{\left(\left(M\_m \cdot M\_m\right) \cdot D\_m\right) \cdot D\_m}{\left(d \cdot d\right) \cdot \ell}, 1\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.0000000000000001e280

                  1. Initial program 68.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    1. Initial program 99.4%

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

                      \[\leadsto w0 \cdot \sqrt{\color{blue}{h \cdot \left(\frac{1}{h} - \frac{1}{4} \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right)}} \]
                    4. Step-by-step derivation
                      1. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

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

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

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

                    1. Initial program 85.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 rewrites93.5%

                        \[\leadsto w0 \cdot \color{blue}{1} \]
                    5. Recombined 3 regimes into one program.
                    6. Final simplification73.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^{+280}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{\left(\left(D \cdot M\right) \cdot h\right) \cdot \left(\left(-D\right) \cdot M\right)}{\left(-2 \cdot d\right) \cdot \ell}}\\ \mathbf{elif}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -20:\\ \;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(h \cdot -0.25, \frac{\left(\left(M \cdot M\right) \cdot D\right) \cdot D}{\left(d \cdot d\right) \cdot \ell}, 1\right)}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot 1\\ \end{array} \]
                    7. Add Preprocessing

                    Alternative 5: 87.6% accurate, 0.5× 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 := w0 \cdot \sqrt{1 - {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}\\ \mathbf{if}\;t\_0 \leq 4 \cdot 10^{+145}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{\frac{\left(D\_m \cdot M\_m\right) \cdot h}{-2}}{d \cdot -2} \cdot \frac{D\_m \cdot \frac{M\_m}{d}}{\ell}}\\ \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
                             (*
                              w0
                              (sqrt (- 1.0 (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ h l)))))))
                       (if (<= t_0 4e+145)
                         t_0
                         (*
                          w0
                          (sqrt
                           (-
                            1.0
                            (*
                             (/ (/ (* (* D_m M_m) h) -2.0) (* d -2.0))
                             (/ (* D_m (/ M_m d)) l))))))))
                    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 = w0 * sqrt((1.0 - (pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l))));
                    	double tmp;
                    	if (t_0 <= 4e+145) {
                    		tmp = t_0;
                    	} else {
                    		tmp = w0 * sqrt((1.0 - (((((D_m * M_m) * h) / -2.0) / (d * -2.0)) * ((D_m * (M_m / d)) / l))));
                    	}
                    	return tmp;
                    }
                    
                    D_m =     private
                    M_m =     private
                    NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
                    module fmin_fmax_functions
                        implicit none
                        private
                        public fmax
                        public fmin
                    
                        interface fmax
                            module procedure fmax88
                            module procedure fmax44
                            module procedure fmax84
                            module procedure fmax48
                        end interface
                        interface fmin
                            module procedure fmin88
                            module procedure fmin44
                            module procedure fmin84
                            module procedure fmin48
                        end interface
                    contains
                        real(8) function fmax88(x, y) result (res)
                            real(8), intent (in) :: x
                            real(8), intent (in) :: y
                            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                        end function
                        real(4) function fmax44(x, y) result (res)
                            real(4), intent (in) :: x
                            real(4), intent (in) :: y
                            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                        end function
                        real(8) function fmax84(x, y) result(res)
                            real(8), intent (in) :: x
                            real(4), intent (in) :: y
                            res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                        end function
                        real(8) function fmax48(x, y) result(res)
                            real(4), intent (in) :: x
                            real(8), intent (in) :: y
                            res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                        end function
                        real(8) function fmin88(x, y) result (res)
                            real(8), intent (in) :: x
                            real(8), intent (in) :: y
                            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                        end function
                        real(4) function fmin44(x, y) result (res)
                            real(4), intent (in) :: x
                            real(4), intent (in) :: y
                            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                        end function
                        real(8) function fmin84(x, y) result(res)
                            real(8), intent (in) :: x
                            real(4), intent (in) :: y
                            res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                        end function
                        real(8) function fmin48(x, y) result(res)
                            real(4), intent (in) :: x
                            real(8), intent (in) :: y
                            res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                        end function
                    end module
                    
                    real(8) function code(w0, m_m, d_m, h, l, d)
                    use fmin_fmax_functions
                        real(8), intent (in) :: w0
                        real(8), intent (in) :: m_m
                        real(8), intent (in) :: d_m
                        real(8), intent (in) :: h
                        real(8), intent (in) :: l
                        real(8), intent (in) :: d
                        real(8) :: t_0
                        real(8) :: tmp
                        t_0 = w0 * sqrt((1.0d0 - ((((m_m * d_m) / (2.0d0 * d)) ** 2.0d0) * (h / l))))
                        if (t_0 <= 4d+145) then
                            tmp = t_0
                        else
                            tmp = w0 * sqrt((1.0d0 - (((((d_m * m_m) * h) / (-2.0d0)) / (d * (-2.0d0))) * ((d_m * (m_m / d)) / l))))
                        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 t_0 = w0 * Math.sqrt((1.0 - (Math.pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l))));
                    	double tmp;
                    	if (t_0 <= 4e+145) {
                    		tmp = t_0;
                    	} else {
                    		tmp = w0 * Math.sqrt((1.0 - (((((D_m * M_m) * h) / -2.0) / (d * -2.0)) * ((D_m * (M_m / d)) / l))));
                    	}
                    	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):
                    	t_0 = w0 * math.sqrt((1.0 - (math.pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l))))
                    	tmp = 0
                    	if t_0 <= 4e+145:
                    		tmp = t_0
                    	else:
                    		tmp = w0 * math.sqrt((1.0 - (((((D_m * M_m) * h) / -2.0) / (d * -2.0)) * ((D_m * (M_m / d)) / l))))
                    	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(w0 * sqrt(Float64(1.0 - Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)))))
                    	tmp = 0.0
                    	if (t_0 <= 4e+145)
                    		tmp = t_0;
                    	else
                    		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(Float64(Float64(D_m * M_m) * h) / -2.0) / Float64(d * -2.0)) * Float64(Float64(D_m * Float64(M_m / d)) / l)))));
                    	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)
                    	t_0 = w0 * sqrt((1.0 - ((((M_m * D_m) / (2.0 * d)) ^ 2.0) * (h / l))));
                    	tmp = 0.0;
                    	if (t_0 <= 4e+145)
                    		tmp = t_0;
                    	else
                    		tmp = w0 * sqrt((1.0 - (((((D_m * M_m) * h) / -2.0) / (d * -2.0)) * ((D_m * (M_m / d)) / l))));
                    	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_] := Block[{t$95$0 = N[(w0 * N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 4e+145], t$95$0, N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * h), $MachinePrecision] / -2.0), $MachinePrecision] / N[(d * -2.0), $MachinePrecision]), $MachinePrecision] * N[(N[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $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}
                    t_0 := w0 \cdot \sqrt{1 - {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}\\
                    \mathbf{if}\;t\_0 \leq 4 \cdot 10^{+145}:\\
                    \;\;\;\;t\_0\\
                    
                    \mathbf{else}:\\
                    \;\;\;\;w0 \cdot \sqrt{1 - \frac{\frac{\left(D\_m \cdot M\_m\right) \cdot h}{-2}}{d \cdot -2} \cdot \frac{D\_m \cdot \frac{M\_m}{d}}{\ell}}\\
                    
                    
                    \end{array}
                    \end{array}
                    
                    Derivation
                    1. Split input into 2 regimes
                    2. if (*.f64 w0 (sqrt.f64 (-.f64 #s(literal 1 binary64) (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l))))) < 4e145

                      1. Initial program 94.0%

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

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

                      1. Initial program 50.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    Alternative 6: 86.2% 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}\;\sqrt{1 - {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \leq 1:\\ \;\;\;\;w0 \cdot 1\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{\left(D\_m \cdot M\_m\right) \cdot \frac{\left(D\_m \cdot M\_m\right) \cdot h}{d \cdot -2}}{\left(-2 \cdot d\right) \cdot \ell}}\\ \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 (<= (sqrt (- 1.0 (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ h l)))) 1.0)
                       (* w0 1.0)
                       (*
                        w0
                        (sqrt
                         (-
                          1.0
                          (/
                           (* (* D_m M_m) (/ (* (* D_m M_m) h) (* d -2.0)))
                           (* (* -2.0 d) l)))))))
                    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 (sqrt((1.0 - (pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)))) <= 1.0) {
                    		tmp = w0 * 1.0;
                    	} else {
                    		tmp = w0 * sqrt((1.0 - (((D_m * M_m) * (((D_m * M_m) * h) / (d * -2.0))) / ((-2.0 * d) * l))));
                    	}
                    	return tmp;
                    }
                    
                    D_m =     private
                    M_m =     private
                    NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
                    module fmin_fmax_functions
                        implicit none
                        private
                        public fmax
                        public fmin
                    
                        interface fmax
                            module procedure fmax88
                            module procedure fmax44
                            module procedure fmax84
                            module procedure fmax48
                        end interface
                        interface fmin
                            module procedure fmin88
                            module procedure fmin44
                            module procedure fmin84
                            module procedure fmin48
                        end interface
                    contains
                        real(8) function fmax88(x, y) result (res)
                            real(8), intent (in) :: x
                            real(8), intent (in) :: y
                            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                        end function
                        real(4) function fmax44(x, y) result (res)
                            real(4), intent (in) :: x
                            real(4), intent (in) :: y
                            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                        end function
                        real(8) function fmax84(x, y) result(res)
                            real(8), intent (in) :: x
                            real(4), intent (in) :: y
                            res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                        end function
                        real(8) function fmax48(x, y) result(res)
                            real(4), intent (in) :: x
                            real(8), intent (in) :: y
                            res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                        end function
                        real(8) function fmin88(x, y) result (res)
                            real(8), intent (in) :: x
                            real(8), intent (in) :: y
                            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                        end function
                        real(4) function fmin44(x, y) result (res)
                            real(4), intent (in) :: x
                            real(4), intent (in) :: y
                            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                        end function
                        real(8) function fmin84(x, y) result(res)
                            real(8), intent (in) :: x
                            real(4), intent (in) :: y
                            res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                        end function
                        real(8) function fmin48(x, y) result(res)
                            real(4), intent (in) :: x
                            real(8), intent (in) :: y
                            res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                        end function
                    end module
                    
                    real(8) function code(w0, m_m, d_m, h, l, d)
                    use fmin_fmax_functions
                        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 (sqrt((1.0d0 - ((((m_m * d_m) / (2.0d0 * d)) ** 2.0d0) * (h / l)))) <= 1.0d0) then
                            tmp = w0 * 1.0d0
                        else
                            tmp = w0 * sqrt((1.0d0 - (((d_m * m_m) * (((d_m * m_m) * h) / (d * (-2.0d0)))) / (((-2.0d0) * d) * l))))
                        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.sqrt((1.0 - (Math.pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)))) <= 1.0) {
                    		tmp = w0 * 1.0;
                    	} else {
                    		tmp = w0 * Math.sqrt((1.0 - (((D_m * M_m) * (((D_m * M_m) * h) / (d * -2.0))) / ((-2.0 * d) * l))));
                    	}
                    	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.sqrt((1.0 - (math.pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)))) <= 1.0:
                    		tmp = w0 * 1.0
                    	else:
                    		tmp = w0 * math.sqrt((1.0 - (((D_m * M_m) * (((D_m * M_m) * h) / (d * -2.0))) / ((-2.0 * d) * l))))
                    	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 (sqrt(Float64(1.0 - Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)))) <= 1.0)
                    		tmp = Float64(w0 * 1.0);
                    	else
                    		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(D_m * M_m) * Float64(Float64(Float64(D_m * M_m) * h) / Float64(d * -2.0))) / Float64(Float64(-2.0 * d) * l)))));
                    	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 (sqrt((1.0 - ((((M_m * D_m) / (2.0 * d)) ^ 2.0) * (h / l)))) <= 1.0)
                    		tmp = w0 * 1.0;
                    	else
                    		tmp = w0 * sqrt((1.0 - (((D_m * M_m) * (((D_m * M_m) * h) / (d * -2.0))) / ((-2.0 * d) * l))));
                    	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[Sqrt[N[(1.0 - N[(N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 1.0], N[(w0 * 1.0), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * h), $MachinePrecision] / N[(d * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(-2.0 * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $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}\;\sqrt{1 - {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \leq 1:\\
                    \;\;\;\;w0 \cdot 1\\
                    
                    \mathbf{else}:\\
                    \;\;\;\;w0 \cdot \sqrt{1 - \frac{\left(D\_m \cdot M\_m\right) \cdot \frac{\left(D\_m \cdot M\_m\right) \cdot h}{d \cdot -2}}{\left(-2 \cdot d\right) \cdot \ell}}\\
                    
                    
                    \end{array}
                    \end{array}
                    
                    Derivation
                    1. Split input into 2 regimes
                    2. if (sqrt.f64 (-.f64 #s(literal 1 binary64) (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)))) < 1

                      1. Initial program 100.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 rewrites100.0%

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

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

                        1. Initial program 56.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                      Alternative 7: 80.4% 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 -5 \cdot 10^{+49}:\\ \;\;\;\;w0 \cdot \sqrt{\left(-0.25 \cdot \left(D\_m \cdot D\_m\right)\right) \cdot \frac{\left(\frac{h}{d \cdot d} \cdot M\_m\right) \cdot M\_m}{\ell}}\\ \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)) -5e+49)
                         (* w0 (sqrt (* (* -0.25 (* D_m D_m)) (/ (* (* (/ h (* d d)) M_m) M_m) 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 tmp;
                      	if ((pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)) <= -5e+49) {
                      		tmp = w0 * sqrt(((-0.25 * (D_m * D_m)) * ((((h / (d * d)) * M_m) * M_m) / l)));
                      	} else {
                      		tmp = w0 * 1.0;
                      	}
                      	return tmp;
                      }
                      
                      D_m =     private
                      M_m =     private
                      NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
                      module fmin_fmax_functions
                          implicit none
                          private
                          public fmax
                          public fmin
                      
                          interface fmax
                              module procedure fmax88
                              module procedure fmax44
                              module procedure fmax84
                              module procedure fmax48
                          end interface
                          interface fmin
                              module procedure fmin88
                              module procedure fmin44
                              module procedure fmin84
                              module procedure fmin48
                          end interface
                      contains
                          real(8) function fmax88(x, y) result (res)
                              real(8), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                          end function
                          real(4) function fmax44(x, y) result (res)
                              real(4), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                          end function
                          real(8) function fmax84(x, y) result(res)
                              real(8), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                          end function
                          real(8) function fmax48(x, y) result(res)
                              real(4), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                          end function
                          real(8) function fmin88(x, y) result (res)
                              real(8), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                          end function
                          real(4) function fmin44(x, y) result (res)
                              real(4), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                          end function
                          real(8) function fmin84(x, y) result(res)
                              real(8), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                          end function
                          real(8) function fmin48(x, y) result(res)
                              real(4), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                          end function
                      end module
                      
                      real(8) function code(w0, m_m, d_m, h, l, d)
                      use fmin_fmax_functions
                          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)) <= (-5d+49)) then
                              tmp = w0 * sqrt((((-0.25d0) * (d_m * d_m)) * ((((h / (d * d)) * m_m) * m_m) / l)))
                          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)) <= -5e+49) {
                      		tmp = w0 * Math.sqrt(((-0.25 * (D_m * D_m)) * ((((h / (d * d)) * M_m) * M_m) / l)));
                      	} 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)) <= -5e+49:
                      		tmp = w0 * math.sqrt(((-0.25 * (D_m * D_m)) * ((((h / (d * d)) * M_m) * M_m) / 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)
                      	tmp = 0.0
                      	if (Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= -5e+49)
                      		tmp = Float64(w0 * sqrt(Float64(Float64(-0.25 * Float64(D_m * D_m)) * Float64(Float64(Float64(Float64(h / Float64(d * d)) * M_m) * M_m) / l))));
                      	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)) <= -5e+49)
                      		tmp = w0 * sqrt(((-0.25 * (D_m * D_m)) * ((((h / (d * d)) * M_m) * M_m) / l)));
                      	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], -5e+49], N[(w0 * N[Sqrt[N[(N[(-0.25 * N[(D$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(h / N[(d * d), $MachinePrecision]), $MachinePrecision] * M$95$m), $MachinePrecision] * M$95$m), $MachinePrecision] / l), $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 -5 \cdot 10^{+49}:\\
                      \;\;\;\;w0 \cdot \sqrt{\left(-0.25 \cdot \left(D\_m \cdot D\_m\right)\right) \cdot \frac{\left(\frac{h}{d \cdot d} \cdot M\_m\right) \cdot M\_m}{\ell}}\\
                      
                      \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.0000000000000004e49

                        1. Initial program 74.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 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-/l*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                          1. Initial program 85.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}{1} \]
                          4. Step-by-step derivation
                            1. Applied rewrites92.3%

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

                          Alternative 8: 72.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 -\infty:\\ \;\;\;\;w0 \cdot \mathsf{fma}\left(-0.25, \frac{D\_m \cdot D\_m}{d} \cdot \frac{\left(M\_m \cdot M\_m\right) \cdot h}{\ell}, 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)) (- INFINITY))
                             (* w0 (fma -0.25 (* (/ (* D_m D_m) d) (/ (* (* M_m M_m) h) 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)) <= -((double) INFINITY)) {
                          		tmp = w0 * fma(-0.25, (((D_m * D_m) / d) * (((M_m * M_m) * h) / 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)) <= Float64(-Inf))
                          		tmp = Float64(w0 * fma(-0.25, Float64(Float64(Float64(D_m * D_m) / d) * Float64(Float64(Float64(M_m * M_m) * h) / 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], (-Infinity)], N[(w0 * N[(-0.25 * N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] / d), $MachinePrecision] * N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] * h), $MachinePrecision] / l), $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 -\infty:\\
                          \;\;\;\;w0 \cdot \mathsf{fma}\left(-0.25, \frac{D\_m \cdot D\_m}{d} \cdot \frac{\left(M\_m \cdot M\_m\right) \cdot h}{\ell}, 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)) < -inf.0

                            1. Initial program 66.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                              \[\leadsto w0 \cdot \color{blue}{\mathsf{fma}\left(-0.25, \frac{D \cdot D}{d} \cdot \frac{\left(M \cdot M\right) \cdot h}{\ell}, 1\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 86.8%

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

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

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

                            Alternative 9: 78.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 -1 \cdot 10^{+304}:\\ \;\;\;\;\frac{M\_m \cdot \left(\left(h \cdot M\_m\right) \cdot \left(\left(D\_m \cdot D\_m\right) \cdot w0\right)\right)}{\left(d \cdot d\right) \cdot \ell} \cdot -0.125\\ \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)) -1e+304)
                               (* (/ (* M_m (* (* h M_m) (* (* D_m D_m) w0))) (* (* d d) l)) -0.125)
                               (* 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)) <= -1e+304) {
                            		tmp = ((M_m * ((h * M_m) * ((D_m * D_m) * w0))) / ((d * d) * l)) * -0.125;
                            	} else {
                            		tmp = w0 * 1.0;
                            	}
                            	return tmp;
                            }
                            
                            D_m =     private
                            M_m =     private
                            NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
                            module fmin_fmax_functions
                                implicit none
                                private
                                public fmax
                                public fmin
                            
                                interface fmax
                                    module procedure fmax88
                                    module procedure fmax44
                                    module procedure fmax84
                                    module procedure fmax48
                                end interface
                                interface fmin
                                    module procedure fmin88
                                    module procedure fmin44
                                    module procedure fmin84
                                    module procedure fmin48
                                end interface
                            contains
                                real(8) function fmax88(x, y) result (res)
                                    real(8), intent (in) :: x
                                    real(8), intent (in) :: y
                                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                end function
                                real(4) function fmax44(x, y) result (res)
                                    real(4), intent (in) :: x
                                    real(4), intent (in) :: y
                                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                end function
                                real(8) function fmax84(x, y) result(res)
                                    real(8), intent (in) :: x
                                    real(4), intent (in) :: y
                                    res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                end function
                                real(8) function fmax48(x, y) result(res)
                                    real(4), intent (in) :: x
                                    real(8), intent (in) :: y
                                    res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                end function
                                real(8) function fmin88(x, y) result (res)
                                    real(8), intent (in) :: x
                                    real(8), intent (in) :: y
                                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                end function
                                real(4) function fmin44(x, y) result (res)
                                    real(4), intent (in) :: x
                                    real(4), intent (in) :: y
                                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                end function
                                real(8) function fmin84(x, y) result(res)
                                    real(8), intent (in) :: x
                                    real(4), intent (in) :: y
                                    res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                end function
                                real(8) function fmin48(x, y) result(res)
                                    real(4), intent (in) :: x
                                    real(8), intent (in) :: y
                                    res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                end function
                            end module
                            
                            real(8) function code(w0, m_m, d_m, h, l, d)
                            use fmin_fmax_functions
                                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)) <= (-1d+304)) then
                                    tmp = ((m_m * ((h * m_m) * ((d_m * d_m) * w0))) / ((d * d) * l)) * (-0.125d0)
                                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)) <= -1e+304) {
                            		tmp = ((M_m * ((h * M_m) * ((D_m * D_m) * w0))) / ((d * d) * l)) * -0.125;
                            	} 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)) <= -1e+304:
                            		tmp = ((M_m * ((h * M_m) * ((D_m * D_m) * w0))) / ((d * d) * l)) * -0.125
                            	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)) <= -1e+304)
                            		tmp = Float64(Float64(Float64(M_m * Float64(Float64(h * M_m) * Float64(Float64(D_m * D_m) * w0))) / Float64(Float64(d * d) * l)) * -0.125);
                            	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)) <= -1e+304)
                            		tmp = ((M_m * ((h * M_m) * ((D_m * D_m) * w0))) / ((d * d) * l)) * -0.125;
                            	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], -1e+304], N[(N[(N[(M$95$m * N[(N[(h * M$95$m), $MachinePrecision] * N[(N[(D$95$m * D$95$m), $MachinePrecision] * w0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * -0.125), $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 -1 \cdot 10^{+304}:\\
                            \;\;\;\;\frac{M\_m \cdot \left(\left(h \cdot M\_m\right) \cdot \left(\left(D\_m \cdot D\_m\right) \cdot w0\right)\right)}{\left(d \cdot d\right) \cdot \ell} \cdot -0.125\\
                            
                            \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)) < -9.9999999999999994e303

                              1. Initial program 67.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                  1. Initial program 86.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}{1} \]
                                  4. Step-by-step derivation
                                    1. Applied rewrites86.0%

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

                                  Alternative 10: 87.2% accurate, 1.6× 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}\;M\_m \cdot D\_m \leq 2 \cdot 10^{-171}:\\ \;\;\;\;w0 \cdot 1\\ \mathbf{elif}\;M\_m \cdot D\_m \leq 5 \cdot 10^{+278}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{\left(M\_m \cdot D\_m\right) \cdot \frac{h}{4 \cdot d}}{\ell \cdot d} \cdot \left(M\_m \cdot D\_m\right)}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(\frac{-0.5 \cdot \left(\left(M\_m \cdot M\_m\right) \cdot h\right)}{d} \cdot \frac{D\_m}{\ell}, \frac{D\_m}{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 (<= (* M_m D_m) 2e-171)
                                     (* w0 1.0)
                                     (if (<= (* M_m D_m) 5e+278)
                                       (*
                                        w0
                                        (sqrt
                                         (- 1.0 (* (/ (* (* M_m D_m) (/ h (* 4.0 d))) (* l d)) (* M_m D_m)))))
                                       (*
                                        w0
                                        (sqrt
                                         (fma (* (/ (* -0.5 (* (* M_m M_m) h)) d) (/ D_m l)) (/ D_m 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 ((M_m * D_m) <= 2e-171) {
                                  		tmp = w0 * 1.0;
                                  	} else if ((M_m * D_m) <= 5e+278) {
                                  		tmp = w0 * sqrt((1.0 - ((((M_m * D_m) * (h / (4.0 * d))) / (l * d)) * (M_m * D_m))));
                                  	} else {
                                  		tmp = w0 * sqrt(fma((((-0.5 * ((M_m * M_m) * h)) / d) * (D_m / l)), (D_m / 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(M_m * D_m) <= 2e-171)
                                  		tmp = Float64(w0 * 1.0);
                                  	elseif (Float64(M_m * D_m) <= 5e+278)
                                  		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(Float64(M_m * D_m) * Float64(h / Float64(4.0 * d))) / Float64(l * d)) * Float64(M_m * D_m)))));
                                  	else
                                  		tmp = Float64(w0 * sqrt(fma(Float64(Float64(Float64(-0.5 * Float64(Float64(M_m * M_m) * h)) / d) * Float64(D_m / l)), Float64(D_m / 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[(M$95$m * D$95$m), $MachinePrecision], 2e-171], N[(w0 * 1.0), $MachinePrecision], If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 5e+278], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(N[(M$95$m * D$95$m), $MachinePrecision] * N[(h / N[(4.0 * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(l * d), $MachinePrecision]), $MachinePrecision] * N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(N[(N[(N[(-0.5 * N[(N[(M$95$m * M$95$m), $MachinePrecision] * h), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision] * N[(D$95$m / l), $MachinePrecision]), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision] + 1.0), $MachinePrecision]], $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}\;M\_m \cdot D\_m \leq 2 \cdot 10^{-171}:\\
                                  \;\;\;\;w0 \cdot 1\\
                                  
                                  \mathbf{elif}\;M\_m \cdot D\_m \leq 5 \cdot 10^{+278}:\\
                                  \;\;\;\;w0 \cdot \sqrt{1 - \frac{\left(M\_m \cdot D\_m\right) \cdot \frac{h}{4 \cdot d}}{\ell \cdot d} \cdot \left(M\_m \cdot D\_m\right)}\\
                                  
                                  \mathbf{else}:\\
                                  \;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(\frac{-0.5 \cdot \left(\left(M\_m \cdot M\_m\right) \cdot h\right)}{d} \cdot \frac{D\_m}{\ell}, \frac{D\_m}{d}, 1\right)}\\
                                  
                                  
                                  \end{array}
                                  \end{array}
                                  
                                  Derivation
                                  1. Split input into 3 regimes
                                  2. if (*.f64 M D) < 2e-171

                                    1. Initial program 83.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 rewrites76.1%

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

                                      if 2e-171 < (*.f64 M D) < 5.00000000000000029e278

                                      1. Initial program 82.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                      if 5.00000000000000029e278 < (*.f64 M D)

                                      1. Initial program 79.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                          \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{-0.5 \cdot \left(\left(M \cdot M\right) \cdot h\right)}{d} \cdot \color{blue}{\frac{D}{\ell}}, \frac{D}{d}, 1\right)} \]
                                      8. Recombined 3 regimes into one program.
                                      9. Add Preprocessing

                                      Alternative 11: 87.9% accurate, 1.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} t_0 := \frac{D\_m \cdot \frac{M\_m}{d}}{\ell}\\ \mathbf{if}\;d \leq 3 \cdot 10^{+83}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{\frac{\left(D\_m \cdot M\_m\right) \cdot h}{-2}}{d \cdot -2} \cdot t\_0}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \left(D\_m \cdot \frac{h \cdot M\_m}{4 \cdot d}\right) \cdot t\_0}\\ \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 (/ (* D_m (/ M_m d)) l)))
                                         (if (<= d 3e+83)
                                           (* w0 (sqrt (- 1.0 (* (/ (/ (* (* D_m M_m) h) -2.0) (* d -2.0)) t_0))))
                                           (* w0 (sqrt (- 1.0 (* (* D_m (/ (* h M_m) (* 4.0 d))) t_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 = (D_m * (M_m / d)) / l;
                                      	double tmp;
                                      	if (d <= 3e+83) {
                                      		tmp = w0 * sqrt((1.0 - (((((D_m * M_m) * h) / -2.0) / (d * -2.0)) * t_0)));
                                      	} else {
                                      		tmp = w0 * sqrt((1.0 - ((D_m * ((h * M_m) / (4.0 * d))) * t_0)));
                                      	}
                                      	return tmp;
                                      }
                                      
                                      D_m =     private
                                      M_m =     private
                                      NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
                                      module fmin_fmax_functions
                                          implicit none
                                          private
                                          public fmax
                                          public fmin
                                      
                                          interface fmax
                                              module procedure fmax88
                                              module procedure fmax44
                                              module procedure fmax84
                                              module procedure fmax48
                                          end interface
                                          interface fmin
                                              module procedure fmin88
                                              module procedure fmin44
                                              module procedure fmin84
                                              module procedure fmin48
                                          end interface
                                      contains
                                          real(8) function fmax88(x, y) result (res)
                                              real(8), intent (in) :: x
                                              real(8), intent (in) :: y
                                              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                          end function
                                          real(4) function fmax44(x, y) result (res)
                                              real(4), intent (in) :: x
                                              real(4), intent (in) :: y
                                              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                          end function
                                          real(8) function fmax84(x, y) result(res)
                                              real(8), intent (in) :: x
                                              real(4), intent (in) :: y
                                              res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                          end function
                                          real(8) function fmax48(x, y) result(res)
                                              real(4), intent (in) :: x
                                              real(8), intent (in) :: y
                                              res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                          end function
                                          real(8) function fmin88(x, y) result (res)
                                              real(8), intent (in) :: x
                                              real(8), intent (in) :: y
                                              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                          end function
                                          real(4) function fmin44(x, y) result (res)
                                              real(4), intent (in) :: x
                                              real(4), intent (in) :: y
                                              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                          end function
                                          real(8) function fmin84(x, y) result(res)
                                              real(8), intent (in) :: x
                                              real(4), intent (in) :: y
                                              res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                          end function
                                          real(8) function fmin48(x, y) result(res)
                                              real(4), intent (in) :: x
                                              real(8), intent (in) :: y
                                              res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                          end function
                                      end module
                                      
                                      real(8) function code(w0, m_m, d_m, h, l, d)
                                      use fmin_fmax_functions
                                          real(8), intent (in) :: w0
                                          real(8), intent (in) :: m_m
                                          real(8), intent (in) :: d_m
                                          real(8), intent (in) :: h
                                          real(8), intent (in) :: l
                                          real(8), intent (in) :: d
                                          real(8) :: t_0
                                          real(8) :: tmp
                                          t_0 = (d_m * (m_m / d)) / l
                                          if (d <= 3d+83) then
                                              tmp = w0 * sqrt((1.0d0 - (((((d_m * m_m) * h) / (-2.0d0)) / (d * (-2.0d0))) * t_0)))
                                          else
                                              tmp = w0 * sqrt((1.0d0 - ((d_m * ((h * m_m) / (4.0d0 * d))) * t_0)))
                                          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 t_0 = (D_m * (M_m / d)) / l;
                                      	double tmp;
                                      	if (d <= 3e+83) {
                                      		tmp = w0 * Math.sqrt((1.0 - (((((D_m * M_m) * h) / -2.0) / (d * -2.0)) * t_0)));
                                      	} else {
                                      		tmp = w0 * Math.sqrt((1.0 - ((D_m * ((h * M_m) / (4.0 * d))) * t_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):
                                      	t_0 = (D_m * (M_m / d)) / l
                                      	tmp = 0
                                      	if d <= 3e+83:
                                      		tmp = w0 * math.sqrt((1.0 - (((((D_m * M_m) * h) / -2.0) / (d * -2.0)) * t_0)))
                                      	else:
                                      		tmp = w0 * math.sqrt((1.0 - ((D_m * ((h * M_m) / (4.0 * d))) * t_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(D_m * Float64(M_m / d)) / l)
                                      	tmp = 0.0
                                      	if (d <= 3e+83)
                                      		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(Float64(Float64(D_m * M_m) * h) / -2.0) / Float64(d * -2.0)) * t_0))));
                                      	else
                                      		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(D_m * Float64(Float64(h * M_m) / Float64(4.0 * d))) * t_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)
                                      	t_0 = (D_m * (M_m / d)) / l;
                                      	tmp = 0.0;
                                      	if (d <= 3e+83)
                                      		tmp = w0 * sqrt((1.0 - (((((D_m * M_m) * h) / -2.0) / (d * -2.0)) * t_0)));
                                      	else
                                      		tmp = w0 * sqrt((1.0 - ((D_m * ((h * M_m) / (4.0 * d))) * t_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_] := Block[{t$95$0 = N[(N[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]}, If[LessEqual[d, 3e+83], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * h), $MachinePrecision] / -2.0), $MachinePrecision] / N[(d * -2.0), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(D$95$m * N[(N[(h * M$95$m), $MachinePrecision] / N[(4.0 * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $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}
                                      t_0 := \frac{D\_m \cdot \frac{M\_m}{d}}{\ell}\\
                                      \mathbf{if}\;d \leq 3 \cdot 10^{+83}:\\
                                      \;\;\;\;w0 \cdot \sqrt{1 - \frac{\frac{\left(D\_m \cdot M\_m\right) \cdot h}{-2}}{d \cdot -2} \cdot t\_0}\\
                                      
                                      \mathbf{else}:\\
                                      \;\;\;\;w0 \cdot \sqrt{1 - \left(D\_m \cdot \frac{h \cdot M\_m}{4 \cdot d}\right) \cdot t\_0}\\
                                      
                                      
                                      \end{array}
                                      \end{array}
                                      
                                      Derivation
                                      1. Split input into 2 regimes
                                      2. if d < 3e83

                                        1. Initial program 83.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                        if 3e83 < d

                                        1. Initial program 80.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                      Alternative 12: 87.3% accurate, 1.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}\;M\_m \cdot D\_m \leq 2 \cdot 10^{-171}:\\ \;\;\;\;w0 \cdot 1\\ \mathbf{elif}\;M\_m \cdot D\_m \leq 5 \cdot 10^{+278}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{\left(M\_m \cdot D\_m\right) \cdot \frac{h}{4 \cdot d}}{\ell \cdot d} \cdot \left(M\_m \cdot D\_m\right)}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(w0 \cdot \left(M\_m \cdot \left(\left(h \cdot M\_m\right) \cdot \left(\frac{D\_m}{d} \cdot \frac{\frac{D\_m}{\ell}}{d}\right)\right)\right), -0.125, w0\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 (<= (* M_m D_m) 2e-171)
                                         (* w0 1.0)
                                         (if (<= (* M_m D_m) 5e+278)
                                           (*
                                            w0
                                            (sqrt
                                             (- 1.0 (* (/ (* (* M_m D_m) (/ h (* 4.0 d))) (* l d)) (* M_m D_m)))))
                                           (fma
                                            (* w0 (* M_m (* (* h M_m) (* (/ D_m d) (/ (/ D_m l) d)))))
                                            -0.125
                                            w0))))
                                      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 ((M_m * D_m) <= 2e-171) {
                                      		tmp = w0 * 1.0;
                                      	} else if ((M_m * D_m) <= 5e+278) {
                                      		tmp = w0 * sqrt((1.0 - ((((M_m * D_m) * (h / (4.0 * d))) / (l * d)) * (M_m * D_m))));
                                      	} else {
                                      		tmp = fma((w0 * (M_m * ((h * M_m) * ((D_m / d) * ((D_m / l) / d))))), -0.125, w0);
                                      	}
                                      	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(M_m * D_m) <= 2e-171)
                                      		tmp = Float64(w0 * 1.0);
                                      	elseif (Float64(M_m * D_m) <= 5e+278)
                                      		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(Float64(M_m * D_m) * Float64(h / Float64(4.0 * d))) / Float64(l * d)) * Float64(M_m * D_m)))));
                                      	else
                                      		tmp = fma(Float64(w0 * Float64(M_m * Float64(Float64(h * M_m) * Float64(Float64(D_m / d) * Float64(Float64(D_m / l) / d))))), -0.125, w0);
                                      	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[(M$95$m * D$95$m), $MachinePrecision], 2e-171], N[(w0 * 1.0), $MachinePrecision], If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 5e+278], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(N[(M$95$m * D$95$m), $MachinePrecision] * N[(h / N[(4.0 * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(l * d), $MachinePrecision]), $MachinePrecision] * N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(w0 * N[(M$95$m * N[(N[(h * M$95$m), $MachinePrecision] * N[(N[(D$95$m / d), $MachinePrecision] * N[(N[(D$95$m / l), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125 + w0), $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}\;M\_m \cdot D\_m \leq 2 \cdot 10^{-171}:\\
                                      \;\;\;\;w0 \cdot 1\\
                                      
                                      \mathbf{elif}\;M\_m \cdot D\_m \leq 5 \cdot 10^{+278}:\\
                                      \;\;\;\;w0 \cdot \sqrt{1 - \frac{\left(M\_m \cdot D\_m\right) \cdot \frac{h}{4 \cdot d}}{\ell \cdot d} \cdot \left(M\_m \cdot D\_m\right)}\\
                                      
                                      \mathbf{else}:\\
                                      \;\;\;\;\mathsf{fma}\left(w0 \cdot \left(M\_m \cdot \left(\left(h \cdot M\_m\right) \cdot \left(\frac{D\_m}{d} \cdot \frac{\frac{D\_m}{\ell}}{d}\right)\right)\right), -0.125, w0\right)\\
                                      
                                      
                                      \end{array}
                                      \end{array}
                                      
                                      Derivation
                                      1. Split input into 3 regimes
                                      2. if (*.f64 M D) < 2e-171

                                        1. Initial program 83.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 rewrites76.1%

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

                                          if 2e-171 < (*.f64 M D) < 5.00000000000000029e278

                                          1. Initial program 82.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                          if 5.00000000000000029e278 < (*.f64 M D)

                                          1. Initial program 79.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                            Alternative 13: 73.0% accurate, 1.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}\;\frac{M\_m \cdot D\_m}{2 \cdot d} \leq 10^{+76}:\\ \;\;\;\;w0 \cdot 1\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{\left(\left(D\_m \cdot M\_m\right) \cdot h\right) \cdot \left(\left(-D\_m\right) \cdot M\_m\right)}{\left(-2 \cdot d\right) \cdot \ell}}\\ \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 (<= (/ (* M_m D_m) (* 2.0 d)) 1e+76)
                                               (* w0 1.0)
                                               (*
                                                w0
                                                (sqrt
                                                 (- 1.0 (/ (* (* (* D_m M_m) h) (* (- D_m) M_m)) (* (* -2.0 d) l)))))))
                                            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 (((M_m * D_m) / (2.0 * d)) <= 1e+76) {
                                            		tmp = w0 * 1.0;
                                            	} else {
                                            		tmp = w0 * sqrt((1.0 - ((((D_m * M_m) * h) * (-D_m * M_m)) / ((-2.0 * d) * l))));
                                            	}
                                            	return tmp;
                                            }
                                            
                                            D_m =     private
                                            M_m =     private
                                            NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
                                            module fmin_fmax_functions
                                                implicit none
                                                private
                                                public fmax
                                                public fmin
                                            
                                                interface fmax
                                                    module procedure fmax88
                                                    module procedure fmax44
                                                    module procedure fmax84
                                                    module procedure fmax48
                                                end interface
                                                interface fmin
                                                    module procedure fmin88
                                                    module procedure fmin44
                                                    module procedure fmin84
                                                    module procedure fmin48
                                                end interface
                                            contains
                                                real(8) function fmax88(x, y) result (res)
                                                    real(8), intent (in) :: x
                                                    real(8), intent (in) :: y
                                                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                end function
                                                real(4) function fmax44(x, y) result (res)
                                                    real(4), intent (in) :: x
                                                    real(4), intent (in) :: y
                                                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                end function
                                                real(8) function fmax84(x, y) result(res)
                                                    real(8), intent (in) :: x
                                                    real(4), intent (in) :: y
                                                    res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                                end function
                                                real(8) function fmax48(x, y) result(res)
                                                    real(4), intent (in) :: x
                                                    real(8), intent (in) :: y
                                                    res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                                end function
                                                real(8) function fmin88(x, y) result (res)
                                                    real(8), intent (in) :: x
                                                    real(8), intent (in) :: y
                                                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                end function
                                                real(4) function fmin44(x, y) result (res)
                                                    real(4), intent (in) :: x
                                                    real(4), intent (in) :: y
                                                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                end function
                                                real(8) function fmin84(x, y) result(res)
                                                    real(8), intent (in) :: x
                                                    real(4), intent (in) :: y
                                                    res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                                end function
                                                real(8) function fmin48(x, y) result(res)
                                                    real(4), intent (in) :: x
                                                    real(8), intent (in) :: y
                                                    res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                                end function
                                            end module
                                            
                                            real(8) function code(w0, m_m, d_m, h, l, d)
                                            use fmin_fmax_functions
                                                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)) <= 1d+76) then
                                                    tmp = w0 * 1.0d0
                                                else
                                                    tmp = w0 * sqrt((1.0d0 - ((((d_m * m_m) * h) * (-d_m * m_m)) / (((-2.0d0) * d) * l))))
                                                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 (((M_m * D_m) / (2.0 * d)) <= 1e+76) {
                                            		tmp = w0 * 1.0;
                                            	} else {
                                            		tmp = w0 * Math.sqrt((1.0 - ((((D_m * M_m) * h) * (-D_m * M_m)) / ((-2.0 * d) * l))));
                                            	}
                                            	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 ((M_m * D_m) / (2.0 * d)) <= 1e+76:
                                            		tmp = w0 * 1.0
                                            	else:
                                            		tmp = w0 * math.sqrt((1.0 - ((((D_m * M_m) * h) * (-D_m * M_m)) / ((-2.0 * d) * l))))
                                            	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(M_m * D_m) / Float64(2.0 * d)) <= 1e+76)
                                            		tmp = Float64(w0 * 1.0);
                                            	else
                                            		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(Float64(D_m * M_m) * h) * Float64(Float64(-D_m) * M_m)) / Float64(Float64(-2.0 * d) * l)))));
                                            	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)) <= 1e+76)
                                            		tmp = w0 * 1.0;
                                            	else
                                            		tmp = w0 * sqrt((1.0 - ((((D_m * M_m) * h) * (-D_m * M_m)) / ((-2.0 * d) * l))));
                                            	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[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 1e+76], N[(w0 * 1.0), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * h), $MachinePrecision] * N[((-D$95$m) * M$95$m), $MachinePrecision]), $MachinePrecision] / N[(N[(-2.0 * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $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}\;\frac{M\_m \cdot D\_m}{2 \cdot d} \leq 10^{+76}:\\
                                            \;\;\;\;w0 \cdot 1\\
                                            
                                            \mathbf{else}:\\
                                            \;\;\;\;w0 \cdot \sqrt{1 - \frac{\left(\left(D\_m \cdot M\_m\right) \cdot h\right) \cdot \left(\left(-D\_m\right) \cdot M\_m\right)}{\left(-2 \cdot d\right) \cdot \ell}}\\
                                            
                                            
                                            \end{array}
                                            \end{array}
                                            
                                            Derivation
                                            1. Split input into 2 regimes
                                            2. if (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) < 1e76

                                              1. Initial program 87.9%

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

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

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

                                                if 1e76 < (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d))

                                                1. Initial program 52.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                Alternative 14: 87.3% accurate, 1.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}\;M\_m \cdot D\_m \leq 2 \cdot 10^{-183}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \left(D\_m \cdot \frac{h \cdot M\_m}{4 \cdot d}\right) \cdot \frac{D\_m \cdot \frac{M\_m}{d}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{\frac{M\_m}{d} \cdot D\_m}{\ell} \cdot \left(\left(M\_m \cdot D\_m\right) \cdot \frac{h}{4 \cdot d}\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 (<= (* M_m D_m) 2e-183)
                                                   (*
                                                    w0
                                                    (sqrt (- 1.0 (* (* D_m (/ (* h M_m) (* 4.0 d))) (/ (* D_m (/ M_m d)) l)))))
                                                   (*
                                                    w0
                                                    (sqrt
                                                     (- 1.0 (* (/ (* (/ M_m d) D_m) l) (* (* M_m D_m) (/ h (* 4.0 d)))))))))
                                                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 ((M_m * D_m) <= 2e-183) {
                                                		tmp = w0 * sqrt((1.0 - ((D_m * ((h * M_m) / (4.0 * d))) * ((D_m * (M_m / d)) / l))));
                                                	} else {
                                                		tmp = w0 * sqrt((1.0 - ((((M_m / d) * D_m) / l) * ((M_m * D_m) * (h / (4.0 * d))))));
                                                	}
                                                	return tmp;
                                                }
                                                
                                                D_m =     private
                                                M_m =     private
                                                NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
                                                module fmin_fmax_functions
                                                    implicit none
                                                    private
                                                    public fmax
                                                    public fmin
                                                
                                                    interface fmax
                                                        module procedure fmax88
                                                        module procedure fmax44
                                                        module procedure fmax84
                                                        module procedure fmax48
                                                    end interface
                                                    interface fmin
                                                        module procedure fmin88
                                                        module procedure fmin44
                                                        module procedure fmin84
                                                        module procedure fmin48
                                                    end interface
                                                contains
                                                    real(8) function fmax88(x, y) result (res)
                                                        real(8), intent (in) :: x
                                                        real(8), intent (in) :: y
                                                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                    end function
                                                    real(4) function fmax44(x, y) result (res)
                                                        real(4), intent (in) :: x
                                                        real(4), intent (in) :: y
                                                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                    end function
                                                    real(8) function fmax84(x, y) result(res)
                                                        real(8), intent (in) :: x
                                                        real(4), intent (in) :: y
                                                        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                                    end function
                                                    real(8) function fmax48(x, y) result(res)
                                                        real(4), intent (in) :: x
                                                        real(8), intent (in) :: y
                                                        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                                    end function
                                                    real(8) function fmin88(x, y) result (res)
                                                        real(8), intent (in) :: x
                                                        real(8), intent (in) :: y
                                                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                    end function
                                                    real(4) function fmin44(x, y) result (res)
                                                        real(4), intent (in) :: x
                                                        real(4), intent (in) :: y
                                                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                    end function
                                                    real(8) function fmin84(x, y) result(res)
                                                        real(8), intent (in) :: x
                                                        real(4), intent (in) :: y
                                                        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                                    end function
                                                    real(8) function fmin48(x, y) result(res)
                                                        real(4), intent (in) :: x
                                                        real(8), intent (in) :: y
                                                        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                                    end function
                                                end module
                                                
                                                real(8) function code(w0, m_m, d_m, h, l, d)
                                                use fmin_fmax_functions
                                                    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) <= 2d-183) then
                                                        tmp = w0 * sqrt((1.0d0 - ((d_m * ((h * m_m) / (4.0d0 * d))) * ((d_m * (m_m / d)) / l))))
                                                    else
                                                        tmp = w0 * sqrt((1.0d0 - ((((m_m / d) * d_m) / l) * ((m_m * d_m) * (h / (4.0d0 * d))))))
                                                    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 ((M_m * D_m) <= 2e-183) {
                                                		tmp = w0 * Math.sqrt((1.0 - ((D_m * ((h * M_m) / (4.0 * d))) * ((D_m * (M_m / d)) / l))));
                                                	} else {
                                                		tmp = w0 * Math.sqrt((1.0 - ((((M_m / d) * D_m) / l) * ((M_m * D_m) * (h / (4.0 * d))))));
                                                	}
                                                	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 (M_m * D_m) <= 2e-183:
                                                		tmp = w0 * math.sqrt((1.0 - ((D_m * ((h * M_m) / (4.0 * d))) * ((D_m * (M_m / d)) / l))))
                                                	else:
                                                		tmp = w0 * math.sqrt((1.0 - ((((M_m / d) * D_m) / l) * ((M_m * D_m) * (h / (4.0 * d))))))
                                                	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(M_m * D_m) <= 2e-183)
                                                		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(D_m * Float64(Float64(h * M_m) / Float64(4.0 * d))) * Float64(Float64(D_m * Float64(M_m / d)) / l)))));
                                                	else
                                                		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(Float64(M_m / d) * D_m) / l) * Float64(Float64(M_m * D_m) * Float64(h / Float64(4.0 * d)))))));
                                                	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) <= 2e-183)
                                                		tmp = w0 * sqrt((1.0 - ((D_m * ((h * M_m) / (4.0 * d))) * ((D_m * (M_m / d)) / l))));
                                                	else
                                                		tmp = w0 * sqrt((1.0 - ((((M_m / d) * D_m) / l) * ((M_m * D_m) * (h / (4.0 * d))))));
                                                	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[(M$95$m * D$95$m), $MachinePrecision], 2e-183], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(D$95$m * N[(N[(h * M$95$m), $MachinePrecision] / N[(4.0 * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(N[(M$95$m / d), $MachinePrecision] * D$95$m), $MachinePrecision] / l), $MachinePrecision] * N[(N[(M$95$m * D$95$m), $MachinePrecision] * N[(h / N[(4.0 * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $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}\;M\_m \cdot D\_m \leq 2 \cdot 10^{-183}:\\
                                                \;\;\;\;w0 \cdot \sqrt{1 - \left(D\_m \cdot \frac{h \cdot M\_m}{4 \cdot d}\right) \cdot \frac{D\_m \cdot \frac{M\_m}{d}}{\ell}}\\
                                                
                                                \mathbf{else}:\\
                                                \;\;\;\;w0 \cdot \sqrt{1 - \frac{\frac{M\_m}{d} \cdot D\_m}{\ell} \cdot \left(\left(M\_m \cdot D\_m\right) \cdot \frac{h}{4 \cdot d}\right)}\\
                                                
                                                
                                                \end{array}
                                                \end{array}
                                                
                                                Derivation
                                                1. Split input into 2 regimes
                                                2. if (*.f64 M D) < 2.00000000000000001e-183

                                                  1. Initial program 83.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                  if 2.00000000000000001e-183 < (*.f64 M D)

                                                  1. Initial program 81.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                Alternative 15: 67.5% 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 =     private
                                                M_m =     private
                                                NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
                                                module fmin_fmax_functions
                                                    implicit none
                                                    private
                                                    public fmax
                                                    public fmin
                                                
                                                    interface fmax
                                                        module procedure fmax88
                                                        module procedure fmax44
                                                        module procedure fmax84
                                                        module procedure fmax48
                                                    end interface
                                                    interface fmin
                                                        module procedure fmin88
                                                        module procedure fmin44
                                                        module procedure fmin84
                                                        module procedure fmin48
                                                    end interface
                                                contains
                                                    real(8) function fmax88(x, y) result (res)
                                                        real(8), intent (in) :: x
                                                        real(8), intent (in) :: y
                                                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                    end function
                                                    real(4) function fmax44(x, y) result (res)
                                                        real(4), intent (in) :: x
                                                        real(4), intent (in) :: y
                                                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                    end function
                                                    real(8) function fmax84(x, y) result(res)
                                                        real(8), intent (in) :: x
                                                        real(4), intent (in) :: y
                                                        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                                    end function
                                                    real(8) function fmax48(x, y) result(res)
                                                        real(4), intent (in) :: x
                                                        real(8), intent (in) :: y
                                                        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                                    end function
                                                    real(8) function fmin88(x, y) result (res)
                                                        real(8), intent (in) :: x
                                                        real(8), intent (in) :: y
                                                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                    end function
                                                    real(4) function fmin44(x, y) result (res)
                                                        real(4), intent (in) :: x
                                                        real(4), intent (in) :: y
                                                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                    end function
                                                    real(8) function fmin84(x, y) result(res)
                                                        real(8), intent (in) :: x
                                                        real(4), intent (in) :: y
                                                        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                                    end function
                                                    real(8) function fmin48(x, y) result(res)
                                                        real(4), intent (in) :: x
                                                        real(8), intent (in) :: y
                                                        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                                    end function
                                                end module
                                                
                                                real(8) function code(w0, m_m, d_m, h, l, d)
                                                use fmin_fmax_functions
                                                    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 82.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}{1} \]
                                                4. Step-by-step derivation
                                                  1. Applied rewrites69.5%

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

                                                  Reproduce

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