Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 80.7% → 85.8%
Time: 3.8s
Alternatives: 9
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 9 alternatives:

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

Initial Program: 80.7% 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: 85.8% 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 := D \cdot \frac{M}{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 (* D (/ M (+ 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 = D * (M / (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 = d * (m / (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 = D * (M / (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 = D * (M / (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(D * Float64(M / 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 = D * (M / (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[(D * N[(M / 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 := D \cdot \frac{M}{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 80.7%

    \[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 rewrites85.5%

    \[\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{\left(\color{blue}{\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{\left(\left(M \cdot \frac{D}{\color{blue}{d + d}}\right) \cdot \left(M \cdot \frac{D}{d + d}\right)\right) \cdot h}{\ell}} \]
    3. lift-/.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 85.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} t_0 := M \cdot \frac{D}{d + d}\\ \mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -100000000:\\ \;\;\;\;\sqrt{1 - \left(t\_0 \cdot t\_0\right) \cdot \frac{h}{\ell}} \cdot w0\\ \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 d)))))
   (if (<= (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l)) -100000000.0)
     (* (sqrt (- 1.0 (* (* t_0 t_0) (/ h l)))) w0)
     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 + d));
	double tmp;
	if ((pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -100000000.0) {
		tmp = sqrt((1.0 - ((t_0 * t_0) * (h / l)))) * w0;
	} 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 + d_1))
    if (((((m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l)) <= (-100000000.0d0)) then
        tmp = sqrt((1.0d0 - ((t_0 * t_0) * (h / l)))) * w0
    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 + d));
	double tmp;
	if ((Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -100000000.0) {
		tmp = Math.sqrt((1.0 - ((t_0 * t_0) * (h / l)))) * w0;
	} 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 + d))
	tmp = 0
	if (math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -100000000.0:
		tmp = math.sqrt((1.0 - ((t_0 * t_0) * (h / l)))) * w0
	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 / Float64(d + d)))
	tmp = 0.0
	if (Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= -100000000.0)
		tmp = Float64(sqrt(Float64(1.0 - Float64(Float64(t_0 * t_0) * Float64(h / l)))) * w0);
	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 + d));
	tmp = 0.0;
	if (((((M * D) / (2.0 * d)) ^ 2.0) * (h / l)) <= -100000000.0)
		tmp = sqrt((1.0 - ((t_0 * t_0) * (h / l)))) * w0;
	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 / N[(d + d), $MachinePrecision]), $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], -100000000.0], N[(N[Sqrt[N[(1.0 - N[(N[(t$95$0 * t$95$0), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * w0), $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 + d}\\
\mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -100000000:\\
\;\;\;\;\sqrt{1 - \left(t\_0 \cdot t\_0\right) \cdot \frac{h}{\ell}} \cdot w0\\

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

    1. Initial program 62.2%

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

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

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

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

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

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

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

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

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

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

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

    if -1e8 < (*.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 rewrites95.9%

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

    Alternative 3: 82.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 -100000000:\\ \;\;\;\;\sqrt{1 - \frac{\left(M \cdot D\right) \cdot \left(M \cdot D\right)}{\left(d + d\right) \cdot \left(d + d\right)} \cdot \frac{h}{\ell}} \cdot w0\\ \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)) -100000000.0)
       (*
        (sqrt (- 1.0 (* (/ (* (* M D) (* M D)) (* (+ d d) (+ d d))) (/ h l))))
        w0)
       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)) <= -100000000.0) {
    		tmp = sqrt((1.0 - ((((M * D) * (M * D)) / ((d + d) * (d + d))) * (h / l)))) * w0;
    	} 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)) <= (-100000000.0d0)) then
            tmp = sqrt((1.0d0 - ((((m * d) * (m * d)) / ((d_1 + d_1) * (d_1 + d_1))) * (h / l)))) * w0
        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)) <= -100000000.0) {
    		tmp = Math.sqrt((1.0 - ((((M * D) * (M * D)) / ((d + d) * (d + d))) * (h / l)))) * w0;
    	} 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)) <= -100000000.0:
    		tmp = math.sqrt((1.0 - ((((M * D) * (M * D)) / ((d + d) * (d + d))) * (h / l)))) * w0
    	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)) <= -100000000.0)
    		tmp = Float64(sqrt(Float64(1.0 - Float64(Float64(Float64(Float64(M * D) * Float64(M * D)) / Float64(Float64(d + d) * Float64(d + d))) * Float64(h / l)))) * w0);
    	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)) <= -100000000.0)
    		tmp = sqrt((1.0 - ((((M * D) * (M * D)) / ((d + d) * (d + d))) * (h / l)))) * w0;
    	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], -100000000.0], N[(N[Sqrt[N[(1.0 - N[(N[(N[(N[(M * D), $MachinePrecision] * N[(M * D), $MachinePrecision]), $MachinePrecision] / N[(N[(d + d), $MachinePrecision] * N[(d + d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * w0), $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 -100000000:\\
    \;\;\;\;\sqrt{1 - \frac{\left(M \cdot D\right) \cdot \left(M \cdot D\right)}{\left(d + d\right) \cdot \left(d + d\right)} \cdot \frac{h}{\ell}} \cdot w0\\
    
    \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)) < -1e8

      1. Initial program 62.2%

        \[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 rewrites62.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{\left(\color{blue}{\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{\left(\left(M \cdot \frac{D}{\color{blue}{d + d}}\right) \cdot \left(M \cdot \frac{D}{d + d}\right)\right) \cdot h}{\ell}} \]
        3. lift-/.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      if -1e8 < (*.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 rewrites95.9%

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

      Alternative 4: 81.6% 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 -100000000:\\ \;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\left(M \cdot D\right) \cdot \left(M \cdot D\right)}{\left(d \cdot d\right) \cdot \ell} \cdot -0.25, h, 1\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)) -100000000.0)
         (* w0 (sqrt (fma (* (/ (* (* M D) (* M D)) (* (* d d) l)) -0.25) h 1.0)))
         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)) <= -100000000.0) {
      		tmp = w0 * sqrt(fma(((((M * D) * (M * D)) / ((d * d) * l)) * -0.25), h, 1.0));
      	} 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)) <= -100000000.0)
      		tmp = Float64(w0 * sqrt(fma(Float64(Float64(Float64(Float64(M * D) * Float64(M * D)) / Float64(Float64(d * d) * l)) * -0.25), h, 1.0)));
      	else
      		tmp = w0;
      	end
      	return 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], -100000000.0], N[(w0 * N[Sqrt[N[(N[(N[(N[(N[(M * D), $MachinePrecision] * N[(M * D), $MachinePrecision]), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision] * h + 1.0), $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 -100000000:\\
      \;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\left(M \cdot D\right) \cdot \left(M \cdot D\right)}{\left(d \cdot d\right) \cdot \ell} \cdot -0.25, h, 1\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)) < -1e8

        1. Initial program 62.2%

          \[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 rewrites62.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{\left(\color{blue}{\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{\left(\left(M \cdot \frac{D}{\color{blue}{d + d}}\right) \cdot \left(M \cdot \frac{D}{d + d}\right)\right) \cdot h}{\ell}} \]
          3. lift-/.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        if -1e8 < (*.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 rewrites95.9%

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

        Alternative 5: 79.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 -4 \cdot 10^{+102}:\\ \;\;\;\;w0 \cdot \mathsf{fma}\left(\left(D \cdot D\right) \cdot \left(M \cdot \left(M \cdot \frac{h}{\left(d \cdot d\right) \cdot \ell}\right)\right), -0.125, 1\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)) -4e+102)
           (* w0 (fma (* (* D D) (* M (* M (/ h (* (* d d) l))))) -0.125 1.0))
           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)) <= -4e+102) {
        		tmp = w0 * fma(((D * D) * (M * (M * (h / ((d * d) * l))))), -0.125, 1.0);
        	} 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)) <= -4e+102)
        		tmp = Float64(w0 * fma(Float64(Float64(D * D) * Float64(M * Float64(M * Float64(h / Float64(Float64(d * d) * l))))), -0.125, 1.0));
        	else
        		tmp = w0;
        	end
        	return 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], -4e+102], N[(w0 * N[(N[(N[(D * D), $MachinePrecision] * N[(M * N[(M * N[(h / N[(N[(d * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125 + 1.0), $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 -4 \cdot 10^{+102}:\\
        \;\;\;\;w0 \cdot \mathsf{fma}\left(\left(D \cdot D\right) \cdot \left(M \cdot \left(M \cdot \frac{h}{\left(d \cdot d\right) \cdot \ell}\right)\right), -0.125, 1\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)) < -3.99999999999999991e102

          1. Initial program 59.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 w0 \cdot \color{blue}{\left(1 + \frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)} \]
          3. Step-by-step derivation
            1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto w0 \cdot \mathsf{fma}\left(\frac{\left(\left(M \cdot M\right) \cdot h\right) \cdot \left(D \cdot D\right)}{\left(d \cdot d\right) \cdot \ell}, -0.125, 1\right) \]
          4. Applied rewrites36.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto w0 \cdot \mathsf{fma}\left(\left(D \cdot D\right) \cdot \left(\left(M \cdot M\right) \cdot \frac{h}{\left(d \cdot d\right) \cdot \ell}\right), \frac{-1}{8}, 1\right) \]
            23. lift-*.f6437.6

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

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

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

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

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

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

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

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

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

          1. Initial program 89.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 rewrites93.0%

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

          Alternative 6: 79.0% 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 -5 \cdot 10^{+207}:\\ \;\;\;\;\mathsf{fma}\left(\frac{\left(M \cdot D\right) \cdot \left(M \cdot D\right)}{\left(d \cdot d\right) \cdot \ell} \cdot -0.125, h, 1\right) \cdot w0\\ \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)) -5e+207)
             (* (fma (* (/ (* (* M D) (* M D)) (* (* d d) l)) -0.125) h 1.0) w0)
             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)) <= -5e+207) {
          		tmp = fma(((((M * D) * (M * D)) / ((d * d) * l)) * -0.125), h, 1.0) * w0;
          	} 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)) <= -5e+207)
          		tmp = Float64(fma(Float64(Float64(Float64(Float64(M * D) * Float64(M * D)) / Float64(Float64(d * d) * l)) * -0.125), h, 1.0) * w0);
          	else
          		tmp = w0;
          	end
          	return 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], -5e+207], N[(N[(N[(N[(N[(N[(M * D), $MachinePrecision] * N[(M * D), $MachinePrecision]), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision] * h + 1.0), $MachinePrecision] * w0), $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 -5 \cdot 10^{+207}:\\
          \;\;\;\;\mathsf{fma}\left(\frac{\left(M \cdot D\right) \cdot \left(M \cdot D\right)}{\left(d \cdot d\right) \cdot \ell} \cdot -0.125, h, 1\right) \cdot w0\\
          
          \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)) < -4.9999999999999999e207

            1. Initial program 55.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 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto w0 \cdot \left(\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}{8}\right) \]
              8. lift-*.f64N/A

                \[\leadsto w0 \cdot \left(\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}{8}\right) \]
              9. lift-*.f64N/A

                \[\leadsto w0 \cdot \left(\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}{8}\right) \]
              10. lift-*.f64N/A

                \[\leadsto w0 \cdot \left(\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}{8}\right) \]
              11. lift-*.f64N/A

                \[\leadsto w0 \cdot \left(\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}{8}\right) \]
              12. lift-/.f64N/A

                \[\leadsto w0 \cdot \left(\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}{8}\right) \]
              13. lower-*.f6439.2

                \[\leadsto w0 \cdot \left(\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.125\right) \]
            7. Applied rewrites41.9%

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

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

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

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

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

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

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

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

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

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

            if -4.9999999999999999e207 < (*.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 rewrites90.7%

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

            Alternative 7: 78.6% 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 -4 \cdot 10^{+102}:\\ \;\;\;\;\left(\left(\left(M \cdot \left(M \cdot \left(h \cdot D\right)\right)\right) \cdot \frac{D}{\left(d \cdot d\right) \cdot \ell}\right) \cdot -0.125\right) \cdot w0\\ \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)) -4e+102)
               (* (* (* (* M (* M (* h D))) (/ D (* (* d d) l))) -0.125) w0)
               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)) <= -4e+102) {
            		tmp = (((M * (M * (h * D))) * (D / ((d * d) * l))) * -0.125) * w0;
            	} 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)) <= (-4d+102)) then
                    tmp = (((m * (m * (h * d))) * (d / ((d_1 * d_1) * l))) * (-0.125d0)) * w0
                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)) <= -4e+102) {
            		tmp = (((M * (M * (h * D))) * (D / ((d * d) * l))) * -0.125) * w0;
            	} 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)) <= -4e+102:
            		tmp = (((M * (M * (h * D))) * (D / ((d * d) * l))) * -0.125) * w0
            	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)) <= -4e+102)
            		tmp = Float64(Float64(Float64(Float64(M * Float64(M * Float64(h * D))) * Float64(D / Float64(Float64(d * d) * l))) * -0.125) * w0);
            	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)) <= -4e+102)
            		tmp = (((M * (M * (h * D))) * (D / ((d * d) * l))) * -0.125) * w0;
            	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], -4e+102], N[(N[(N[(N[(M * N[(M * N[(h * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(D / N[(N[(d * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision] * w0), $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 -4 \cdot 10^{+102}:\\
            \;\;\;\;\left(\left(\left(M \cdot \left(M \cdot \left(h \cdot D\right)\right)\right) \cdot \frac{D}{\left(d \cdot d\right) \cdot \ell}\right) \cdot -0.125\right) \cdot w0\\
            
            \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)) < -3.99999999999999991e102

              1. Initial program 59.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 w0 \cdot \color{blue}{\left(1 + \frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)} \]
              3. Step-by-step derivation
                1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto w0 \cdot \mathsf{fma}\left(\frac{\left(\left(M \cdot M\right) \cdot h\right) \cdot \left(D \cdot D\right)}{\left(d \cdot d\right) \cdot \ell}, -0.125, 1\right) \]
              4. Applied rewrites36.9%

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

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

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

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

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

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

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

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

                  \[\leadsto w0 \cdot \left(\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}{8}\right) \]
                8. lift-*.f64N/A

                  \[\leadsto w0 \cdot \left(\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}{8}\right) \]
                9. lift-*.f64N/A

                  \[\leadsto w0 \cdot \left(\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}{8}\right) \]
                10. lift-*.f64N/A

                  \[\leadsto w0 \cdot \left(\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}{8}\right) \]
                11. lift-*.f64N/A

                  \[\leadsto w0 \cdot \left(\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}{8}\right) \]
                12. lift-/.f64N/A

                  \[\leadsto w0 \cdot \left(\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}{8}\right) \]
                13. lower-*.f6436.8

                  \[\leadsto w0 \cdot \left(\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.125\right) \]
              7. Applied rewrites39.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              1. Initial program 89.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 rewrites93.0%

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

              Alternative 8: 77.6% 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 -5 \cdot 10^{+207}:\\ \;\;\;\;\left(\left(\left(D \cdot D\right) \cdot \left(\left(M \cdot M\right) \cdot \frac{h}{\left(d \cdot d\right) \cdot \ell}\right)\right) \cdot -0.125\right) \cdot w0\\ \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)) -5e+207)
                 (* (* (* (* D D) (* (* M M) (/ h (* (* d d) l)))) -0.125) w0)
                 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)) <= -5e+207) {
              		tmp = (((D * D) * ((M * M) * (h / ((d * d) * l)))) * -0.125) * w0;
              	} 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)) <= (-5d+207)) then
                      tmp = (((d * d) * ((m * m) * (h / ((d_1 * d_1) * l)))) * (-0.125d0)) * w0
                  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)) <= -5e+207) {
              		tmp = (((D * D) * ((M * M) * (h / ((d * d) * l)))) * -0.125) * w0;
              	} 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)) <= -5e+207:
              		tmp = (((D * D) * ((M * M) * (h / ((d * d) * l)))) * -0.125) * w0
              	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)) <= -5e+207)
              		tmp = Float64(Float64(Float64(Float64(D * D) * Float64(Float64(M * M) * Float64(h / Float64(Float64(d * d) * l)))) * -0.125) * w0);
              	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)) <= -5e+207)
              		tmp = (((D * D) * ((M * M) * (h / ((d * d) * l)))) * -0.125) * w0;
              	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], -5e+207], N[(N[(N[(N[(D * D), $MachinePrecision] * N[(N[(M * M), $MachinePrecision] * N[(h / N[(N[(d * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision] * w0), $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 -5 \cdot 10^{+207}:\\
              \;\;\;\;\left(\left(\left(D \cdot D\right) \cdot \left(\left(M \cdot M\right) \cdot \frac{h}{\left(d \cdot d\right) \cdot \ell}\right)\right) \cdot -0.125\right) \cdot w0\\
              
              \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)) < -4.9999999999999999e207

                1. Initial program 55.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 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto w0 \cdot \left(\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}{8}\right) \]
                  8. lift-*.f64N/A

                    \[\leadsto w0 \cdot \left(\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}{8}\right) \]
                  9. lift-*.f64N/A

                    \[\leadsto w0 \cdot \left(\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}{8}\right) \]
                  10. lift-*.f64N/A

                    \[\leadsto w0 \cdot \left(\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}{8}\right) \]
                  11. lift-*.f64N/A

                    \[\leadsto w0 \cdot \left(\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}{8}\right) \]
                  12. lift-/.f64N/A

                    \[\leadsto w0 \cdot \left(\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}{8}\right) \]
                  13. lower-*.f6439.2

                    \[\leadsto w0 \cdot \left(\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.125\right) \]
                7. Applied rewrites41.9%

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

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

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

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

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

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

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

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

                    \[\leadsto \left(\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}{8}\right) \cdot w0 \]
                  8. pow2N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

                if -4.9999999999999999e207 < (*.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 rewrites90.7%

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

                Alternative 9: 68.6% 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 80.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 rewrites68.6%

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

                  Reproduce

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