Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 81.1% → 88.2%
Time: 5.6s
Alternatives: 11
Speedup: 1.1×

Specification

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

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

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

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

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 11 alternatives:

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

Initial Program: 81.1% accurate, 1.0× speedup?

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

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

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

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

Alternative 1: 88.2% accurate, 1.1× speedup?

\[\begin{array}{l} [w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\ \\ \begin{array}{l} t_0 := \frac{D}{d + d} \cdot M\\ w0 \cdot \sqrt{1 - \frac{t\_0 \cdot \left(t\_0 \cdot h\right)}{\ell}} \end{array} \end{array} \]
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M D h l d)
 :precision binary64
 (let* ((t_0 (* (/ D (+ d d)) M)))
   (* w0 (sqrt (- 1.0 (/ (* t_0 (* t_0 h)) l))))))
assert(w0 < M && M < D && D < h && h < l && l < d);
double code(double w0, double M, double D, double h, double l, double d) {
	double t_0 = (D / (d + d)) * M;
	return w0 * sqrt((1.0 - ((t_0 * (t_0 * h)) / l)));
}
NOTE: w0, M, D, 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, 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
    real(8) :: t_0
    t_0 = (d / (d_1 + d_1)) * m
    code = w0 * sqrt((1.0d0 - ((t_0 * (t_0 * h)) / l)))
end function
assert w0 < M && M < D && D < h && h < l && l < d;
public static double code(double w0, double M, double D, double h, double l, double d) {
	double t_0 = (D / (d + d)) * M;
	return w0 * Math.sqrt((1.0 - ((t_0 * (t_0 * h)) / l)));
}
[w0, M, D, h, l, d] = sort([w0, M, D, h, l, d])
def code(w0, M, D, h, l, d):
	t_0 = (D / (d + d)) * M
	return w0 * math.sqrt((1.0 - ((t_0 * (t_0 * h)) / l)))
w0, M, D, h, l, d = sort([w0, M, D, h, l, d])
function code(w0, M, D, h, l, d)
	t_0 = Float64(Float64(D / Float64(d + d)) * M)
	return Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(t_0 * Float64(t_0 * h)) / l))))
end
w0, M, D, h, l, d = num2cell(sort([w0, M, D, h, l, d])){:}
function tmp = code(w0, M, D, h, l, d)
	t_0 = (D / (d + d)) * M;
	tmp = w0 * sqrt((1.0 - ((t_0 * (t_0 * h)) / l)));
