Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 80.2% → 89.3%
Time: 11.1s
Alternatives: 18
Speedup: 2.0×

Specification

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

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

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 18 alternatives:

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

Initial Program: 80.2% accurate, 1.0× speedup?

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

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

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

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

Alternative 1: 89.3% accurate, 1.9× speedup?

\[\begin{array}{l} D_m = \left|D\right| \\ M_m = \left|M\right| \\ [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\ \\ w0 \cdot \sqrt{1 - \left(\frac{\left(D\_m \cdot \frac{M\_m}{d}\right) \cdot h}{\ell} \cdot \frac{M\_m}{d}\right) \cdot \frac{D\_m}{4}} \end{array} \]
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
 :precision binary64
 (*
  w0
  (sqrt (- 1.0 (* (* (/ (* (* D_m (/ M_m d)) h) l) (/ M_m d)) (/ D_m 4.0))))))
D_m = fabs(D);
M_m = fabs(M);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
	return w0 * sqrt((1.0 - (((((D_m * (M_m / d)) * h) / l) * (M_m / d)) * (D_m / 4.0))));
}
D_m =     private
M_m =     private
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(w0, m_m, d_m, h, l, d)
use fmin_fmax_functions
    real(8), intent (in) :: w0
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d
    code = w0 * sqrt((1.0d0 - (((((d_m * (m_m / d)) * h) / l) * (m_m / d)) * (d_m / 4.0d0))))
end function
D_m = Math.abs(D);
M_m = Math.abs(M);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
	return w0 * Math.sqrt((1.0 - (((((D_m * (M_m / d)) * h) / l) * (M_m / d)) * (D_m / 4.0))));
}
D_m = math.fabs(D)
M_m = math.fabs(M)
[w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d])
def code(w0, M_m, D_m, h, l, d):
	return w0 * math.sqrt((1.0 - (((((D_m * (M_m / d)) * h) / l) * (M_m / d)) * (D_m / 4.0))))
D_m = abs(D)
M_m = abs(M)
w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d])
function code(w0, M_m, D_m, h, l, d)
	return Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(Float64(Float64(D_m * Float64(M_m / d)) * h) / l) * Float64(M_m / d)) * Float64(D_m / 4.0)))))
end
D_m = abs(D);
M_m = abs(M);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp = code(w0, M_m, D_m, h, l, d)
	tmp = w0 * sqrt((1.0 - (((((D_m * (M_m / d)) * h) / l) * (M_m / d)) * (D_m / 4.0))));
