Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 81.1% → 89.7%
Time: 10.5s
Alternatives: 9
Speedup: 2.0×

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 9 alternatives:

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

Initial Program: 81.1% 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: 89.7% accurate, 2.0× 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 \sqrt{1 + \frac{h \cdot \left(\frac{M\_m}{d} \cdot D\_m\right)}{\ell \cdot -4} \cdot \left(D\_m \cdot \frac{M\_m}{d}\right)} \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
  (sqrt (+ 1.0 (* (/ (* h (* (/ M_m d) D_m)) (* l -4.0)) (* D_m (/ M_m 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) {
	return w0 * sqrt((1.0 + (((h * ((M_m / d) * D_m)) / (l * -4.0)) * (D_m * (M_m / d)))));
}
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 * sqrt((1.0d0 + (((h * ((m_m / d) * d_m)) / (l * (-4.0d0))) * (d_m * (m_m / d)))))
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 * Math.sqrt((1.0 + (((h * ((M_m / d) * D_m)) / (l * -4.0)) * (D_m * (M_m / d)))));
}
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 * math.sqrt((1.0 + (((h * ((M_m / d) * D_m)) / (l * -4.0)) * (D_m * (M_m / d)))))
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 * sqrt(Float64(1.0 + Float64(Float64(Float64(h * Float64(Float64(M_m / d) * D_m)) / Float64(l * -4.0)) * Float64(D_m * Float64(M_m / d))))))
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 * sqrt((1.0 + (((h * ((M_m / d) * D_m)) / (l * -4.0)) * (D_m * (M_m / d)))));
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 * N[Sqrt[N[(1.0 + N[(N[(N[(h * N[(N[(M$95$m / d), $MachinePrecision] * D$95$m), $MachinePrecision]), $MachinePrecision] / N[(l * -4.0), $MachinePrecision]), $MachinePrecision] * N[(D$95$m * N[(M$95$m / d), $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])\\
\\
w0 \cdot \sqrt{1 + \frac{h \cdot \left(\frac{M\_m}{d} \cdot D\_m\right)}{\ell \cdot -4} \cdot \left(D\_m \cdot \frac{M\_m}{d}\right)}
\end{array}
Derivation
  1. Initial program 80.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 83.7% 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 1000:\\ \;\;\;\;w0 \cdot 1\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 + \frac{\left(M\_m \cdot D\_m\right) \cdot \left(\left(M\_m \cdot D\_m\right) \cdot h\right)}{d \cdot \left(\left(-4 \cdot d\right) \cdot \ell\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 (<= (sqrt (- 1.0 (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ h l)))) 1000.0)
   (* w0 1.0)
   (*
    w0
    (sqrt
     (+ 1.0 (/ (* (* M_m D_m) (* (* M_m D_m) h)) (* d (* (* -4.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)))) <= 1000.0) {
		tmp = w0 * 1.0;
	} else {
		tmp = w0 * sqrt((1.0 + (((M_m * D_m) * ((M_m * D_m) * h)) / (d * ((-4.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)))) <= 1000.0d0) then
        tmp = w0 * 1.0d0
    else
        tmp = w0 * sqrt((1.0d0 + (((m_m * d_m) * ((m_m * d_m) * h)) / (d * (((-4.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)))) <= 1000.0) {
		tmp = w0 * 1.0;
	} else {
		tmp = w0 * Math.sqrt((1.0 + (((M_m * D_m) * ((M_m * D_m) * h)) / (d * ((-4.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)))) <= 1000.0:
		tmp = w0 * 1.0
	else:
		tmp = w0 * math.sqrt((1.0 + (((M_m * D_m) * ((M_m * D_m) * h)) / (d * ((-4.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)))) <= 1000.0)
		tmp = Float64(w0 * 1.0);
	else
		tmp = Float64(w0 * sqrt(Float64(1.0 + Float64(Float64(Float64(M_m * D_m) * Float64(Float64(M_m * D_m) * h)) / Float64(d * Float64(Float64(-4.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)))) <= 1000.0)
		tmp = w0 * 1.0;
	else
		tmp = w0 * sqrt((1.0 + (((M_m * D_m) * ((M_m * D_m) * h)) / (d * ((-4.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], 1000.0], N[(w0 * 1.0), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 + N[(N[(N[(M$95$m * D$95$m), $MachinePrecision] * N[(N[(M$95$m * D$95$m), $MachinePrecision] * h), $MachinePrecision]), $MachinePrecision] / N[(d * N[(N[(-4.0 * d), $MachinePrecision] * l), $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}\;\sqrt{1 - {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \leq 1000:\\
\;\;\;\;w0 \cdot 1\\

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


\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)))) < 1e3

    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 rewrites98.9%

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

      if 1e3 < (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 48.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 3: 79.8% accurate, 0.8× speedup?

    \[\begin{array}{l} D_m = \left|D\right| \\ M_m = \left|M\right| \\ [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;{\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -5 \cdot 10^{-9}:\\ \;\;\;\;w0 \cdot \mathsf{fma}\left(\left(D\_m \cdot D\_m\right) \cdot -0.125, \frac{M\_m}{d} \cdot \frac{h \cdot M\_m}{\ell \cdot d}, 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)) -5e-9)
       (* w0 (fma (* (* D_m D_m) -0.125) (* (/ M_m d) (/ (* h M_m) (* l d))) 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)) <= -5e-9) {
    		tmp = w0 * fma(((D_m * D_m) * -0.125), ((M_m / d) * ((h * M_m) / (l * d))), 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)) <= -5e-9)
    		tmp = Float64(w0 * fma(Float64(Float64(D_m * D_m) * -0.125), Float64(Float64(M_m / d) * Float64(Float64(h * M_m) / Float64(l * d))), 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], -5e-9], N[(w0 * N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] * -0.125), $MachinePrecision] * N[(N[(M$95$m / d), $MachinePrecision] * N[(N[(h * M$95$m), $MachinePrecision] / N[(l * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(w0 * 1.0), $MachinePrecision]]
    
    \begin{array}{l}
    D_m = \left|D\right|
    \\
    M_m = \left|M\right|
    \\
    [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
    \\
    \begin{array}{l}
    \mathbf{if}\;{\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -5 \cdot 10^{-9}:\\
    \;\;\;\;w0 \cdot \mathsf{fma}\left(\left(D\_m \cdot D\_m\right) \cdot -0.125, \frac{M\_m}{d} \cdot \frac{h \cdot M\_m}{\ell \cdot d}, 1\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;w0 \cdot 1\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < -5.0000000000000001e-9

      1. Initial program 61.0%

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

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

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

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

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

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

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

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

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

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

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

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

        1. Initial program 89.8%

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

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

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

        Alternative 4: 79.2% 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 -5 \cdot 10^{+195}:\\ \;\;\;\;w0 \cdot \mathsf{fma}\left(\left(D\_m \cdot D\_m\right) \cdot -0.125, M\_m \cdot \frac{h \cdot M\_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
         (if (<= (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ h l)) -5e+195)
           (* w0 (fma (* (* D_m D_m) -0.125) (* M_m (/ (* h M_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 tmp;
        	if ((pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)) <= -5e+195) {
        		tmp = w0 * fma(((D_m * D_m) * -0.125), (M_m * ((h * M_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)
        	tmp = 0.0
        	if (Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= -5e+195)
        		tmp = Float64(w0 * fma(Float64(Float64(D_m * D_m) * -0.125), Float64(M_m * Float64(Float64(h * M_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_] := 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+195], N[(w0 * N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] * -0.125), $MachinePrecision] * N[(M$95$m * N[(N[(h * M$95$m), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(w0 * 1.0), $MachinePrecision]]
        
        \begin{array}{l}
        D_m = \left|D\right|
        \\
        M_m = \left|M\right|
        \\
        [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
        \\
        \begin{array}{l}
        \mathbf{if}\;{\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -5 \cdot 10^{+195}:\\
        \;\;\;\;w0 \cdot \mathsf{fma}\left(\left(D\_m \cdot D\_m\right) \cdot -0.125, M\_m \cdot \frac{h \cdot M\_m}{\left(d \cdot d\right) \cdot \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)) < -4.9999999999999998e195

          1. Initial program 52.3%

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

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

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

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

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

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

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

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

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

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

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

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

            1. Initial program 90.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 rewrites89.4%

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

            Alternative 5: 79.2% 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 -5 \cdot 10^{+195}:\\ \;\;\;\;\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)) -5e+195)
               (* (/ (* 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)) <= -5e+195) {
            		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)) <= (-5d+195)) 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)) <= -5e+195) {
            		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)) <= -5e+195:
            		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)) <= -5e+195)
            		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)) <= -5e+195)
            		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], -5e+195], 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 -5 \cdot 10^{+195}:\\
            \;\;\;\;\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)) < -4.9999999999999998e195

              1. Initial program 52.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{\left(\left(\frac{h}{\ell} \cdot D\right) \cdot \frac{\frac{M}{d}}{2}\right) \cdot \left(\left(-M\right) \cdot D\right)}{-2 \cdot d}}} \]
              5. 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}} \]
              6. 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-*.f6435.8

                  \[\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) \]
              7. Applied rewrites35.8%

                \[\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)} \]
              8. 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}} \]
              9. Step-by-step derivation
                1. Applied rewrites35.8%

                  \[\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 rewrites39.2%

                    \[\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 -4.9999999999999998e195 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l))

                  1. Initial program 90.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 rewrites89.4%

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

                  Alternative 6: 86.4% accurate, 1.9× 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}\;D\_m \leq 1.25 \cdot 10^{-80}:\\ \;\;\;\;w0 \cdot \sqrt{1 + \frac{M\_m}{d} \cdot \left(D\_m \cdot \left(\frac{M\_m \cdot h}{\ell} \cdot \frac{D\_m}{-4 \cdot d}\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 + D\_m \cdot \frac{\left(\frac{M\_m}{d} \cdot h\right) \cdot \left(M\_m \cdot D\_m\right)}{\left(-4 \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 (<= D_m 1.25e-80)
                     (*
                      w0
                      (sqrt
                       (+ 1.0 (* (/ M_m d) (* D_m (* (/ (* M_m h) l) (/ D_m (* -4.0 d))))))))
                     (*
                      w0
                      (sqrt
                       (+ 1.0 (* D_m (/ (* (* (/ M_m d) h) (* M_m D_m)) (* (* -4.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 (D_m <= 1.25e-80) {
                  		tmp = w0 * sqrt((1.0 + ((M_m / d) * (D_m * (((M_m * h) / l) * (D_m / (-4.0 * d)))))));
                  	} else {
                  		tmp = w0 * sqrt((1.0 + (D_m * ((((M_m / d) * h) * (M_m * D_m)) / ((-4.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 (d_m <= 1.25d-80) then
                          tmp = w0 * sqrt((1.0d0 + ((m_m / d) * (d_m * (((m_m * h) / l) * (d_m / ((-4.0d0) * d)))))))
                      else
                          tmp = w0 * sqrt((1.0d0 + (d_m * ((((m_m / d) * h) * (m_m * d_m)) / (((-4.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 (D_m <= 1.25e-80) {
                  		tmp = w0 * Math.sqrt((1.0 + ((M_m / d) * (D_m * (((M_m * h) / l) * (D_m / (-4.0 * d)))))));
                  	} else {
                  		tmp = w0 * Math.sqrt((1.0 + (D_m * ((((M_m / d) * h) * (M_m * D_m)) / ((-4.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 D_m <= 1.25e-80:
                  		tmp = w0 * math.sqrt((1.0 + ((M_m / d) * (D_m * (((M_m * h) / l) * (D_m / (-4.0 * d)))))))
                  	else:
                  		tmp = w0 * math.sqrt((1.0 + (D_m * ((((M_m / d) * h) * (M_m * D_m)) / ((-4.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 (D_m <= 1.25e-80)
                  		tmp = Float64(w0 * sqrt(Float64(1.0 + Float64(Float64(M_m / d) * Float64(D_m * Float64(Float64(Float64(M_m * h) / l) * Float64(D_m / Float64(-4.0 * d))))))));
                  	else
                  		tmp = Float64(w0 * sqrt(Float64(1.0 + Float64(D_m * Float64(Float64(Float64(Float64(M_m / d) * h) * Float64(M_m * D_m)) / Float64(Float64(-4.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 (D_m <= 1.25e-80)
                  		tmp = w0 * sqrt((1.0 + ((M_m / d) * (D_m * (((M_m * h) / l) * (D_m / (-4.0 * d)))))));
                  	else
                  		tmp = w0 * sqrt((1.0 + (D_m * ((((M_m / d) * h) * (M_m * D_m)) / ((-4.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[D$95$m, 1.25e-80], N[(w0 * N[Sqrt[N[(1.0 + N[(N[(M$95$m / d), $MachinePrecision] * N[(D$95$m * N[(N[(N[(M$95$m * h), $MachinePrecision] / l), $MachinePrecision] * N[(D$95$m / N[(-4.0 * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 + N[(D$95$m * N[(N[(N[(N[(M$95$m / d), $MachinePrecision] * h), $MachinePrecision] * N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] / N[(N[(-4.0 * d), $MachinePrecision] * l), $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}\;D\_m \leq 1.25 \cdot 10^{-80}:\\
                  \;\;\;\;w0 \cdot \sqrt{1 + \frac{M\_m}{d} \cdot \left(D\_m \cdot \left(\frac{M\_m \cdot h}{\ell} \cdot \frac{D\_m}{-4 \cdot d}\right)\right)}\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;w0 \cdot \sqrt{1 + D\_m \cdot \frac{\left(\frac{M\_m}{d} \cdot h\right) \cdot \left(M\_m \cdot D\_m\right)}{\left(-4 \cdot d\right) \cdot \ell}}\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if D < 1.25e-80

                    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. Step-by-step derivation
                      1. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    if 1.25e-80 < D

                    1. Initial program 77.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    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 rewrites71.6%

                      \[\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. Step-by-step derivation
                      1. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

                    if 1.25e-80 < D

                    1. Initial program 77.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  Alternative 8: 86.4% accurate, 1.9× 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^{-286}:\\ \;\;\;\;w0 \cdot 1\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 + D\_m \cdot \frac{\left(\frac{M\_m}{d} \cdot h\right) \cdot \left(M\_m \cdot D\_m\right)}{\left(-4 \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) 2e-286)
                     (* w0 1.0)
                     (*
                      w0
                      (sqrt
                       (+ 1.0 (* D_m (/ (* (* (/ M_m d) h) (* M_m D_m)) (* (* -4.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) <= 2e-286) {
                  		tmp = w0 * 1.0;
                  	} else {
                  		tmp = w0 * sqrt((1.0 + (D_m * ((((M_m / d) * h) * (M_m * D_m)) / ((-4.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) <= 2d-286) then
                          tmp = w0 * 1.0d0
                      else
                          tmp = w0 * sqrt((1.0d0 + (d_m * ((((m_m / d) * h) * (m_m * d_m)) / (((-4.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) <= 2e-286) {
                  		tmp = w0 * 1.0;
                  	} else {
                  		tmp = w0 * Math.sqrt((1.0 + (D_m * ((((M_m / d) * h) * (M_m * D_m)) / ((-4.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) <= 2e-286:
                  		tmp = w0 * 1.0
                  	else:
                  		tmp = w0 * math.sqrt((1.0 + (D_m * ((((M_m / d) * h) * (M_m * D_m)) / ((-4.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(M_m * D_m) <= 2e-286)
                  		tmp = Float64(w0 * 1.0);
                  	else
                  		tmp = Float64(w0 * sqrt(Float64(1.0 + Float64(D_m * Float64(Float64(Float64(Float64(M_m / d) * h) * Float64(M_m * D_m)) / Float64(Float64(-4.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) <= 2e-286)
                  		tmp = w0 * 1.0;
                  	else
                  		tmp = w0 * sqrt((1.0 + (D_m * ((((M_m / d) * h) * (M_m * D_m)) / ((-4.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[(M$95$m * D$95$m), $MachinePrecision], 2e-286], N[(w0 * 1.0), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 + N[(D$95$m * N[(N[(N[(N[(M$95$m / d), $MachinePrecision] * h), $MachinePrecision] * N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] / N[(N[(-4.0 * d), $MachinePrecision] * l), $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^{-286}:\\
                  \;\;\;\;w0 \cdot 1\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;w0 \cdot \sqrt{1 + D\_m \cdot \frac{\left(\frac{M\_m}{d} \cdot h\right) \cdot \left(M\_m \cdot D\_m\right)}{\left(-4 \cdot d\right) \cdot \ell}}\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if (*.f64 M D) < 2.0000000000000001e-286

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

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

                      if 2.0000000000000001e-286 < (*.f64 M D)

                      1. Initial program 79.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    Alternative 9: 68.1% 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 80.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 rewrites67.9%

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

                      Reproduce

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