Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 81.6% → 89.0%
Time: 9.1s
Alternatives: 14
Speedup: 1.8×

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 14 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.6% accurate, 1.0× speedup?

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

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

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

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

Alternative 1: 89.0% accurate, 0.6× speedup?

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

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


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

    1. Initial program 88.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. *-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. lower-*.f64N/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}}} \]
      7. lower-*.f6489.8

        \[\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}} \]
      8. lift-/.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 0.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 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. Applied rewrites73.3%

        \[\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)}} \]
      2. Step-by-step derivation
        1. Applied rewrites73.3%

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

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

        Alternative 2: 81.5% accurate, 0.4× speedup?

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

          1. Initial program 100.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 \color{blue}{w0} \]
          4. Step-by-step derivation
            1. Applied rewrites99.6%

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

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

            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 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. Applied rewrites23.2%

                \[\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)}} \]
              2. Step-by-step derivation
                1. Applied rewrites24.0%

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

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

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

                    if 4.00000000000000003e78 < (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 40.2%

                      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
                    2. Add Preprocessing
                    3. Taylor expanded in M around 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)} \]
                    4. Step-by-step derivation
                      1. Applied rewrites46.5%

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

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

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

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

                          Alternative 3: 84.4% accurate, 0.7× speedup?

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

                            1. Initial program 100.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 \color{blue}{w0} \]
                            4. Step-by-step derivation
                              1. Applied rewrites99.1%

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

                              if 5e7 < (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 48.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. Applied rewrites44.2%

                                  \[\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)}} \]
                                2. Step-by-step derivation
                                  1. Applied rewrites59.9%

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

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

                                  Alternative 4: 83.9% accurate, 0.7× speedup?

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

                                    1. Initial program 100.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 \color{blue}{w0} \]
                                    4. Step-by-step derivation
                                      1. Applied rewrites99.6%

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

                                      if 2 < (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 48.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 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. Applied rewrites43.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)}} \]
                                        2. Step-by-step derivation
                                          1. Applied rewrites49.0%

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

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

                                          Alternative 5: 84.7% accurate, 0.8× speedup?

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

                                            1. Initial program 92.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 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. Applied rewrites75.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)}} \]
                                              2. Step-by-step derivation
                                                1. Applied rewrites77.6%

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

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

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

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

                                                    1. Initial program 59.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 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. Applied rewrites38.2%

                                                        \[\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)}} \]
                                                      2. Step-by-step derivation
                                                        1. Applied rewrites55.9%

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

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

                                                        Alternative 6: 79.8% accurate, 0.8× speedup?

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

                                                          1. Initial program 55.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}{\left(1 + \frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)} \]
                                                          4. Step-by-step derivation
                                                            1. Applied rewrites38.3%

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

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

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

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

                                                                1. Initial program 88.6%

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

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

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

                                                                Alternative 7: 79.3% accurate, 0.8× speedup?

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

                                                                  1. Initial program 54.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}{\left(1 + \frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)} \]
                                                                  4. Step-by-step derivation
                                                                    1. Applied rewrites38.9%

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

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

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

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

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

                                                                          1. Initial program 88.7%

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

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

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

                                                                          Alternative 8: 78.0% accurate, 0.8× speedup?

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

                                                                            1. Initial program 54.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}{\left(1 + \frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)} \]
                                                                            4. Step-by-step derivation
                                                                              1. Applied rewrites38.9%

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

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

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

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

                                                                                  1. Initial program 88.7%

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

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

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

                                                                                  Alternative 9: 86.4% accurate, 1.6× speedup?

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

                                                                                    1. Initial program 80.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 l around 0

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

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

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

                                                                                        if 9.99999999999999979e-121 < (*.f64 M D) < 1.50000000000000001e146

                                                                                        1. Initial program 87.9%

                                                                                          \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
                                                                                        2. Add Preprocessing
                                                                                        3. Taylor expanded in 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. Applied rewrites71.4%

                                                                                            \[\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)}} \]
                                                                                          2. Step-by-step derivation
                                                                                            1. Applied rewrites77.5%

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

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

                                                                                              if 1.50000000000000001e146 < (*.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. 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. Applied rewrites35.6%

                                                                                                  \[\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)}} \]
                                                                                                2. Step-by-step derivation
                                                                                                  1. Applied rewrites60.1%

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

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

                                                                                                  Alternative 10: 83.5% accurate, 1.8× speedup?

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

                                                                                                    1. Initial program 78.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. Applied rewrites59.1%

                                                                                                        \[\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)}} \]
                                                                                                      2. Step-by-step derivation
                                                                                                        1. Applied rewrites61.9%

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

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

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

                                                                                                            if -1.9999999999999999e-143 < (/.f64 h l)

                                                                                                            1. Initial program 82.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. Applied rewrites64.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)}} \]
                                                                                                              2. Step-by-step derivation
                                                                                                                1. Applied rewrites68.4%

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

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

                                                                                                                Alternative 11: 83.8% accurate, 1.8× speedup?

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

                                                                                                                  1. Initial program 80.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 \color{blue}{w0} \]
                                                                                                                  4. Step-by-step derivation
                                                                                                                    1. Applied rewrites77.4%

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

                                                                                                                    if 9.99999999999999979e-121 < (*.f64 M D) < 2.0000000000000001e148

                                                                                                                    1. Initial program 88.1%

                                                                                                                      \[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. Applied rewrites71.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)}} \]
                                                                                                                      2. Step-by-step derivation
                                                                                                                        1. Applied rewrites77.9%

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

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

                                                                                                                          if 2.0000000000000001e148 < (*.f64 M D)

                                                                                                                          1. Initial program 65.9%

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

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

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

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

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

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

                                                                                                                                Alternative 12: 80.0% accurate, 2.1× speedup?

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

                                                                                                                                  1. Initial program 81.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 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. Applied rewrites62.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)}} \]
                                                                                                                                    2. Step-by-step derivation
                                                                                                                                      1. Applied rewrites72.8%

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

                                                                                                                                      if 1.0500000000000001e96 < D

                                                                                                                                      1. Initial program 72.9%

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

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

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

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

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

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

                                                                                                                                            Alternative 13: 78.9% accurate, 2.7× speedup?

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

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

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

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

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

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

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

                                                                                                                                                    Alternative 14: 67.7% accurate, 157.0× speedup?

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

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

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

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

                                                                                                                                                      Reproduce

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