end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(N[(N[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision] * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision] * N[(D$95$m / 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
w0 \cdot \sqrt{1 - \left(\frac{\left(D\_m \cdot \frac{M\_m}{d}\right) \cdot h}{\ell} \cdot \frac{M\_m}{d}\right) \cdot \frac{D\_m}{4}}
\end{array}
Derivation
  1. Initial program 79.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 83.0% accurate, 0.7× speedup?

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

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

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

\mathbf{else}:\\
\;\;\;\;w0 \cdot 1\\


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

    1. Initial program 62.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        1. Initial program 84.8%

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

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

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

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

        Alternative 3: 82.1% accurate, 0.7× speedup?

        \[\begin{array}{l} D_m = \left|D\right| \\ M_m = \left|M\right| \\ [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;{\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -50000000000000:\\ \;\;\;\;w0 \cdot \sqrt{\left(-0.25 \cdot \left(D\_m \cdot D\_m\right)\right) \cdot \left(\frac{h \cdot M\_m}{d} \cdot \frac{M\_m}{\ell \cdot d}\right)}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot 1\\ \end{array} \end{array} \]
        D_m = (fabs.f64 D)
        M_m = (fabs.f64 M)
        NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
        (FPCore (w0 M_m D_m h l d)
         :precision binary64
         (if (<= (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ h l)) -50000000000000.0)
           (* w0 (sqrt (* (* -0.25 (* D_m D_m)) (* (/ (* h M_m) d) (/ M_m (* l d))))))
           (* w0 1.0)))
        D_m = fabs(D);
        M_m = fabs(M);
        assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
        double code(double w0, double M_m, double D_m, double h, double l, double d) {
        	double tmp;
        	if ((pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)) <= -50000000000000.0) {
        		tmp = w0 * sqrt(((-0.25 * (D_m * D_m)) * (((h * M_m) / d) * (M_m / (l * d)))));
        	} else {
        		tmp = w0 * 1.0;
        	}
        	return tmp;
        }
        
        D_m =     private
        M_m =     private
        NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
        module fmin_fmax_functions
            implicit none
            private
            public fmax
            public fmin
        
            interface fmax
                module procedure fmax88
                module procedure fmax44
                module procedure fmax84
                module procedure fmax48
            end interface
            interface fmin
                module procedure fmin88
                module procedure fmin44
                module procedure fmin84
                module procedure fmin48
            end interface
        contains
            real(8) function fmax88(x, y) result (res)
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
            end function
            real(4) function fmax44(x, y) result (res)
                real(4), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
            end function
            real(8) function fmax84(x, y) result(res)
                real(8), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
            end function
            real(8) function fmax48(x, y) result(res)
                real(4), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
            end function
            real(8) function fmin88(x, y) result (res)
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
            end function
            real(4) function fmin44(x, y) result (res)
                real(4), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
            end function
            real(8) function fmin84(x, y) result(res)
                real(8), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
            end function
            real(8) function fmin48(x, y) result(res)
                real(4), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
            end function
        end module
        
        real(8) function code(w0, m_m, d_m, h, l, d)
        use fmin_fmax_functions
            real(8), intent (in) :: w0
            real(8), intent (in) :: m_m
            real(8), intent (in) :: d_m
            real(8), intent (in) :: h
            real(8), intent (in) :: l
            real(8), intent (in) :: d
            real(8) :: tmp
            if (((((m_m * d_m) / (2.0d0 * d)) ** 2.0d0) * (h / l)) <= (-50000000000000.0d0)) then
                tmp = w0 * sqrt((((-0.25d0) * (d_m * d_m)) * (((h * m_m) / d) * (m_m / (l * d)))))
            else
                tmp = w0 * 1.0d0
            end if
            code = tmp
        end function
        
        D_m = Math.abs(D);
        M_m = Math.abs(M);
        assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
        public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
        	double tmp;
        	if ((Math.pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)) <= -50000000000000.0) {
        		tmp = w0 * Math.sqrt(((-0.25 * (D_m * D_m)) * (((h * M_m) / d) * (M_m / (l * d)))));
        	} else {
        		tmp = w0 * 1.0;
        	}
        	return tmp;
        }
        
        D_m = math.fabs(D)
        M_m = math.fabs(M)
        [w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d])
        def code(w0, M_m, D_m, h, l, d):
        	tmp = 0
        	if (math.pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)) <= -50000000000000.0:
        		tmp = w0 * math.sqrt(((-0.25 * (D_m * D_m)) * (((h * M_m) / d) * (M_m / (l * d)))))
        	else:
        		tmp = w0 * 1.0
        	return tmp
        
        D_m = abs(D)
        M_m = abs(M)
        w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d])
        function code(w0, M_m, D_m, h, l, d)
        	tmp = 0.0
        	if (Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= -50000000000000.0)
        		tmp = Float64(w0 * sqrt(Float64(Float64(-0.25 * Float64(D_m * D_m)) * Float64(Float64(Float64(h * M_m) / d) * Float64(M_m / Float64(l * d))))));
        	else
        		tmp = Float64(w0 * 1.0);
        	end
        	return tmp
        end
        
        D_m = abs(D);
        M_m = abs(M);
        w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
        function tmp_2 = code(w0, M_m, D_m, h, l, d)
        	tmp = 0.0;
        	if (((((M_m * D_m) / (2.0 * d)) ^ 2.0) * (h / l)) <= -50000000000000.0)
        		tmp = w0 * sqrt(((-0.25 * (D_m * D_m)) * (((h * M_m) / d) * (M_m / (l * d)))));
        	else
        		tmp = w0 * 1.0;
        	end
        	tmp_2 = tmp;
        end
        
        D_m = N[Abs[D], $MachinePrecision]
        M_m = N[Abs[M], $MachinePrecision]
        NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
        code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[N[(N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -50000000000000.0], N[(w0 * N[Sqrt[N[(N[(-0.25 * N[(D$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(h * M$95$m), $MachinePrecision] / d), $MachinePrecision] * N[(M$95$m / N[(l * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * 1.0), $MachinePrecision]]
        
        \begin{array}{l}
        D_m = \left|D\right|
        \\
        M_m = \left|M\right|
        \\
        [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
        \\
        \begin{array}{l}
        \mathbf{if}\;{\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -50000000000000:\\
        \;\;\;\;w0 \cdot \sqrt{\left(-0.25 \cdot \left(D\_m \cdot D\_m\right)\right) \cdot \left(\frac{h \cdot M\_m}{d} \cdot \frac{M\_m}{\ell \cdot d}\right)}\\
        
        \mathbf{else}:\\
        \;\;\;\;w0 \cdot 1\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < -5e13

          1. Initial program 62.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            1. Initial program 84.8%

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

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

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

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

            Alternative 4: 81.6% accurate, 0.7× speedup?

            \[\begin{array}{l} D_m = \left|D\right| \\ M_m = \left|M\right| \\ [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;{\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -50000000000000:\\ \;\;\;\;w0 \cdot \sqrt{\left(-0.25 \cdot \left(D\_m \cdot D\_m\right)\right) \cdot \left(h \cdot \frac{\frac{M\_m}{d} \cdot M\_m}{\ell \cdot d}\right)}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot 1\\ \end{array} \end{array} \]
            D_m = (fabs.f64 D)
            M_m = (fabs.f64 M)
            NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
            (FPCore (w0 M_m D_m h l d)
             :precision binary64
             (if (<= (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ h l)) -50000000000000.0)
               (* w0 (sqrt (* (* -0.25 (* D_m D_m)) (* h (/ (* (/ M_m d) M_m) (* l d))))))
               (* w0 1.0)))
            D_m = fabs(D);
            M_m = fabs(M);
            assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
            double code(double w0, double M_m, double D_m, double h, double l, double d) {
            	double tmp;
            	if ((pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)) <= -50000000000000.0) {
            		tmp = w0 * sqrt(((-0.25 * (D_m * D_m)) * (h * (((M_m / d) * M_m) / (l * d)))));
            	} else {
            		tmp = w0 * 1.0;
            	}
            	return tmp;
            }
            
            D_m =     private
            M_m =     private
            NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
            module fmin_fmax_functions
                implicit none
                private
                public fmax
                public fmin
            
                interface fmax
                    module procedure fmax88
                    module procedure fmax44
                    module procedure fmax84
                    module procedure fmax48
                end interface
                interface fmin
                    module procedure fmin88
                    module procedure fmin44
                    module procedure fmin84
                    module procedure fmin48
                end interface
            contains
                real(8) function fmax88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(4) function fmax44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(8) function fmax84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmax48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                end function
                real(8) function fmin88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(4) function fmin44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(8) function fmin84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmin48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                end function
            end module
            
            real(8) function code(w0, m_m, d_m, h, l, d)
            use fmin_fmax_functions
                real(8), intent (in) :: w0
                real(8), intent (in) :: m_m
                real(8), intent (in) :: d_m
                real(8), intent (in) :: h
                real(8), intent (in) :: l
                real(8), intent (in) :: d
                real(8) :: tmp
                if (((((m_m * d_m) / (2.0d0 * d)) ** 2.0d0) * (h / l)) <= (-50000000000000.0d0)) then
                    tmp = w0 * sqrt((((-0.25d0) * (d_m * d_m)) * (h * (((m_m / d) * m_m) / (l * d)))))
                else
                    tmp = w0 * 1.0d0
                end if
                code = tmp
            end function
            
            D_m = Math.abs(D);
            M_m = Math.abs(M);
            assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
            public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
            	double tmp;
            	if ((Math.pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)) <= -50000000000000.0) {
            		tmp = w0 * Math.sqrt(((-0.25 * (D_m * D_m)) * (h * (((M_m / d) * M_m) / (l * d)))));
            	} else {
            		tmp = w0 * 1.0;
            	}
            	return tmp;
            }
            
            D_m = math.fabs(D)
            M_m = math.fabs(M)
            [w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d])
            def code(w0, M_m, D_m, h, l, d):
            	tmp = 0
            	if (math.pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)) <= -50000000000000.0:
            		tmp = w0 * math.sqrt(((-0.25 * (D_m * D_m)) * (h * (((M_m / d) * M_m) / (l * d)))))
            	else:
            		tmp = w0 * 1.0
            	return tmp
            
            D_m = abs(D)
            M_m = abs(M)
            w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d])
            function code(w0, M_m, D_m, h, l, d)
            	tmp = 0.0
            	if (Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= -50000000000000.0)
            		tmp = Float64(w0 * sqrt(Float64(Float64(-0.25 * Float64(D_m * D_m)) * Float64(h * Float64(Float64(Float64(M_m / d) * M_m) / Float64(l * d))))));
            	else
            		tmp = Float64(w0 * 1.0);
            	end
            	return tmp
            end
            
            D_m = abs(D);
            M_m = abs(M);
            w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
            function tmp_2 = code(w0, M_m, D_m, h, l, d)
            	tmp = 0.0;
            	if (((((M_m * D_m) / (2.0 * d)) ^ 2.0) * (h / l)) <= -50000000000000.0)
            		tmp = w0 * sqrt(((-0.25 * (D_m * D_m)) * (h * (((M_m / d) * M_m) / (l * d)))));
            	else
            		tmp = w0 * 1.0;
            	end
            	tmp_2 = tmp;
            end
            
            D_m = N[Abs[D], $MachinePrecision]
            M_m = N[Abs[M], $MachinePrecision]
            NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
            code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[N[(N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -50000000000000.0], N[(w0 * N[Sqrt[N[(N[(-0.25 * N[(D$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] * N[(h * N[(N[(N[(M$95$m / d), $MachinePrecision] * M$95$m), $MachinePrecision] / N[(l * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * 1.0), $MachinePrecision]]
            
            \begin{array}{l}
            D_m = \left|D\right|
            \\
            M_m = \left|M\right|
            \\
            [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
            \\
            \begin{array}{l}
            \mathbf{if}\;{\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -50000000000000:\\
            \;\;\;\;w0 \cdot \sqrt{\left(-0.25 \cdot \left(D\_m \cdot D\_m\right)\right) \cdot \left(h \cdot \frac{\frac{M\_m}{d} \cdot M\_m}{\ell \cdot d}\right)}\\
            
            \mathbf{else}:\\
            \;\;\;\;w0 \cdot 1\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < -5e13

              1. Initial program 62.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  1. Initial program 84.8%

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

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

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

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

                  Alternative 5: 80.4% accurate, 0.7× speedup?

                  \[\begin{array}{l} D_m = \left|D\right| \\ M_m = \left|M\right| \\ [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;{\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -50000000000000:\\ \;\;\;\;w0 \cdot \sqrt{\left(-0.25 \cdot \left(D\_m \cdot D\_m\right)\right) \cdot \left(h \cdot \left(\frac{M\_m}{d \cdot d} \cdot \frac{M\_m}{\ell}\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot 1\\ \end{array} \end{array} \]
                  D_m = (fabs.f64 D)
                  M_m = (fabs.f64 M)
                  NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
                  (FPCore (w0 M_m D_m h l d)
                   :precision binary64
                   (if (<= (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ h l)) -50000000000000.0)
                     (* w0 (sqrt (* (* -0.25 (* D_m D_m)) (* h (* (/ M_m (* d d)) (/ M_m l))))))
                     (* w0 1.0)))
                  D_m = fabs(D);
                  M_m = fabs(M);
                  assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
                  double code(double w0, double M_m, double D_m, double h, double l, double d) {
                  	double tmp;
                  	if ((pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)) <= -50000000000000.0) {
                  		tmp = w0 * sqrt(((-0.25 * (D_m * D_m)) * (h * ((M_m / (d * d)) * (M_m / l)))));
                  	} else {
                  		tmp = w0 * 1.0;
                  	}
                  	return tmp;
                  }
                  
                  D_m =     private
                  M_m =     private
                  NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
                  module fmin_fmax_functions
                      implicit none
                      private
                      public fmax
                      public fmin
                  
                      interface fmax
                          module procedure fmax88
                          module procedure fmax44
                          module procedure fmax84
                          module procedure fmax48
                      end interface
                      interface fmin
                          module procedure fmin88
                          module procedure fmin44
                          module procedure fmin84
                          module procedure fmin48
                      end interface
                  contains
                      real(8) function fmax88(x, y) result (res)
                          real(8), intent (in) :: x
                          real(8), intent (in) :: y
                          res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                      end function
                      real(4) function fmax44(x, y) result (res)
                          real(4), intent (in) :: x
                          real(4), intent (in) :: y
                          res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                      end function
                      real(8) function fmax84(x, y) result(res)
                          real(8), intent (in) :: x
                          real(4), intent (in) :: y
                          res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                      end function
                      real(8) function fmax48(x, y) result(res)
                          real(4), intent (in) :: x
                          real(8), intent (in) :: y
                          res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                      end function
                      real(8) function fmin88(x, y) result (res)
                          real(8), intent (in) :: x
                          real(8), intent (in) :: y
                          res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                      end function
                      real(4) function fmin44(x, y) result (res)
                          real(4), intent (in) :: x
                          real(4), intent (in) :: y
                          res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                      end function
                      real(8) function fmin84(x, y) result(res)
                          real(8), intent (in) :: x
                          real(4), intent (in) :: y
                          res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                      end function
                      real(8) function fmin48(x, y) result(res)
                          real(4), intent (in) :: x
                          real(8), intent (in) :: y
                          res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                      end function
                  end module
                  
                  real(8) function code(w0, m_m, d_m, h, l, d)
                  use fmin_fmax_functions
                      real(8), intent (in) :: w0
                      real(8), intent (in) :: m_m
                      real(8), intent (in) :: d_m
                      real(8), intent (in) :: h
                      real(8), intent (in) :: l
                      real(8), intent (in) :: d
                      real(8) :: tmp
                      if (((((m_m * d_m) / (2.0d0 * d)) ** 2.0d0) * (h / l)) <= (-50000000000000.0d0)) then
                          tmp = w0 * sqrt((((-0.25d0) * (d_m * d_m)) * (h * ((m_m / (d * d)) * (m_m / l)))))
                      else
                          tmp = w0 * 1.0d0
                      end if
                      code = tmp
                  end function
                  
                  D_m = Math.abs(D);
                  M_m = Math.abs(M);
                  assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
                  public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
                  	double tmp;
                  	if ((Math.pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)) <= -50000000000000.0) {
                  		tmp = w0 * Math.sqrt(((-0.25 * (D_m * D_m)) * (h * ((M_m / (d * d)) * (M_m / l)))));
                  	} else {
                  		tmp = w0 * 1.0;
                  	}
                  	return tmp;
                  }
                  
                  D_m = math.fabs(D)
                  M_m = math.fabs(M)
                  [w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d])
                  def code(w0, M_m, D_m, h, l, d):
                  	tmp = 0
                  	if (math.pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)) <= -50000000000000.0:
                  		tmp = w0 * math.sqrt(((-0.25 * (D_m * D_m)) * (h * ((M_m / (d * d)) * (M_m / l)))))
                  	else:
                  		tmp = w0 * 1.0
                  	return tmp
                  
                  D_m = abs(D)
                  M_m = abs(M)
                  w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d])
                  function code(w0, M_m, D_m, h, l, d)
                  	tmp = 0.0
                  	if (Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= -50000000000000.0)
                  		tmp = Float64(w0 * sqrt(Float64(Float64(-0.25 * Float64(D_m * D_m)) * Float64(h * Float64(Float64(M_m / Float64(d * d)) * Float64(M_m / l))))));
                  	else
                  		tmp = Float64(w0 * 1.0);
                  	end
                  	return tmp
                  end
                  
                  D_m = abs(D);
                  M_m = abs(M);
                  w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
                  function tmp_2 = code(w0, M_m, D_m, h, l, d)
                  	tmp = 0.0;
                  	if (((((M_m * D_m) / (2.0 * d)) ^ 2.0) * (h / l)) <= -50000000000000.0)
                  		tmp = w0 * sqrt(((-0.25 * (D_m * D_m)) * (h * ((M_m / (d * d)) * (M_m / l)))));
                  	else
                  		tmp = w0 * 1.0;
                  	end
                  	tmp_2 = tmp;
                  end
                  
                  D_m = N[Abs[D], $MachinePrecision]
                  M_m = N[Abs[M], $MachinePrecision]
                  NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
                  code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[N[(N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -50000000000000.0], N[(w0 * N[Sqrt[N[(N[(-0.25 * N[(D$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] * N[(h * N[(N[(M$95$m / N[(d * d), $MachinePrecision]), $MachinePrecision] * N[(M$95$m / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * 1.0), $MachinePrecision]]
                  
                  \begin{array}{l}
                  D_m = \left|D\right|
                  \\
                  M_m = \left|M\right|
                  \\
                  [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
                  \\
                  \begin{array}{l}
                  \mathbf{if}\;{\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -50000000000000:\\
                  \;\;\;\;w0 \cdot \sqrt{\left(-0.25 \cdot \left(D\_m \cdot D\_m\right)\right) \cdot \left(h \cdot \left(\frac{M\_m}{d \cdot d} \cdot \frac{M\_m}{\ell}\right)\right)}\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;w0 \cdot 1\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < -5e13

                    1. Initial program 62.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                      1. Initial program 84.8%

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

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

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

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

                      Alternative 6: 71.9% accurate, 0.8× speedup?

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

                        1. Initial program 54.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                        1. Initial program 85.5%

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

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

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

                        Alternative 7: 78.3% accurate, 0.8× speedup?

                        \[\begin{array}{l} D_m = \left|D\right| \\ M_m = \left|M\right| \\ [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;{\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -5 \cdot 10^{+269}:\\ \;\;\;\;\frac{M\_m \cdot \left(\left(M\_m \cdot h\right) \cdot \left(\left(D\_m \cdot w0\right) \cdot D\_m\right)\right)}{\left(d \cdot d\right) \cdot \ell} \cdot -0.125\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot 1\\ \end{array} \end{array} \]
                        D_m = (fabs.f64 D)
                        M_m = (fabs.f64 M)
                        NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
                        (FPCore (w0 M_m D_m h l d)
                         :precision binary64
                         (if (<= (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ h l)) -5e+269)
                           (* (/ (* M_m (* (* M_m h) (* (* D_m w0) D_m))) (* (* d d) l)) -0.125)
                           (* w0 1.0)))
                        D_m = fabs(D);
                        M_m = fabs(M);
                        assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
                        double code(double w0, double M_m, double D_m, double h, double l, double d) {
                        	double tmp;
                        	if ((pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)) <= -5e+269) {
                        		tmp = ((M_m * ((M_m * h) * ((D_m * w0) * D_m))) / ((d * d) * l)) * -0.125;
                        	} else {
                        		tmp = w0 * 1.0;
                        	}
                        	return tmp;
                        }
                        
                        D_m =     private
                        M_m =     private
                        NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
                        module fmin_fmax_functions
                            implicit none
                            private
                            public fmax
                            public fmin
                        
                            interface fmax
                                module procedure fmax88
                                module procedure fmax44
                                module procedure fmax84
                                module procedure fmax48
                            end interface
                            interface fmin
                                module procedure fmin88
                                module procedure fmin44
                                module procedure fmin84
                                module procedure fmin48
                            end interface
                        contains
                            real(8) function fmax88(x, y) result (res)
                                real(8), intent (in) :: x
                                real(8), intent (in) :: y
                                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                            end function
                            real(4) function fmax44(x, y) result (res)
                                real(4), intent (in) :: x
                                real(4), intent (in) :: y
                                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                            end function
                            real(8) function fmax84(x, y) result(res)
                                real(8), intent (in) :: x
                                real(4), intent (in) :: y
                                res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                            end function
                            real(8) function fmax48(x, y) result(res)
                                real(4), intent (in) :: x
                                real(8), intent (in) :: y
                                res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                            end function
                            real(8) function fmin88(x, y) result (res)
                                real(8), intent (in) :: x
                                real(8), intent (in) :: y
                                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                            end function
                            real(4) function fmin44(x, y) result (res)
                                real(4), intent (in) :: x
                                real(4), intent (in) :: y
                                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                            end function
                            real(8) function fmin84(x, y) result(res)
                                real(8), intent (in) :: x
                                real(4), intent (in) :: y
                                res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                            end function
                            real(8) function fmin48(x, y) result(res)
                                real(4), intent (in) :: x
                                real(8), intent (in) :: y
                                res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                            end function
                        end module
                        
                        real(8) function code(w0, m_m, d_m, h, l, d)
                        use fmin_fmax_functions
                            real(8), intent (in) :: w0
                            real(8), intent (in) :: m_m
                            real(8), intent (in) :: d_m
                            real(8), intent (in) :: h
                            real(8), intent (in) :: l
                            real(8), intent (in) :: d
                            real(8) :: tmp
                            if (((((m_m * d_m) / (2.0d0 * d)) ** 2.0d0) * (h / l)) <= (-5d+269)) then
                                tmp = ((m_m * ((m_m * h) * ((d_m * w0) * d_m))) / ((d * d) * l)) * (-0.125d0)
                            else
                                tmp = w0 * 1.0d0
                            end if
                            code = tmp
                        end function
                        
                        D_m = Math.abs(D);
                        M_m = Math.abs(M);
                        assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
                        public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
                        	double tmp;
                        	if ((Math.pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)) <= -5e+269) {
                        		tmp = ((M_m * ((M_m * h) * ((D_m * w0) * D_m))) / ((d * d) * l)) * -0.125;
                        	} else {
                        		tmp = w0 * 1.0;
                        	}
                        	return tmp;
                        }
                        
                        D_m = math.fabs(D)
                        M_m = math.fabs(M)
                        [w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d])
                        def code(w0, M_m, D_m, h, l, d):
                        	tmp = 0
                        	if (math.pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)) <= -5e+269:
                        		tmp = ((M_m * ((M_m * h) * ((D_m * w0) * D_m))) / ((d * d) * l)) * -0.125
                        	else:
                        		tmp = w0 * 1.0
                        	return tmp
                        
                        D_m = abs(D)
                        M_m = abs(M)
                        w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d])
                        function code(w0, M_m, D_m, h, l, d)
                        	tmp = 0.0
                        	if (Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= -5e+269)
                        		tmp = Float64(Float64(Float64(M_m * Float64(Float64(M_m * h) * Float64(Float64(D_m * w0) * D_m))) / Float64(Float64(d * d) * l)) * -0.125);
                        	else
                        		tmp = Float64(w0 * 1.0);
                        	end
                        	return tmp
                        end
                        
                        D_m = abs(D);
                        M_m = abs(M);
                        w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
                        function tmp_2 = code(w0, M_m, D_m, h, l, d)
                        	tmp = 0.0;
                        	if (((((M_m * D_m) / (2.0 * d)) ^ 2.0) * (h / l)) <= -5e+269)
                        		tmp = ((M_m * ((M_m * h) * ((D_m * w0) * D_m))) / ((d * d) * l)) * -0.125;
                        	else
                        		tmp = w0 * 1.0;
                        	end
                        	tmp_2 = tmp;
                        end
                        
                        D_m = N[Abs[D], $MachinePrecision]
                        M_m = N[Abs[M], $MachinePrecision]
                        NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
                        code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[N[(N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -5e+269], N[(N[(N[(M$95$m * N[(N[(M$95$m * h), $MachinePrecision] * N[(N[(D$95$m * w0), $MachinePrecision] * D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision], N[(w0 * 1.0), $MachinePrecision]]
                        
                        \begin{array}{l}
                        D_m = \left|D\right|
                        \\
                        M_m = \left|M\right|
                        \\
                        [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
                        \\
                        \begin{array}{l}
                        \mathbf{if}\;{\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -5 \cdot 10^{+269}:\\
                        \;\;\;\;\frac{M\_m \cdot \left(\left(M\_m \cdot h\right) \cdot \left(\left(D\_m \cdot w0\right) \cdot D\_m\right)\right)}{\left(d \cdot d\right) \cdot \ell} \cdot -0.125\\
                        
                        \mathbf{else}:\\
                        \;\;\;\;w0 \cdot 1\\
                        
                        
                        \end{array}
                        \end{array}
                        
                        Derivation
                        1. Split input into 2 regimes
                        2. if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < -5.0000000000000002e269

                          1. Initial program 54.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                              1. Initial program 85.5%

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

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

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

                              Alternative 8: 81.6% accurate, 0.9× speedup?

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

                                1. Initial program 83.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                if 1.9999999999999999e-178 < M

                                1. Initial program 74.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                Alternative 9: 73.1% accurate, 1.7× speedup?

                                \[\begin{array}{l} D_m = \left|D\right| \\ M_m = \left|M\right| \\ [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;\frac{M\_m \cdot D\_m}{2 \cdot d} \leq 4 \cdot 10^{+38}:\\ \;\;\;\;w0 \cdot 1\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \left(M\_m \cdot D\_m\right) \cdot \frac{\frac{\left(M\_m \cdot D\_m\right) \cdot h}{\ell}}{2 \cdot d}}\\ \end{array} \end{array} \]
                                D_m = (fabs.f64 D)
                                M_m = (fabs.f64 M)
                                NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
                                (FPCore (w0 M_m D_m h l d)
                                 :precision binary64
                                 (if (<= (/ (* M_m D_m) (* 2.0 d)) 4e+38)
                                   (* w0 1.0)
                                   (*
                                    w0
                                    (sqrt (- 1.0 (* (* M_m D_m) (/ (/ (* (* M_m D_m) h) l) (* 2.0 d))))))))
                                D_m = fabs(D);
                                M_m = fabs(M);
                                assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
                                double code(double w0, double M_m, double D_m, double h, double l, double d) {
                                	double tmp;
                                	if (((M_m * D_m) / (2.0 * d)) <= 4e+38) {
                                		tmp = w0 * 1.0;
                                	} else {
                                		tmp = w0 * sqrt((1.0 - ((M_m * D_m) * ((((M_m * D_m) * h) / l) / (2.0 * d)))));
                                	}
                                	return tmp;
                                }
                                
                                D_m =     private
                                M_m =     private
                                NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
                                module fmin_fmax_functions
                                    implicit none
                                    private
                                    public fmax
                                    public fmin
                                
                                    interface fmax
                                        module procedure fmax88
                                        module procedure fmax44
                                        module procedure fmax84
                                        module procedure fmax48
                                    end interface
                                    interface fmin
                                        module procedure fmin88
                                        module procedure fmin44
                                        module procedure fmin84
                                        module procedure fmin48
                                    end interface
                                contains
                                    real(8) function fmax88(x, y) result (res)
                                        real(8), intent (in) :: x
                                        real(8), intent (in) :: y
                                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                    end function
                                    real(4) function fmax44(x, y) result (res)
                                        real(4), intent (in) :: x
                                        real(4), intent (in) :: y
                                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                    end function
                                    real(8) function fmax84(x, y) result(res)
                                        real(8), intent (in) :: x
                                        real(4), intent (in) :: y
                                        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                    end function
                                    real(8) function fmax48(x, y) result(res)
                                        real(4), intent (in) :: x
                                        real(8), intent (in) :: y
                                        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                    end function
                                    real(8) function fmin88(x, y) result (res)
                                        real(8), intent (in) :: x
                                        real(8), intent (in) :: y
                                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                    end function
                                    real(4) function fmin44(x, y) result (res)
                                        real(4), intent (in) :: x
                                        real(4), intent (in) :: y
                                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                    end function
                                    real(8) function fmin84(x, y) result(res)
                                        real(8), intent (in) :: x
                                        real(4), intent (in) :: y
                                        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                    end function
                                    real(8) function fmin48(x, y) result(res)
                                        real(4), intent (in) :: x
                                        real(8), intent (in) :: y
                                        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                    end function
                                end module
                                
                                real(8) function code(w0, m_m, d_m, h, l, d)
                                use fmin_fmax_functions
                                    real(8), intent (in) :: w0
                                    real(8), intent (in) :: m_m
                                    real(8), intent (in) :: d_m
                                    real(8), intent (in) :: h
                                    real(8), intent (in) :: l
                                    real(8), intent (in) :: d
                                    real(8) :: tmp
                                    if (((m_m * d_m) / (2.0d0 * d)) <= 4d+38) then
                                        tmp = w0 * 1.0d0
                                    else
                                        tmp = w0 * sqrt((1.0d0 - ((m_m * d_m) * ((((m_m * d_m) * h) / l) / (2.0d0 * d)))))
                                    end if
                                    code = tmp
                                end function
                                
                                D_m = Math.abs(D);
                                M_m = Math.abs(M);
                                assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
                                public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
                                	double tmp;
                                	if (((M_m * D_m) / (2.0 * d)) <= 4e+38) {
                                		tmp = w0 * 1.0;
                                	} else {
                                		tmp = w0 * Math.sqrt((1.0 - ((M_m * D_m) * ((((M_m * D_m) * h) / l) / (2.0 * d)))));
                                	}
                                	return tmp;
                                }
                                
                                D_m = math.fabs(D)
                                M_m = math.fabs(M)
                                [w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d])
                                def code(w0, M_m, D_m, h, l, d):
                                	tmp = 0
                                	if ((M_m * D_m) / (2.0 * d)) <= 4e+38:
                                		tmp = w0 * 1.0
                                	else:
                                		tmp = w0 * math.sqrt((1.0 - ((M_m * D_m) * ((((M_m * D_m) * h) / l) / (2.0 * d)))))
                                	return tmp
                                
                                D_m = abs(D)
                                M_m = abs(M)
                                w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d])
                                function code(w0, M_m, D_m, h, l, d)
                                	tmp = 0.0
                                	if (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) <= 4e+38)
                                		tmp = Float64(w0 * 1.0);
                                	else
                                		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(M_m * D_m) * Float64(Float64(Float64(Float64(M_m * D_m) * h) / l) / Float64(2.0 * d))))));
                                	end
                                	return tmp
                                end
                                
                                D_m = abs(D);
                                M_m = abs(M);
                                w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
                                function tmp_2 = code(w0, M_m, D_m, h, l, d)
                                	tmp = 0.0;
                                	if (((M_m * D_m) / (2.0 * d)) <= 4e+38)
                                		tmp = w0 * 1.0;
                                	else
                                		tmp = w0 * sqrt((1.0 - ((M_m * D_m) * ((((M_m * D_m) * h) / l) / (2.0 * d)))));
                                	end
                                	tmp_2 = tmp;
                                end
                                
                                D_m = N[Abs[D], $MachinePrecision]
                                M_m = N[Abs[M], $MachinePrecision]
                                NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
                                code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 4e+38], N[(w0 * 1.0), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(M$95$m * D$95$m), $MachinePrecision] * N[(N[(N[(N[(M$95$m * D$95$m), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
                                
                                \begin{array}{l}
                                D_m = \left|D\right|
                                \\
                                M_m = \left|M\right|
                                \\
                                [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
                                \\
                                \begin{array}{l}
                                \mathbf{if}\;\frac{M\_m \cdot D\_m}{2 \cdot d} \leq 4 \cdot 10^{+38}:\\
                                \;\;\;\;w0 \cdot 1\\
                                
                                \mathbf{else}:\\
                                \;\;\;\;w0 \cdot \sqrt{1 - \left(M\_m \cdot D\_m\right) \cdot \frac{\frac{\left(M\_m \cdot D\_m\right) \cdot h}{\ell}}{2 \cdot d}}\\
                                
                                
                                \end{array}
                                \end{array}
                                
                                Derivation
                                1. Split input into 2 regimes
                                2. if (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) < 3.99999999999999991e38

                                  1. Initial program 82.8%

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

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

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

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

                                    1. Initial program 58.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                  Alternative 10: 73.2% accurate, 1.7× speedup?

                                  \[\begin{array}{l} D_m = \left|D\right| \\ M_m = \left|M\right| \\ [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;\frac{M\_m \cdot D\_m}{2 \cdot d} \leq 4 \cdot 10^{+38}:\\ \;\;\;\;w0 \cdot 1\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{D\_m \cdot M\_m}{d + d} \cdot \frac{\left(D\_m \cdot M\_m\right) \cdot h}{\ell}}\\ \end{array} \end{array} \]
                                  D_m = (fabs.f64 D)
                                  M_m = (fabs.f64 M)
                                  NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
                                  (FPCore (w0 M_m D_m h l d)
                                   :precision binary64
                                   (if (<= (/ (* M_m D_m) (* 2.0 d)) 4e+38)
                                     (* w0 1.0)
                                     (* w0 (sqrt (- 1.0 (* (/ (* D_m M_m) (+ d d)) (/ (* (* D_m M_m) h) l)))))))
                                  D_m = fabs(D);
                                  M_m = fabs(M);
                                  assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
                                  double code(double w0, double M_m, double D_m, double h, double l, double d) {
                                  	double tmp;
                                  	if (((M_m * D_m) / (2.0 * d)) <= 4e+38) {
                                  		tmp = w0 * 1.0;
                                  	} else {
                                  		tmp = w0 * sqrt((1.0 - (((D_m * M_m) / (d + d)) * (((D_m * M_m) * h) / l))));
                                  	}
                                  	return tmp;
                                  }
                                  
                                  D_m =     private
                                  M_m =     private
                                  NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
                                  module fmin_fmax_functions
                                      implicit none
                                      private
                                      public fmax
                                      public fmin
                                  
                                      interface fmax
                                          module procedure fmax88
                                          module procedure fmax44
                                          module procedure fmax84
                                          module procedure fmax48
                                      end interface
                                      interface fmin
                                          module procedure fmin88
                                          module procedure fmin44
                                          module procedure fmin84
                                          module procedure fmin48
                                      end interface
                                  contains
                                      real(8) function fmax88(x, y) result (res)
                                          real(8), intent (in) :: x
                                          real(8), intent (in) :: y
                                          res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                      end function
                                      real(4) function fmax44(x, y) result (res)
                                          real(4), intent (in) :: x
                                          real(4), intent (in) :: y
                                          res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                      end function
                                      real(8) function fmax84(x, y) result(res)
                                          real(8), intent (in) :: x
                                          real(4), intent (in) :: y
                                          res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                      end function
                                      real(8) function fmax48(x, y) result(res)
                                          real(4), intent (in) :: x
                                          real(8), intent (in) :: y
                                          res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                      end function
                                      real(8) function fmin88(x, y) result (res)
                                          real(8), intent (in) :: x
                                          real(8), intent (in) :: y
                                          res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                      end function
                                      real(4) function fmin44(x, y) result (res)
                                          real(4), intent (in) :: x
                                          real(4), intent (in) :: y
                                          res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                      end function
                                      real(8) function fmin84(x, y) result(res)
                                          real(8), intent (in) :: x
                                          real(4), intent (in) :: y
                                          res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                      end function
                                      real(8) function fmin48(x, y) result(res)
                                          real(4), intent (in) :: x
                                          real(8), intent (in) :: y
                                          res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                      end function
                                  end module
                                  
                                  real(8) function code(w0, m_m, d_m, h, l, d)
                                  use fmin_fmax_functions
                                      real(8), intent (in) :: w0
                                      real(8), intent (in) :: m_m
                                      real(8), intent (in) :: d_m
                                      real(8), intent (in) :: h
                                      real(8), intent (in) :: l
                                      real(8), intent (in) :: d
                                      real(8) :: tmp
                                      if (((m_m * d_m) / (2.0d0 * d)) <= 4d+38) then
                                          tmp = w0 * 1.0d0
                                      else
                                          tmp = w0 * sqrt((1.0d0 - (((d_m * m_m) / (d + d)) * (((d_m * m_m) * h) / l))))
                                      end if
                                      code = tmp
                                  end function
                                  
                                  D_m = Math.abs(D);
                                  M_m = Math.abs(M);
                                  assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
                                  public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
                                  	double tmp;
                                  	if (((M_m * D_m) / (2.0 * d)) <= 4e+38) {
                                  		tmp = w0 * 1.0;
                                  	} else {
                                  		tmp = w0 * Math.sqrt((1.0 - (((D_m * M_m) / (d + d)) * (((D_m * M_m) * h) / l))));
                                  	}
                                  	return tmp;
                                  }
                                  
                                  D_m = math.fabs(D)
                                  M_m = math.fabs(M)
                                  [w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d])
                                  def code(w0, M_m, D_m, h, l, d):
                                  	tmp = 0
                                  	if ((M_m * D_m) / (2.0 * d)) <= 4e+38:
                                  		tmp = w0 * 1.0
                                  	else:
                                  		tmp = w0 * math.sqrt((1.0 - (((D_m * M_m) / (d + d)) * (((D_m * M_m) * h) / l))))
                                  	return tmp
                                  
                                  D_m = abs(D)
                                  M_m = abs(M)
                                  w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d])
                                  function code(w0, M_m, D_m, h, l, d)
                                  	tmp = 0.0
                                  	if (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) <= 4e+38)
                                  		tmp = Float64(w0 * 1.0);
                                  	else
                                  		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(D_m * M_m) / Float64(d + d)) * Float64(Float64(Float64(D_m * M_m) * h) / l)))));
                                  	end
                                  	return tmp
                                  end
                                  
                                  D_m = abs(D);
                                  M_m = abs(M);
                                  w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
                                  function tmp_2 = code(w0, M_m, D_m, h, l, d)
                                  	tmp = 0.0;
                                  	if (((M_m * D_m) / (2.0 * d)) <= 4e+38)
                                  		tmp = w0 * 1.0;
                                  	else
                                  		tmp = w0 * sqrt((1.0 - (((D_m * M_m) / (d + d)) * (((D_m * M_m) * h) / l))));
                                  	end
                                  	tmp_2 = tmp;
                                  end
                                  
                                  D_m = N[Abs[D], $MachinePrecision]
                                  M_m = N[Abs[M], $MachinePrecision]
                                  NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
                                  code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 4e+38], N[(w0 * 1.0), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] / N[(d + d), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
                                  
                                  \begin{array}{l}
                                  D_m = \left|D\right|
                                  \\
                                  M_m = \left|M\right|
                                  \\
                                  [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
                                  \\
                                  \begin{array}{l}
                                  \mathbf{if}\;\frac{M\_m \cdot D\_m}{2 \cdot d} \leq 4 \cdot 10^{+38}:\\
                                  \;\;\;\;w0 \cdot 1\\
                                  
                                  \mathbf{else}:\\
                                  \;\;\;\;w0 \cdot \sqrt{1 - \frac{D\_m \cdot M\_m}{d + d} \cdot \frac{\left(D\_m \cdot M\_m\right) \cdot h}{\ell}}\\
                                  
                                  
                                  \end{array}
                                  \end{array}
                                  
                                  Derivation
                                  1. Split input into 2 regimes
                                  2. if (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) < 3.99999999999999991e38

                                    1. Initial program 82.8%

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

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

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

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

                                      1. Initial program 58.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                    Alternative 11: 73.1% accurate, 1.8× speedup?

                                    \[\begin{array}{l} D_m = \left|D\right| \\ M_m = \left|M\right| \\ [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;\frac{M\_m \cdot D\_m}{2 \cdot d} \leq 2 \cdot 10^{+43}:\\ \;\;\;\;w0 \cdot 1\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \left(M\_m \cdot D\_m\right) \cdot \frac{\left(M\_m \cdot D\_m\right) \cdot h}{\left(2 \cdot d\right) \cdot \ell}}\\ \end{array} \end{array} \]
                                    D_m = (fabs.f64 D)
                                    M_m = (fabs.f64 M)
                                    NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
                                    (FPCore (w0 M_m D_m h l d)
                                     :precision binary64
                                     (if (<= (/ (* M_m D_m) (* 2.0 d)) 2e+43)
                                       (* w0 1.0)
                                       (*
                                        w0
                                        (sqrt (- 1.0 (* (* M_m D_m) (/ (* (* M_m D_m) h) (* (* 2.0 d) l))))))))
                                    D_m = fabs(D);
                                    M_m = fabs(M);
                                    assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
                                    double code(double w0, double M_m, double D_m, double h, double l, double d) {
                                    	double tmp;
                                    	if (((M_m * D_m) / (2.0 * d)) <= 2e+43) {
                                    		tmp = w0 * 1.0;
                                    	} else {
                                    		tmp = w0 * sqrt((1.0 - ((M_m * D_m) * (((M_m * D_m) * h) / ((2.0 * d) * l)))));
                                    	}
                                    	return tmp;
                                    }
                                    
                                    D_m =     private
                                    M_m =     private
                                    NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
                                    module fmin_fmax_functions
                                        implicit none
                                        private
                                        public fmax
                                        public fmin
                                    
                                        interface fmax
                                            module procedure fmax88
                                            module procedure fmax44
                                            module procedure fmax84
                                            module procedure fmax48
                                        end interface
                                        interface fmin
                                            module procedure fmin88
                                            module procedure fmin44
                                            module procedure fmin84
                                            module procedure fmin48
                                        end interface
                                    contains
                                        real(8) function fmax88(x, y) result (res)
                                            real(8), intent (in) :: x
                                            real(8), intent (in) :: y
                                            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                        end function
                                        real(4) function fmax44(x, y) result (res)
                                            real(4), intent (in) :: x
                                            real(4), intent (in) :: y
                                            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                        end function
                                        real(8) function fmax84(x, y) result(res)
                                            real(8), intent (in) :: x
                                            real(4), intent (in) :: y
                                            res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                        end function
                                        real(8) function fmax48(x, y) result(res)
                                            real(4), intent (in) :: x
                                            real(8), intent (in) :: y
                                            res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                        end function
                                        real(8) function fmin88(x, y) result (res)
                                            real(8), intent (in) :: x
                                            real(8), intent (in) :: y
                                            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                        end function
                                        real(4) function fmin44(x, y) result (res)
                                            real(4), intent (in) :: x
                                            real(4), intent (in) :: y
                                            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                        end function
                                        real(8) function fmin84(x, y) result(res)
                                            real(8), intent (in) :: x
                                            real(4), intent (in) :: y
                                            res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                        end function
                                        real(8) function fmin48(x, y) result(res)
                                            real(4), intent (in) :: x
                                            real(8), intent (in) :: y
                                            res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                        end function
                                    end module
                                    
                                    real(8) function code(w0, m_m, d_m, h, l, d)
                                    use fmin_fmax_functions
                                        real(8), intent (in) :: w0
                                        real(8), intent (in) :: m_m
                                        real(8), intent (in) :: d_m
                                        real(8), intent (in) :: h
                                        real(8), intent (in) :: l
                                        real(8), intent (in) :: d
                                        real(8) :: tmp
                                        if (((m_m * d_m) / (2.0d0 * d)) <= 2d+43) then
                                            tmp = w0 * 1.0d0
                                        else
                                            tmp = w0 * sqrt((1.0d0 - ((m_m * d_m) * (((m_m * d_m) * h) / ((2.0d0 * d) * l)))))
                                        end if
                                        code = tmp
                                    end function
                                    
                                    D_m = Math.abs(D);
                                    M_m = Math.abs(M);
                                    assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
                                    public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
                                    	double tmp;
                                    	if (((M_m * D_m) / (2.0 * d)) <= 2e+43) {
                                    		tmp = w0 * 1.0;
                                    	} else {
                                    		tmp = w0 * Math.sqrt((1.0 - ((M_m * D_m) * (((M_m * D_m) * h) / ((2.0 * d) * l)))));
                                    	}
                                    	return tmp;
                                    }
                                    
                                    D_m = math.fabs(D)
                                    M_m = math.fabs(M)
                                    [w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d])
                                    def code(w0, M_m, D_m, h, l, d):
                                    	tmp = 0
                                    	if ((M_m * D_m) / (2.0 * d)) <= 2e+43:
                                    		tmp = w0 * 1.0
                                    	else:
                                    		tmp = w0 * math.sqrt((1.0 - ((M_m * D_m) * (((M_m * D_m) * h) / ((2.0 * d) * l)))))
                                    	return tmp
                                    
                                    D_m = abs(D)
                                    M_m = abs(M)
                                    w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d])
                                    function code(w0, M_m, D_m, h, l, d)
                                    	tmp = 0.0
                                    	if (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) <= 2e+43)
                                    		tmp = Float64(w0 * 1.0);
                                    	else
                                    		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(M_m * D_m) * Float64(Float64(Float64(M_m * D_m) * h) / Float64(Float64(2.0 * d) * l))))));
                                    	end
                                    	return tmp
                                    end
                                    
                                    D_m = abs(D);
                                    M_m = abs(M);
                                    w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
                                    function tmp_2 = code(w0, M_m, D_m, h, l, d)
                                    	tmp = 0.0;
                                    	if (((M_m * D_m) / (2.0 * d)) <= 2e+43)
                                    		tmp = w0 * 1.0;
                                    	else
                                    		tmp = w0 * sqrt((1.0 - ((M_m * D_m) * (((M_m * D_m) * h) / ((2.0 * d) * l)))));
                                    	end
                                    	tmp_2 = tmp;
                                    end
                                    
                                    D_m = N[Abs[D], $MachinePrecision]
                                    M_m = N[Abs[M], $MachinePrecision]
                                    NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
                                    code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2e+43], N[(w0 * 1.0), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(M$95$m * D$95$m), $MachinePrecision] * N[(N[(N[(M$95$m * D$95$m), $MachinePrecision] * h), $MachinePrecision] / N[(N[(2.0 * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
                                    
                                    \begin{array}{l}
                                    D_m = \left|D\right|
                                    \\
                                    M_m = \left|M\right|
                                    \\
                                    [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
                                    \\
                                    \begin{array}{l}
                                    \mathbf{if}\;\frac{M\_m \cdot D\_m}{2 \cdot d} \leq 2 \cdot 10^{+43}:\\
                                    \;\;\;\;w0 \cdot 1\\
                                    
                                    \mathbf{else}:\\
                                    \;\;\;\;w0 \cdot \sqrt{1 - \left(M\_m \cdot D\_m\right) \cdot \frac{\left(M\_m \cdot D\_m\right) \cdot h}{\left(2 \cdot d\right) \cdot \ell}}\\
                                    
                                    
                                    \end{array}
                                    \end{array}
                                    
                                    Derivation
                                    1. Split input into 2 regimes
                                    2. if (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) < 2.00000000000000003e43

                                      1. Initial program 82.9%

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

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

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

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

                                        1. Initial program 56.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                      Alternative 12: 72.2% accurate, 1.8× speedup?

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

                                        1. Initial program 83.6%

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

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

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

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

                                          1. Initial program 36.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                          Alternative 13: 88.2% accurate, 1.9× speedup?

                                          \[\begin{array}{l} D_m = \left|D\right| \\ M_m = \left|M\right| \\ [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\ \\ \begin{array}{l} t_0 := \frac{M\_m}{d} \cdot D\_m\\ w0 \cdot \sqrt{1 - \frac{t\_0 \cdot \left(h \cdot t\_0\right)}{2 \cdot \left(\ell \cdot 2\right)}} \end{array} \end{array} \]
                                          D_m = (fabs.f64 D)
                                          M_m = (fabs.f64 M)
                                          NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
                                          (FPCore (w0 M_m D_m h l d)
                                           :precision binary64
                                           (let* ((t_0 (* (/ M_m d) D_m)))
                                             (* w0 (sqrt (- 1.0 (/ (* t_0 (* h t_0)) (* 2.0 (* l 2.0))))))))
                                          D_m = fabs(D);
                                          M_m = fabs(M);
                                          assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
                                          double code(double w0, double M_m, double D_m, double h, double l, double d) {
                                          	double t_0 = (M_m / d) * D_m;
                                          	return w0 * sqrt((1.0 - ((t_0 * (h * t_0)) / (2.0 * (l * 2.0)))));
                                          }
                                          
                                          D_m =     private
                                          M_m =     private
                                          NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
                                          module fmin_fmax_functions
                                              implicit none
                                              private
                                              public fmax
                                              public fmin
                                          
                                              interface fmax
                                                  module procedure fmax88
                                                  module procedure fmax44
                                                  module procedure fmax84
                                                  module procedure fmax48
                                              end interface
                                              interface fmin
                                                  module procedure fmin88
                                                  module procedure fmin44
                                                  module procedure fmin84
                                                  module procedure fmin48
                                              end interface
                                          contains
                                              real(8) function fmax88(x, y) result (res)
                                                  real(8), intent (in) :: x
                                                  real(8), intent (in) :: y
                                                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                              end function
                                              real(4) function fmax44(x, y) result (res)
                                                  real(4), intent (in) :: x
                                                  real(4), intent (in) :: y
                                                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                              end function
                                              real(8) function fmax84(x, y) result(res)
                                                  real(8), intent (in) :: x
                                                  real(4), intent (in) :: y
                                                  res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                              end function
                                              real(8) function fmax48(x, y) result(res)
                                                  real(4), intent (in) :: x
                                                  real(8), intent (in) :: y
                                                  res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                              end function
                                              real(8) function fmin88(x, y) result (res)
                                                  real(8), intent (in) :: x
                                                  real(8), intent (in) :: y
                                                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                              end function
                                              real(4) function fmin44(x, y) result (res)
                                                  real(4), intent (in) :: x
                                                  real(4), intent (in) :: y
                                                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                              end function
                                              real(8) function fmin84(x, y) result(res)
                                                  real(8), intent (in) :: x
                                                  real(4), intent (in) :: y
                                                  res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                              end function
                                              real(8) function fmin48(x, y) result(res)
                                                  real(4), intent (in) :: x
                                                  real(8), intent (in) :: y
                                                  res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                              end function
                                          end module
                                          
                                          real(8) function code(w0, m_m, d_m, h, l, d)
                                          use fmin_fmax_functions
                                              real(8), intent (in) :: w0
                                              real(8), intent (in) :: m_m
                                              real(8), intent (in) :: d_m
                                              real(8), intent (in) :: h
                                              real(8), intent (in) :: l
                                              real(8), intent (in) :: d
                                              real(8) :: t_0
                                              t_0 = (m_m / d) * d_m
                                              code = w0 * sqrt((1.0d0 - ((t_0 * (h * t_0)) / (2.0d0 * (l * 2.0d0)))))
                                          end function
                                          
                                          D_m = Math.abs(D);
                                          M_m = Math.abs(M);
                                          assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
                                          public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
                                          	double t_0 = (M_m / d) * D_m;
                                          	return w0 * Math.sqrt((1.0 - ((t_0 * (h * t_0)) / (2.0 * (l * 2.0)))));
                                          }
                                          
                                          D_m = math.fabs(D)
                                          M_m = math.fabs(M)
                                          [w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d])
                                          def code(w0, M_m, D_m, h, l, d):
                                          	t_0 = (M_m / d) * D_m
                                          	return w0 * math.sqrt((1.0 - ((t_0 * (h * t_0)) / (2.0 * (l * 2.0)))))
                                          
                                          D_m = abs(D)
                                          M_m = abs(M)
                                          w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d])
                                          function code(w0, M_m, D_m, h, l, d)
                                          	t_0 = Float64(Float64(M_m / d) * D_m)
                                          	return Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(t_0 * Float64(h * t_0)) / Float64(2.0 * Float64(l * 2.0))))))
                                          end
                                          
                                          D_m = abs(D);
                                          M_m = abs(M);
                                          w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
                                          function tmp = code(w0, M_m, D_m, h, l, d)
                                          	t_0 = (M_m / d) * D_m;
                                          	tmp = w0 * sqrt((1.0 - ((t_0 * (h * t_0)) / (2.0 * (l * 2.0)))));
                                          end
                                          
                                          D_m = N[Abs[D], $MachinePrecision]
                                          M_m = N[Abs[M], $MachinePrecision]
                                          NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
                                          code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := Block[{t$95$0 = N[(N[(M$95$m / d), $MachinePrecision] * D$95$m), $MachinePrecision]}, N[(w0 * N[Sqrt[N[(1.0 - N[(N[(t$95$0 * N[(h * t$95$0), $MachinePrecision]), $MachinePrecision] / N[(2.0 * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
                                          
                                          \begin{array}{l}
                                          D_m = \left|D\right|
                                          \\
                                          M_m = \left|M\right|
                                          \\
                                          [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
                                          \\
                                          \begin{array}{l}
                                          t_0 := \frac{M\_m}{d} \cdot D\_m\\
                                          w0 \cdot \sqrt{1 - \frac{t\_0 \cdot \left(h \cdot t\_0\right)}{2 \cdot \left(\ell \cdot 2\right)}}
                                          \end{array}
                                          \end{array}
                                          
                                          Derivation
                                          1. Initial program 79.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                          Alternative 14: 71.5% accurate, 2.0× speedup?

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

                                            1. Initial program 83.6%

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

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

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

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

                                              1. Initial program 36.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                              Alternative 15: 71.3% accurate, 2.0× speedup?

                                              \[\begin{array}{l} D_m = \left|D\right| \\ M_m = \left|M\right| \\ [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;\frac{M\_m \cdot D\_m}{2 \cdot d} \leq 5 \cdot 10^{+182}:\\ \;\;\;\;w0 \cdot 1\\ \mathbf{else}:\\ \;\;\;\;\left(\left(\left(\left(\left(M\_m \cdot M\_m\right) \cdot h\right) \cdot w0\right) \cdot D\_m\right) \cdot \frac{D\_m}{\left(d \cdot d\right) \cdot \ell}\right) \cdot -0.125\\ \end{array} \end{array} \]
                                              D_m = (fabs.f64 D)
                                              M_m = (fabs.f64 M)
                                              NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
                                              (FPCore (w0 M_m D_m h l d)
                                               :precision binary64
                                               (if (<= (/ (* M_m D_m) (* 2.0 d)) 5e+182)
                                                 (* w0 1.0)
                                                 (* (* (* (* (* (* M_m M_m) h) w0) D_m) (/ D_m (* (* d d) l))) -0.125)))
                                              D_m = fabs(D);
                                              M_m = fabs(M);
                                              assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
                                              double code(double w0, double M_m, double D_m, double h, double l, double d) {
                                              	double tmp;
                                              	if (((M_m * D_m) / (2.0 * d)) <= 5e+182) {
                                              		tmp = w0 * 1.0;
                                              	} else {
                                              		tmp = (((((M_m * M_m) * h) * w0) * D_m) * (D_m / ((d * d) * l))) * -0.125;
                                              	}
                                              	return tmp;
                                              }
                                              
                                              D_m =     private
                                              M_m =     private
                                              NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
                                              module fmin_fmax_functions
                                                  implicit none
                                                  private
                                                  public fmax
                                                  public fmin
                                              
                                                  interface fmax
                                                      module procedure fmax88
                                                      module procedure fmax44
                                                      module procedure fmax84
                                                      module procedure fmax48
                                                  end interface
                                                  interface fmin
                                                      module procedure fmin88
                                                      module procedure fmin44
                                                      module procedure fmin84
                                                      module procedure fmin48
                                                  end interface
                                              contains
                                                  real(8) function fmax88(x, y) result (res)
                                                      real(8), intent (in) :: x
                                                      real(8), intent (in) :: y
                                                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                  end function
                                                  real(4) function fmax44(x, y) result (res)
                                                      real(4), intent (in) :: x
                                                      real(4), intent (in) :: y
                                                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                  end function
                                                  real(8) function fmax84(x, y) result(res)
                                                      real(8), intent (in) :: x
                                                      real(4), intent (in) :: y
                                                      res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                                  end function
                                                  real(8) function fmax48(x, y) result(res)
                                                      real(4), intent (in) :: x
                                                      real(8), intent (in) :: y
                                                      res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                                  end function
                                                  real(8) function fmin88(x, y) result (res)
                                                      real(8), intent (in) :: x
                                                      real(8), intent (in) :: y
                                                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                  end function
                                                  real(4) function fmin44(x, y) result (res)
                                                      real(4), intent (in) :: x
                                                      real(4), intent (in) :: y
                                                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                  end function
                                                  real(8) function fmin84(x, y) result(res)
                                                      real(8), intent (in) :: x
                                                      real(4), intent (in) :: y
                                                      res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                                  end function
                                                  real(8) function fmin48(x, y) result(res)
                                                      real(4), intent (in) :: x
                                                      real(8), intent (in) :: y
                                                      res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                                  end function
                                              end module
                                              
                                              real(8) function code(w0, m_m, d_m, h, l, d)
                                              use fmin_fmax_functions
                                                  real(8), intent (in) :: w0
                                                  real(8), intent (in) :: m_m
                                                  real(8), intent (in) :: d_m
                                                  real(8), intent (in) :: h
                                                  real(8), intent (in) :: l
                                                  real(8), intent (in) :: d
                                                  real(8) :: tmp
                                                  if (((m_m * d_m) / (2.0d0 * d)) <= 5d+182) then
                                                      tmp = w0 * 1.0d0
                                                  else
                                                      tmp = (((((m_m * m_m) * h) * w0) * d_m) * (d_m / ((d * d) * l))) * (-0.125d0)
                                                  end if
                                                  code = tmp
                                              end function
                                              
                                              D_m = Math.abs(D);
                                              M_m = Math.abs(M);
                                              assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
                                              public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
                                              	double tmp;
                                              	if (((M_m * D_m) / (2.0 * d)) <= 5e+182) {
                                              		tmp = w0 * 1.0;
                                              	} else {
                                              		tmp = (((((M_m * M_m) * h) * w0) * D_m) * (D_m / ((d * d) * l))) * -0.125;
                                              	}
                                              	return tmp;
                                              }
                                              
                                              D_m = math.fabs(D)
                                              M_m = math.fabs(M)
                                              [w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d])
                                              def code(w0, M_m, D_m, h, l, d):
                                              	tmp = 0
                                              	if ((M_m * D_m) / (2.0 * d)) <= 5e+182:
                                              		tmp = w0 * 1.0
                                              	else:
                                              		tmp = (((((M_m * M_m) * h) * w0) * D_m) * (D_m / ((d * d) * l))) * -0.125
                                              	return tmp
                                              
                                              D_m = abs(D)
                                              M_m = abs(M)
                                              w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d])
                                              function code(w0, M_m, D_m, h, l, d)
                                              	tmp = 0.0
                                              	if (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) <= 5e+182)
                                              		tmp = Float64(w0 * 1.0);
                                              	else
                                              		tmp = Float64(Float64(Float64(Float64(Float64(Float64(M_m * M_m) * h) * w0) * D_m) * Float64(D_m / Float64(Float64(d * d) * l))) * -0.125);
                                              	end
                                              	return tmp
                                              end
                                              
                                              D_m = abs(D);
                                              M_m = abs(M);
                                              w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
                                              function tmp_2 = code(w0, M_m, D_m, h, l, d)
                                              	tmp = 0.0;
                                              	if (((M_m * D_m) / (2.0 * d)) <= 5e+182)
                                              		tmp = w0 * 1.0;
                                              	else
                                              		tmp = (((((M_m * M_m) * h) * w0) * D_m) * (D_m / ((d * d) * l))) * -0.125;
                                              	end
                                              	tmp_2 = tmp;
                                              end
                                              
                                              D_m = N[Abs[D], $MachinePrecision]
                                              M_m = N[Abs[M], $MachinePrecision]
                                              NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
                                              code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 5e+182], N[(w0 * 1.0), $MachinePrecision], N[(N[(N[(N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] * h), $MachinePrecision] * w0), $MachinePrecision] * D$95$m), $MachinePrecision] * N[(D$95$m / N[(N[(d * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision]]
                                              
                                              \begin{array}{l}
                                              D_m = \left|D\right|
                                              \\
                                              M_m = \left|M\right|
                                              \\
                                              [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
                                              \\
                                              \begin{array}{l}
                                              \mathbf{if}\;\frac{M\_m \cdot D\_m}{2 \cdot d} \leq 5 \cdot 10^{+182}:\\
                                              \;\;\;\;w0 \cdot 1\\
                                              
                                              \mathbf{else}:\\
                                              \;\;\;\;\left(\left(\left(\left(\left(M\_m \cdot M\_m\right) \cdot h\right) \cdot w0\right) \cdot D\_m\right) \cdot \frac{D\_m}{\left(d \cdot d\right) \cdot \ell}\right) \cdot -0.125\\
                                              
                                              
                                              \end{array}
                                              \end{array}
                                              
                                              Derivation
                                              1. Split input into 2 regimes
                                              2. if (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) < 4.99999999999999973e182

                                                1. Initial program 82.7%

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

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

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

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

                                                  1. Initial program 34.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                    Alternative 16: 71.3% accurate, 2.0× speedup?

                                                    \[\begin{array}{l} D_m = \left|D\right| \\ M_m = \left|M\right| \\ [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;\frac{M\_m \cdot D\_m}{2 \cdot d} \leq 5 \cdot 10^{+182}:\\ \;\;\;\;w0 \cdot 1\\ \mathbf{else}:\\ \;\;\;\;\left(\left(D\_m \cdot D\_m\right) \cdot \frac{\left(\left(M\_m \cdot M\_m\right) \cdot h\right) \cdot w0}{\left(d \cdot d\right) \cdot \ell}\right) \cdot -0.125\\ \end{array} \end{array} \]
                                                    D_m = (fabs.f64 D)
                                                    M_m = (fabs.f64 M)
                                                    NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
                                                    (FPCore (w0 M_m D_m h l d)
                                                     :precision binary64
                                                     (if (<= (/ (* M_m D_m) (* 2.0 d)) 5e+182)
                                                       (* w0 1.0)
                                                       (* (* (* D_m D_m) (/ (* (* (* M_m M_m) h) w0) (* (* d d) l))) -0.125)))
                                                    D_m = fabs(D);
                                                    M_m = fabs(M);
                                                    assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
                                                    double code(double w0, double M_m, double D_m, double h, double l, double d) {
                                                    	double tmp;
                                                    	if (((M_m * D_m) / (2.0 * d)) <= 5e+182) {
                                                    		tmp = w0 * 1.0;
                                                    	} else {
                                                    		tmp = ((D_m * D_m) * ((((M_m * M_m) * h) * w0) / ((d * d) * l))) * -0.125;
                                                    	}
                                                    	return tmp;
                                                    }
                                                    
                                                    D_m =     private
                                                    M_m =     private
                                                    NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
                                                    module fmin_fmax_functions
                                                        implicit none
                                                        private
                                                        public fmax
                                                        public fmin
                                                    
                                                        interface fmax
                                                            module procedure fmax88
                                                            module procedure fmax44
                                                            module procedure fmax84
                                                            module procedure fmax48
                                                        end interface
                                                        interface fmin
                                                            module procedure fmin88
                                                            module procedure fmin44
                                                            module procedure fmin84
                                                            module procedure fmin48
                                                        end interface
                                                    contains
                                                        real(8) function fmax88(x, y) result (res)
                                                            real(8), intent (in) :: x
                                                            real(8), intent (in) :: y
                                                            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                        end function
                                                        real(4) function fmax44(x, y) result (res)
                                                            real(4), intent (in) :: x
                                                            real(4), intent (in) :: y
                                                            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                        end function
                                                        real(8) function fmax84(x, y) result(res)
                                                            real(8), intent (in) :: x
                                                            real(4), intent (in) :: y
                                                            res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                                        end function
                                                        real(8) function fmax48(x, y) result(res)
                                                            real(4), intent (in) :: x
                                                            real(8), intent (in) :: y
                                                            res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                                        end function
                                                        real(8) function fmin88(x, y) result (res)
                                                            real(8), intent (in) :: x
                                                            real(8), intent (in) :: y
                                                            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                        end function
                                                        real(4) function fmin44(x, y) result (res)
                                                            real(4), intent (in) :: x
                                                            real(4), intent (in) :: y
                                                            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                        end function
                                                        real(8) function fmin84(x, y) result(res)
                                                            real(8), intent (in) :: x
                                                            real(4), intent (in) :: y
                                                            res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                                        end function
                                                        real(8) function fmin48(x, y) result(res)
                                                            real(4), intent (in) :: x
                                                            real(8), intent (in) :: y
                                                            res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                                        end function
                                                    end module
                                                    
                                                    real(8) function code(w0, m_m, d_m, h, l, d)
                                                    use fmin_fmax_functions
                                                        real(8), intent (in) :: w0
                                                        real(8), intent (in) :: m_m
                                                        real(8), intent (in) :: d_m
                                                        real(8), intent (in) :: h
                                                        real(8), intent (in) :: l
                                                        real(8), intent (in) :: d
                                                        real(8) :: tmp
                                                        if (((m_m * d_m) / (2.0d0 * d)) <= 5d+182) then
                                                            tmp = w0 * 1.0d0
                                                        else
                                                            tmp = ((d_m * d_m) * ((((m_m * m_m) * h) * w0) / ((d * d) * l))) * (-0.125d0)
                                                        end if
                                                        code = tmp
                                                    end function
                                                    
                                                    D_m = Math.abs(D);
                                                    M_m = Math.abs(M);
                                                    assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
                                                    public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
                                                    	double tmp;
                                                    	if (((M_m * D_m) / (2.0 * d)) <= 5e+182) {
                                                    		tmp = w0 * 1.0;
                                                    	} else {
                                                    		tmp = ((D_m * D_m) * ((((M_m * M_m) * h) * w0) / ((d * d) * l))) * -0.125;
                                                    	}
                                                    	return tmp;
                                                    }
                                                    
                                                    D_m = math.fabs(D)
                                                    M_m = math.fabs(M)
                                                    [w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d])
                                                    def code(w0, M_m, D_m, h, l, d):
                                                    	tmp = 0
                                                    	if ((M_m * D_m) / (2.0 * d)) <= 5e+182:
                                                    		tmp = w0 * 1.0
                                                    	else:
                                                    		tmp = ((D_m * D_m) * ((((M_m * M_m) * h) * w0) / ((d * d) * l))) * -0.125
                                                    	return tmp
                                                    
                                                    D_m = abs(D)
                                                    M_m = abs(M)
                                                    w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d])
                                                    function code(w0, M_m, D_m, h, l, d)
                                                    	tmp = 0.0
                                                    	if (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) <= 5e+182)
                                                    		tmp = Float64(w0 * 1.0);
                                                    	else
                                                    		tmp = Float64(Float64(Float64(D_m * D_m) * Float64(Float64(Float64(Float64(M_m * M_m) * h) * w0) / Float64(Float64(d * d) * l))) * -0.125);
                                                    	end
                                                    	return tmp
                                                    end
                                                    
                                                    D_m = abs(D);
                                                    M_m = abs(M);
                                                    w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
                                                    function tmp_2 = code(w0, M_m, D_m, h, l, d)
                                                    	tmp = 0.0;
                                                    	if (((M_m * D_m) / (2.0 * d)) <= 5e+182)
                                                    		tmp = w0 * 1.0;
                                                    	else
                                                    		tmp = ((D_m * D_m) * ((((M_m * M_m) * h) * w0) / ((d * d) * l))) * -0.125;
                                                    	end
                                                    	tmp_2 = tmp;
                                                    end
                                                    
                                                    D_m = N[Abs[D], $MachinePrecision]
                                                    M_m = N[Abs[M], $MachinePrecision]
                                                    NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
                                                    code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 5e+182], N[(w0 * 1.0), $MachinePrecision], N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] * N[(N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] * h), $MachinePrecision] * w0), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision]]
                                                    
                                                    \begin{array}{l}
                                                    D_m = \left|D\right|
                                                    \\
                                                    M_m = \left|M\right|
                                                    \\
                                                    [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
                                                    \\
                                                    \begin{array}{l}
                                                    \mathbf{if}\;\frac{M\_m \cdot D\_m}{2 \cdot d} \leq 5 \cdot 10^{+182}:\\
                                                    \;\;\;\;w0 \cdot 1\\
                                                    
                                                    \mathbf{else}:\\
                                                    \;\;\;\;\left(\left(D\_m \cdot D\_m\right) \cdot \frac{\left(\left(M\_m \cdot M\_m\right) \cdot h\right) \cdot w0}{\left(d \cdot d\right) \cdot \ell}\right) \cdot -0.125\\
                                                    
                                                    
                                                    \end{array}
                                                    \end{array}
                                                    
                                                    Derivation
                                                    1. Split input into 2 regimes
                                                    2. if (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) < 4.99999999999999973e182

                                                      1. Initial program 82.7%

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

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

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

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

                                                        1. Initial program 34.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                          Alternative 17: 87.2% accurate, 2.0× speedup?

                                                          \[\begin{array}{l} D_m = \left|D\right| \\ M_m = \left|M\right| \\ [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\ \\ w0 \cdot \sqrt{1 - \frac{\left(\frac{M\_m \cdot D\_m}{d} \cdot h\right) \cdot \left(D\_m \cdot \frac{M\_m}{d}\right)}{\ell \cdot 4}} \end{array} \]
                                                          D_m = (fabs.f64 D)
                                                          M_m = (fabs.f64 M)
                                                          NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
                                                          (FPCore (w0 M_m D_m h l d)
                                                           :precision binary64
                                                           (*
                                                            w0
                                                            (sqrt (- 1.0 (/ (* (* (/ (* M_m D_m) d) h) (* D_m (/ M_m d))) (* l 4.0))))))
                                                          D_m = fabs(D);
                                                          M_m = fabs(M);
                                                          assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
                                                          double code(double w0, double M_m, double D_m, double h, double l, double d) {
                                                          	return w0 * sqrt((1.0 - (((((M_m * D_m) / d) * h) * (D_m * (M_m / d))) / (l * 4.0))));
                                                          }
                                                          
                                                          D_m =     private
                                                          M_m =     private
                                                          NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
                                                          module fmin_fmax_functions
                                                              implicit none
                                                              private
                                                              public fmax
                                                              public fmin
                                                          
                                                              interface fmax
                                                                  module procedure fmax88
                                                                  module procedure fmax44
                                                                  module procedure fmax84
                                                                  module procedure fmax48
                                                              end interface
                                                              interface fmin
                                                                  module procedure fmin88
                                                                  module procedure fmin44
                                                                  module procedure fmin84
                                                                  module procedure fmin48
                                                              end interface
                                                          contains
                                                              real(8) function fmax88(x, y) result (res)
                                                                  real(8), intent (in) :: x
                                                                  real(8), intent (in) :: y
                                                                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                              end function
                                                              real(4) function fmax44(x, y) result (res)
                                                                  real(4), intent (in) :: x
                                                                  real(4), intent (in) :: y
                                                                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                              end function
                                                              real(8) function fmax84(x, y) result(res)
                                                                  real(8), intent (in) :: x
                                                                  real(4), intent (in) :: y
                                                                  res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                                              end function
                                                              real(8) function fmax48(x, y) result(res)
                                                                  real(4), intent (in) :: x
                                                                  real(8), intent (in) :: y
                                                                  res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                                              end function
                                                              real(8) function fmin88(x, y) result (res)
                                                                  real(8), intent (in) :: x
                                                                  real(8), intent (in) :: y
                                                                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                              end function
                                                              real(4) function fmin44(x, y) result (res)
                                                                  real(4), intent (in) :: x
                                                                  real(4), intent (in) :: y
                                                                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                              end function
                                                              real(8) function fmin84(x, y) result(res)
                                                                  real(8), intent (in) :: x
                                                                  real(4), intent (in) :: y
                                                                  res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                                              end function
                                                              real(8) function fmin48(x, y) result(res)
                                                                  real(4), intent (in) :: x
                                                                  real(8), intent (in) :: y
                                                                  res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                                              end function
                                                          end module
                                                          
                                                          real(8) function code(w0, m_m, d_m, h, l, d)
                                                          use fmin_fmax_functions
                                                              real(8), intent (in) :: w0
                                                              real(8), intent (in) :: m_m
                                                              real(8), intent (in) :: d_m
                                                              real(8), intent (in) :: h
                                                              real(8), intent (in) :: l
                                                              real(8), intent (in) :: d
                                                              code = w0 * sqrt((1.0d0 - (((((m_m * d_m) / d) * h) * (d_m * (m_m / d))) / (l * 4.0d0))))
                                                          end function
                                                          
                                                          D_m = Math.abs(D);
                                                          M_m = Math.abs(M);
                                                          assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
                                                          public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
                                                          	return w0 * Math.sqrt((1.0 - (((((M_m * D_m) / d) * h) * (D_m * (M_m / d))) / (l * 4.0))));
                                                          }
                                                          
                                                          D_m = math.fabs(D)
                                                          M_m = math.fabs(M)
                                                          [w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d])
                                                          def code(w0, M_m, D_m, h, l, d):
                                                          	return w0 * math.sqrt((1.0 - (((((M_m * D_m) / d) * h) * (D_m * (M_m / d))) / (l * 4.0))))
                                                          
                                                          D_m = abs(D)
                                                          M_m = abs(M)
                                                          w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d])
                                                          function code(w0, M_m, D_m, h, l, d)
                                                          	return Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(Float64(Float64(M_m * D_m) / d) * h) * Float64(D_m * Float64(M_m / d))) / Float64(l * 4.0)))))
                                                          end
                                                          
                                                          D_m = abs(D);
                                                          M_m = abs(M);
                                                          w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
                                                          function tmp = code(w0, M_m, D_m, h, l, d)
                                                          	tmp = w0 * sqrt((1.0 - (((((M_m * D_m) / d) * h) * (D_m * (M_m / d))) / (l * 4.0))));
                                                          end
                                                          
                                                          D_m = N[Abs[D], $MachinePrecision]
                                                          M_m = N[Abs[M], $MachinePrecision]
                                                          NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
                                                          code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(N[(N[(M$95$m * D$95$m), $MachinePrecision] / d), $MachinePrecision] * h), $MachinePrecision] * N[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(l * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
                                                          
                                                          \begin{array}{l}
                                                          D_m = \left|D\right|
                                                          \\
                                                          M_m = \left|M\right|
                                                          \\
                                                          [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
                                                          \\
                                                          w0 \cdot \sqrt{1 - \frac{\left(\frac{M\_m \cdot D\_m}{d} \cdot h\right) \cdot \left(D\_m \cdot \frac{M\_m}{d}\right)}{\ell \cdot 4}}
                                                          \end{array}
                                                          
                                                          Derivation
                                                          1. Initial program 79.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                          Alternative 18: 67.5% accurate, 26.2× speedup?

                                                          \[\begin{array}{l} D_m = \left|D\right| \\ M_m = \left|M\right| \\ [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\ \\ w0 \cdot 1 \end{array} \]
                                                          D_m = (fabs.f64 D)
                                                          M_m = (fabs.f64 M)
                                                          NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
                                                          (FPCore (w0 M_m D_m h l d) :precision binary64 (* w0 1.0))
                                                          D_m = fabs(D);
                                                          M_m = fabs(M);
                                                          assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
                                                          double code(double w0, double M_m, double D_m, double h, double l, double d) {
                                                          	return w0 * 1.0;
                                                          }
                                                          
                                                          D_m =     private
                                                          M_m =     private
                                                          NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
                                                          module fmin_fmax_functions
                                                              implicit none
                                                              private
                                                              public fmax
                                                              public fmin
                                                          
                                                              interface fmax
                                                                  module procedure fmax88
                                                                  module procedure fmax44
                                                                  module procedure fmax84
                                                                  module procedure fmax48
                                                              end interface
                                                              interface fmin
                                                                  module procedure fmin88
                                                                  module procedure fmin44
                                                                  module procedure fmin84
                                                                  module procedure fmin48
                                                              end interface
                                                          contains
                                                              real(8) function fmax88(x, y) result (res)
                                                                  real(8), intent (in) :: x
                                                                  real(8), intent (in) :: y
                                                                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                              end function
                                                              real(4) function fmax44(x, y) result (res)
                                                                  real(4), intent (in) :: x
                                                                  real(4), intent (in) :: y
                                                                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                              end function
                                                              real(8) function fmax84(x, y) result(res)
                                                                  real(8), intent (in) :: x
                                                                  real(4), intent (in) :: y
                                                                  res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                                              end function
                                                              real(8) function fmax48(x, y) result(res)
                                                                  real(4), intent (in) :: x
                                                                  real(8), intent (in) :: y
                                                                  res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                                              end function
                                                              real(8) function fmin88(x, y) result (res)
                                                                  real(8), intent (in) :: x
                                                                  real(8), intent (in) :: y
                                                                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                              end function
                                                              real(4) function fmin44(x, y) result (res)
                                                                  real(4), intent (in) :: x
                                                                  real(4), intent (in) :: y
                                                                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                              end function
                                                              real(8) function fmin84(x, y) result(res)
                                                                  real(8), intent (in) :: x
                                                                  real(4), intent (in) :: y
                                                                  res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                                              end function
                                                              real(8) function fmin48(x, y) result(res)
                                                                  real(4), intent (in) :: x
                                                                  real(8), intent (in) :: y
                                                                  res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                                              end function
                                                          end module
                                                          
                                                          real(8) function code(w0, m_m, d_m, h, l, d)
                                                          use fmin_fmax_functions
                                                              real(8), intent (in) :: w0
                                                              real(8), intent (in) :: m_m
                                                              real(8), intent (in) :: d_m
                                                              real(8), intent (in) :: h
                                                              real(8), intent (in) :: l
                                                              real(8), intent (in) :: d
                                                              code = w0 * 1.0d0
                                                          end function
                                                          
                                                          D_m = Math.abs(D);
                                                          M_m = Math.abs(M);
                                                          assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
                                                          public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
                                                          	return w0 * 1.0;
                                                          }
                                                          
                                                          D_m = math.fabs(D)
                                                          M_m = math.fabs(M)
                                                          [w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d])
                                                          def code(w0, M_m, D_m, h, l, d):
                                                          	return w0 * 1.0
                                                          
                                                          D_m = abs(D)
                                                          M_m = abs(M)
                                                          w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d])
                                                          function code(w0, M_m, D_m, h, l, d)
                                                          	return Float64(w0 * 1.0)
                                                          end
                                                          
                                                          D_m = abs(D);
                                                          M_m = abs(M);
                                                          w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
                                                          function tmp = code(w0, M_m, D_m, h, l, d)
                                                          	tmp = w0 * 1.0;
                                                          end
                                                          
                                                          D_m = N[Abs[D], $MachinePrecision]
                                                          M_m = N[Abs[M], $MachinePrecision]
                                                          NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
                                                          code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := N[(w0 * 1.0), $MachinePrecision]
                                                          
                                                          \begin{array}{l}
                                                          D_m = \left|D\right|
                                                          \\
                                                          M_m = \left|M\right|
                                                          \\
                                                          [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
                                                          \\
                                                          w0 \cdot 1
                                                          \end{array}
                                                          
                                                          Derivation
                                                          1. Initial program 79.7%

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

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

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

                                                            Reproduce

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