Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 81.3% → 87.7%
Time: 6.8s
Alternatives: 11
Speedup: 0.7×

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}

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 11 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.3% 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: 87.7% accurate, 0.6× speedup?

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

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


\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)) < 0.0

    1. Initial program 81.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 81.3%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. 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. 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(M \cdot D\right)}{2 \cdot d}}} \]
      8. 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(M \cdot D\right)}{2 \cdot d}}} \]
    3. Applied rewrites84.3%

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

Alternative 2: 86.6% accurate, 0.5× speedup?

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

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


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

    1. Initial program 81.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{M \cdot D}{d} \cdot \frac{\color{blue}{D \cdot M}}{d}}{4} \cdot \frac{h}{\ell}} \]
      5. lower-/.f6481.3

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

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

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{M \cdot D}{d} \cdot \frac{\color{blue}{M \cdot D}}{d}}{4} \cdot \frac{h}{\ell}} \]
      8. lower-*.f6481.3

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{M \cdot D}{d} \cdot \frac{\color{blue}{M \cdot D}}{d}}{4} \cdot \frac{h}{\ell}} \]
    7. Applied rewrites81.3%

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

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

    1. Initial program 81.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 85.3% accurate, 0.5× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\ \\ \begin{array}{l} t_0 := \frac{M\_m \cdot D\_m}{d}\\ \mathbf{if}\;w0 \cdot \sqrt{1 - {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \leq 2 \cdot 10^{+302}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{t\_0 \cdot t\_0}{4} \cdot \frac{h}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{\left(\left(D\_m \cdot M\_m\right) \cdot \left(0.25 \cdot M\_m\right)\right) \cdot \left(h \cdot D\_m\right)}{d \cdot \left(\ell \cdot d\right)}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
 :precision binary64
 (let* ((t_0 (/ (* M_m D_m) d)))
   (if (<=
        (* w0 (sqrt (- 1.0 (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ h l)))))
        2e+302)
     (* w0 (sqrt (- 1.0 (* (/ (* t_0 t_0) 4.0) (/ h l)))))
     (*
      w0
      (sqrt
       (-
        1.0
        (/ (* (* (* D_m M_m) (* 0.25 M_m)) (* h D_m)) (* d (* l d)))))))))
M_m = fabs(M);
D_m = fabs(D);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
	double t_0 = (M_m * D_m) / d;
	double tmp;
	if ((w0 * sqrt((1.0 - (pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l))))) <= 2e+302) {
		tmp = w0 * sqrt((1.0 - (((t_0 * t_0) / 4.0) * (h / l))));
	} else {
		tmp = w0 * sqrt((1.0 - ((((D_m * M_m) * (0.25 * M_m)) * (h * D_m)) / (d * (l * d)))));
	}
	return tmp;
}
M_m =     private
D_m =     private
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

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

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


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

    1. Initial program 81.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{M \cdot D}{d} \cdot \frac{\color{blue}{D \cdot M}}{d}}{4} \cdot \frac{h}{\ell}} \]
      5. lower-/.f6481.3

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

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

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{M \cdot D}{d} \cdot \frac{\color{blue}{M \cdot D}}{d}}{4} \cdot \frac{h}{\ell}} \]
      8. lower-*.f6481.3

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{M \cdot D}{d} \cdot \frac{\color{blue}{M \cdot D}}{d}}{4} \cdot \frac{h}{\ell}} \]
    7. Applied rewrites81.3%

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

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

    1. Initial program 81.3%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. 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. lift-pow.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 84.5% accurate, 0.5× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\ \\ \begin{array}{l} t_0 := \frac{D\_m}{d} \cdot M\_m\\ \mathbf{if}\;w0 \cdot \sqrt{1 - {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \leq 2 \cdot 10^{+302}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{t\_0 \cdot t\_0}{4} \cdot \frac{h}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{\left(\left(D\_m \cdot M\_m\right) \cdot \left(0.25 \cdot M\_m\right)\right) \cdot \left(h \cdot D\_m\right)}{d \cdot \left(\ell \cdot d\right)}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
 :precision binary64
 (let* ((t_0 (* (/ D_m d) M_m)))
   (if (<=
        (* w0 (sqrt (- 1.0 (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ h l)))))
        2e+302)
     (* w0 (sqrt (- 1.0 (* (/ (* t_0 t_0) 4.0) (/ h l)))))
     (*
      w0
      (sqrt
       (-
        1.0
        (/ (* (* (* D_m M_m) (* 0.25 M_m)) (* h D_m)) (* d (* l d)))))))))
