Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 80.6% → 91.8%
Time: 7.6s
Alternatives: 8
Speedup: 0.5×

Specification

?
\[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
(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]
w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}

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 8 alternatives:

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

Initial Program: 80.6% accurate, 1.0× speedup?

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

Alternative 1: 91.8% accurate, 0.4× speedup?

\[\begin{array}{l} t_0 := \mathsf{max}\left(\left|M\right|, \left|D\right|\right)\\ t_1 := \mathsf{min}\left(\left|M\right|, \left|D\right|\right)\\ t_2 := \frac{t\_0}{\left|d\right|} \cdot t\_1\\ \mathbf{if}\;{\left(\frac{t\_1 \cdot t\_0}{2 \cdot \left|d\right|}\right)}^{2} \cdot \frac{h}{\ell} \leq -100000000:\\ \;\;\;\;w0 \cdot \left(\left(\frac{\sqrt{-0.25 \cdot \frac{h}{\ell}}}{\left|d\right|} \cdot t\_1\right) \cdot t\_0\right)\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \left(t\_2 \cdot 0.25\right) \cdot \frac{t\_2 \cdot h}{\ell}}\\ \end{array} \]
(FPCore (w0 M D h l d)
 :precision binary64
 (let* ((t_0 (fmax (fabs M) (fabs D)))
        (t_1 (fmin (fabs M) (fabs D)))
        (t_2 (* (/ t_0 (fabs d)) t_1)))
   (if (<= (* (pow (/ (* t_1 t_0) (* 2.0 (fabs d))) 2.0) (/ h l)) -100000000.0)
     (* w0 (* (* (/ (sqrt (* -0.25 (/ h l))) (fabs d)) t_1) t_0))
     (* w0 (sqrt (- 1.0 (* (* t_2 0.25) (/ (* t_2 h) l))))))))
double code(double w0, double M, double D, double h, double l, double d) {
	double t_0 = fmax(fabs(M), fabs(D));
	double t_1 = fmin(fabs(M), fabs(D));
	double t_2 = (t_0 / fabs(d)) * t_1;
	double tmp;
	if ((pow(((t_1 * t_0) / (2.0 * fabs(d))), 2.0) * (h / l)) <= -100000000.0) {
		tmp = w0 * (((sqrt((-0.25 * (h / l))) / fabs(d)) * t_1) * t_0);
	} else {
		tmp = w0 * sqrt((1.0 - ((t_2 * 0.25) * ((t_2 * h) / l))));
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(w0, m, d, h, l, d_1)
use fmin_fmax_functions
    real(8), intent (in) :: w0
    real(8), intent (in) :: m
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d_1
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_0 = fmax(abs(m), abs(d))
    t_1 = fmin(abs(m), abs(d))
    t_2 = (t_0 / abs(d_1)) * t_1
    if (((((t_1 * t_0) / (2.0d0 * abs(d_1))) ** 2.0d0) * (h / l)) <= (-100000000.0d0)) then
        tmp = w0 * (((sqrt(((-0.25d0) * (h / l))) / abs(d_1)) * t_1) * t_0)
    else
        tmp = w0 * sqrt((1.0d0 - ((t_2 * 0.25d0) * ((t_2 * h) / l))))
    end if
    code = tmp
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
	double t_0 = fmax(Math.abs(M), Math.abs(D));
	double t_1 = fmin(Math.abs(M), Math.abs(D));
	double t_2 = (t_0 / Math.abs(d)) * t_1;
	double tmp;
	if ((Math.pow(((t_1 * t_0) / (2.0 * Math.abs(d))), 2.0) * (h / l)) <= -100000000.0) {
		tmp = w0 * (((Math.sqrt((-0.25 * (h / l))) / Math.abs(d)) * t_1) * t_0);
	} else {
		tmp = w0 * Math.sqrt((1.0 - ((t_2 * 0.25) * ((t_2 * h) / l))));
	}
	return tmp;
}
def code(w0, M, D, h, l, d):
	t_0 = fmax(math.fabs(M), math.fabs(D))
	t_1 = fmin(math.fabs(M), math.fabs(D))
	t_2 = (t_0 / math.fabs(d)) * t_1
	tmp = 0
	if (math.pow(((t_1 * t_0) / (2.0 * math.fabs(d))), 2.0) * (h / l)) <= -100000000.0:
		tmp = w0 * (((math.sqrt((-0.25 * (h / l))) / math.fabs(d)) * t_1) * t_0)
	else:
		tmp = w0 * math.sqrt((1.0 - ((t_2 * 0.25) * ((t_2 * h) / l))))
	return tmp
function code(w0, M, D, h, l, d)
	t_0 = fmax(abs(M), abs(D))
	t_1 = fmin(abs(M), abs(D))
	t_2 = Float64(Float64(t_0 / abs(d)) * t_1)
	tmp = 0.0
	if (Float64((Float64(Float64(t_1 * t_0) / Float64(2.0 * abs(d))) ^ 2.0) * Float64(h / l)) <= -100000000.0)
		tmp = Float64(w0 * Float64(Float64(Float64(sqrt(Float64(-0.25 * Float64(h / l))) / abs(d)) * t_1) * t_0));
	else
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(t_2 * 0.25) * Float64(Float64(t_2 * h) / l)))));
	end
	return tmp
end
function tmp_2 = code(w0, M, D, h, l, d)
	t_0 = max(abs(M), abs(D));
	t_1 = min(abs(M), abs(D));
	t_2 = (t_0 / abs(d)) * t_1;
	tmp = 0.0;
	if (((((t_1 * t_0) / (2.0 * abs(d))) ^ 2.0) * (h / l)) <= -100000000.0)
		tmp = w0 * (((sqrt((-0.25 * (h / l))) / abs(d)) * t_1) * t_0);
	else
		tmp = w0 * sqrt((1.0 - ((t_2 * 0.25) * ((t_2 * h) / l))));
	end
	tmp_2 = tmp;
