Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 81.2% → 86.8%
Time: 10.3s
Alternatives: 10
Speedup: 2.3×

Specification

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

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

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 10 alternatives:

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

Initial Program: 81.2% accurate, 1.0× speedup?

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

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

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

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

Alternative 1: 86.8% accurate, 1.9× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 81.4% accurate, 0.7× speedup?

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

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


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

    1. Initial program 99.4%

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

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

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

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

      1. Initial program 54.2%

        \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
      2. Add Preprocessing
      3. Taylor expanded in 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)}} \]
      4. Step-by-step derivation
        1. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

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

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

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

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

        Alternative 3: 73.3% accurate, 0.8× speedup?

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

          1. Initial program 64.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          1. Initial program 90.8%

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

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

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

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

          Alternative 4: 78.9% accurate, 0.8× speedup?

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

            1. Initial program 62.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              1. Initial program 91.0%

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

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

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

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

              Alternative 5: 79.5% accurate, 0.8× speedup?

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

                1. Initial program 62.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    1. Initial program 91.0%

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

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

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

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

                    Alternative 6: 78.3% accurate, 0.8× speedup?

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

                      1. Initial program 64.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                        \[\leadsto w0 \cdot \color{blue}{\mathsf{fma}\left(-0.125, \frac{\left(\left(M \cdot M\right) \cdot h\right) \cdot \left(D \cdot D\right)}{\left(d \cdot d\right) \cdot \ell}, 1\right)} \]
                      8. 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) \]
                      9. Step-by-step derivation
                        1. Applied rewrites36.8%

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

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

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

                          1. Initial program 90.8%

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

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

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

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

                          Alternative 7: 75.1% accurate, 1.8× speedup?

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

                            1. Initial program 83.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                if 5e-166 < (*.f64 M D) < 5.0000000000000001e296

                                1. Initial program 81.2%

                                  \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
                                2. Add Preprocessing
                                3. Taylor expanded in 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)}} \]
                                4. Step-by-step derivation
                                  1. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

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

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

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

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

                                    if 5.0000000000000001e296 < (*.f64 M D)

                                    1. Initial program 67.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{D \cdot D}{d} \cdot \frac{\left(\left(M \cdot M\right) \cdot h\right) \cdot w0}{\ell}, -0.25, w0\right)} \]
                                  3. Recombined 3 regimes into one program.
                                  4. Final simplification75.2%

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

                                  Alternative 8: 73.8% accurate, 1.8× speedup?

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

                                    1. Initial program 83.7%

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

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

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

                                      if 4.99999999999999989e-114 < (*.f64 M D) < 5.0000000000000001e296

                                      1. Initial program 81.5%

                                        \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
                                      2. Add Preprocessing
                                      3. Taylor expanded in 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)}} \]
                                      4. Step-by-step derivation
                                        1. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

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

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

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

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

                                          if 5.0000000000000001e296 < (*.f64 M D)

                                          1. Initial program 67.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                        Alternative 9: 83.0% accurate, 2.3× speedup?

                                        \[\begin{array}{l} M_m = \left|M\right| \\ [w0, M_m, D, h, l, d] = \mathsf{sort}([w0, M_m, D, h, l, d])\\ \\ w0 \cdot \sqrt{\mathsf{fma}\left(h \cdot -0.25, D \cdot \frac{\left(D \cdot \frac{M\_m}{d}\right) \cdot M\_m}{\ell \cdot d}, 1\right)} \end{array} \]
                                        M_m = (fabs.f64 M)
                                        NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function.
                                        (FPCore (w0 M_m D h l d)
                                         :precision binary64
                                         (* w0 (sqrt (fma (* h -0.25) (* D (/ (* (* D (/ M_m d)) M_m) (* l d))) 1.0))))
                                        M_m = fabs(M);
                                        assert(w0 < M_m && M_m < D && D < h && h < l && l < d);
                                        double code(double w0, double M_m, double D, double h, double l, double d) {
                                        	return w0 * sqrt(fma((h * -0.25), (D * (((D * (M_m / d)) * M_m) / (l * d))), 1.0));
                                        }
                                        
                                        M_m = abs(M)
                                        w0, M_m, D, h, l, d = sort([w0, M_m, D, h, l, d])
                                        function code(w0, M_m, D, h, l, d)
                                        	return Float64(w0 * sqrt(fma(Float64(h * -0.25), Float64(D * Float64(Float64(Float64(D * Float64(M_m / d)) * M_m) / Float64(l * d))), 1.0)))
                                        end
                                        
                                        M_m = N[Abs[M], $MachinePrecision]
                                        NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function.
                                        code[w0_, M$95$m_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(N[(h * -0.25), $MachinePrecision] * N[(D * N[(N[(N[(D * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision] * M$95$m), $MachinePrecision] / N[(l * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
                                        
                                        \begin{array}{l}
                                        M_m = \left|M\right|
                                        \\
                                        [w0, M_m, D, h, l, d] = \mathsf{sort}([w0, M_m, D, h, l, d])\\
                                        \\
                                        w0 \cdot \sqrt{\mathsf{fma}\left(h \cdot -0.25, D \cdot \frac{\left(D \cdot \frac{M\_m}{d}\right) \cdot M\_m}{\ell \cdot d}, 1\right)}
                                        \end{array}
                                        
                                        Derivation
                                        1. Initial program 82.3%

                                          \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
                                        2. Add Preprocessing
                                        3. Taylor expanded in 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)}} \]
                                        4. Step-by-step derivation
                                          1. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

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

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

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

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

                                            Alternative 10: 67.9% accurate, 26.2× speedup?

                                            \[\begin{array}{l} M_m = \left|M\right| \\ [w0, M_m, D, h, l, d] = \mathsf{sort}([w0, M_m, D, h, l, d])\\ \\ w0 \cdot 1 \end{array} \]
                                            M_m = (fabs.f64 M)
                                            NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function.
                                            (FPCore (w0 M_m D h l d) :precision binary64 (* w0 1.0))
                                            M_m = fabs(M);
                                            assert(w0 < M_m && M_m < D && D < h && h < l && l < d);
                                            double code(double w0, double M_m, double D, double h, double l, double d) {
                                            	return w0 * 1.0;
                                            }
                                            
                                            M_m =     private
                                            NOTE: w0, M_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_m, d, h, l, d_1)
                                            use fmin_fmax_functions
                                                real(8), intent (in) :: w0
                                                real(8), intent (in) :: m_m
                                                real(8), intent (in) :: d
                                                real(8), intent (in) :: h
                                                real(8), intent (in) :: l
                                                real(8), intent (in) :: d_1
                                                code = w0 * 1.0d0
                                            end function
                                            
                                            M_m = Math.abs(M);
                                            assert w0 < M_m && M_m < D && D < h && h < l && l < d;
                                            public static double code(double w0, double M_m, double D, double h, double l, double d) {
                                            	return w0 * 1.0;
                                            }
                                            
                                            M_m = math.fabs(M)
                                            [w0, M_m, D, h, l, d] = sort([w0, M_m, D, h, l, d])
                                            def code(w0, M_m, D, h, l, d):
                                            	return w0 * 1.0
                                            
                                            M_m = abs(M)
                                            w0, M_m, D, h, l, d = sort([w0, M_m, D, h, l, d])
                                            function code(w0, M_m, D, h, l, d)
                                            	return Float64(w0 * 1.0)
                                            end
                                            
                                            M_m = abs(M);
                                            w0, M_m, D, h, l, d = num2cell(sort([w0, M_m, D, h, l, d])){:}
                                            function tmp = code(w0, M_m, D, h, l, d)
                                            	tmp = w0 * 1.0;
                                            end
                                            
                                            M_m = N[Abs[M], $MachinePrecision]
                                            NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function.
                                            code[w0_, M$95$m_, D_, h_, l_, d_] := N[(w0 * 1.0), $MachinePrecision]
                                            
                                            \begin{array}{l}
                                            M_m = \left|M\right|
                                            \\
                                            [w0, M_m, D, h, l, d] = \mathsf{sort}([w0, M_m, D, h, l, d])\\
                                            \\
                                            w0 \cdot 1
                                            \end{array}
                                            
                                            Derivation
                                            1. Initial program 82.3%

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

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

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

                                              Reproduce

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