M_m = fabs(M);
D_m = fabs(D);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
	double t_0 = (D_m / d) * M_m;
	double tmp;
	if ((w0 * sqrt((1.0 - (pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l))))) <= 2e+302) {
		tmp = w0 * sqrt((1.0 - (((t_0 * t_0) / 4.0) * (h / l))));
	} else {
		tmp = w0 * sqrt((1.0 - ((((D_m * M_m) * (0.25 * M_m)) * (h * D_m)) / (d * (l * d)))));
	}
	return tmp;
}
M_m =     private
D_m =     private
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

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

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


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

    1. Initial program 81.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 81.3%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. 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. lift-pow.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 84.4% accurate, 0.5× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;w0 \cdot \sqrt{1 - {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \leq 2 \cdot 10^{+302}:\\ \;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(\left(\left(\left(\frac{D\_m}{d} \cdot M\_m\right) \cdot M\_m\right) \cdot -0.25\right) \cdot \frac{h}{\ell}, \frac{D\_m}{d}, 1\right)}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{\left(\left(D\_m \cdot M\_m\right) \cdot \left(0.25 \cdot M\_m\right)\right) \cdot \left(h \cdot D\_m\right)}{d \cdot \left(\ell \cdot d\right)}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
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 (<=
      (* w0 (sqrt (- 1.0 (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ h l)))))
      2e+302)
   (*
    w0
    (sqrt (fma (* (* (* (* (/ D_m d) M_m) M_m) -0.25) (/ h l)) (/ D_m d) 1.0)))
   (*
    w0
    (sqrt
     (- 1.0 (/ (* (* (* D_m M_m) (* 0.25 M_m)) (* h D_m)) (* d (* l d))))))))