end
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[Max[N[Abs[M], $MachinePrecision], N[Abs[D], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Min[N[Abs[M], $MachinePrecision], N[Abs[D], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(t$95$0 / N[Abs[d], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]}, If[LessEqual[N[(N[Power[N[(N[(t$95$1 * t$95$0), $MachinePrecision] / N[(2.0 * N[Abs[d], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -100000000.0], N[(w0 * N[(N[(N[(N[Sqrt[N[(-0.25 * N[(h / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Abs[d], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(t$95$2 * 0.25), $MachinePrecision] * N[(N[(t$95$2 * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \mathsf{max}\left(\left|M\right|, \left|D\right|\right)\\
t_1 := \mathsf{min}\left(\left|M\right|, \left|D\right|\right)\\
t_2 := \frac{t\_0}{\left|d\right|} \cdot t\_1\\
\mathbf{if}\;{\left(\frac{t\_1 \cdot t\_0}{2 \cdot \left|d\right|}\right)}^{2} \cdot \frac{h}{\ell} \leq -100000000:\\
\;\;\;\;w0 \cdot \left(\left(\frac{\sqrt{-0.25 \cdot \frac{h}{\ell}}}{\left|d\right|} \cdot t\_1\right) \cdot t\_0\right)\\

\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \left(t\_2 \cdot 0.25\right) \cdot \frac{t\_2 \cdot h}{\ell}}\\


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

    1. Initial program 80.6%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto D \cdot \left(w0 \cdot \sqrt{-\frac{1}{4} \cdot \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}}\right) \]
      10. lower-pow.f649.5%

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

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

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

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

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

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

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

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

        \[\leadsto D \cdot \left(w0 \cdot \left(M \cdot \sqrt{-\frac{1}{4} \cdot \frac{h}{{d}^{2} \cdot \ell}}\right)\right) \]
      7. lower-pow.f6411.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 80.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 91.8% accurate, 0.3× speedup?

\[\begin{array}{l} t_0 := \mathsf{max}\left(\left|M\right|, \left|D\right|\right)\\ t_1 := \mathsf{min}\left(\left|M\right|, \left|D\right|\right)\\ t_2 := {\left(\frac{t\_1 \cdot t\_0}{2 \cdot \left|d\right|}\right)}^{2} \cdot \frac{h}{\ell}\\ t_3 := t\_1 \cdot \frac{t\_0}{\left|d\right|}\\ \mathbf{if}\;t\_2 \leq -100000000:\\ \;\;\;\;w0 \cdot \left(\left(\frac{\sqrt{-0.25 \cdot \frac{h}{\ell}}}{\left|d\right|} \cdot t\_1\right) \cdot t\_0\right)\\ \mathbf{elif}\;t\_2 \leq 2 \cdot 10^{-18}:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(\left(t\_3 \cdot t\_3\right) \cdot -0.25, \frac{h}{\ell}, 1\right)} \cdot w0\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{0.25 \cdot \left(t\_3 \cdot \frac{\left(h \cdot t\_1\right) \cdot t\_0}{\left|d\right|}\right)}{\ell}}\\ \end{array} \]
(FPCore (w0 M D h l d)
 :precision binary64
 (let* ((t_0 (fmax (fabs M) (fabs D)))
        (t_1 (fmin (fabs M) (fabs D)))
        (t_2 (* (pow (/ (* t_1 t_0) (* 2.0 (fabs d))) 2.0) (/ h l)))
        (t_3 (* t_1 (/ t_0 (fabs d)))))
   (if (<= t_2 -100000000.0)
     (* w0 (* (* (/ (sqrt (* -0.25 (/ h l))) (fabs d)) t_1) t_0))
     (if (<= t_2 2e-18)
       (* (sqrt (fma (* (* t_3 t_3) -0.25) (/ h l) 1.0)) w0)
       (*
        w0
        (sqrt
         (- 1.0 (/ (* 0.25 (* t_3 (/ (* (* h t_1) t_0) (fabs d)))) l))))))))
double code(double w0, double M, double D, double h, double l, double d) {
	double t_0 = fmax(fabs(M), fabs(D));
	double t_1 = fmin(fabs(M), fabs(D));
	double t_2 = pow(((t_1 * t_0) / (2.0 * fabs(d))), 2.0) * (h / l);
	double t_3 = t_1 * (t_0 / fabs(d));
	double tmp;
	if (t_2 <= -100000000.0) {
		tmp = w0 * (((sqrt((-0.25 * (h / l))) / fabs(d)) * t_1) * t_0);
	} else if (t_2 <= 2e-18) {
		tmp = sqrt(fma(((t_3 * t_3) * -0.25), (h / l), 1.0)) * w0;
	} else {
		tmp = w0 * sqrt((1.0 - ((0.25 * (t_3 * (((h * t_1) * t_0) / fabs(d)))) / l)));
	}
	return tmp;
}
function code(w0, M, D, h, l, d)
	t_0 = fmax(abs(M), abs(D))
	t_1 = fmin(abs(M), abs(D))
	t_2 = Float64((Float64(Float64(t_1 * t_0) / Float64(2.0 * abs(d))) ^ 2.0) * Float64(h / l))
	t_3 = Float64(t_1 * Float64(t_0 / abs(d)))
	tmp = 0.0
	if (t_2 <= -100000000.0)
		tmp = Float64(w0 * Float64(Float64(Float64(sqrt(Float64(-0.25 * Float64(h / l))) / abs(d)) * t_1) * t_0));
	elseif (t_2 <= 2e-18)
		tmp = Float64(sqrt(fma(Float64(Float64(t_3 * t_3) * -0.25), Float64(h / l), 1.0)) * w0);
	else
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(0.25 * Float64(t_3 * Float64(Float64(Float64(h * t_1) * t_0) / abs(d)))) / l))));
	end
	return tmp
end
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[Max[N[Abs[M], $MachinePrecision], N[Abs[D], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Min[N[Abs[M], $MachinePrecision], N[Abs[D], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Power[N[(N[(t$95$1 * t$95$0), $MachinePrecision] / N[(2.0 * N[Abs[d], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$1 * N[(t$95$0 / N[Abs[d], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -100000000.0], N[(w0 * N[(N[(N[(N[Sqrt[N[(-0.25 * N[(h / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Abs[d], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2e-18], N[(N[Sqrt[N[(N[(N[(t$95$3 * t$95$3), $MachinePrecision] * -0.25), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision] * w0), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(0.25 * N[(t$95$3 * N[(N[(N[(h * t$95$1), $MachinePrecision] * t$95$0), $MachinePrecision] / N[Abs[d], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
t_0 := \mathsf{max}\left(\left|M\right|, \left|D\right|\right)\\
t_1 := \mathsf{min}\left(\left|M\right|, \left|D\right|\right)\\
t_2 := {\left(\frac{t\_1 \cdot t\_0}{2 \cdot \left|d\right|}\right)}^{2} \cdot \frac{h}{\ell}\\
t_3 := t\_1 \cdot \frac{t\_0}{\left|d\right|}\\
\mathbf{if}\;t\_2 \leq -100000000:\\
\;\;\;\;w0 \cdot \left(\left(\frac{\sqrt{-0.25 \cdot \frac{h}{\ell}}}{\left|d\right|} \cdot t\_1\right) \cdot t\_0\right)\\

\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{-18}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(\left(t\_3 \cdot t\_3\right) \cdot -0.25, \frac{h}{\ell}, 1\right)} \cdot w0\\

\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{0.25 \cdot \left(t\_3 \cdot \frac{\left(h \cdot t\_1\right) \cdot t\_0}{\left|d\right|}\right)}{\ell}}\\


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

    1. Initial program 80.6%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto D \cdot \left(w0 \cdot \sqrt{-\frac{1}{4} \cdot \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}}\right) \]
      10. lower-pow.f649.5%

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

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

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

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

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

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

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

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

        \[\leadsto D \cdot \left(w0 \cdot \left(M \cdot \sqrt{-\frac{1}{4} \cdot \frac{h}{{d}^{2} \cdot \ell}}\right)\right) \]
      7. lower-pow.f6411.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1e8 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < 2.0000000000000001e-18

    1. Initial program 80.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 80.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 91.6% accurate, 0.3× speedup?

\[\begin{array}{l} t_0 := \mathsf{max}\left(\left|M\right|, \left|D\right|\right)\\ t_1 := \mathsf{min}\left(\left|M\right|, \left|D\right|\right)\\ t_2 := t\_1 \cdot \frac{t\_0}{\left|d\right|}\\ t_3 := t\_1 \cdot t\_0\\ t_4 := 1 - {\left(\frac{t\_3}{2 \cdot \left|d\right|}\right)}^{2} \cdot \frac{h}{\ell}\\ \mathbf{if}\;t\_4 \leq 1000000:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(\left(t\_2 \cdot t\_2\right) \cdot -0.25, \frac{h}{\ell}, 1\right)} \cdot w0\\ \mathbf{elif}\;t\_4 \leq \infty:\\ \;\;\;\;w0 \cdot \left(\left(\frac{\sqrt{-0.25 \cdot \frac{h}{\ell}}}{\left|d\right|} \cdot t\_1\right) \cdot t\_0\right)\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{\frac{\left(t\_3 \cdot t\_0\right) \cdot t\_1}{\left|d\right|} \cdot h}{\left(4 \cdot \left|d\right|\right) \cdot \ell}}\\ \end{array} \]
(FPCore (w0 M D h l d)
 :precision binary64
 (let* ((t_0 (fmax (fabs M) (fabs D)))
        (t_1 (fmin (fabs M) (fabs D)))
        (t_2 (* t_1 (/ t_0 (fabs d))))
        (t_3 (* t_1 t_0))
        (t_4 (- 1.0 (* (pow (/ t_3 (* 2.0 (fabs d))) 2.0) (/ h l)))))
   (if (<= t_4 1000000.0)
     (* (sqrt (fma (* (* t_2 t_2) -0.25) (/ h l) 1.0)) w0)
     (if (<= t_4 INFINITY)
       (* w0 (* (* (/ (sqrt (* -0.25 (/ h l))) (fabs d)) t_1) t_0))
       (*
        w0
        (sqrt
         (-
          1.0
          (/
           (* (/ (* (* t_3 t_0) t_1) (fabs d)) h)
           (* (* 4.0 (fabs d)) l)))))))))
double code(double w0, double M, double D, double h, double l, double d) {
	double t_0 = fmax(fabs(M), fabs(D));
	double t_1 = fmin(fabs(M), fabs(D));
	double t_2 = t_1 * (t_0 / fabs(d));
	double t_3 = t_1 * t_0;
	double t_4 = 1.0 - (pow((t_3 / (2.0 * fabs(d))), 2.0) * (h / l));
	double tmp;
	if (t_4 <= 1000000.0) {
		tmp = sqrt(fma(((t_2 * t_2) * -0.25), (h / l), 1.0)) * w0;
	} else if (t_4 <= ((double) INFINITY)) {
		tmp = w0 * (((sqrt((-0.25 * (h / l))) / fabs(d)) * t_1) * t_0);
	} else {
		tmp = w0 * sqrt((1.0 - (((((t_3 * t_0) * t_1) / fabs(d)) * h) / ((4.0 * fabs(d)) * l))));
	}
	return tmp;
}
function code(w0, M, D, h, l, d)
	t_0 = fmax(abs(M), abs(D))
	t_1 = fmin(abs(M), abs(D))
	t_2 = Float64(t_1 * Float64(t_0 / abs(d)))
	t_3 = Float64(t_1 * t_0)
	t_4 = Float64(1.0 - Float64((Float64(t_3 / Float64(2.0 * abs(d))) ^ 2.0) * Float64(h / l)))
	tmp = 0.0
	if (t_4 <= 1000000.0)
		tmp = Float64(sqrt(fma(Float64(Float64(t_2 * t_2) * -0.25), Float64(h / l), 1.0)) * w0);
	elseif (t_4 <= Inf)
		tmp = Float64(w0 * Float64(Float64(Float64(sqrt(Float64(-0.25 * Float64(h / l))) / abs(d)) * t_1) * t_0));
	else
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(Float64(Float64(t_3 * t_0) * t_1) / abs(d)) * h) / Float64(Float64(4.0 * abs(d)) * l)))));
	end
	return tmp
end
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[Max[N[Abs[M], $MachinePrecision], N[Abs[D], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Min[N[Abs[M], $MachinePrecision], N[Abs[D], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * N[(t$95$0 / N[Abs[d], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$1 * t$95$0), $MachinePrecision]}, Block[{t$95$4 = N[(1.0 - N[(N[Power[N[(t$95$3 / N[(2.0 * N[Abs[d], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$4, 1000000.0], N[(N[Sqrt[N[(N[(N[(t$95$2 * t$95$2), $MachinePrecision] * -0.25), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision] * w0), $MachinePrecision], If[LessEqual[t$95$4, Infinity], N[(w0 * N[(N[(N[(N[Sqrt[N[(-0.25 * N[(h / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Abs[d], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(N[(N[(t$95$3 * t$95$0), $MachinePrecision] * t$95$1), $MachinePrecision] / N[Abs[d], $MachinePrecision]), $MachinePrecision] * h), $MachinePrecision] / N[(N[(4.0 * N[Abs[d], $MachinePrecision]), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
t_0 := \mathsf{max}\left(\left|M\right|, \left|D\right|\right)\\
t_1 := \mathsf{min}\left(\left|M\right|, \left|D\right|\right)\\
t_2 := t\_1 \cdot \frac{t\_0}{\left|d\right|}\\
t_3 := t\_1 \cdot t\_0\\
t_4 := 1 - {\left(\frac{t\_3}{2 \cdot \left|d\right|}\right)}^{2} \cdot \frac{h}{\ell}\\
\mathbf{if}\;t\_4 \leq 1000000:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(\left(t\_2 \cdot t\_2\right) \cdot -0.25, \frac{h}{\ell}, 1\right)} \cdot w0\\

\mathbf{elif}\;t\_4 \leq \infty:\\
\;\;\;\;w0 \cdot \left(\left(\frac{\sqrt{-0.25 \cdot \frac{h}{\ell}}}{\left|d\right|} \cdot t\_1\right) \cdot t\_0\right)\\

\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{\frac{\left(t\_3 \cdot t\_0\right) \cdot t\_1}{\left|d\right|} \cdot h}{\left(4 \cdot \left|d\right|\right) \cdot \ell}}\\


\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (-.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))) < 1e6

    1. Initial program 80.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1e6 < (-.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 80.6%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto D \cdot \left(w0 \cdot \sqrt{-\frac{1}{4} \cdot \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}}\right) \]
      10. lower-pow.f649.5%

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

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

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

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

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

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

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

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

        \[\leadsto D \cdot \left(w0 \cdot \left(M \cdot \sqrt{-\frac{1}{4} \cdot \frac{h}{{d}^{2} \cdot \ell}}\right)\right) \]
      7. lower-pow.f6411.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if +inf.0 < (-.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 80.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 91.0% accurate, 0.3× speedup?

\[\begin{array}{l} t_0 := \mathsf{max}\left(\left|M\right|, \left|D\right|\right)\\ t_1 := \mathsf{min}\left(\left|M\right|, \left|D\right|\right)\\ t_2 := t\_1 \cdot \frac{t\_0}{\left|d\right|}\\ t_3 := 1 - {\left(\frac{t\_1 \cdot t\_0}{2 \cdot \left|d\right|}\right)}^{2} \cdot \frac{h}{\ell}\\ \mathbf{if}\;t\_3 \leq 1000000:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(\left(t\_2 \cdot t\_2\right) \cdot -0.25, \frac{h}{\ell}, 1\right)} \cdot w0\\ \mathbf{elif}\;t\_3 \leq \infty:\\ \;\;\;\;w0 \cdot \left(\left(\frac{\sqrt{-0.25 \cdot \frac{h}{\ell}}}{\left|d\right|} \cdot t\_1\right) \cdot t\_0\right)\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{\left(\left(\left(t\_0 \cdot t\_1\right) \cdot t\_0\right) \cdot t\_1\right) \cdot h}{\left|d\right|} \cdot \frac{0.25}{\left|d\right| \cdot \ell}}\\ \end{array} \]
(FPCore (w0 M D h l d)
 :precision binary64
 (let* ((t_0 (fmax (fabs M) (fabs D)))
        (t_1 (fmin (fabs M) (fabs D)))
        (t_2 (* t_1 (/ t_0 (fabs d))))
        (t_3 (- 1.0 (* (pow (/ (* t_1 t_0) (* 2.0 (fabs d))) 2.0) (/ h l)))))
   (if (<= t_3 1000000.0)
     (* (sqrt (fma (* (* t_2 t_2) -0.25) (/ h l) 1.0)) w0)
     (if (<= t_3 INFINITY)
       (* w0 (* (* (/ (sqrt (* -0.25 (/ h l))) (fabs d)) t_1) t_0))
       (*
        w0
        (sqrt
         (-
          1.0
          (*
           (/ (* (* (* (* t_0 t_1) t_0) t_1) h) (fabs d))
           (/ 0.25 (* (fabs d) l))))))))))
double code(double w0, double M, double D, double h, double l, double d) {
	double t_0 = fmax(fabs(M), fabs(D));
	double t_1 = fmin(fabs(M), fabs(D));
	double t_2 = t_1 * (t_0 / fabs(d));
	double t_3 = 1.0 - (pow(((t_1 * t_0) / (2.0 * fabs(d))), 2.0) * (h / l));
	double tmp;
	if (t_3 <= 1000000.0) {
		tmp = sqrt(fma(((t_2 * t_2) * -0.25), (h / l), 1.0)) * w0;
	} else if (t_3 <= ((double) INFINITY)) {
		tmp = w0 * (((sqrt((-0.25 * (h / l))) / fabs(d)) * t_1) * t_0);
	} else {
		tmp = w0 * sqrt((1.0 - ((((((t_0 * t_1) * t_0) * t_1) * h) / fabs(d)) * (0.25 / (fabs(d) * l)))));
	}
	return tmp;
}
function code(w0, M, D, h, l, d)
	t_0 = fmax(abs(M), abs(D))
	t_1 = fmin(abs(M), abs(D))
	t_2 = Float64(t_1 * Float64(t_0 / abs(d)))
	t_3 = Float64(1.0 - Float64((Float64(Float64(t_1 * t_0) / Float64(2.0 * abs(d))) ^ 2.0) * Float64(h / l)))
	tmp = 0.0
	if (t_3 <= 1000000.0)
		tmp = Float64(sqrt(fma(Float64(Float64(t_2 * t_2) * -0.25), Float64(h / l), 1.0)) * w0);
	elseif (t_3 <= Inf)
		tmp = Float64(w0 * Float64(Float64(Float64(sqrt(Float64(-0.25 * Float64(h / l))) / abs(d)) * t_1) * t_0));
	else
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(Float64(Float64(Float64(t_0 * t_1) * t_0) * t_1) * h) / abs(d)) * Float64(0.25 / Float64(abs(d) * l))))));
	end
	return tmp
end
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[Max[N[Abs[M], $MachinePrecision], N[Abs[D], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Min[N[Abs[M], $MachinePrecision], N[Abs[D], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * N[(t$95$0 / N[Abs[d], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(1.0 - N[(N[Power[N[(N[(t$95$1 * t$95$0), $MachinePrecision] / N[(2.0 * N[Abs[d], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$3, 1000000.0], N[(N[Sqrt[N[(N[(N[(t$95$2 * t$95$2), $MachinePrecision] * -0.25), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision] * w0), $MachinePrecision], If[LessEqual[t$95$3, Infinity], N[(w0 * N[(N[(N[(N[Sqrt[N[(-0.25 * N[(h / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Abs[d], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(N[(N[(N[(t$95$0 * t$95$1), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$1), $MachinePrecision] * h), $MachinePrecision] / N[Abs[d], $MachinePrecision]), $MachinePrecision] * N[(0.25 / N[(N[Abs[d], $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
t_0 := \mathsf{max}\left(\left|M\right|, \left|D\right|\right)\\
t_1 := \mathsf{min}\left(\left|M\right|, \left|D\right|\right)\\
t_2 := t\_1 \cdot \frac{t\_0}{\left|d\right|}\\
t_3 := 1 - {\left(\frac{t\_1 \cdot t\_0}{2 \cdot \left|d\right|}\right)}^{2} \cdot \frac{h}{\ell}\\
\mathbf{if}\;t\_3 \leq 1000000:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(\left(t\_2 \cdot t\_2\right) \cdot -0.25, \frac{h}{\ell}, 1\right)} \cdot w0\\

\mathbf{elif}\;t\_3 \leq \infty:\\
\;\;\;\;w0 \cdot \left(\left(\frac{\sqrt{-0.25 \cdot \frac{h}{\ell}}}{\left|d\right|} \cdot t\_1\right) \cdot t\_0\right)\\

\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{\left(\left(\left(t\_0 \cdot t\_1\right) \cdot t\_0\right) \cdot t\_1\right) \cdot h}{\left|d\right|} \cdot \frac{0.25}{\left|d\right| \cdot \ell}}\\


\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (-.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))) < 1e6

    1. Initial program 80.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1e6 < (-.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 80.6%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto D \cdot \left(w0 \cdot \sqrt{-\frac{1}{4} \cdot \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}}\right) \]
      10. lower-pow.f649.5%

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

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

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

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

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

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

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

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

        \[\leadsto D \cdot \left(w0 \cdot \left(M \cdot \sqrt{-\frac{1}{4} \cdot \frac{h}{{d}^{2} \cdot \ell}}\right)\right) \]
      7. lower-pow.f6411.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if +inf.0 < (-.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 80.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 90.9% accurate, 0.3× speedup?

\[\begin{array}{l} t_0 := \mathsf{max}\left(\left|M\right|, \left|D\right|\right)\\ t_1 := \mathsf{min}\left(\left|M\right|, \left|D\right|\right)\\ t_2 := t\_1 \cdot \frac{t\_0}{\left|d\right|}\\ t_3 := t\_1 \cdot t\_0\\ t_4 := 1 - {\left(\frac{t\_3}{2 \cdot \left|d\right|}\right)}^{2} \cdot \frac{h}{\ell}\\ \mathbf{if}\;t\_4 \leq 1000000:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(\left(t\_2 \cdot t\_2\right) \cdot -0.25, \frac{h}{\ell}, 1\right)} \cdot w0\\ \mathbf{elif}\;t\_4 \leq \infty:\\ \;\;\;\;w0 \cdot \left(\left(\frac{\sqrt{-0.25 \cdot \frac{h}{\ell}}}{\left|d\right|} \cdot t\_1\right) \cdot t\_0\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(-0.25, \frac{\left(\left(t\_3 \cdot t\_0\right) \cdot t\_1\right) \cdot h}{\left(\ell \cdot \left|d\right|\right) \cdot \left|d\right|}, 1\right)} \cdot w0\\ \end{array} \]
(FPCore (w0 M D h l d)
 :precision binary64
 (let* ((t_0 (fmax (fabs M) (fabs D)))
        (t_1 (fmin (fabs M) (fabs D)))
        (t_2 (* t_1 (/ t_0 (fabs d))))
        (t_3 (* t_1 t_0))
        (t_4 (- 1.0 (* (pow (/ t_3 (* 2.0 (fabs d))) 2.0) (/ h l)))))
   (if (<= t_4 1000000.0)
     (* (sqrt (fma (* (* t_2 t_2) -0.25) (/ h l) 1.0)) w0)
     (if (<= t_4 INFINITY)
       (* w0 (* (* (/ (sqrt (* -0.25 (/ h l))) (fabs d)) t_1) t_0))
       (*
        (sqrt
         (fma
          -0.25
          (/ (* (* (* t_3 t_0) t_1) h) (* (* l (fabs d)) (fabs d)))
          1.0))
        w0)))))
double code(double w0, double M, double D, double h, double l, double d) {
	double t_0 = fmax(fabs(M), fabs(D));
	double t_1 = fmin(fabs(M), fabs(D));
	double t_2 = t_1 * (t_0 / fabs(d));
	double t_3 = t_1 * t_0;
	double t_4 = 1.0 - (pow((t_3 / (2.0 * fabs(d))), 2.0) * (h / l));
	double tmp;
	if (t_4 <= 1000000.0) {
		tmp = sqrt(fma(((t_2 * t_2) * -0.25), (h / l), 1.0)) * w0;
	} else if (t_4 <= ((double) INFINITY)) {
		tmp = w0 * (((sqrt((-0.25 * (h / l))) / fabs(d)) * t_1) * t_0);
	} else {
		tmp = sqrt(fma(-0.25, ((((t_3 * t_0) * t_1) * h) / ((l * fabs(d)) * fabs(d))), 1.0)) * w0;
	}
	return tmp;
}
function code(w0, M, D, h, l, d)
	t_0 = fmax(abs(M), abs(D))
	t_1 = fmin(abs(M), abs(D))
	t_2 = Float64(t_1 * Float64(t_0 / abs(d)))
	t_3 = Float64(t_1 * t_0)
	t_4 = Float64(1.0 - Float64((Float64(t_3 / Float64(2.0 * abs(d))) ^ 2.0) * Float64(h / l)))
	tmp = 0.0
	if (t_4 <= 1000000.0)
		tmp = Float64(sqrt(fma(Float64(Float64(t_2 * t_2) * -0.25), Float64(h / l), 1.0)) * w0);
	elseif (t_4 <= Inf)
		tmp = Float64(w0 * Float64(Float64(Float64(sqrt(Float64(-0.25 * Float64(h / l))) / abs(d)) * t_1) * t_0));
	else
		tmp = Float64(sqrt(fma(-0.25, Float64(Float64(Float64(Float64(t_3 * t_0) * t_1) * h) / Float64(Float64(l * abs(d)) * abs(d))), 1.0)) * w0);
	end
	return tmp
end
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[Max[N[Abs[M], $MachinePrecision], N[Abs[D], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Min[N[Abs[M], $MachinePrecision], N[Abs[D], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * N[(t$95$0 / N[Abs[d], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$1 * t$95$0), $MachinePrecision]}, Block[{t$95$4 = N[(1.0 - N[(N[Power[N[(t$95$3 / N[(2.0 * N[Abs[d], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$4, 1000000.0], N[(N[Sqrt[N[(N[(N[(t$95$2 * t$95$2), $MachinePrecision] * -0.25), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision] * w0), $MachinePrecision], If[LessEqual[t$95$4, Infinity], N[(w0 * N[(N[(N[(N[Sqrt[N[(-0.25 * N[(h / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Abs[d], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(-0.25 * N[(N[(N[(N[(t$95$3 * t$95$0), $MachinePrecision] * t$95$1), $MachinePrecision] * h), $MachinePrecision] / N[(N[(l * N[Abs[d], $MachinePrecision]), $MachinePrecision] * N[Abs[d], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision] * w0), $MachinePrecision]]]]]]]]
\begin{array}{l}
t_0 := \mathsf{max}\left(\left|M\right|, \left|D\right|\right)\\
t_1 := \mathsf{min}\left(\left|M\right|, \left|D\right|\right)\\
t_2 := t\_1 \cdot \frac{t\_0}{\left|d\right|}\\
t_3 := t\_1 \cdot t\_0\\
t_4 := 1 - {\left(\frac{t\_3}{2 \cdot \left|d\right|}\right)}^{2} \cdot \frac{h}{\ell}\\
\mathbf{if}\;t\_4 \leq 1000000:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(\left(t\_2 \cdot t\_2\right) \cdot -0.25, \frac{h}{\ell}, 1\right)} \cdot w0\\

\mathbf{elif}\;t\_4 \leq \infty:\\
\;\;\;\;w0 \cdot \left(\left(\frac{\sqrt{-0.25 \cdot \frac{h}{\ell}}}{\left|d\right|} \cdot t\_1\right) \cdot t\_0\right)\\

\mathbf{else}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(-0.25, \frac{\left(\left(t\_3 \cdot t\_0\right) \cdot t\_1\right) \cdot h}{\left(\ell \cdot \left|d\right|\right) \cdot \left|d\right|}, 1\right)} \cdot w0\\


\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (-.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))) < 1e6

    1. Initial program 80.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1e6 < (-.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 80.6%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto D \cdot \left(w0 \cdot \sqrt{-\frac{1}{4} \cdot \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}}\right) \]
      10. lower-pow.f649.5%

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

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

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

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

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

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

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

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

        \[\leadsto D \cdot \left(w0 \cdot \left(M \cdot \sqrt{-\frac{1}{4} \cdot \frac{h}{{d}^{2} \cdot \ell}}\right)\right) \]
      7. lower-pow.f6411.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if +inf.0 < (-.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 80.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(\frac{1}{4}\right), \frac{\left(\left(\left(D \cdot M\right) \cdot D\right) \cdot M\right) \cdot h}{\left(d \cdot d\right) \cdot \ell}, 1\right)}} \cdot w0 \]
    7. Applied rewrites71.9%

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

Alternative 6: 90.8% accurate, 0.5× speedup?

\[\begin{array}{l} t_0 := \mathsf{max}\left(\left|M\right|, \left|D\right|\right)\\ t_1 := \mathsf{min}\left(\left|M\right|, \left|D\right|\right)\\ \mathbf{if}\;{\left(\frac{t\_1 \cdot t\_0}{2 \cdot \left|d\right|}\right)}^{2} \cdot \frac{h}{\ell} \leq -400000:\\ \;\;\;\;w0 \cdot \left(\left(\frac{\sqrt{-0.25 \cdot \frac{h}{\ell}}}{\left|d\right|} \cdot t\_1\right) \cdot t\_0\right)\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot 1\\ \end{array} \]
(FPCore (w0 M D h l d)
 :precision binary64
 (let* ((t_0 (fmax (fabs M) (fabs D))) (t_1 (fmin (fabs M) (fabs D))))
   (if (<= (* (pow (/ (* t_1 t_0) (* 2.0 (fabs d))) 2.0) (/ h l)) -400000.0)
     (* w0 (* (* (/ (sqrt (* -0.25 (/ h l))) (fabs d)) t_1) t_0))
     (* w0 1.0))))
double code(double w0, double M, double D, double h, double l, double d) {
	double t_0 = fmax(fabs(M), fabs(D));
	double t_1 = fmin(fabs(M), fabs(D));
	double tmp;
	if ((pow(((t_1 * t_0) / (2.0 * fabs(d))), 2.0) * (h / l)) <= -400000.0) {
		tmp = w0 * (((sqrt((-0.25 * (h / l))) / fabs(d)) * t_1) * t_0);
	} else {
		tmp = w0 * 1.0;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(w0, m, d, h, l, d_1)
use fmin_fmax_functions
    real(8), intent (in) :: w0
    real(8), intent (in) :: m
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d_1
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = fmax(abs(m), abs(d))
    t_1 = fmin(abs(m), abs(d))
    if (((((t_1 * t_0) / (2.0d0 * abs(d_1))) ** 2.0d0) * (h / l)) <= (-400000.0d0)) then
        tmp = w0 * (((sqrt(((-0.25d0) * (h / l))) / abs(d_1)) * t_1) * t_0)
    else
        tmp = w0 * 1.0d0
    end if
    code = tmp
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
	double t_0 = fmax(Math.abs(M), Math.abs(D));
	double t_1 = fmin(Math.abs(M), Math.abs(D));
	double tmp;
	if ((Math.pow(((t_1 * t_0) / (2.0 * Math.abs(d))), 2.0) * (h / l)) <= -400000.0) {
		tmp = w0 * (((Math.sqrt((-0.25 * (h / l))) / Math.abs(d)) * t_1) * t_0);
	} else {
		tmp = w0 * 1.0;
	}
	return tmp;
}
def code(w0, M, D, h, l, d):
	t_0 = fmax(math.fabs(M), math.fabs(D))
	t_1 = fmin(math.fabs(M), math.fabs(D))
	tmp = 0
	if (math.pow(((t_1 * t_0) / (2.0 * math.fabs(d))), 2.0) * (h / l)) <= -400000.0:
		tmp = w0 * (((math.sqrt((-0.25 * (h / l))) / math.fabs(d)) * t_1) * t_0)
	else:
		tmp = w0 * 1.0
	return tmp
function code(w0, M, D, h, l, d)
	t_0 = fmax(abs(M), abs(D))
	t_1 = fmin(abs(M), abs(D))
	tmp = 0.0
	if (Float64((Float64(Float64(t_1 * t_0) / Float64(2.0 * abs(d))) ^ 2.0) * Float64(h / l)) <= -400000.0)
		tmp = Float64(w0 * Float64(Float64(Float64(sqrt(Float64(-0.25 * Float64(h / l))) / abs(d)) * t_1) * t_0));
	else
		tmp = Float64(w0 * 1.0);
	end
	return tmp
end
function tmp_2 = code(w0, M, D, h, l, d)
	t_0 = max(abs(M), abs(D));
	t_1 = min(abs(M), abs(D));
	tmp = 0.0;
	if (((((t_1 * t_0) / (2.0 * abs(d))) ^ 2.0) * (h / l)) <= -400000.0)
		tmp = w0 * (((sqrt((-0.25 * (h / l))) / abs(d)) * t_1) * t_0);
	else
		tmp = w0 * 1.0;
	end
	tmp_2 = tmp;
end
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[Max[N[Abs[M], $MachinePrecision], N[Abs[D], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Min[N[Abs[M], $MachinePrecision], N[Abs[D], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[Power[N[(N[(t$95$1 * t$95$0), $MachinePrecision] / N[(2.0 * N[Abs[d], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -400000.0], N[(w0 * N[(N[(N[(N[Sqrt[N[(-0.25 * N[(h / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Abs[d], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], N[(w0 * 1.0), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \mathsf{max}\left(\left|M\right|, \left|D\right|\right)\\
t_1 := \mathsf{min}\left(\left|M\right|, \left|D\right|\right)\\
\mathbf{if}\;{\left(\frac{t\_1 \cdot t\_0}{2 \cdot \left|d\right|}\right)}^{2} \cdot \frac{h}{\ell} \leq -400000:\\
\;\;\;\;w0 \cdot \left(\left(\frac{\sqrt{-0.25 \cdot \frac{h}{\ell}}}{\left|d\right|} \cdot t\_1\right) \cdot t\_0\right)\\

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


\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)) < -4e5

    1. Initial program 80.6%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto D \cdot \left(w0 \cdot \sqrt{-\frac{1}{4} \cdot \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}}\right) \]
      10. lower-pow.f649.5%

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

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

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

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

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

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

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

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

        \[\leadsto D \cdot \left(w0 \cdot \left(M \cdot \sqrt{-\frac{1}{4} \cdot \frac{h}{{d}^{2} \cdot \ell}}\right)\right) \]
      7. lower-pow.f6411.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 80.6%

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

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

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

    Alternative 7: 90.5% accurate, 0.5× speedup?

    \[\begin{array}{l} t_0 := \mathsf{max}\left(\left|M\right|, \left|D\right|\right)\\ t_1 := \mathsf{min}\left(\left|M\right|, \left|D\right|\right)\\ \mathbf{if}\;{\left(\frac{t\_1 \cdot t\_0}{2 \cdot \left|d\right|}\right)}^{2} \cdot \frac{h}{\ell} \leq -500000:\\ \;\;\;\;\left(\left(\frac{\sqrt{-0.25 \cdot \frac{h}{\ell}}}{\left|d\right|} \cdot t\_1\right) \cdot w0\right) \cdot t\_0\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot 1\\ \end{array} \]
    (FPCore (w0 M D h l d)
     :precision binary64
     (let* ((t_0 (fmax (fabs M) (fabs D))) (t_1 (fmin (fabs M) (fabs D))))
       (if (<= (* (pow (/ (* t_1 t_0) (* 2.0 (fabs d))) 2.0) (/ h l)) -500000.0)
         (* (* (* (/ (sqrt (* -0.25 (/ h l))) (fabs d)) t_1) w0) t_0)
         (* w0 1.0))))
    double code(double w0, double M, double D, double h, double l, double d) {
    	double t_0 = fmax(fabs(M), fabs(D));
    	double t_1 = fmin(fabs(M), fabs(D));
    	double tmp;
    	if ((pow(((t_1 * t_0) / (2.0 * fabs(d))), 2.0) * (h / l)) <= -500000.0) {
    		tmp = (((sqrt((-0.25 * (h / l))) / fabs(d)) * t_1) * w0) * t_0;
    	} else {
    		tmp = w0 * 1.0;
    	}
    	return tmp;
    }
    
    module fmin_fmax_functions
        implicit none
        private
        public fmax
        public fmin
    
        interface fmax
            module procedure fmax88
            module procedure fmax44
            module procedure fmax84
            module procedure fmax48
        end interface
        interface fmin
            module procedure fmin88
            module procedure fmin44
            module procedure fmin84
            module procedure fmin48
        end interface
    contains
        real(8) function fmax88(x, y) result (res)
            real(8), intent (in) :: x
            real(8), intent (in) :: y
            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
        end function
        real(4) function fmax44(x, y) result (res)
            real(4), intent (in) :: x
            real(4), intent (in) :: y
            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
        end function
        real(8) function fmax84(x, y) result(res)
            real(8), intent (in) :: x
            real(4), intent (in) :: y
            res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
        end function
        real(8) function fmax48(x, y) result(res)
            real(4), intent (in) :: x
            real(8), intent (in) :: y
            res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
        end function
        real(8) function fmin88(x, y) result (res)
            real(8), intent (in) :: x
            real(8), intent (in) :: y
            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
        end function
        real(4) function fmin44(x, y) result (res)
            real(4), intent (in) :: x
            real(4), intent (in) :: y
            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
        end function
        real(8) function fmin84(x, y) result(res)
            real(8), intent (in) :: x
            real(4), intent (in) :: y
            res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
        end function
        real(8) function fmin48(x, y) result(res)
            real(4), intent (in) :: x
            real(8), intent (in) :: y
            res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
        end function
    end module
    
    real(8) function code(w0, m, d, h, l, d_1)
    use fmin_fmax_functions
        real(8), intent (in) :: w0
        real(8), intent (in) :: m
        real(8), intent (in) :: d
        real(8), intent (in) :: h
        real(8), intent (in) :: l
        real(8), intent (in) :: d_1
        real(8) :: t_0
        real(8) :: t_1
        real(8) :: tmp
        t_0 = fmax(abs(m), abs(d))
        t_1 = fmin(abs(m), abs(d))
        if (((((t_1 * t_0) / (2.0d0 * abs(d_1))) ** 2.0d0) * (h / l)) <= (-500000.0d0)) then
            tmp = (((sqrt(((-0.25d0) * (h / l))) / abs(d_1)) * t_1) * w0) * t_0
        else
            tmp = w0 * 1.0d0
        end if
        code = tmp
    end function
    
    public static double code(double w0, double M, double D, double h, double l, double d) {
    	double t_0 = fmax(Math.abs(M), Math.abs(D));
    	double t_1 = fmin(Math.abs(M), Math.abs(D));
    	double tmp;
    	if ((Math.pow(((t_1 * t_0) / (2.0 * Math.abs(d))), 2.0) * (h / l)) <= -500000.0) {
    		tmp = (((Math.sqrt((-0.25 * (h / l))) / Math.abs(d)) * t_1) * w0) * t_0;
    	} else {
    		tmp = w0 * 1.0;
    	}
    	return tmp;
    }
    
    def code(w0, M, D, h, l, d):
    	t_0 = fmax(math.fabs(M), math.fabs(D))
    	t_1 = fmin(math.fabs(M), math.fabs(D))
    	tmp = 0
    	if (math.pow(((t_1 * t_0) / (2.0 * math.fabs(d))), 2.0) * (h / l)) <= -500000.0:
    		tmp = (((math.sqrt((-0.25 * (h / l))) / math.fabs(d)) * t_1) * w0) * t_0
    	else:
    		tmp = w0 * 1.0
    	return tmp
    
    function code(w0, M, D, h, l, d)
    	t_0 = fmax(abs(M), abs(D))
    	t_1 = fmin(abs(M), abs(D))
    	tmp = 0.0
    	if (Float64((Float64(Float64(t_1 * t_0) / Float64(2.0 * abs(d))) ^ 2.0) * Float64(h / l)) <= -500000.0)
    		tmp = Float64(Float64(Float64(Float64(sqrt(Float64(-0.25 * Float64(h / l))) / abs(d)) * t_1) * w0) * t_0);
    	else
    		tmp = Float64(w0 * 1.0);
    	end
    	return tmp
    end
    
    function tmp_2 = code(w0, M, D, h, l, d)
    	t_0 = max(abs(M), abs(D));
    	t_1 = min(abs(M), abs(D));
    	tmp = 0.0;
    	if (((((t_1 * t_0) / (2.0 * abs(d))) ^ 2.0) * (h / l)) <= -500000.0)
    		tmp = (((sqrt((-0.25 * (h / l))) / abs(d)) * t_1) * w0) * t_0;
    	else
    		tmp = w0 * 1.0;
    	end
    	tmp_2 = tmp;
    end
    
    code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[Max[N[Abs[M], $MachinePrecision], N[Abs[D], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Min[N[Abs[M], $MachinePrecision], N[Abs[D], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[Power[N[(N[(t$95$1 * t$95$0), $MachinePrecision] / N[(2.0 * N[Abs[d], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -500000.0], N[(N[(N[(N[(N[Sqrt[N[(-0.25 * N[(h / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Abs[d], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] * w0), $MachinePrecision] * t$95$0), $MachinePrecision], N[(w0 * 1.0), $MachinePrecision]]]]
    
    \begin{array}{l}
    t_0 := \mathsf{max}\left(\left|M\right|, \left|D\right|\right)\\
    t_1 := \mathsf{min}\left(\left|M\right|, \left|D\right|\right)\\
    \mathbf{if}\;{\left(\frac{t\_1 \cdot t\_0}{2 \cdot \left|d\right|}\right)}^{2} \cdot \frac{h}{\ell} \leq -500000:\\
    \;\;\;\;\left(\left(\frac{\sqrt{-0.25 \cdot \frac{h}{\ell}}}{\left|d\right|} \cdot t\_1\right) \cdot w0\right) \cdot t\_0\\
    
    \mathbf{else}:\\
    \;\;\;\;w0 \cdot 1\\
    
    
    \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)) < -5e5

      1. Initial program 80.6%

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

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

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

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

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

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

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

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

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

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

          \[\leadsto D \cdot \left(w0 \cdot \sqrt{-\frac{1}{4} \cdot \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}}\right) \]
        10. lower-pow.f649.5%

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

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

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

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

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

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

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

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

          \[\leadsto D \cdot \left(w0 \cdot \left(M \cdot \sqrt{-\frac{1}{4} \cdot \frac{h}{{d}^{2} \cdot \ell}}\right)\right) \]
        7. lower-pow.f6411.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      1. Initial program 80.6%

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

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

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

      Alternative 8: 68.0% accurate, 10.1× speedup?

      \[w0 \cdot 1 \]
      (FPCore (w0 M D h l d) :precision binary64 (* w0 1.0))
      double code(double w0, double M, double D, double h, double l, double d) {
      	return w0 * 1.0;
      }
      
      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 * 1.0d0
      end function
      
      public static double code(double w0, double M, double D, double h, double l, double d) {
      	return w0 * 1.0;
      }
      
      def code(w0, M, D, h, l, d):
      	return w0 * 1.0
      
      function code(w0, M, D, h, l, d)
      	return Float64(w0 * 1.0)
      end
      
      function tmp = code(w0, M, D, h, l, d)
      	tmp = w0 * 1.0;
      end
      
      code[w0_, M_, D_, h_, l_, d_] := N[(w0 * 1.0), $MachinePrecision]
      
      w0 \cdot 1
      
      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. Taylor expanded in M around 0

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

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

        Reproduce

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