end
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[(N[(D / N[(d + d), $MachinePrecision]), $MachinePrecision] * M), $MachinePrecision]}, N[(w0 * N[Sqrt[N[(1.0 - N[(N[(t$95$0 * N[(t$95$0 * h), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\
\\
\begin{array}{l}
t_0 := \frac{D}{d + d} \cdot M\\
w0 \cdot \sqrt{1 - \frac{t\_0 \cdot \left(t\_0 \cdot h\right)}{\ell}}
\end{array}
\end{array}
Derivation
  1. Initial program 81.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 86.5% accurate, 1.1× speedup?

\[\begin{array}{l} [w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\ \\ \begin{array}{l} t_0 := M \cdot \frac{D}{d + d}\\ w0 \cdot \sqrt{1 - \frac{\left(t\_0 \cdot t\_0\right) \cdot h}{\ell}} \end{array} \end{array} \]
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M D h l d)
 :precision binary64
 (let* ((t_0 (* M (/ D (+ d d)))))
   (* w0 (sqrt (- 1.0 (/ (* (* t_0 t_0) h) l))))))
assert(w0 < M && M < D && D < h && h < l && l < d);
double code(double w0, double M, double D, double h, double l, double d) {
	double t_0 = M * (D / (d + d));
	return w0 * sqrt((1.0 - (((t_0 * t_0) * h) / l)));
}
NOTE: w0, M, D, 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, 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
    real(8) :: t_0
    t_0 = m * (d / (d_1 + d_1))
    code = w0 * sqrt((1.0d0 - (((t_0 * t_0) * h) / l)))
end function
assert w0 < M && M < D && D < h && h < l && l < d;
public static double code(double w0, double M, double D, double h, double l, double d) {
	double t_0 = M * (D / (d + d));
	return w0 * Math.sqrt((1.0 - (((t_0 * t_0) * h) / l)));
}
[w0, M, D, h, l, d] = sort([w0, M, D, h, l, d])
def code(w0, M, D, h, l, d):
	t_0 = M * (D / (d + d))
	return w0 * math.sqrt((1.0 - (((t_0 * t_0) * h) / l)))
w0, M, D, h, l, d = sort([w0, M, D, h, l, d])
function code(w0, M, D, h, l, d)
	t_0 = Float64(M * Float64(D / Float64(d + d)))
	return Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(t_0 * t_0) * h) / l))))
end
w0, M, D, h, l, d = num2cell(sort([w0, M, D, h, l, d])){:}
function tmp = code(w0, M, D, h, l, d)
	t_0 = M * (D / (d + d));
	tmp = w0 * sqrt((1.0 - (((t_0 * t_0) * h) / l)));
end
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[(M * N[(D / N[(d + d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\
\\
\begin{array}{l}
t_0 := M \cdot \frac{D}{d + d}\\
w0 \cdot \sqrt{1 - \frac{\left(t\_0 \cdot t\_0\right) \cdot h}{\ell}}
\end{array}
\end{array}
Derivation
  1. Initial program 81.1%

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

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

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

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

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

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

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

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

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

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

Alternative 3: 86.3% accurate, 0.5× speedup?

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

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


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

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 41.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 86.2% accurate, 0.6× speedup?

\[\begin{array}{l} [w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\ \\ \begin{array}{l} t_0 := M \cdot \frac{D}{d}\\ \mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq 0:\\ \;\;\;\;w0 \cdot \sqrt{1 - \left(\left(t\_0 \cdot t\_0\right) \cdot 0.25\right) \cdot \frac{h}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \end{array} \]
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M D h l d)
 :precision binary64
 (let* ((t_0 (* M (/ D d))))
   (if (<= (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l)) 0.0)
     (* w0 (sqrt (- 1.0 (* (* (* t_0 t_0) 0.25) (/ h l)))))
     w0)))
assert(w0 < M && M < D && D < h && h < l && l < d);
double code(double w0, double M, double D, double h, double l, double d) {
	double t_0 = M * (D / d);
	double tmp;
	if ((pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= 0.0) {
		tmp = w0 * sqrt((1.0 - (((t_0 * t_0) * 0.25) * (h / l))));
	} else {
		tmp = w0;
	}
	return tmp;
}
NOTE: w0, M, D, 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, 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
    real(8) :: t_0
    real(8) :: tmp
    t_0 = m * (d / d_1)
    if (((((m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l)) <= 0.0d0) then
        tmp = w0 * sqrt((1.0d0 - (((t_0 * t_0) * 0.25d0) * (h / l))))
    else
        tmp = w0
    end if
    code = tmp
end function
assert w0 < M && M < D && D < h && h < l && l < d;
public static double code(double w0, double M, double D, double h, double l, double d) {
	double t_0 = M * (D / d);
	double tmp;
	if ((Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= 0.0) {
		tmp = w0 * Math.sqrt((1.0 - (((t_0 * t_0) * 0.25) * (h / l))));
	} else {
		tmp = w0;
	}
	return tmp;
}
[w0, M, D, h, l, d] = sort([w0, M, D, h, l, d])
def code(w0, M, D, h, l, d):
	t_0 = M * (D / d)
	tmp = 0
	if (math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= 0.0:
		tmp = w0 * math.sqrt((1.0 - (((t_0 * t_0) * 0.25) * (h / l))))
	else:
		tmp = w0
	return tmp
w0, M, D, h, l, d = sort([w0, M, D, h, l, d])
function code(w0, M, D, h, l, d)
	t_0 = Float64(M * Float64(D / d))
	tmp = 0.0
	if (Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= 0.0)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(t_0 * t_0) * 0.25) * Float64(h / l)))));
	else
		tmp = w0;
	end
	return tmp
end
w0, M, D, h, l, d = num2cell(sort([w0, M, D, h, l, d])){:}
function tmp_2 = code(w0, M, D, h, l, d)
	t_0 = M * (D / d);
	tmp = 0.0;
	if (((((M * D) / (2.0 * d)) ^ 2.0) * (h / l)) <= 0.0)
		tmp = w0 * sqrt((1.0 - (((t_0 * t_0) * 0.25) * (h / l))));
	else
		tmp = w0;
	end
	tmp_2 = tmp;
end
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[(M * N[(D / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], 0.0], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] * 0.25), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0]]
\begin{array}{l}
[w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\
\\
\begin{array}{l}
t_0 := M \cdot \frac{D}{d}\\
\mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq 0:\\
\;\;\;\;w0 \cdot \sqrt{1 - \left(\left(t\_0 \cdot t\_0\right) \cdot 0.25\right) \cdot \frac{h}{\ell}}\\

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


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

    1. Initial program 87.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 47.2%

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

      \[\leadsto \color{blue}{w0} \]
    3. Step-by-step derivation
      1. Applied rewrites82.8%

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

    Alternative 5: 81.7% accurate, 0.6× speedup?

    \[\begin{array}{l} [w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -2 \cdot 10^{+60}:\\ \;\;\;\;w0 \cdot \sqrt{\frac{\left(h \cdot M\right) \cdot M}{d} \cdot \left(\left(D \cdot \frac{D}{\ell \cdot d}\right) \cdot -0.25\right)}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \end{array} \]
    NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
    (FPCore (w0 M D h l d)
     :precision binary64
     (if (<= (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l)) -2e+60)
       (* w0 (sqrt (* (/ (* (* h M) M) d) (* (* D (/ D (* l d))) -0.25))))
       w0))
    assert(w0 < M && M < D && D < h && h < l && l < d);
    double code(double w0, double M, double D, double h, double l, double d) {
    	double tmp;
    	if ((pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -2e+60) {
    		tmp = w0 * sqrt(((((h * M) * M) / d) * ((D * (D / (l * d))) * -0.25)));
    	} else {
    		tmp = w0;
    	}
    	return tmp;
    }
    
    NOTE: w0, M, D, 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, 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
        real(8) :: tmp
        if (((((m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l)) <= (-2d+60)) then
            tmp = w0 * sqrt(((((h * m) * m) / d_1) * ((d * (d / (l * d_1))) * (-0.25d0))))
        else
            tmp = w0
        end if
        code = tmp
    end function
    
    assert w0 < M && M < D && D < h && h < l && l < d;
    public static double code(double w0, double M, double D, double h, double l, double d) {
    	double tmp;
    	if ((Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -2e+60) {
    		tmp = w0 * Math.sqrt(((((h * M) * M) / d) * ((D * (D / (l * d))) * -0.25)));
    	} else {
    		tmp = w0;
    	}
    	return tmp;
    }
    
    [w0, M, D, h, l, d] = sort([w0, M, D, h, l, d])
    def code(w0, M, D, h, l, d):
    	tmp = 0
    	if (math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -2e+60:
    		tmp = w0 * math.sqrt(((((h * M) * M) / d) * ((D * (D / (l * d))) * -0.25)))
    	else:
    		tmp = w0
    	return tmp
    
    w0, M, D, h, l, d = sort([w0, M, D, h, l, d])
    function code(w0, M, D, h, l, d)
    	tmp = 0.0
    	if (Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= -2e+60)
    		tmp = Float64(w0 * sqrt(Float64(Float64(Float64(Float64(h * M) * M) / d) * Float64(Float64(D * Float64(D / Float64(l * d))) * -0.25))));
    	else
    		tmp = w0;
    	end
    	return tmp
    end
    
    w0, M, D, h, l, d = num2cell(sort([w0, M, D, h, l, d])){:}
    function tmp_2 = code(w0, M, D, h, l, d)
    	tmp = 0.0;
    	if (((((M * D) / (2.0 * d)) ^ 2.0) * (h / l)) <= -2e+60)
    		tmp = w0 * sqrt(((((h * M) * M) / d) * ((D * (D / (l * d))) * -0.25)));
    	else
    		tmp = w0;
    	end
    	tmp_2 = tmp;
    end
    
    NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
    code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -2e+60], N[(w0 * N[Sqrt[N[(N[(N[(N[(h * M), $MachinePrecision] * M), $MachinePrecision] / d), $MachinePrecision] * N[(N[(D * N[(D / N[(l * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0]
    
    \begin{array}{l}
    [w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\
    \\
    \begin{array}{l}
    \mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -2 \cdot 10^{+60}:\\
    \;\;\;\;w0 \cdot \sqrt{\frac{\left(h \cdot M\right) \cdot M}{d} \cdot \left(\left(D \cdot \frac{D}{\ell \cdot d}\right) \cdot -0.25\right)}\\
    
    \mathbf{else}:\\
    \;\;\;\;w0\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < -1.9999999999999999e60

      1. Initial program 63.1%

        \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
      2. 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}}} \]
      3. Step-by-step derivation
        1. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      1. Initial program 88.6%

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

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

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

      Alternative 6: 81.1% accurate, 0.6× speedup?

      \[\begin{array}{l} [w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -2 \cdot 10^{+72}:\\ \;\;\;\;w0 \cdot \sqrt{\left(\left(\left(h \cdot M\right) \cdot \frac{M}{d}\right) \cdot \frac{D \cdot D}{\ell \cdot d}\right) \cdot -0.25}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \end{array} \]
      NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
      (FPCore (w0 M D h l d)
       :precision binary64
       (if (<= (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l)) -2e+72)
         (* w0 (sqrt (* (* (* (* h M) (/ M d)) (/ (* D D) (* l d))) -0.25)))
         w0))
      assert(w0 < M && M < D && D < h && h < l && l < d);
      double code(double w0, double M, double D, double h, double l, double d) {
      	double tmp;
      	if ((pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -2e+72) {
      		tmp = w0 * sqrt(((((h * M) * (M / d)) * ((D * D) / (l * d))) * -0.25));
      	} else {
      		tmp = w0;
      	}
      	return tmp;
      }
      
      NOTE: w0, M, D, 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, 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
          real(8) :: tmp
          if (((((m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l)) <= (-2d+72)) then
              tmp = w0 * sqrt(((((h * m) * (m / d_1)) * ((d * d) / (l * d_1))) * (-0.25d0)))
          else
              tmp = w0
          end if
          code = tmp
      end function
      
      assert w0 < M && M < D && D < h && h < l && l < d;
      public static double code(double w0, double M, double D, double h, double l, double d) {
      	double tmp;
      	if ((Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -2e+72) {
      		tmp = w0 * Math.sqrt(((((h * M) * (M / d)) * ((D * D) / (l * d))) * -0.25));
      	} else {
      		tmp = w0;
      	}
      	return tmp;
      }
      
      [w0, M, D, h, l, d] = sort([w0, M, D, h, l, d])
      def code(w0, M, D, h, l, d):
      	tmp = 0
      	if (math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -2e+72:
      		tmp = w0 * math.sqrt(((((h * M) * (M / d)) * ((D * D) / (l * d))) * -0.25))
      	else:
      		tmp = w0
      	return tmp
      
      w0, M, D, h, l, d = sort([w0, M, D, h, l, d])
      function code(w0, M, D, h, l, d)
      	tmp = 0.0
      	if (Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= -2e+72)
      		tmp = Float64(w0 * sqrt(Float64(Float64(Float64(Float64(h * M) * Float64(M / d)) * Float64(Float64(D * D) / Float64(l * d))) * -0.25)));
      	else
      		tmp = w0;
      	end
      	return tmp
      end
      
      w0, M, D, h, l, d = num2cell(sort([w0, M, D, h, l, d])){:}
      function tmp_2 = code(w0, M, D, h, l, d)
      	tmp = 0.0;
      	if (((((M * D) / (2.0 * d)) ^ 2.0) * (h / l)) <= -2e+72)
      		tmp = w0 * sqrt(((((h * M) * (M / d)) * ((D * D) / (l * d))) * -0.25));
      	else
      		tmp = w0;
      	end
      	tmp_2 = tmp;
      end
      
      NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
      code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -2e+72], N[(w0 * N[Sqrt[N[(N[(N[(N[(h * M), $MachinePrecision] * N[(M / d), $MachinePrecision]), $MachinePrecision] * N[(N[(D * D), $MachinePrecision] / N[(l * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0]
      
      \begin{array}{l}
      [w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\
      \\
      \begin{array}{l}
      \mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -2 \cdot 10^{+72}:\\
      \;\;\;\;w0 \cdot \sqrt{\left(\left(\left(h \cdot M\right) \cdot \frac{M}{d}\right) \cdot \frac{D \cdot D}{\ell \cdot d}\right) \cdot -0.25}\\
      
      \mathbf{else}:\\
      \;\;\;\;w0\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < -1.99999999999999989e72

        1. Initial program 62.7%

          \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
        2. 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}}} \]
        3. Step-by-step derivation
          1. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        1. Initial program 88.7%

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

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

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

        Alternative 7: 80.7% accurate, 0.6× speedup?

        \[\begin{array}{l} [w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -1 \cdot 10^{+39}:\\ \;\;\;\;w0 \cdot \sqrt{\frac{\left(\left(\left(M \cdot D\right) \cdot D\right) \cdot M\right) \cdot h}{d \cdot \left(d \cdot \ell\right)} \cdot -0.25}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \end{array} \]
        NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
        (FPCore (w0 M D h l d)
         :precision binary64
         (if (<= (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l)) -1e+39)
           (* w0 (sqrt (* (/ (* (* (* (* M D) D) M) h) (* d (* d l))) -0.25)))
           w0))
        assert(w0 < M && M < D && D < h && h < l && l < d);
        double code(double w0, double M, double D, double h, double l, double d) {
        	double tmp;
        	if ((pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -1e+39) {
        		tmp = w0 * sqrt(((((((M * D) * D) * M) * h) / (d * (d * l))) * -0.25));
        	} else {
        		tmp = w0;
        	}
        	return tmp;
        }
        
        NOTE: w0, M, D, 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, 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
            real(8) :: tmp
            if (((((m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l)) <= (-1d+39)) then
                tmp = w0 * sqrt(((((((m * d) * d) * m) * h) / (d_1 * (d_1 * l))) * (-0.25d0)))
            else
                tmp = w0
            end if
            code = tmp
        end function
        
        assert w0 < M && M < D && D < h && h < l && l < d;
        public static double code(double w0, double M, double D, double h, double l, double d) {
        	double tmp;
        	if ((Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -1e+39) {
        		tmp = w0 * Math.sqrt(((((((M * D) * D) * M) * h) / (d * (d * l))) * -0.25));
        	} else {
        		tmp = w0;
        	}
        	return tmp;
        }
        
        [w0, M, D, h, l, d] = sort([w0, M, D, h, l, d])
        def code(w0, M, D, h, l, d):
        	tmp = 0
        	if (math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -1e+39:
        		tmp = w0 * math.sqrt(((((((M * D) * D) * M) * h) / (d * (d * l))) * -0.25))
        	else:
        		tmp = w0
        	return tmp
        
        w0, M, D, h, l, d = sort([w0, M, D, h, l, d])
        function code(w0, M, D, h, l, d)
        	tmp = 0.0
        	if (Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= -1e+39)
        		tmp = Float64(w0 * sqrt(Float64(Float64(Float64(Float64(Float64(Float64(M * D) * D) * M) * h) / Float64(d * Float64(d * l))) * -0.25)));
        	else
        		tmp = w0;
        	end
        	return tmp
        end
        
        w0, M, D, h, l, d = num2cell(sort([w0, M, D, h, l, d])){:}
        function tmp_2 = code(w0, M, D, h, l, d)
        	tmp = 0.0;
        	if (((((M * D) / (2.0 * d)) ^ 2.0) * (h / l)) <= -1e+39)
        		tmp = w0 * sqrt(((((((M * D) * D) * M) * h) / (d * (d * l))) * -0.25));
        	else
        		tmp = w0;
        	end
        	tmp_2 = tmp;
        end
        
        NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
        code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -1e+39], N[(w0 * N[Sqrt[N[(N[(N[(N[(N[(N[(M * D), $MachinePrecision] * D), $MachinePrecision] * M), $MachinePrecision] * h), $MachinePrecision] / N[(d * N[(d * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0]
        
        \begin{array}{l}
        [w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\
        \\
        \begin{array}{l}
        \mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -1 \cdot 10^{+39}:\\
        \;\;\;\;w0 \cdot \sqrt{\frac{\left(\left(\left(M \cdot D\right) \cdot D\right) \cdot M\right) \cdot h}{d \cdot \left(d \cdot \ell\right)} \cdot -0.25}\\
        
        \mathbf{else}:\\
        \;\;\;\;w0\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < -9.9999999999999994e38

          1. Initial program 63.9%

            \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
          2. 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}}} \]
          3. Step-by-step derivation
            1. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          1. Initial program 88.5%

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

            \[\leadsto \color{blue}{w0} \]
          3. Step-by-step derivation
            1. Applied rewrites94.6%

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

          Alternative 8: 78.8% accurate, 0.6× speedup?

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

            1. Initial program 55.5%

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

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

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

                \[\leadsto \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 \mathsf{fma}\left(\frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(h \cdot w0\right)\right)}{{d}^{2} \cdot \ell}, \color{blue}{\frac{-1}{8}}, w0\right) \]
            4. Applied rewrites43.5%

              \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{\left(\left(\left(M \cdot M\right) \cdot h\right) \cdot w0\right) \cdot \left(D \cdot D\right)}{\left(d \cdot d\right) \cdot \ell}, -0.125, w0\right)} \]
            5. 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}} \]
            6. Applied rewrites43.1%

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

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

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

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

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

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

                \[\leadsto \frac{\left(\left(\left(h \cdot M\right) \cdot M\right) \cdot \left(w0 \cdot \left(D \cdot D\right)\right)\right) \cdot \frac{-1}{8}}{d \cdot \left(\ell \cdot \color{blue}{d}\right)} \]
              6. lift-*.f6446.6

                \[\leadsto \frac{\left(\left(\left(h \cdot M\right) \cdot M\right) \cdot \left(w0 \cdot \left(D \cdot D\right)\right)\right) \cdot -0.125}{d \cdot \left(\ell \cdot d\right)} \]
            9. Applied rewrites46.6%

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

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

            1. Initial program 89.3%

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

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

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

            Alternative 9: 77.8% accurate, 0.6× speedup?

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

              1. Initial program 55.5%

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

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

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

                  \[\leadsto \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 \mathsf{fma}\left(\frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(h \cdot w0\right)\right)}{{d}^{2} \cdot \ell}, \color{blue}{\frac{-1}{8}}, w0\right) \]
              4. Applied rewrites43.5%

                \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{\left(\left(\left(M \cdot M\right) \cdot h\right) \cdot w0\right) \cdot \left(D \cdot D\right)}{\left(d \cdot d\right) \cdot \ell}, -0.125, w0\right)} \]
              5. 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}} \]
              6. Applied rewrites43.1%

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \frac{\left(\left(h \cdot M\right) \cdot \left(M \cdot \left({D}^{2} \cdot w0\right)\right)\right) \cdot \frac{-1}{8}}{\left(d \cdot d\right) \cdot \ell} \]
                11. pow2N/A

                  \[\leadsto \frac{\left(\left(h \cdot M\right) \cdot \left(M \cdot \left(\left(D \cdot D\right) \cdot w0\right)\right)\right) \cdot \frac{-1}{8}}{\left(d \cdot d\right) \cdot \ell} \]
                12. lift-*.f6446.5

                  \[\leadsto \frac{\left(\left(h \cdot M\right) \cdot \left(M \cdot \left(\left(D \cdot D\right) \cdot w0\right)\right)\right) \cdot -0.125}{\left(d \cdot d\right) \cdot \ell} \]
              9. Applied rewrites46.5%

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

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

              1. Initial program 89.3%

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

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

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

              Alternative 10: 77.8% accurate, 0.6× speedup?

              \[\begin{array}{l} [w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -2 \cdot 10^{+246}:\\ \;\;\;\;\left(\left(\left(D \cdot \left(h \cdot w0\right)\right) \cdot \left(M \cdot \frac{M}{\left(d \cdot d\right) \cdot \ell}\right)\right) \cdot D\right) \cdot -0.125\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \end{array} \]
              NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
              (FPCore (w0 M D h l d)
               :precision binary64
               (if (<= (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l)) -2e+246)
                 (* (* (* (* D (* h w0)) (* M (/ M (* (* d d) l)))) D) -0.125)
                 w0))
              assert(w0 < M && M < D && D < h && h < l && l < d);
              double code(double w0, double M, double D, double h, double l, double d) {
              	double tmp;
              	if ((pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -2e+246) {
              		tmp = (((D * (h * w0)) * (M * (M / ((d * d) * l)))) * D) * -0.125;
              	} else {
              		tmp = w0;
              	}
              	return tmp;
              }
              
              NOTE: w0, M, D, 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, 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
                  real(8) :: tmp
                  if (((((m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l)) <= (-2d+246)) then
                      tmp = (((d * (h * w0)) * (m * (m / ((d_1 * d_1) * l)))) * d) * (-0.125d0)
                  else
                      tmp = w0
                  end if
                  code = tmp
              end function
              
              assert w0 < M && M < D && D < h && h < l && l < d;
              public static double code(double w0, double M, double D, double h, double l, double d) {
              	double tmp;
              	if ((Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -2e+246) {
              		tmp = (((D * (h * w0)) * (M * (M / ((d * d) * l)))) * D) * -0.125;
              	} else {
              		tmp = w0;
              	}
              	return tmp;
              }
              
              [w0, M, D, h, l, d] = sort([w0, M, D, h, l, d])
              def code(w0, M, D, h, l, d):
              	tmp = 0
              	if (math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -2e+246:
              		tmp = (((D * (h * w0)) * (M * (M / ((d * d) * l)))) * D) * -0.125
              	else:
              		tmp = w0
              	return tmp
              
              w0, M, D, h, l, d = sort([w0, M, D, h, l, d])
              function code(w0, M, D, h, l, d)
              	tmp = 0.0
              	if (Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= -2e+246)
              		tmp = Float64(Float64(Float64(Float64(D * Float64(h * w0)) * Float64(M * Float64(M / Float64(Float64(d * d) * l)))) * D) * -0.125);
              	else
              		tmp = w0;
              	end
              	return tmp
              end
              
              w0, M, D, h, l, d = num2cell(sort([w0, M, D, h, l, d])){:}
              function tmp_2 = code(w0, M, D, h, l, d)
              	tmp = 0.0;
              	if (((((M * D) / (2.0 * d)) ^ 2.0) * (h / l)) <= -2e+246)
              		tmp = (((D * (h * w0)) * (M * (M / ((d * d) * l)))) * D) * -0.125;
              	else
              		tmp = w0;
              	end
              	tmp_2 = tmp;
              end
              
              NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
              code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -2e+246], N[(N[(N[(N[(D * N[(h * w0), $MachinePrecision]), $MachinePrecision] * N[(M * N[(M / N[(N[(d * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * D), $MachinePrecision] * -0.125), $MachinePrecision], w0]
              
              \begin{array}{l}
              [w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\
              \\
              \begin{array}{l}
              \mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -2 \cdot 10^{+246}:\\
              \;\;\;\;\left(\left(\left(D \cdot \left(h \cdot w0\right)\right) \cdot \left(M \cdot \frac{M}{\left(d \cdot d\right) \cdot \ell}\right)\right) \cdot D\right) \cdot -0.125\\
              
              \mathbf{else}:\\
              \;\;\;\;w0\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < -2.00000000000000014e246

                1. Initial program 57.0%

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

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

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

                    \[\leadsto \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 \mathsf{fma}\left(\frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(h \cdot w0\right)\right)}{{d}^{2} \cdot \ell}, \color{blue}{\frac{-1}{8}}, w0\right) \]
                4. Applied rewrites42.5%

                  \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{\left(\left(\left(M \cdot M\right) \cdot h\right) \cdot w0\right) \cdot \left(D \cdot D\right)}{\left(d \cdot d\right) \cdot \ell}, -0.125, w0\right)} \]
                5. 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}} \]
                6. Applied rewrites42.2%

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \left(D \cdot \left(D \cdot \frac{\left(h \cdot w0\right) \cdot \left(M \cdot M\right)}{\left(d \cdot d\right) \cdot \ell}\right)\right) \cdot \frac{-1}{8} \]
                  12. pow2N/A

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

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

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

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

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

                    \[\leadsto \left(D \cdot \left(D \cdot \left(\left(h \cdot w0\right) \cdot \frac{{M}^{2}}{\left(d \cdot d\right) \cdot \ell}\right)\right)\right) \cdot \frac{-1}{8} \]
                  18. pow2N/A

                    \[\leadsto \left(D \cdot \left(D \cdot \left(\left(h \cdot w0\right) \cdot \frac{{M}^{2}}{{d}^{2} \cdot \ell}\right)\right)\right) \cdot \frac{-1}{8} \]
                8. Applied rewrites46.0%

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

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

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

                1. Initial program 89.2%

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

                  \[\leadsto \color{blue}{w0} \]
                3. Step-by-step derivation
                  1. Applied rewrites88.8%

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

                Alternative 11: 67.7% accurate, 39.8× speedup?

                \[\begin{array}{l} [w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\ \\ w0 \end{array} \]
                NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
                (FPCore (w0 M D h l d) :precision binary64 w0)
                assert(w0 < M && M < D && D < h && h < l && l < d);
                double code(double w0, double M, double D, double h, double l, double d) {
                	return w0;
                }
                
                NOTE: w0, M, D, 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, 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
                end function
                
                assert w0 < M && M < D && D < h && h < l && l < d;
                public static double code(double w0, double M, double D, double h, double l, double d) {
                	return w0;
                }
                
                [w0, M, D, h, l, d] = sort([w0, M, D, h, l, d])
                def code(w0, M, D, h, l, d):
                	return w0
                
                w0, M, D, h, l, d = sort([w0, M, D, h, l, d])
                function code(w0, M, D, h, l, d)
                	return w0
                end
                
                w0, M, D, h, l, d = num2cell(sort([w0, M, D, h, l, d])){:}
                function tmp = code(w0, M, D, h, l, d)
                	tmp = w0;
                end
                
                NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
                code[w0_, M_, D_, h_, l_, d_] := w0
                
                \begin{array}{l}
                [w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\
                \\
                w0
                \end{array}
                
                Derivation
                1. Initial program 81.1%

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

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

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

                  Reproduce

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