M_m = fabs(M);
D_m = fabs(D);
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 ((w0 * sqrt((1.0 - (pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l))))) <= 2e+302) {
		tmp = w0 * sqrt(fma((((((D_m / d) * M_m) * M_m) * -0.25) * (h / l)), (D_m / d), 1.0));
	} else {
		tmp = w0 * sqrt((1.0 - ((((D_m * M_m) * (0.25 * M_m)) * (h * D_m)) / (d * (l * d)))));
	}
	return tmp;
}
M_m = abs(M)
D_m = abs(D)
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(w0 * sqrt(Float64(1.0 - Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l))))) <= 2e+302)
		tmp = Float64(w0 * sqrt(fma(Float64(Float64(Float64(Float64(Float64(D_m / d) * M_m) * M_m) * -0.25) * Float64(h / l)), Float64(D_m / d), 1.0)));
	else
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(Float64(D_m * M_m) * Float64(0.25 * M_m)) * Float64(h * D_m)) / Float64(d * Float64(l * d))))));
	end
	return tmp
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $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[(w0 * N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2e+302], N[(w0 * N[Sqrt[N[(N[(N[(N[(N[(N[(D$95$m / d), $MachinePrecision] * M$95$m), $MachinePrecision] * M$95$m), $MachinePrecision] * -0.25), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * N[(0.25 * M$95$m), $MachinePrecision]), $MachinePrecision] * N[(h * D$95$m), $MachinePrecision]), $MachinePrecision] / N[(d * N[(l * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;w0 \cdot \sqrt{1 - {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \leq 2 \cdot 10^{+302}:\\
\;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(\left(\left(\left(\frac{D\_m}{d} \cdot M\_m\right) \cdot M\_m\right) \cdot -0.25\right) \cdot \frac{h}{\ell}, \frac{D\_m}{d}, 1\right)}\\

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


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

    1. Initial program 81.3%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. 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. lift-pow.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 81.3%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. 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. lift-pow.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 83.7% accurate, 0.4× speedup?

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

\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+51}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(\left(\left(\frac{D\_m}{d} \cdot M\_m\right) \cdot M\_m\right) \cdot -0.25, D\_m \cdot \frac{h}{\ell \cdot d}, 1\right)} \cdot w0\\

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


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

    1. Initial program 81.3%

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

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

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

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

      1. Initial program 81.3%

        \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
      2. 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. lift-pow.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      if 2e51 < (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 81.3%

        \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
      2. 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. lift-pow.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 7: 83.2% accurate, 0.7× speedup?

    \[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\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} \leq 4 \cdot 10^{-237}:\\ \;\;\;\;w0 \cdot 1\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(\left(\left(\frac{D\_m}{d} \cdot M\_m\right) \cdot M\_m\right) \cdot -0.25, D\_m \cdot \frac{h}{\ell \cdot d}, 1\right)} \cdot w0\\ \end{array} \end{array} \]
    M_m = (fabs.f64 M)
    D_m = (fabs.f64 D)
    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) 4e-237)
       (* w0 1.0)
       (*
        (sqrt (fma (* (* (* (/ D_m d) M_m) M_m) -0.25) (* D_m (/ h (* l d))) 1.0))
        w0)))
    M_m = fabs(M);
    D_m = fabs(D);
    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) <= 4e-237) {
    		tmp = w0 * 1.0;
    	} else {
    		tmp = sqrt(fma(((((D_m / d) * M_m) * M_m) * -0.25), (D_m * (h / (l * d))), 1.0)) * w0;
    	}
    	return tmp;
    }
    
    M_m = abs(M)
    D_m = abs(D)
    w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d])
    function code(w0, M_m, D_m, h, l, d)
    	tmp = 0.0
    	if ((Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0) <= 4e-237)
    		tmp = Float64(w0 * 1.0);
    	else
    		tmp = Float64(sqrt(fma(Float64(Float64(Float64(Float64(D_m / d) * M_m) * M_m) * -0.25), Float64(D_m * Float64(h / Float64(l * d))), 1.0)) * w0);
    	end
    	return tmp
    end
    
    M_m = N[Abs[M], $MachinePrecision]
    D_m = N[Abs[D], $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[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], 4e-237], N[(w0 * 1.0), $MachinePrecision], N[(N[Sqrt[N[(N[(N[(N[(N[(D$95$m / d), $MachinePrecision] * M$95$m), $MachinePrecision] * M$95$m), $MachinePrecision] * -0.25), $MachinePrecision] * N[(D$95$m * N[(h / N[(l * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision] * w0), $MachinePrecision]]
    
    \begin{array}{l}
    M_m = \left|M\right|
    \\
    D_m = \left|D\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} \leq 4 \cdot 10^{-237}:\\
    \;\;\;\;w0 \cdot 1\\
    
    \mathbf{else}:\\
    \;\;\;\;\sqrt{\mathsf{fma}\left(\left(\left(\frac{D\_m}{d} \cdot M\_m\right) \cdot M\_m\right) \cdot -0.25, D\_m \cdot \frac{h}{\ell \cdot d}, 1\right)} \cdot w0\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) < 4e-237

      1. Initial program 81.3%

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

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

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

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

        1. Initial program 81.3%

          \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
        2. 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. lift-pow.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      Alternative 8: 82.4% accurate, 0.4× speedup?

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

        1. Initial program 81.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        1. Initial program 81.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        1. Initial program 81.3%

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

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

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

        Alternative 9: 82.3% accurate, 0.6× speedup?

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

          1. Initial program 81.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          1. Initial program 81.3%

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

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

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

          Alternative 10: 82.1% accurate, 0.6× speedup?

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

            1. Initial program 81.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            1. Initial program 81.3%

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

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

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

            Alternative 11: 67.9% accurate, 10.1× speedup?

            \[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\ \\ w0 \cdot 1 \end{array} \]
            M_m = (fabs.f64 M)
            D_m = (fabs.f64 D)
            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))
            M_m = fabs(M);
            D_m = fabs(D);
            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;
            }
            
            M_m =     private
            D_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
            
            M_m = Math.abs(M);
            D_m = Math.abs(D);
            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;
            }
            
            M_m = math.fabs(M)
            D_m = math.fabs(D)
            [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
            
            M_m = abs(M)
            D_m = abs(D)
            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
            
            M_m = abs(M);
            D_m = abs(D);
            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
            
            M_m = N[Abs[M], $MachinePrecision]
            D_m = N[Abs[D], $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}
            M_m = \left|M\right|
            \\
            D_m = \left|D\right|
            \\
            [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
            \\
            w0 \cdot 1
            \end{array}
            
            Derivation
            1. Initial program 81.3%

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

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

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

              Reproduce

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