Henrywood and Agarwal, Equation (12)

Percentage Accurate: 35.8% → 78.3%
Time: 8.0s
Alternatives: 16
Speedup: 7.7×

Specification

?
\[\begin{array}{l} \\ \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (*
  (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
  (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
double code(double d, double h, double l, double M, double D) {
	return (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.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(d, h, l, m, d_1)
use fmin_fmax_functions
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    code = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
end function
public static double code(double d, double h, double l, double M, double D) {
	return (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
def code(d, h, l, M, D):
	return (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)))
function code(d, h, l, M, D)
	return Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l))))
end
function tmp = code(d, h, l, M, D)
	tmp = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l)));
end
code[d_, h_, l_, M_, D_] := N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 16 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: 35.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (*
  (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
  (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
double code(double d, double h, double l, double M, double D) {
	return (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.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(d, h, l, m, d_1)
use fmin_fmax_functions
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    code = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
end function
public static double code(double d, double h, double l, double M, double D) {
	return (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
def code(d, h, l, M, D):
	return (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)))
function code(d, h, l, M, D)
	return Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l))))
end
function tmp = code(d, h, l, M, D)
	tmp = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l)));
end
code[d_, h_, l_, M_, D_] := N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Alternative 1: 78.3% accurate, 1.5× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} t_0 := M \cdot \frac{D}{d\_m + d\_m}\\ \mathbf{if}\;\ell \leq -1 \cdot 10^{+221}:\\ \;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\_m\right)}{h}\\ \mathbf{elif}\;\ell \leq -2 \cdot 10^{-307}:\\ \;\;\;\;\left(\frac{1}{\sqrt{\ell \cdot h}} \cdot d\_m\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{\sqrt{\ell} \cdot \sqrt{h}} \cdot d\_m\right) \cdot \left(1 - \frac{\left(\left(t\_0 \cdot t\_0\right) \cdot 0.5\right) \cdot h}{\ell}\right)\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
(FPCore (d_m h l M D)
 :precision binary64
 (let* ((t_0 (* M (/ D (+ d_m d_m)))))
   (if (<= l -1e+221)
     (/ (* (sqrt (/ h l)) (- d_m)) h)
     (if (<= l -2e-307)
       (*
        (* (/ 1.0 (sqrt (* l h))) d_m)
        (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d_m)) 2.0)) (/ h l))))
       (*
        (* (/ 1.0 (* (sqrt l) (sqrt h))) d_m)
        (- 1.0 (/ (* (* (* t_0 t_0) 0.5) h) l)))))))
d_m = fabs(d);
double code(double d_m, double h, double l, double M, double D) {
	double t_0 = M * (D / (d_m + d_m));
	double tmp;
	if (l <= -1e+221) {
		tmp = (sqrt((h / l)) * -d_m) / h;
	} else if (l <= -2e-307) {
		tmp = ((1.0 / sqrt((l * h))) * d_m) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l)));
	} else {
		tmp = ((1.0 / (sqrt(l) * sqrt(h))) * d_m) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l));
	}
	return tmp;
}
d_m =     private
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(d_m, h, l, m, d)
use fmin_fmax_functions
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d
    real(8) :: t_0
    real(8) :: tmp
    t_0 = m * (d / (d_m + d_m))
    if (l <= (-1d+221)) then
        tmp = (sqrt((h / l)) * -d_m) / h
    else if (l <= (-2d-307)) then
        tmp = ((1.0d0 / sqrt((l * h))) * d_m) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d) / (2.0d0 * d_m)) ** 2.0d0)) * (h / l)))
    else
        tmp = ((1.0d0 / (sqrt(l) * sqrt(h))) * d_m) * (1.0d0 - ((((t_0 * t_0) * 0.5d0) * h) / l))
    end if
    code = tmp
end function
d_m = Math.abs(d);
public static double code(double d_m, double h, double l, double M, double D) {
	double t_0 = M * (D / (d_m + d_m));
	double tmp;
	if (l <= -1e+221) {
		tmp = (Math.sqrt((h / l)) * -d_m) / h;
	} else if (l <= -2e-307) {
		tmp = ((1.0 / Math.sqrt((l * h))) * d_m) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l)));
	} else {
		tmp = ((1.0 / (Math.sqrt(l) * Math.sqrt(h))) * d_m) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l));
	}
	return tmp;
}
d_m = math.fabs(d)
def code(d_m, h, l, M, D):
	t_0 = M * (D / (d_m + d_m))
	tmp = 0
	if l <= -1e+221:
		tmp = (math.sqrt((h / l)) * -d_m) / h
	elif l <= -2e-307:
		tmp = ((1.0 / math.sqrt((l * h))) * d_m) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l)))
	else:
		tmp = ((1.0 / (math.sqrt(l) * math.sqrt(h))) * d_m) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l))
	return tmp
d_m = abs(d)
function code(d_m, h, l, M, D)
	t_0 = Float64(M * Float64(D / Float64(d_m + d_m)))
	tmp = 0.0
	if (l <= -1e+221)
		tmp = Float64(Float64(sqrt(Float64(h / l)) * Float64(-d_m)) / h);
	elseif (l <= -2e-307)
		tmp = Float64(Float64(Float64(1.0 / sqrt(Float64(l * h))) * d_m) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d_m)) ^ 2.0)) * Float64(h / l))));
	else
		tmp = Float64(Float64(Float64(1.0 / Float64(sqrt(l) * sqrt(h))) * d_m) * Float64(1.0 - Float64(Float64(Float64(Float64(t_0 * t_0) * 0.5) * h) / l)));
	end
	return tmp
end
d_m = abs(d);
function tmp_2 = code(d_m, h, l, M, D)
	t_0 = M * (D / (d_m + d_m));
	tmp = 0.0;
	if (l <= -1e+221)
		tmp = (sqrt((h / l)) * -d_m) / h;
	elseif (l <= -2e-307)
		tmp = ((1.0 / sqrt((l * h))) * d_m) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d_m)) ^ 2.0)) * (h / l)));
	else
		tmp = ((1.0 / (sqrt(l) * sqrt(h))) * d_m) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l));
	end
	tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
code[d$95$m_, h_, l_, M_, D_] := Block[{t$95$0 = N[(M * N[(D / N[(d$95$m + d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -1e+221], N[(N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * (-d$95$m)), $MachinePrecision] / h), $MachinePrecision], If[LessEqual[l, -2e-307], N[(N[(N[(1.0 / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * d$95$m), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * d$95$m), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
d_m = \left|d\right|

\\
\begin{array}{l}
t_0 := M \cdot \frac{D}{d\_m + d\_m}\\
\mathbf{if}\;\ell \leq -1 \cdot 10^{+221}:\\
\;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\_m\right)}{h}\\

\mathbf{elif}\;\ell \leq -2 \cdot 10^{-307}:\\
\;\;\;\;\left(\frac{1}{\sqrt{\ell \cdot h}} \cdot d\_m\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\

\mathbf{else}:\\
\;\;\;\;\left(\frac{1}{\sqrt{\ell} \cdot \sqrt{h}} \cdot d\_m\right) \cdot \left(1 - \frac{\left(\left(t\_0 \cdot t\_0\right) \cdot 0.5\right) \cdot h}{\ell}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -1e221

    1. Initial program 35.8%

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(d \cdot {-1}^{\left(\frac{2}{2}\right)}\right)}{h} \]
      3. metadata-evalN/A

        \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(d \cdot {-1}^{1}\right)}{h} \]
      4. metadata-evalN/A

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

        \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(-1 \cdot d\right)}{h} \]
      6. mul-1-negN/A

        \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(\mathsf{neg}\left(d\right)\right)}{h} \]
      7. lift-neg.f64N/A

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

        \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\right)}{h} \]
      9. lift-sqrt.f64N/A

        \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\right)}{h} \]
      10. lift-/.f6425.0

        \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\right)}{h} \]
    7. Applied rewrites25.0%

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

    if -1e221 < l < -1.99999999999999982e-307

    1. Initial program 35.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\frac{1}{\sqrt{\ell \cdot h}} \cdot d\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      10. lift-*.f6470.7

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

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

    if -1.99999999999999982e-307 < l

    1. Initial program 35.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\frac{1}{\sqrt{\ell \cdot h}} \cdot d\right) \cdot \left(1 - \frac{\left(\left(\left(M \cdot \frac{D}{d + d}\right) \cdot \left(M \cdot \frac{D}{d + d}\right)\right) \cdot \frac{1}{2}\right) \cdot h}{\ell}\right) \]
      10. lift-*.f6474.7

        \[\leadsto \left(\frac{1}{\sqrt{\ell \cdot h}} \cdot d\right) \cdot \left(1 - \frac{\left(\left(\left(M \cdot \frac{D}{d + d}\right) \cdot \left(M \cdot \frac{D}{d + d}\right)\right) \cdot 0.5\right) \cdot h}{\ell}\right) \]
    8. Applied rewrites74.7%

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

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

        \[\leadsto \left(\frac{1}{\sqrt{\ell \cdot h}} \cdot d\right) \cdot \left(1 - \frac{\left(\left(\left(M \cdot \frac{D}{d + d}\right) \cdot \left(M \cdot \frac{D}{d + d}\right)\right) \cdot \frac{1}{2}\right) \cdot h}{\ell}\right) \]
      3. sqrt-prodN/A

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

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

        \[\leadsto \left(\frac{1}{\sqrt{\ell} \cdot \sqrt{h}} \cdot d\right) \cdot \left(1 - \frac{\left(\left(\left(M \cdot \frac{D}{d + d}\right) \cdot \left(M \cdot \frac{D}{d + d}\right)\right) \cdot \frac{1}{2}\right) \cdot h}{\ell}\right) \]
      6. lower-sqrt.f6441.5

        \[\leadsto \left(\frac{1}{\sqrt{\ell} \cdot \sqrt{h}} \cdot d\right) \cdot \left(1 - \frac{\left(\left(\left(M \cdot \frac{D}{d + d}\right) \cdot \left(M \cdot \frac{D}{d + d}\right)\right) \cdot 0.5\right) \cdot h}{\ell}\right) \]
    10. Applied rewrites41.5%

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

Alternative 2: 77.2% accurate, 1.6× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} t_0 := M \cdot \frac{D}{d\_m + d\_m}\\ t_1 := 1 - \frac{\left(\left(t\_0 \cdot t\_0\right) \cdot 0.5\right) \cdot h}{\ell}\\ \mathbf{if}\;\ell \leq -1 \cdot 10^{+216}:\\ \;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\_m\right)}{h}\\ \mathbf{elif}\;\ell \leq -2 \cdot 10^{-307}:\\ \;\;\;\;\left(\sqrt{\frac{1}{\ell \cdot h}} \cdot d\_m\right) \cdot t\_1\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{\sqrt{\ell} \cdot \sqrt{h}} \cdot d\_m\right) \cdot t\_1\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
(FPCore (d_m h l M D)
 :precision binary64
 (let* ((t_0 (* M (/ D (+ d_m d_m))))
        (t_1 (- 1.0 (/ (* (* (* t_0 t_0) 0.5) h) l))))
   (if (<= l -1e+216)
     (/ (* (sqrt (/ h l)) (- d_m)) h)
     (if (<= l -2e-307)
       (* (* (sqrt (/ 1.0 (* l h))) d_m) t_1)
       (* (* (/ 1.0 (* (sqrt l) (sqrt h))) d_m) t_1)))))
d_m = fabs(d);
double code(double d_m, double h, double l, double M, double D) {
	double t_0 = M * (D / (d_m + d_m));
	double t_1 = 1.0 - ((((t_0 * t_0) * 0.5) * h) / l);
	double tmp;
	if (l <= -1e+216) {
		tmp = (sqrt((h / l)) * -d_m) / h;
	} else if (l <= -2e-307) {
		tmp = (sqrt((1.0 / (l * h))) * d_m) * t_1;
	} else {
		tmp = ((1.0 / (sqrt(l) * sqrt(h))) * d_m) * t_1;
	}
	return tmp;
}
d_m =     private
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(d_m, h, l, m, d)
use fmin_fmax_functions
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = m * (d / (d_m + d_m))
    t_1 = 1.0d0 - ((((t_0 * t_0) * 0.5d0) * h) / l)
    if (l <= (-1d+216)) then
        tmp = (sqrt((h / l)) * -d_m) / h
    else if (l <= (-2d-307)) then
        tmp = (sqrt((1.0d0 / (l * h))) * d_m) * t_1
    else
        tmp = ((1.0d0 / (sqrt(l) * sqrt(h))) * d_m) * t_1
    end if
    code = tmp
end function
d_m = Math.abs(d);
public static double code(double d_m, double h, double l, double M, double D) {
	double t_0 = M * (D / (d_m + d_m));
	double t_1 = 1.0 - ((((t_0 * t_0) * 0.5) * h) / l);
	double tmp;
	if (l <= -1e+216) {
		tmp = (Math.sqrt((h / l)) * -d_m) / h;
	} else if (l <= -2e-307) {
		tmp = (Math.sqrt((1.0 / (l * h))) * d_m) * t_1;
	} else {
		tmp = ((1.0 / (Math.sqrt(l) * Math.sqrt(h))) * d_m) * t_1;
	}
	return tmp;
}
d_m = math.fabs(d)
def code(d_m, h, l, M, D):
	t_0 = M * (D / (d_m + d_m))
	t_1 = 1.0 - ((((t_0 * t_0) * 0.5) * h) / l)
	tmp = 0
	if l <= -1e+216:
		tmp = (math.sqrt((h / l)) * -d_m) / h
	elif l <= -2e-307:
		tmp = (math.sqrt((1.0 / (l * h))) * d_m) * t_1
	else:
		tmp = ((1.0 / (math.sqrt(l) * math.sqrt(h))) * d_m) * t_1
	return tmp
d_m = abs(d)
function code(d_m, h, l, M, D)
	t_0 = Float64(M * Float64(D / Float64(d_m + d_m)))
	t_1 = Float64(1.0 - Float64(Float64(Float64(Float64(t_0 * t_0) * 0.5) * h) / l))
	tmp = 0.0
	if (l <= -1e+216)
		tmp = Float64(Float64(sqrt(Float64(h / l)) * Float64(-d_m)) / h);
	elseif (l <= -2e-307)
		tmp = Float64(Float64(sqrt(Float64(1.0 / Float64(l * h))) * d_m) * t_1);
	else
		tmp = Float64(Float64(Float64(1.0 / Float64(sqrt(l) * sqrt(h))) * d_m) * t_1);
	end
	return tmp
end
d_m = abs(d);
function tmp_2 = code(d_m, h, l, M, D)
	t_0 = M * (D / (d_m + d_m));
	t_1 = 1.0 - ((((t_0 * t_0) * 0.5) * h) / l);
	tmp = 0.0;
	if (l <= -1e+216)
		tmp = (sqrt((h / l)) * -d_m) / h;
	elseif (l <= -2e-307)
		tmp = (sqrt((1.0 / (l * h))) * d_m) * t_1;
	else
		tmp = ((1.0 / (sqrt(l) * sqrt(h))) * d_m) * t_1;
	end
	tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
code[d$95$m_, h_, l_, M_, D_] := Block[{t$95$0 = N[(M * N[(D / N[(d$95$m + d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -1e+216], N[(N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * (-d$95$m)), $MachinePrecision] / h), $MachinePrecision], If[LessEqual[l, -2e-307], N[(N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision] * t$95$1), $MachinePrecision], N[(N[(N[(1.0 / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * d$95$m), $MachinePrecision] * t$95$1), $MachinePrecision]]]]]
\begin{array}{l}
d_m = \left|d\right|

\\
\begin{array}{l}
t_0 := M \cdot \frac{D}{d\_m + d\_m}\\
t_1 := 1 - \frac{\left(\left(t\_0 \cdot t\_0\right) \cdot 0.5\right) \cdot h}{\ell}\\
\mathbf{if}\;\ell \leq -1 \cdot 10^{+216}:\\
\;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\_m\right)}{h}\\

\mathbf{elif}\;\ell \leq -2 \cdot 10^{-307}:\\
\;\;\;\;\left(\sqrt{\frac{1}{\ell \cdot h}} \cdot d\_m\right) \cdot t\_1\\

\mathbf{else}:\\
\;\;\;\;\left(\frac{1}{\sqrt{\ell} \cdot \sqrt{h}} \cdot d\_m\right) \cdot t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -1e216

    1. Initial program 35.8%

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(d \cdot {-1}^{\left(\frac{2}{2}\right)}\right)}{h} \]
      3. metadata-evalN/A

        \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(d \cdot {-1}^{1}\right)}{h} \]
      4. metadata-evalN/A

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

        \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(-1 \cdot d\right)}{h} \]
      6. mul-1-negN/A

        \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(\mathsf{neg}\left(d\right)\right)}{h} \]
      7. lift-neg.f64N/A

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

        \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\right)}{h} \]
      9. lift-sqrt.f64N/A

        \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\right)}{h} \]
      10. lift-/.f6425.0

        \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\right)}{h} \]
    7. Applied rewrites25.0%

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

    if -1e216 < l < -1.99999999999999982e-307

    1. Initial program 35.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.99999999999999982e-307 < l

    1. Initial program 35.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\frac{1}{\sqrt{\ell \cdot h}} \cdot d\right) \cdot \left(1 - \frac{\left(\left(\left(M \cdot \frac{D}{d + d}\right) \cdot \left(M \cdot \frac{D}{d + d}\right)\right) \cdot \frac{1}{2}\right) \cdot h}{\ell}\right) \]
      10. lift-*.f6474.7

        \[\leadsto \left(\frac{1}{\sqrt{\ell \cdot h}} \cdot d\right) \cdot \left(1 - \frac{\left(\left(\left(M \cdot \frac{D}{d + d}\right) \cdot \left(M \cdot \frac{D}{d + d}\right)\right) \cdot 0.5\right) \cdot h}{\ell}\right) \]
    8. Applied rewrites74.7%

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

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

        \[\leadsto \left(\frac{1}{\sqrt{\ell \cdot h}} \cdot d\right) \cdot \left(1 - \frac{\left(\left(\left(M \cdot \frac{D}{d + d}\right) \cdot \left(M \cdot \frac{D}{d + d}\right)\right) \cdot \frac{1}{2}\right) \cdot h}{\ell}\right) \]
      3. sqrt-prodN/A

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

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

        \[\leadsto \left(\frac{1}{\sqrt{\ell} \cdot \sqrt{h}} \cdot d\right) \cdot \left(1 - \frac{\left(\left(\left(M \cdot \frac{D}{d + d}\right) \cdot \left(M \cdot \frac{D}{d + d}\right)\right) \cdot \frac{1}{2}\right) \cdot h}{\ell}\right) \]
      6. lower-sqrt.f6441.5

        \[\leadsto \left(\frac{1}{\sqrt{\ell} \cdot \sqrt{h}} \cdot d\right) \cdot \left(1 - \frac{\left(\left(\left(M \cdot \frac{D}{d + d}\right) \cdot \left(M \cdot \frac{D}{d + d}\right)\right) \cdot 0.5\right) \cdot h}{\ell}\right) \]
    10. Applied rewrites41.5%

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

Alternative 3: 76.7% accurate, 0.4× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} t_0 := \frac{D}{d\_m + d\_m}\\ t_1 := {\left(\frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)}\\ t_2 := \left(t\_1 \cdot {\left(\frac{d\_m}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\ t_3 := M \cdot t\_0\\ \mathbf{if}\;t\_2 \leq 2 \cdot 10^{-264}:\\ \;\;\;\;\left(\sqrt{\frac{\frac{1}{\ell}}{h}} \cdot d\_m\right) \cdot \left(1 - \left(\left(M \cdot \left(t\_0 \cdot \left(t\_0 \cdot M\right)\right)\right) \cdot 0.5\right) \cdot \frac{h}{\ell}\right)\\ \mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+238}:\\ \;\;\;\;\left(t\_1 \cdot \frac{\sqrt{d\_m}}{\sqrt{\ell}}\right) \cdot 1\\ \mathbf{else}:\\ \;\;\;\;\frac{1 \cdot d\_m}{\sqrt{\ell \cdot h}} \cdot \left(1 - \frac{\left(\left(t\_3 \cdot t\_3\right) \cdot 0.5\right) \cdot h}{\ell}\right)\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
(FPCore (d_m h l M D)
 :precision binary64
 (let* ((t_0 (/ D (+ d_m d_m)))
        (t_1 (pow (/ d_m h) (/ 1.0 2.0)))
        (t_2
         (*
          (* t_1 (pow (/ d_m l) (/ 1.0 2.0)))
          (-
           1.0
           (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d_m)) 2.0)) (/ h l)))))
        (t_3 (* M t_0)))
   (if (<= t_2 2e-264)
     (*
      (* (sqrt (/ (/ 1.0 l) h)) d_m)
      (- 1.0 (* (* (* M (* t_0 (* t_0 M))) 0.5) (/ h l))))
     (if (<= t_2 2e+238)
       (* (* t_1 (/ (sqrt d_m) (sqrt l))) 1.0)
       (*
        (/ (* 1.0 d_m) (sqrt (* l h)))
        (- 1.0 (/ (* (* (* t_3 t_3) 0.5) h) l)))))))
d_m = fabs(d);
double code(double d_m, double h, double l, double M, double D) {
	double t_0 = D / (d_m + d_m);
	double t_1 = pow((d_m / h), (1.0 / 2.0));
	double t_2 = (t_1 * pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l)));
	double t_3 = M * t_0;
	double tmp;
	if (t_2 <= 2e-264) {
		tmp = (sqrt(((1.0 / l) / h)) * d_m) * (1.0 - (((M * (t_0 * (t_0 * M))) * 0.5) * (h / l)));
	} else if (t_2 <= 2e+238) {
		tmp = (t_1 * (sqrt(d_m) / sqrt(l))) * 1.0;
	} else {
		tmp = ((1.0 * d_m) / sqrt((l * h))) * (1.0 - ((((t_3 * t_3) * 0.5) * h) / l));
	}
	return tmp;
}
d_m =     private
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(d_m, h, l, m, d)
use fmin_fmax_functions
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: t_3
    real(8) :: tmp
    t_0 = d / (d_m + d_m)
    t_1 = (d_m / h) ** (1.0d0 / 2.0d0)
    t_2 = (t_1 * ((d_m / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d) / (2.0d0 * d_m)) ** 2.0d0)) * (h / l)))
    t_3 = m * t_0
    if (t_2 <= 2d-264) then
        tmp = (sqrt(((1.0d0 / l) / h)) * d_m) * (1.0d0 - (((m * (t_0 * (t_0 * m))) * 0.5d0) * (h / l)))
    else if (t_2 <= 2d+238) then
        tmp = (t_1 * (sqrt(d_m) / sqrt(l))) * 1.0d0
    else
        tmp = ((1.0d0 * d_m) / sqrt((l * h))) * (1.0d0 - ((((t_3 * t_3) * 0.5d0) * h) / l))
    end if
    code = tmp
end function
d_m = Math.abs(d);
public static double code(double d_m, double h, double l, double M, double D) {
	double t_0 = D / (d_m + d_m);
	double t_1 = Math.pow((d_m / h), (1.0 / 2.0));
	double t_2 = (t_1 * Math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l)));
	double t_3 = M * t_0;
	double tmp;
	if (t_2 <= 2e-264) {
		tmp = (Math.sqrt(((1.0 / l) / h)) * d_m) * (1.0 - (((M * (t_0 * (t_0 * M))) * 0.5) * (h / l)));
	} else if (t_2 <= 2e+238) {
		tmp = (t_1 * (Math.sqrt(d_m) / Math.sqrt(l))) * 1.0;
	} else {
		tmp = ((1.0 * d_m) / Math.sqrt((l * h))) * (1.0 - ((((t_3 * t_3) * 0.5) * h) / l));
	}
	return tmp;
}
d_m = math.fabs(d)
def code(d_m, h, l, M, D):
	t_0 = D / (d_m + d_m)
	t_1 = math.pow((d_m / h), (1.0 / 2.0))
	t_2 = (t_1 * math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l)))
	t_3 = M * t_0
	tmp = 0
	if t_2 <= 2e-264:
		tmp = (math.sqrt(((1.0 / l) / h)) * d_m) * (1.0 - (((M * (t_0 * (t_0 * M))) * 0.5) * (h / l)))
	elif t_2 <= 2e+238:
		tmp = (t_1 * (math.sqrt(d_m) / math.sqrt(l))) * 1.0
	else:
		tmp = ((1.0 * d_m) / math.sqrt((l * h))) * (1.0 - ((((t_3 * t_3) * 0.5) * h) / l))
	return tmp
d_m = abs(d)
function code(d_m, h, l, M, D)
	t_0 = Float64(D / Float64(d_m + d_m))
	t_1 = Float64(d_m / h) ^ Float64(1.0 / 2.0)
	t_2 = Float64(Float64(t_1 * (Float64(d_m / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d_m)) ^ 2.0)) * Float64(h / l))))
	t_3 = Float64(M * t_0)
	tmp = 0.0
	if (t_2 <= 2e-264)
		tmp = Float64(Float64(sqrt(Float64(Float64(1.0 / l) / h)) * d_m) * Float64(1.0 - Float64(Float64(Float64(M * Float64(t_0 * Float64(t_0 * M))) * 0.5) * Float64(h / l))));
	elseif (t_2 <= 2e+238)
		tmp = Float64(Float64(t_1 * Float64(sqrt(d_m) / sqrt(l))) * 1.0);
	else
		tmp = Float64(Float64(Float64(1.0 * d_m) / sqrt(Float64(l * h))) * Float64(1.0 - Float64(Float64(Float64(Float64(t_3 * t_3) * 0.5) * h) / l)));
	end
	return tmp
end
d_m = abs(d);
function tmp_2 = code(d_m, h, l, M, D)
	t_0 = D / (d_m + d_m);
	t_1 = (d_m / h) ^ (1.0 / 2.0);
	t_2 = (t_1 * ((d_m / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d_m)) ^ 2.0)) * (h / l)));
	t_3 = M * t_0;
	tmp = 0.0;
	if (t_2 <= 2e-264)
		tmp = (sqrt(((1.0 / l) / h)) * d_m) * (1.0 - (((M * (t_0 * (t_0 * M))) * 0.5) * (h / l)));
	elseif (t_2 <= 2e+238)
		tmp = (t_1 * (sqrt(d_m) / sqrt(l))) * 1.0;
	else
		tmp = ((1.0 * d_m) / sqrt((l * h))) * (1.0 - ((((t_3 * t_3) * 0.5) * h) / l));
	end
	tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
code[d$95$m_, h_, l_, M_, D_] := Block[{t$95$0 = N[(D / N[(d$95$m + d$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(d$95$m / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(t$95$1 * N[Power[N[(d$95$m / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(M * t$95$0), $MachinePrecision]}, If[LessEqual[t$95$2, 2e-264], N[(N[(N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision] * N[(1.0 - N[(N[(N[(M * N[(t$95$0 * N[(t$95$0 * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2e+238], N[(N[(t$95$1 * N[(N[Sqrt[d$95$m], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision], N[(N[(N[(1.0 * d$95$m), $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(t$95$3 * t$95$3), $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
d_m = \left|d\right|

\\
\begin{array}{l}
t_0 := \frac{D}{d\_m + d\_m}\\
t_1 := {\left(\frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)}\\
t_2 := \left(t\_1 \cdot {\left(\frac{d\_m}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_3 := M \cdot t\_0\\
\mathbf{if}\;t\_2 \leq 2 \cdot 10^{-264}:\\
\;\;\;\;\left(\sqrt{\frac{\frac{1}{\ell}}{h}} \cdot d\_m\right) \cdot \left(1 - \left(\left(M \cdot \left(t\_0 \cdot \left(t\_0 \cdot M\right)\right)\right) \cdot 0.5\right) \cdot \frac{h}{\ell}\right)\\

\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+238}:\\
\;\;\;\;\left(t\_1 \cdot \frac{\sqrt{d\_m}}{\sqrt{\ell}}\right) \cdot 1\\

\mathbf{else}:\\
\;\;\;\;\frac{1 \cdot d\_m}{\sqrt{\ell \cdot h}} \cdot \left(1 - \frac{\left(\left(t\_3 \cdot t\_3\right) \cdot 0.5\right) \cdot h}{\ell}\right)\\


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

    1. Initial program 35.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\sqrt{\frac{\frac{1}{\ell}}{h}} \cdot d\right) \cdot \left(1 - \frac{\left(\left(\left(M \cdot \frac{D}{d + d}\right) \cdot \left(M \cdot \frac{D}{d + d}\right)\right) \cdot \frac{1}{2}\right) \cdot h}{\ell}\right) \]
      5. lower-/.f6475.2

        \[\leadsto \left(\sqrt{\frac{\frac{1}{\ell}}{h}} \cdot d\right) \cdot \left(1 - \frac{\left(\left(\left(M \cdot \frac{D}{d + d}\right) \cdot \left(M \cdot \frac{D}{d + d}\right)\right) \cdot 0.5\right) \cdot h}{\ell}\right) \]
    8. Applied rewrites75.2%

      \[\leadsto \left(\sqrt{\frac{\frac{1}{\ell}}{h}} \cdot d\right) \cdot \left(1 - \frac{\left(\left(\left(M \cdot \frac{D}{d + d}\right) \cdot \left(M \cdot \frac{D}{d + d}\right)\right) \cdot 0.5\right) \cdot h}{\ell}\right) \]
    9. Step-by-step derivation
      1. metadata-evalN/A

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

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

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

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

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

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

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

    1. Initial program 35.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      1. Initial program 35.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \left(\sqrt{\frac{\frac{1}{\ell}}{h}} \cdot d\right) \cdot \left(1 - \frac{\left(\left(\left(M \cdot \frac{D}{d + d}\right) \cdot \left(M \cdot \frac{D}{d + d}\right)\right) \cdot \frac{1}{2}\right) \cdot h}{\ell}\right) \]
        5. lower-/.f6475.2

          \[\leadsto \left(\sqrt{\frac{\frac{1}{\ell}}{h}} \cdot d\right) \cdot \left(1 - \frac{\left(\left(\left(M \cdot \frac{D}{d + d}\right) \cdot \left(M \cdot \frac{D}{d + d}\right)\right) \cdot 0.5\right) \cdot h}{\ell}\right) \]
      8. Applied rewrites75.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \frac{1 \cdot d}{\sqrt{\ell \cdot h}} \cdot \left(1 - \frac{\left(\left(\left(M \cdot \frac{D}{d + d}\right) \cdot \left(M \cdot \frac{D}{d + d}\right)\right) \cdot \frac{1}{2}\right) \cdot h}{\ell}\right) \]
        18. lift-sqrt.f6474.8

          \[\leadsto \frac{1 \cdot d}{\sqrt{\ell \cdot h}} \cdot \left(1 - \frac{\left(\left(\left(M \cdot \frac{D}{d + d}\right) \cdot \left(M \cdot \frac{D}{d + d}\right)\right) \cdot 0.5\right) \cdot h}{\ell}\right) \]
      10. Applied rewrites74.8%

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

    Alternative 4: 74.3% accurate, 1.8× speedup?

    \[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} t_0 := M \cdot \frac{D}{d\_m + d\_m}\\ \mathbf{if}\;\ell \leq -1 \cdot 10^{+216}:\\ \;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\_m\right)}{h}\\ \mathbf{else}:\\ \;\;\;\;\left(\sqrt{\frac{\frac{1}{\ell}}{h}} \cdot d\_m\right) \cdot \left(1 - \frac{\left(\left(t\_0 \cdot t\_0\right) \cdot 0.5\right) \cdot h}{\ell}\right)\\ \end{array} \end{array} \]
    d_m = (fabs.f64 d)
    (FPCore (d_m h l M D)
     :precision binary64
     (let* ((t_0 (* M (/ D (+ d_m d_m)))))
       (if (<= l -1e+216)
         (/ (* (sqrt (/ h l)) (- d_m)) h)
         (*
          (* (sqrt (/ (/ 1.0 l) h)) d_m)
          (- 1.0 (/ (* (* (* t_0 t_0) 0.5) h) l))))))
    d_m = fabs(d);
    double code(double d_m, double h, double l, double M, double D) {
    	double t_0 = M * (D / (d_m + d_m));
    	double tmp;
    	if (l <= -1e+216) {
    		tmp = (sqrt((h / l)) * -d_m) / h;
    	} else {
    		tmp = (sqrt(((1.0 / l) / h)) * d_m) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l));
    	}
    	return tmp;
    }
    
    d_m =     private
    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(d_m, h, l, m, d)
    use fmin_fmax_functions
        real(8), intent (in) :: d_m
        real(8), intent (in) :: h
        real(8), intent (in) :: l
        real(8), intent (in) :: m
        real(8), intent (in) :: d
        real(8) :: t_0
        real(8) :: tmp
        t_0 = m * (d / (d_m + d_m))
        if (l <= (-1d+216)) then
            tmp = (sqrt((h / l)) * -d_m) / h
        else
            tmp = (sqrt(((1.0d0 / l) / h)) * d_m) * (1.0d0 - ((((t_0 * t_0) * 0.5d0) * h) / l))
        end if
        code = tmp
    end function
    
    d_m = Math.abs(d);
    public static double code(double d_m, double h, double l, double M, double D) {
    	double t_0 = M * (D / (d_m + d_m));
    	double tmp;
    	if (l <= -1e+216) {
    		tmp = (Math.sqrt((h / l)) * -d_m) / h;
    	} else {
    		tmp = (Math.sqrt(((1.0 / l) / h)) * d_m) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l));
    	}
    	return tmp;
    }
    
    d_m = math.fabs(d)
    def code(d_m, h, l, M, D):
    	t_0 = M * (D / (d_m + d_m))
    	tmp = 0
    	if l <= -1e+216:
    		tmp = (math.sqrt((h / l)) * -d_m) / h
    	else:
    		tmp = (math.sqrt(((1.0 / l) / h)) * d_m) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l))
    	return tmp
    
    d_m = abs(d)
    function code(d_m, h, l, M, D)
    	t_0 = Float64(M * Float64(D / Float64(d_m + d_m)))
    	tmp = 0.0
    	if (l <= -1e+216)
    		tmp = Float64(Float64(sqrt(Float64(h / l)) * Float64(-d_m)) / h);
    	else
    		tmp = Float64(Float64(sqrt(Float64(Float64(1.0 / l) / h)) * d_m) * Float64(1.0 - Float64(Float64(Float64(Float64(t_0 * t_0) * 0.5) * h) / l)));
    	end
    	return tmp
    end
    
    d_m = abs(d);
    function tmp_2 = code(d_m, h, l, M, D)
    	t_0 = M * (D / (d_m + d_m));
    	tmp = 0.0;
    	if (l <= -1e+216)
    		tmp = (sqrt((h / l)) * -d_m) / h;
    	else
    		tmp = (sqrt(((1.0 / l) / h)) * d_m) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l));
    	end
    	tmp_2 = tmp;
    end
    
    d_m = N[Abs[d], $MachinePrecision]
    code[d$95$m_, h_, l_, M_, D_] := Block[{t$95$0 = N[(M * N[(D / N[(d$95$m + d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -1e+216], N[(N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * (-d$95$m)), $MachinePrecision] / h), $MachinePrecision], N[(N[(N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
    
    \begin{array}{l}
    d_m = \left|d\right|
    
    \\
    \begin{array}{l}
    t_0 := M \cdot \frac{D}{d\_m + d\_m}\\
    \mathbf{if}\;\ell \leq -1 \cdot 10^{+216}:\\
    \;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\_m\right)}{h}\\
    
    \mathbf{else}:\\
    \;\;\;\;\left(\sqrt{\frac{\frac{1}{\ell}}{h}} \cdot d\_m\right) \cdot \left(1 - \frac{\left(\left(t\_0 \cdot t\_0\right) \cdot 0.5\right) \cdot h}{\ell}\right)\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if l < -1e216

      1. Initial program 35.8%

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

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

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

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

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

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

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(d \cdot {-1}^{\left(\frac{2}{2}\right)}\right)}{h} \]
        3. metadata-evalN/A

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(d \cdot {-1}^{1}\right)}{h} \]
        4. metadata-evalN/A

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

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(-1 \cdot d\right)}{h} \]
        6. mul-1-negN/A

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(\mathsf{neg}\left(d\right)\right)}{h} \]
        7. lift-neg.f64N/A

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

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\right)}{h} \]
        9. lift-sqrt.f64N/A

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\right)}{h} \]
        10. lift-/.f6425.0

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\right)}{h} \]
      7. Applied rewrites25.0%

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

      if -1e216 < l

      1. Initial program 35.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \left(\sqrt{\frac{\frac{1}{\ell}}{h}} \cdot d\right) \cdot \left(1 - \frac{\left(\left(\left(M \cdot \frac{D}{d + d}\right) \cdot \left(M \cdot \frac{D}{d + d}\right)\right) \cdot \frac{1}{2}\right) \cdot h}{\ell}\right) \]
        5. lower-/.f6475.2

          \[\leadsto \left(\sqrt{\frac{\frac{1}{\ell}}{h}} \cdot d\right) \cdot \left(1 - \frac{\left(\left(\left(M \cdot \frac{D}{d + d}\right) \cdot \left(M \cdot \frac{D}{d + d}\right)\right) \cdot 0.5\right) \cdot h}{\ell}\right) \]
      8. Applied rewrites75.2%

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

    Alternative 5: 73.9% accurate, 1.8× speedup?

    \[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} t_0 := M \cdot \frac{D}{d\_m + d\_m}\\ \mathbf{if}\;\ell \leq -1 \cdot 10^{+216}:\\ \;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\_m\right)}{h}\\ \mathbf{else}:\\ \;\;\;\;\frac{1 \cdot d\_m}{\sqrt{\ell \cdot h}} \cdot \left(1 - \frac{\left(\left(t\_0 \cdot t\_0\right) \cdot 0.5\right) \cdot h}{\ell}\right)\\ \end{array} \end{array} \]
    d_m = (fabs.f64 d)
    (FPCore (d_m h l M D)
     :precision binary64
     (let* ((t_0 (* M (/ D (+ d_m d_m)))))
       (if (<= l -1e+216)
         (/ (* (sqrt (/ h l)) (- d_m)) h)
         (*
          (/ (* 1.0 d_m) (sqrt (* l h)))
          (- 1.0 (/ (* (* (* t_0 t_0) 0.5) h) l))))))
    d_m = fabs(d);
    double code(double d_m, double h, double l, double M, double D) {
    	double t_0 = M * (D / (d_m + d_m));
    	double tmp;
    	if (l <= -1e+216) {
    		tmp = (sqrt((h / l)) * -d_m) / h;
    	} else {
    		tmp = ((1.0 * d_m) / sqrt((l * h))) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l));
    	}
    	return tmp;
    }
    
    d_m =     private
    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(d_m, h, l, m, d)
    use fmin_fmax_functions
        real(8), intent (in) :: d_m
        real(8), intent (in) :: h
        real(8), intent (in) :: l
        real(8), intent (in) :: m
        real(8), intent (in) :: d
        real(8) :: t_0
        real(8) :: tmp
        t_0 = m * (d / (d_m + d_m))
        if (l <= (-1d+216)) then
            tmp = (sqrt((h / l)) * -d_m) / h
        else
            tmp = ((1.0d0 * d_m) / sqrt((l * h))) * (1.0d0 - ((((t_0 * t_0) * 0.5d0) * h) / l))
        end if
        code = tmp
    end function
    
    d_m = Math.abs(d);
    public static double code(double d_m, double h, double l, double M, double D) {
    	double t_0 = M * (D / (d_m + d_m));
    	double tmp;
    	if (l <= -1e+216) {
    		tmp = (Math.sqrt((h / l)) * -d_m) / h;
    	} else {
    		tmp = ((1.0 * d_m) / Math.sqrt((l * h))) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l));
    	}
    	return tmp;
    }
    
    d_m = math.fabs(d)
    def code(d_m, h, l, M, D):
    	t_0 = M * (D / (d_m + d_m))
    	tmp = 0
    	if l <= -1e+216:
    		tmp = (math.sqrt((h / l)) * -d_m) / h
    	else:
    		tmp = ((1.0 * d_m) / math.sqrt((l * h))) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l))
    	return tmp
    
    d_m = abs(d)
    function code(d_m, h, l, M, D)
    	t_0 = Float64(M * Float64(D / Float64(d_m + d_m)))
    	tmp = 0.0
    	if (l <= -1e+216)
    		tmp = Float64(Float64(sqrt(Float64(h / l)) * Float64(-d_m)) / h);
    	else
    		tmp = Float64(Float64(Float64(1.0 * d_m) / sqrt(Float64(l * h))) * Float64(1.0 - Float64(Float64(Float64(Float64(t_0 * t_0) * 0.5) * h) / l)));
    	end
    	return tmp
    end
    
    d_m = abs(d);
    function tmp_2 = code(d_m, h, l, M, D)
    	t_0 = M * (D / (d_m + d_m));
    	tmp = 0.0;
    	if (l <= -1e+216)
    		tmp = (sqrt((h / l)) * -d_m) / h;
    	else
    		tmp = ((1.0 * d_m) / sqrt((l * h))) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l));
    	end
    	tmp_2 = tmp;
    end
    
    d_m = N[Abs[d], $MachinePrecision]
    code[d$95$m_, h_, l_, M_, D_] := Block[{t$95$0 = N[(M * N[(D / N[(d$95$m + d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -1e+216], N[(N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * (-d$95$m)), $MachinePrecision] / h), $MachinePrecision], N[(N[(N[(1.0 * d$95$m), $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
    
    \begin{array}{l}
    d_m = \left|d\right|
    
    \\
    \begin{array}{l}
    t_0 := M \cdot \frac{D}{d\_m + d\_m}\\
    \mathbf{if}\;\ell \leq -1 \cdot 10^{+216}:\\
    \;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\_m\right)}{h}\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{1 \cdot d\_m}{\sqrt{\ell \cdot h}} \cdot \left(1 - \frac{\left(\left(t\_0 \cdot t\_0\right) \cdot 0.5\right) \cdot h}{\ell}\right)\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if l < -1e216

      1. Initial program 35.8%

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

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

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

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

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

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

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(d \cdot {-1}^{\left(\frac{2}{2}\right)}\right)}{h} \]
        3. metadata-evalN/A

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(d \cdot {-1}^{1}\right)}{h} \]
        4. metadata-evalN/A

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

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(-1 \cdot d\right)}{h} \]
        6. mul-1-negN/A

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(\mathsf{neg}\left(d\right)\right)}{h} \]
        7. lift-neg.f64N/A

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

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\right)}{h} \]
        9. lift-sqrt.f64N/A

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\right)}{h} \]
        10. lift-/.f6425.0

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\right)}{h} \]
      7. Applied rewrites25.0%

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

      if -1e216 < l

      1. Initial program 35.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \left(\sqrt{\frac{\frac{1}{\ell}}{h}} \cdot d\right) \cdot \left(1 - \frac{\left(\left(\left(M \cdot \frac{D}{d + d}\right) \cdot \left(M \cdot \frac{D}{d + d}\right)\right) \cdot \frac{1}{2}\right) \cdot h}{\ell}\right) \]
        5. lower-/.f6475.2

          \[\leadsto \left(\sqrt{\frac{\frac{1}{\ell}}{h}} \cdot d\right) \cdot \left(1 - \frac{\left(\left(\left(M \cdot \frac{D}{d + d}\right) \cdot \left(M \cdot \frac{D}{d + d}\right)\right) \cdot 0.5\right) \cdot h}{\ell}\right) \]
      8. Applied rewrites75.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \frac{1 \cdot d}{\sqrt{\ell \cdot h}} \cdot \left(1 - \frac{\left(\left(\left(M \cdot \frac{D}{d + d}\right) \cdot \left(M \cdot \frac{D}{d + d}\right)\right) \cdot \frac{1}{2}\right) \cdot h}{\ell}\right) \]
        18. lift-sqrt.f6474.8

          \[\leadsto \frac{1 \cdot d}{\sqrt{\ell \cdot h}} \cdot \left(1 - \frac{\left(\left(\left(M \cdot \frac{D}{d + d}\right) \cdot \left(M \cdot \frac{D}{d + d}\right)\right) \cdot 0.5\right) \cdot h}{\ell}\right) \]
      10. Applied rewrites74.8%

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

    Alternative 6: 73.8% accurate, 1.8× speedup?

    \[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} t_0 := M \cdot \frac{D}{d\_m + d\_m}\\ \mathbf{if}\;\ell \leq -1 \cdot 10^{+216}:\\ \;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\_m\right)}{h}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{\sqrt{\ell \cdot h}} \cdot d\_m\right) \cdot \left(1 - \frac{\left(\left(t\_0 \cdot t\_0\right) \cdot 0.5\right) \cdot h}{\ell}\right)\\ \end{array} \end{array} \]
    d_m = (fabs.f64 d)
    (FPCore (d_m h l M D)
     :precision binary64
     (let* ((t_0 (* M (/ D (+ d_m d_m)))))
       (if (<= l -1e+216)
         (/ (* (sqrt (/ h l)) (- d_m)) h)
         (*
          (* (/ 1.0 (sqrt (* l h))) d_m)
          (- 1.0 (/ (* (* (* t_0 t_0) 0.5) h) l))))))
    d_m = fabs(d);
    double code(double d_m, double h, double l, double M, double D) {
    	double t_0 = M * (D / (d_m + d_m));
    	double tmp;
    	if (l <= -1e+216) {
    		tmp = (sqrt((h / l)) * -d_m) / h;
    	} else {
    		tmp = ((1.0 / sqrt((l * h))) * d_m) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l));
    	}
    	return tmp;
    }
    
    d_m =     private
    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(d_m, h, l, m, d)
    use fmin_fmax_functions
        real(8), intent (in) :: d_m
        real(8), intent (in) :: h
        real(8), intent (in) :: l
        real(8), intent (in) :: m
        real(8), intent (in) :: d
        real(8) :: t_0
        real(8) :: tmp
        t_0 = m * (d / (d_m + d_m))
        if (l <= (-1d+216)) then
            tmp = (sqrt((h / l)) * -d_m) / h
        else
            tmp = ((1.0d0 / sqrt((l * h))) * d_m) * (1.0d0 - ((((t_0 * t_0) * 0.5d0) * h) / l))
        end if
        code = tmp
    end function
    
    d_m = Math.abs(d);
    public static double code(double d_m, double h, double l, double M, double D) {
    	double t_0 = M * (D / (d_m + d_m));
    	double tmp;
    	if (l <= -1e+216) {
    		tmp = (Math.sqrt((h / l)) * -d_m) / h;
    	} else {
    		tmp = ((1.0 / Math.sqrt((l * h))) * d_m) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l));
    	}
    	return tmp;
    }
    
    d_m = math.fabs(d)
    def code(d_m, h, l, M, D):
    	t_0 = M * (D / (d_m + d_m))
    	tmp = 0
    	if l <= -1e+216:
    		tmp = (math.sqrt((h / l)) * -d_m) / h
    	else:
    		tmp = ((1.0 / math.sqrt((l * h))) * d_m) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l))
    	return tmp
    
    d_m = abs(d)
    function code(d_m, h, l, M, D)
    	t_0 = Float64(M * Float64(D / Float64(d_m + d_m)))
    	tmp = 0.0
    	if (l <= -1e+216)
    		tmp = Float64(Float64(sqrt(Float64(h / l)) * Float64(-d_m)) / h);
    	else
    		tmp = Float64(Float64(Float64(1.0 / sqrt(Float64(l * h))) * d_m) * Float64(1.0 - Float64(Float64(Float64(Float64(t_0 * t_0) * 0.5) * h) / l)));
    	end
    	return tmp
    end
    
    d_m = abs(d);
    function tmp_2 = code(d_m, h, l, M, D)
    	t_0 = M * (D / (d_m + d_m));
    	tmp = 0.0;
    	if (l <= -1e+216)
    		tmp = (sqrt((h / l)) * -d_m) / h;
    	else
    		tmp = ((1.0 / sqrt((l * h))) * d_m) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l));
    	end
    	tmp_2 = tmp;
    end
    
    d_m = N[Abs[d], $MachinePrecision]
    code[d$95$m_, h_, l_, M_, D_] := Block[{t$95$0 = N[(M * N[(D / N[(d$95$m + d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -1e+216], N[(N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * (-d$95$m)), $MachinePrecision] / h), $MachinePrecision], N[(N[(N[(1.0 / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * d$95$m), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
    
    \begin{array}{l}
    d_m = \left|d\right|
    
    \\
    \begin{array}{l}
    t_0 := M \cdot \frac{D}{d\_m + d\_m}\\
    \mathbf{if}\;\ell \leq -1 \cdot 10^{+216}:\\
    \;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\_m\right)}{h}\\
    
    \mathbf{else}:\\
    \;\;\;\;\left(\frac{1}{\sqrt{\ell \cdot h}} \cdot d\_m\right) \cdot \left(1 - \frac{\left(\left(t\_0 \cdot t\_0\right) \cdot 0.5\right) \cdot h}{\ell}\right)\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if l < -1e216

      1. Initial program 35.8%

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

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

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

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

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

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

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(d \cdot {-1}^{\left(\frac{2}{2}\right)}\right)}{h} \]
        3. metadata-evalN/A

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(d \cdot {-1}^{1}\right)}{h} \]
        4. metadata-evalN/A

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

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(-1 \cdot d\right)}{h} \]
        6. mul-1-negN/A

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(\mathsf{neg}\left(d\right)\right)}{h} \]
        7. lift-neg.f64N/A

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

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\right)}{h} \]
        9. lift-sqrt.f64N/A

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\right)}{h} \]
        10. lift-/.f6425.0

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\right)}{h} \]
      7. Applied rewrites25.0%

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

      if -1e216 < l

      1. Initial program 35.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \left(\frac{1}{\sqrt{\ell \cdot h}} \cdot d\right) \cdot \left(1 - \frac{\left(\left(\left(M \cdot \frac{D}{d + d}\right) \cdot \left(M \cdot \frac{D}{d + d}\right)\right) \cdot \frac{1}{2}\right) \cdot h}{\ell}\right) \]
        10. lift-*.f6474.7

          \[\leadsto \left(\frac{1}{\sqrt{\ell \cdot h}} \cdot d\right) \cdot \left(1 - \frac{\left(\left(\left(M \cdot \frac{D}{d + d}\right) \cdot \left(M \cdot \frac{D}{d + d}\right)\right) \cdot 0.5\right) \cdot h}{\ell}\right) \]
      8. Applied rewrites74.7%

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

    Alternative 7: 73.6% accurate, 1.8× speedup?

    \[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} t_0 := M \cdot \frac{D}{d\_m + d\_m}\\ \mathbf{if}\;\ell \leq -1 \cdot 10^{+216}:\\ \;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\_m\right)}{h}\\ \mathbf{else}:\\ \;\;\;\;\left(\sqrt{\frac{1}{\ell \cdot h}} \cdot d\_m\right) \cdot \left(1 - \frac{\left(\left(t\_0 \cdot t\_0\right) \cdot 0.5\right) \cdot h}{\ell}\right)\\ \end{array} \end{array} \]
    d_m = (fabs.f64 d)
    (FPCore (d_m h l M D)
     :precision binary64
     (let* ((t_0 (* M (/ D (+ d_m d_m)))))
       (if (<= l -1e+216)
         (/ (* (sqrt (/ h l)) (- d_m)) h)
         (*
          (* (sqrt (/ 1.0 (* l h))) d_m)
          (- 1.0 (/ (* (* (* t_0 t_0) 0.5) h) l))))))
    d_m = fabs(d);
    double code(double d_m, double h, double l, double M, double D) {
    	double t_0 = M * (D / (d_m + d_m));
    	double tmp;
    	if (l <= -1e+216) {
    		tmp = (sqrt((h / l)) * -d_m) / h;
    	} else {
    		tmp = (sqrt((1.0 / (l * h))) * d_m) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l));
    	}
    	return tmp;
    }
    
    d_m =     private
    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(d_m, h, l, m, d)
    use fmin_fmax_functions
        real(8), intent (in) :: d_m
        real(8), intent (in) :: h
        real(8), intent (in) :: l
        real(8), intent (in) :: m
        real(8), intent (in) :: d
        real(8) :: t_0
        real(8) :: tmp
        t_0 = m * (d / (d_m + d_m))
        if (l <= (-1d+216)) then
            tmp = (sqrt((h / l)) * -d_m) / h
        else
            tmp = (sqrt((1.0d0 / (l * h))) * d_m) * (1.0d0 - ((((t_0 * t_0) * 0.5d0) * h) / l))
        end if
        code = tmp
    end function
    
    d_m = Math.abs(d);
    public static double code(double d_m, double h, double l, double M, double D) {
    	double t_0 = M * (D / (d_m + d_m));
    	double tmp;
    	if (l <= -1e+216) {
    		tmp = (Math.sqrt((h / l)) * -d_m) / h;
    	} else {
    		tmp = (Math.sqrt((1.0 / (l * h))) * d_m) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l));
    	}
    	return tmp;
    }
    
    d_m = math.fabs(d)
    def code(d_m, h, l, M, D):
    	t_0 = M * (D / (d_m + d_m))
    	tmp = 0
    	if l <= -1e+216:
    		tmp = (math.sqrt((h / l)) * -d_m) / h
    	else:
    		tmp = (math.sqrt((1.0 / (l * h))) * d_m) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l))
    	return tmp
    
    d_m = abs(d)
    function code(d_m, h, l, M, D)
    	t_0 = Float64(M * Float64(D / Float64(d_m + d_m)))
    	tmp = 0.0
    	if (l <= -1e+216)
    		tmp = Float64(Float64(sqrt(Float64(h / l)) * Float64(-d_m)) / h);
    	else
    		tmp = Float64(Float64(sqrt(Float64(1.0 / Float64(l * h))) * d_m) * Float64(1.0 - Float64(Float64(Float64(Float64(t_0 * t_0) * 0.5) * h) / l)));
    	end
    	return tmp
    end
    
    d_m = abs(d);
    function tmp_2 = code(d_m, h, l, M, D)
    	t_0 = M * (D / (d_m + d_m));
    	tmp = 0.0;
    	if (l <= -1e+216)
    		tmp = (sqrt((h / l)) * -d_m) / h;
    	else
    		tmp = (sqrt((1.0 / (l * h))) * d_m) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l));
    	end
    	tmp_2 = tmp;
    end
    
    d_m = N[Abs[d], $MachinePrecision]
    code[d$95$m_, h_, l_, M_, D_] := Block[{t$95$0 = N[(M * N[(D / N[(d$95$m + d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -1e+216], N[(N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * (-d$95$m)), $MachinePrecision] / h), $MachinePrecision], N[(N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
    
    \begin{array}{l}
    d_m = \left|d\right|
    
    \\
    \begin{array}{l}
    t_0 := M \cdot \frac{D}{d\_m + d\_m}\\
    \mathbf{if}\;\ell \leq -1 \cdot 10^{+216}:\\
    \;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\_m\right)}{h}\\
    
    \mathbf{else}:\\
    \;\;\;\;\left(\sqrt{\frac{1}{\ell \cdot h}} \cdot d\_m\right) \cdot \left(1 - \frac{\left(\left(t\_0 \cdot t\_0\right) \cdot 0.5\right) \cdot h}{\ell}\right)\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if l < -1e216

      1. Initial program 35.8%

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

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

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

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

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

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

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(d \cdot {-1}^{\left(\frac{2}{2}\right)}\right)}{h} \]
        3. metadata-evalN/A

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(d \cdot {-1}^{1}\right)}{h} \]
        4. metadata-evalN/A

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

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(-1 \cdot d\right)}{h} \]
        6. mul-1-negN/A

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(\mathsf{neg}\left(d\right)\right)}{h} \]
        7. lift-neg.f64N/A

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

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\right)}{h} \]
        9. lift-sqrt.f64N/A

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\right)}{h} \]
        10. lift-/.f6425.0

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\right)}{h} \]
      7. Applied rewrites25.0%

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

      if -1e216 < l

      1. Initial program 35.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 8: 72.7% accurate, 1.8× speedup?

    \[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} t_0 := \frac{D}{d\_m + d\_m}\\ \mathbf{if}\;\ell \leq -1 \cdot 10^{+216}:\\ \;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\_m\right)}{h}\\ \mathbf{else}:\\ \;\;\;\;\left(\sqrt{\frac{1}{\ell \cdot h}} \cdot d\_m\right) \cdot \left(1 - \frac{\left(\left(M \cdot \left(t\_0 \cdot \left(t\_0 \cdot M\right)\right)\right) \cdot 0.5\right) \cdot h}{\ell}\right)\\ \end{array} \end{array} \]
    d_m = (fabs.f64 d)
    (FPCore (d_m h l M D)
     :precision binary64
     (let* ((t_0 (/ D (+ d_m d_m))))
       (if (<= l -1e+216)
         (/ (* (sqrt (/ h l)) (- d_m)) h)
         (*
          (* (sqrt (/ 1.0 (* l h))) d_m)
          (- 1.0 (/ (* (* (* M (* t_0 (* t_0 M))) 0.5) h) l))))))
    d_m = fabs(d);
    double code(double d_m, double h, double l, double M, double D) {
    	double t_0 = D / (d_m + d_m);
    	double tmp;
    	if (l <= -1e+216) {
    		tmp = (sqrt((h / l)) * -d_m) / h;
    	} else {
    		tmp = (sqrt((1.0 / (l * h))) * d_m) * (1.0 - ((((M * (t_0 * (t_0 * M))) * 0.5) * h) / l));
    	}
    	return tmp;
    }
    
    d_m =     private
    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(d_m, h, l, m, d)
    use fmin_fmax_functions
        real(8), intent (in) :: d_m
        real(8), intent (in) :: h
        real(8), intent (in) :: l
        real(8), intent (in) :: m
        real(8), intent (in) :: d
        real(8) :: t_0
        real(8) :: tmp
        t_0 = d / (d_m + d_m)
        if (l <= (-1d+216)) then
            tmp = (sqrt((h / l)) * -d_m) / h
        else
            tmp = (sqrt((1.0d0 / (l * h))) * d_m) * (1.0d0 - ((((m * (t_0 * (t_0 * m))) * 0.5d0) * h) / l))
        end if
        code = tmp
    end function
    
    d_m = Math.abs(d);
    public static double code(double d_m, double h, double l, double M, double D) {
    	double t_0 = D / (d_m + d_m);
    	double tmp;
    	if (l <= -1e+216) {
    		tmp = (Math.sqrt((h / l)) * -d_m) / h;
    	} else {
    		tmp = (Math.sqrt((1.0 / (l * h))) * d_m) * (1.0 - ((((M * (t_0 * (t_0 * M))) * 0.5) * h) / l));
    	}
    	return tmp;
    }
    
    d_m = math.fabs(d)
    def code(d_m, h, l, M, D):
    	t_0 = D / (d_m + d_m)
    	tmp = 0
    	if l <= -1e+216:
    		tmp = (math.sqrt((h / l)) * -d_m) / h
    	else:
    		tmp = (math.sqrt((1.0 / (l * h))) * d_m) * (1.0 - ((((M * (t_0 * (t_0 * M))) * 0.5) * h) / l))
    	return tmp
    
    d_m = abs(d)
    function code(d_m, h, l, M, D)
    	t_0 = Float64(D / Float64(d_m + d_m))
    	tmp = 0.0
    	if (l <= -1e+216)
    		tmp = Float64(Float64(sqrt(Float64(h / l)) * Float64(-d_m)) / h);
    	else
    		tmp = Float64(Float64(sqrt(Float64(1.0 / Float64(l * h))) * d_m) * Float64(1.0 - Float64(Float64(Float64(Float64(M * Float64(t_0 * Float64(t_0 * M))) * 0.5) * h) / l)));
    	end
    	return tmp
    end
    
    d_m = abs(d);
    function tmp_2 = code(d_m, h, l, M, D)
    	t_0 = D / (d_m + d_m);
    	tmp = 0.0;
    	if (l <= -1e+216)
    		tmp = (sqrt((h / l)) * -d_m) / h;
    	else
    		tmp = (sqrt((1.0 / (l * h))) * d_m) * (1.0 - ((((M * (t_0 * (t_0 * M))) * 0.5) * h) / l));
    	end
    	tmp_2 = tmp;
    end
    
    d_m = N[Abs[d], $MachinePrecision]
    code[d$95$m_, h_, l_, M_, D_] := Block[{t$95$0 = N[(D / N[(d$95$m + d$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -1e+216], N[(N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * (-d$95$m)), $MachinePrecision] / h), $MachinePrecision], N[(N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(M * N[(t$95$0 * N[(t$95$0 * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
    
    \begin{array}{l}
    d_m = \left|d\right|
    
    \\
    \begin{array}{l}
    t_0 := \frac{D}{d\_m + d\_m}\\
    \mathbf{if}\;\ell \leq -1 \cdot 10^{+216}:\\
    \;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\_m\right)}{h}\\
    
    \mathbf{else}:\\
    \;\;\;\;\left(\sqrt{\frac{1}{\ell \cdot h}} \cdot d\_m\right) \cdot \left(1 - \frac{\left(\left(M \cdot \left(t\_0 \cdot \left(t\_0 \cdot M\right)\right)\right) \cdot 0.5\right) \cdot h}{\ell}\right)\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if l < -1e216

      1. Initial program 35.8%

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

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

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

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

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

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

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(d \cdot {-1}^{\left(\frac{2}{2}\right)}\right)}{h} \]
        3. metadata-evalN/A

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(d \cdot {-1}^{1}\right)}{h} \]
        4. metadata-evalN/A

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

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(-1 \cdot d\right)}{h} \]
        6. mul-1-negN/A

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(\mathsf{neg}\left(d\right)\right)}{h} \]
        7. lift-neg.f64N/A

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

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\right)}{h} \]
        9. lift-sqrt.f64N/A

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\right)}{h} \]
        10. lift-/.f6425.0

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\right)}{h} \]
      7. Applied rewrites25.0%

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

      if -1e216 < l

      1. Initial program 35.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\sqrt{\frac{1}{\ell \cdot h}} \cdot d\right) \cdot \left(1 - \color{blue}{\frac{\left(\left(\left(M \cdot \frac{D}{d + d}\right) \cdot \left(M \cdot \frac{D}{d + d}\right)\right) \cdot 0.5\right) \cdot h}{\ell}}\right) \]
      7. Step-by-step derivation
        1. metadata-evalN/A

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

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

    Alternative 9: 51.0% accurate, 2.5× speedup?

    \[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} \mathbf{if}\;M \cdot D \leq 2 \cdot 10^{+64}:\\ \;\;\;\;\left(-\left(-d\_m\right)\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-0.125 \cdot \left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)}{d\_m} \cdot \sqrt{\frac{h}{\left(\ell \cdot \ell\right) \cdot \ell}}\\ \end{array} \end{array} \]
    d_m = (fabs.f64 d)
    (FPCore (d_m h l M D)
     :precision binary64
     (if (<= (* M D) 2e+64)
       (* (- (- d_m)) (sqrt (/ (/ 1.0 h) l)))
       (* (/ (* -0.125 (* (* D M) (* D M))) d_m) (sqrt (/ h (* (* l l) l))))))
    d_m = fabs(d);
    double code(double d_m, double h, double l, double M, double D) {
    	double tmp;
    	if ((M * D) <= 2e+64) {
    		tmp = -(-d_m) * sqrt(((1.0 / h) / l));
    	} else {
    		tmp = ((-0.125 * ((D * M) * (D * M))) / d_m) * sqrt((h / ((l * l) * l)));
    	}
    	return tmp;
    }
    
    d_m =     private
    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(d_m, h, l, m, d)
    use fmin_fmax_functions
        real(8), intent (in) :: d_m
        real(8), intent (in) :: h
        real(8), intent (in) :: l
        real(8), intent (in) :: m
        real(8), intent (in) :: d
        real(8) :: tmp
        if ((m * d) <= 2d+64) then
            tmp = -(-d_m) * sqrt(((1.0d0 / h) / l))
        else
            tmp = (((-0.125d0) * ((d * m) * (d * m))) / d_m) * sqrt((h / ((l * l) * l)))
        end if
        code = tmp
    end function
    
    d_m = Math.abs(d);
    public static double code(double d_m, double h, double l, double M, double D) {
    	double tmp;
    	if ((M * D) <= 2e+64) {
    		tmp = -(-d_m) * Math.sqrt(((1.0 / h) / l));
    	} else {
    		tmp = ((-0.125 * ((D * M) * (D * M))) / d_m) * Math.sqrt((h / ((l * l) * l)));
    	}
    	return tmp;
    }
    
    d_m = math.fabs(d)
    def code(d_m, h, l, M, D):
    	tmp = 0
    	if (M * D) <= 2e+64:
    		tmp = -(-d_m) * math.sqrt(((1.0 / h) / l))
    	else:
    		tmp = ((-0.125 * ((D * M) * (D * M))) / d_m) * math.sqrt((h / ((l * l) * l)))
    	return tmp
    
    d_m = abs(d)
    function code(d_m, h, l, M, D)
    	tmp = 0.0
    	if (Float64(M * D) <= 2e+64)
    		tmp = Float64(Float64(-Float64(-d_m)) * sqrt(Float64(Float64(1.0 / h) / l)));
    	else
    		tmp = Float64(Float64(Float64(-0.125 * Float64(Float64(D * M) * Float64(D * M))) / d_m) * sqrt(Float64(h / Float64(Float64(l * l) * l))));
    	end
    	return tmp
    end
    
    d_m = abs(d);
    function tmp_2 = code(d_m, h, l, M, D)
    	tmp = 0.0;
    	if ((M * D) <= 2e+64)
    		tmp = -(-d_m) * sqrt(((1.0 / h) / l));
    	else
    		tmp = ((-0.125 * ((D * M) * (D * M))) / d_m) * sqrt((h / ((l * l) * l)));
    	end
    	tmp_2 = tmp;
    end
    
    d_m = N[Abs[d], $MachinePrecision]
    code[d$95$m_, h_, l_, M_, D_] := If[LessEqual[N[(M * D), $MachinePrecision], 2e+64], N[((-(-d$95$m)) * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[(-0.125 * N[(N[(D * M), $MachinePrecision] * N[(D * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d$95$m), $MachinePrecision] * N[Sqrt[N[(h / N[(N[(l * l), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
    
    \begin{array}{l}
    d_m = \left|d\right|
    
    \\
    \begin{array}{l}
    \mathbf{if}\;M \cdot D \leq 2 \cdot 10^{+64}:\\
    \;\;\;\;\left(-\left(-d\_m\right)\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{-0.125 \cdot \left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)}{d\_m} \cdot \sqrt{\frac{h}{\left(\ell \cdot \ell\right) \cdot \ell}}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (*.f64 M D) < 2.00000000000000004e64

      1. Initial program 35.8%

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

        \[\leadsto \color{blue}{-1 \cdot \left(\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      3. Step-by-step derivation
        1. mul-1-negN/A

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

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

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

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

          \[\leadsto -\left(d \cdot {-1}^{1}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
        6. metadata-evalN/A

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

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

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

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

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

          \[\leadsto -\left(-1 \cdot d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
        12. lower-*.f6443.1

          \[\leadsto -\left(-1 \cdot d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
      4. Applied rewrites43.1%

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

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

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

          \[\leadsto \mathsf{neg}\left(\left(-1 \cdot d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\right) \]
        4. distribute-lft-neg-inN/A

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

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

          \[\leadsto \left(\mathsf{neg}\left(d \cdot {-1}^{1}\right)\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
        7. metadata-evalN/A

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

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

          \[\leadsto \left(\mathsf{neg}\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
        10. lift-/.f64N/A

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

          \[\leadsto \left(\mathsf{neg}\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
        12. *-commutativeN/A

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

          \[\leadsto \left(\mathsf{neg}\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)\right) \cdot \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \]
        14. sqrt-pow2N/A

          \[\leadsto \left(\mathsf{neg}\left(d \cdot {-1}^{\left(\frac{2}{2}\right)}\right)\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
        15. metadata-evalN/A

          \[\leadsto \left(\mathsf{neg}\left(d \cdot {-1}^{1}\right)\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
        16. metadata-evalN/A

          \[\leadsto \left(\mathsf{neg}\left(d \cdot -1\right)\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
        17. *-commutativeN/A

          \[\leadsto \left(\mathsf{neg}\left(-1 \cdot d\right)\right) \cdot \sqrt{\frac{\color{blue}{1}}{h \cdot \ell}} \]
        18. mul-1-negN/A

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

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

          \[\leadsto \left(-\left(-d\right)\right) \cdot \sqrt{\frac{\color{blue}{1}}{h \cdot \ell}} \]
      6. Applied rewrites43.1%

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

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

          \[\leadsto \left(-\left(-d\right)\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
        3. *-commutativeN/A

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

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

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

          \[\leadsto \left(-\left(-d\right)\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}} \]
      8. Applied rewrites43.4%

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

      if 2.00000000000000004e64 < (*.f64 M D)

      1. Initial program 35.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \left(\left(\frac{-1}{8} \cdot \left(D \cdot D\right)\right) \cdot \left(M \cdot \frac{M}{d}\right)\right) \cdot \sqrt{\frac{h}{{\ell}^{\color{blue}{3}}}} \]
      7. Applied rewrites28.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \frac{\frac{-1}{8} \cdot \left(\left(M \cdot M\right) \cdot \left(D \cdot D\right)\right)}{d} \cdot \sqrt{\frac{h}{\left(\ell \cdot \ell\right) \cdot \ell}} \]
        19. lift-*.f6427.9

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 10: 50.5% accurate, 2.5× speedup?

    \[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} \mathbf{if}\;M \cdot D \leq 2 \cdot 10^{+64}:\\ \;\;\;\;\left(-\left(-d\_m\right)\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(-0.125 \cdot \left(D \cdot D\right)\right) \cdot \left(M \cdot \frac{M}{d\_m}\right)\right) \cdot \sqrt{\frac{h}{\left(\ell \cdot \ell\right) \cdot \ell}}\\ \end{array} \end{array} \]
    d_m = (fabs.f64 d)
    (FPCore (d_m h l M D)
     :precision binary64
     (if (<= (* M D) 2e+64)
       (* (- (- d_m)) (sqrt (/ (/ 1.0 h) l)))
       (* (* (* -0.125 (* D D)) (* M (/ M d_m))) (sqrt (/ h (* (* l l) l))))))
    d_m = fabs(d);
    double code(double d_m, double h, double l, double M, double D) {
    	double tmp;
    	if ((M * D) <= 2e+64) {
    		tmp = -(-d_m) * sqrt(((1.0 / h) / l));
    	} else {
    		tmp = ((-0.125 * (D * D)) * (M * (M / d_m))) * sqrt((h / ((l * l) * l)));
    	}
    	return tmp;
    }
    
    d_m =     private
    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(d_m, h, l, m, d)
    use fmin_fmax_functions
        real(8), intent (in) :: d_m
        real(8), intent (in) :: h
        real(8), intent (in) :: l
        real(8), intent (in) :: m
        real(8), intent (in) :: d
        real(8) :: tmp
        if ((m * d) <= 2d+64) then
            tmp = -(-d_m) * sqrt(((1.0d0 / h) / l))
        else
            tmp = (((-0.125d0) * (d * d)) * (m * (m / d_m))) * sqrt((h / ((l * l) * l)))
        end if
        code = tmp
    end function
    
    d_m = Math.abs(d);
    public static double code(double d_m, double h, double l, double M, double D) {
    	double tmp;
    	if ((M * D) <= 2e+64) {
    		tmp = -(-d_m) * Math.sqrt(((1.0 / h) / l));
    	} else {
    		tmp = ((-0.125 * (D * D)) * (M * (M / d_m))) * Math.sqrt((h / ((l * l) * l)));
    	}
    	return tmp;
    }
    
    d_m = math.fabs(d)
    def code(d_m, h, l, M, D):
    	tmp = 0
    	if (M * D) <= 2e+64:
    		tmp = -(-d_m) * math.sqrt(((1.0 / h) / l))
    	else:
    		tmp = ((-0.125 * (D * D)) * (M * (M / d_m))) * math.sqrt((h / ((l * l) * l)))
    	return tmp
    
    d_m = abs(d)
    function code(d_m, h, l, M, D)
    	tmp = 0.0
    	if (Float64(M * D) <= 2e+64)
    		tmp = Float64(Float64(-Float64(-d_m)) * sqrt(Float64(Float64(1.0 / h) / l)));
    	else
    		tmp = Float64(Float64(Float64(-0.125 * Float64(D * D)) * Float64(M * Float64(M / d_m))) * sqrt(Float64(h / Float64(Float64(l * l) * l))));
    	end
    	return tmp
    end
    
    d_m = abs(d);
    function tmp_2 = code(d_m, h, l, M, D)
    	tmp = 0.0;
    	if ((M * D) <= 2e+64)
    		tmp = -(-d_m) * sqrt(((1.0 / h) / l));
    	else
    		tmp = ((-0.125 * (D * D)) * (M * (M / d_m))) * sqrt((h / ((l * l) * l)));
    	end
    	tmp_2 = tmp;
    end
    
    d_m = N[Abs[d], $MachinePrecision]
    code[d$95$m_, h_, l_, M_, D_] := If[LessEqual[N[(M * D), $MachinePrecision], 2e+64], N[((-(-d$95$m)) * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[(-0.125 * N[(D * D), $MachinePrecision]), $MachinePrecision] * N[(M * N[(M / d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(h / N[(N[(l * l), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
    
    \begin{array}{l}
    d_m = \left|d\right|
    
    \\
    \begin{array}{l}
    \mathbf{if}\;M \cdot D \leq 2 \cdot 10^{+64}:\\
    \;\;\;\;\left(-\left(-d\_m\right)\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\
    
    \mathbf{else}:\\
    \;\;\;\;\left(\left(-0.125 \cdot \left(D \cdot D\right)\right) \cdot \left(M \cdot \frac{M}{d\_m}\right)\right) \cdot \sqrt{\frac{h}{\left(\ell \cdot \ell\right) \cdot \ell}}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (*.f64 M D) < 2.00000000000000004e64

      1. Initial program 35.8%

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

        \[\leadsto \color{blue}{-1 \cdot \left(\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      3. Step-by-step derivation
        1. mul-1-negN/A

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

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

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

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

          \[\leadsto -\left(d \cdot {-1}^{1}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
        6. metadata-evalN/A

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

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

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

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

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

          \[\leadsto -\left(-1 \cdot d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
        12. lower-*.f6443.1

          \[\leadsto -\left(-1 \cdot d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
      4. Applied rewrites43.1%

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

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

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

          \[\leadsto \mathsf{neg}\left(\left(-1 \cdot d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\right) \]
        4. distribute-lft-neg-inN/A

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

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

          \[\leadsto \left(\mathsf{neg}\left(d \cdot {-1}^{1}\right)\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
        7. metadata-evalN/A

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

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

          \[\leadsto \left(\mathsf{neg}\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
        10. lift-/.f64N/A

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

          \[\leadsto \left(\mathsf{neg}\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
        12. *-commutativeN/A

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

          \[\leadsto \left(\mathsf{neg}\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)\right) \cdot \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \]
        14. sqrt-pow2N/A

          \[\leadsto \left(\mathsf{neg}\left(d \cdot {-1}^{\left(\frac{2}{2}\right)}\right)\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
        15. metadata-evalN/A

          \[\leadsto \left(\mathsf{neg}\left(d \cdot {-1}^{1}\right)\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
        16. metadata-evalN/A

          \[\leadsto \left(\mathsf{neg}\left(d \cdot -1\right)\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
        17. *-commutativeN/A

          \[\leadsto \left(\mathsf{neg}\left(-1 \cdot d\right)\right) \cdot \sqrt{\frac{\color{blue}{1}}{h \cdot \ell}} \]
        18. mul-1-negN/A

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

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

          \[\leadsto \left(-\left(-d\right)\right) \cdot \sqrt{\frac{\color{blue}{1}}{h \cdot \ell}} \]
      6. Applied rewrites43.1%

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

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

          \[\leadsto \left(-\left(-d\right)\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
        3. *-commutativeN/A

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

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

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

          \[\leadsto \left(-\left(-d\right)\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}} \]
      8. Applied rewrites43.4%

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

      if 2.00000000000000004e64 < (*.f64 M D)

      1. Initial program 35.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \left(\left(\frac{-1}{8} \cdot \left(D \cdot D\right)\right) \cdot \left(M \cdot \frac{M}{d}\right)\right) \cdot \sqrt{\frac{h}{{\ell}^{\color{blue}{3}}}} \]
      7. Applied rewrites28.6%

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

    Alternative 11: 50.4% accurate, 2.5× speedup?

    \[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} \mathbf{if}\;M \cdot D \leq 2 \cdot 10^{+64}:\\ \;\;\;\;\left(-\left(-d\_m\right)\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;\left(-0.125 \cdot \left(\left(D \cdot D\right) \cdot \frac{M \cdot M}{d\_m}\right)\right) \cdot \sqrt{\frac{h}{\left(\ell \cdot \ell\right) \cdot \ell}}\\ \end{array} \end{array} \]
    d_m = (fabs.f64 d)
    (FPCore (d_m h l M D)
     :precision binary64
     (if (<= (* M D) 2e+64)
       (* (- (- d_m)) (sqrt (/ (/ 1.0 h) l)))
       (* (* -0.125 (* (* D D) (/ (* M M) d_m))) (sqrt (/ h (* (* l l) l))))))
    d_m = fabs(d);
    double code(double d_m, double h, double l, double M, double D) {
    	double tmp;
    	if ((M * D) <= 2e+64) {
    		tmp = -(-d_m) * sqrt(((1.0 / h) / l));
    	} else {
    		tmp = (-0.125 * ((D * D) * ((M * M) / d_m))) * sqrt((h / ((l * l) * l)));
    	}
    	return tmp;
    }
    
    d_m =     private
    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(d_m, h, l, m, d)
    use fmin_fmax_functions
        real(8), intent (in) :: d_m
        real(8), intent (in) :: h
        real(8), intent (in) :: l
        real(8), intent (in) :: m
        real(8), intent (in) :: d
        real(8) :: tmp
        if ((m * d) <= 2d+64) then
            tmp = -(-d_m) * sqrt(((1.0d0 / h) / l))
        else
            tmp = ((-0.125d0) * ((d * d) * ((m * m) / d_m))) * sqrt((h / ((l * l) * l)))
        end if
        code = tmp
    end function
    
    d_m = Math.abs(d);
    public static double code(double d_m, double h, double l, double M, double D) {
    	double tmp;
    	if ((M * D) <= 2e+64) {
    		tmp = -(-d_m) * Math.sqrt(((1.0 / h) / l));
    	} else {
    		tmp = (-0.125 * ((D * D) * ((M * M) / d_m))) * Math.sqrt((h / ((l * l) * l)));
    	}
    	return tmp;
    }
    
    d_m = math.fabs(d)
    def code(d_m, h, l, M, D):
    	tmp = 0
    	if (M * D) <= 2e+64:
    		tmp = -(-d_m) * math.sqrt(((1.0 / h) / l))
    	else:
    		tmp = (-0.125 * ((D * D) * ((M * M) / d_m))) * math.sqrt((h / ((l * l) * l)))
    	return tmp
    
    d_m = abs(d)
    function code(d_m, h, l, M, D)
    	tmp = 0.0
    	if (Float64(M * D) <= 2e+64)
    		tmp = Float64(Float64(-Float64(-d_m)) * sqrt(Float64(Float64(1.0 / h) / l)));
    	else
    		tmp = Float64(Float64(-0.125 * Float64(Float64(D * D) * Float64(Float64(M * M) / d_m))) * sqrt(Float64(h / Float64(Float64(l * l) * l))));
    	end
    	return tmp
    end
    
    d_m = abs(d);
    function tmp_2 = code(d_m, h, l, M, D)
    	tmp = 0.0;
    	if ((M * D) <= 2e+64)
    		tmp = -(-d_m) * sqrt(((1.0 / h) / l));
    	else
    		tmp = (-0.125 * ((D * D) * ((M * M) / d_m))) * sqrt((h / ((l * l) * l)));
    	end
    	tmp_2 = tmp;
    end
    
    d_m = N[Abs[d], $MachinePrecision]
    code[d$95$m_, h_, l_, M_, D_] := If[LessEqual[N[(M * D), $MachinePrecision], 2e+64], N[((-(-d$95$m)) * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(-0.125 * N[(N[(D * D), $MachinePrecision] * N[(N[(M * M), $MachinePrecision] / d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(h / N[(N[(l * l), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
    
    \begin{array}{l}
    d_m = \left|d\right|
    
    \\
    \begin{array}{l}
    \mathbf{if}\;M \cdot D \leq 2 \cdot 10^{+64}:\\
    \;\;\;\;\left(-\left(-d\_m\right)\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\
    
    \mathbf{else}:\\
    \;\;\;\;\left(-0.125 \cdot \left(\left(D \cdot D\right) \cdot \frac{M \cdot M}{d\_m}\right)\right) \cdot \sqrt{\frac{h}{\left(\ell \cdot \ell\right) \cdot \ell}}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (*.f64 M D) < 2.00000000000000004e64

      1. Initial program 35.8%

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

        \[\leadsto \color{blue}{-1 \cdot \left(\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      3. Step-by-step derivation
        1. mul-1-negN/A

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

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

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

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

          \[\leadsto -\left(d \cdot {-1}^{1}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
        6. metadata-evalN/A

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

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

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

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

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

          \[\leadsto -\left(-1 \cdot d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
        12. lower-*.f6443.1

          \[\leadsto -\left(-1 \cdot d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
      4. Applied rewrites43.1%

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

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

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

          \[\leadsto \mathsf{neg}\left(\left(-1 \cdot d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\right) \]
        4. distribute-lft-neg-inN/A

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

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

          \[\leadsto \left(\mathsf{neg}\left(d \cdot {-1}^{1}\right)\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
        7. metadata-evalN/A

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

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

          \[\leadsto \left(\mathsf{neg}\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
        10. lift-/.f64N/A

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

          \[\leadsto \left(\mathsf{neg}\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
        12. *-commutativeN/A

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

          \[\leadsto \left(\mathsf{neg}\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)\right) \cdot \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \]
        14. sqrt-pow2N/A

          \[\leadsto \left(\mathsf{neg}\left(d \cdot {-1}^{\left(\frac{2}{2}\right)}\right)\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
        15. metadata-evalN/A

          \[\leadsto \left(\mathsf{neg}\left(d \cdot {-1}^{1}\right)\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
        16. metadata-evalN/A

          \[\leadsto \left(\mathsf{neg}\left(d \cdot -1\right)\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
        17. *-commutativeN/A

          \[\leadsto \left(\mathsf{neg}\left(-1 \cdot d\right)\right) \cdot \sqrt{\frac{\color{blue}{1}}{h \cdot \ell}} \]
        18. mul-1-negN/A

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

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

          \[\leadsto \left(-\left(-d\right)\right) \cdot \sqrt{\frac{\color{blue}{1}}{h \cdot \ell}} \]
      6. Applied rewrites43.1%

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

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

          \[\leadsto \left(-\left(-d\right)\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
        3. *-commutativeN/A

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

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

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

          \[\leadsto \left(-\left(-d\right)\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}} \]
      8. Applied rewrites43.4%

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

      if 2.00000000000000004e64 < (*.f64 M D)

      1. Initial program 35.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 12: 44.3% accurate, 0.5× speedup?

    \[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} t_0 := \left({\left(\frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d\_m}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\ \mathbf{if}\;t\_0 \leq -2 \cdot 10^{-242}:\\ \;\;\;\;\left(d\_m \cdot \left(-\sqrt{\frac{1}{\left(\left(h \cdot h\right) \cdot h\right) \cdot \ell}}\right)\right) \cdot h\\ \mathbf{elif}\;t\_0 \leq \infty:\\ \;\;\;\;\left(-\left(-d\_m\right)\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\_m\right)}{h}\\ \end{array} \end{array} \]
    d_m = (fabs.f64 d)
    (FPCore (d_m h l M D)
     :precision binary64
     (let* ((t_0
             (*
              (* (pow (/ d_m h) (/ 1.0 2.0)) (pow (/ d_m l) (/ 1.0 2.0)))
              (-
               1.0
               (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d_m)) 2.0)) (/ h l))))))
       (if (<= t_0 -2e-242)
         (* (* d_m (- (sqrt (/ 1.0 (* (* (* h h) h) l))))) h)
         (if (<= t_0 INFINITY)
           (* (- (- d_m)) (sqrt (/ (/ 1.0 h) l)))
           (/ (* (sqrt (/ h l)) (- d_m)) h)))))
    d_m = fabs(d);
    double code(double d_m, double h, double l, double M, double D) {
    	double t_0 = (pow((d_m / h), (1.0 / 2.0)) * pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l)));
    	double tmp;
    	if (t_0 <= -2e-242) {
    		tmp = (d_m * -sqrt((1.0 / (((h * h) * h) * l)))) * h;
    	} else if (t_0 <= ((double) INFINITY)) {
    		tmp = -(-d_m) * sqrt(((1.0 / h) / l));
    	} else {
    		tmp = (sqrt((h / l)) * -d_m) / h;
    	}
    	return tmp;
    }
    
    d_m = Math.abs(d);
    public static double code(double d_m, double h, double l, double M, double D) {
    	double t_0 = (Math.pow((d_m / h), (1.0 / 2.0)) * Math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l)));
    	double tmp;
    	if (t_0 <= -2e-242) {
    		tmp = (d_m * -Math.sqrt((1.0 / (((h * h) * h) * l)))) * h;
    	} else if (t_0 <= Double.POSITIVE_INFINITY) {
    		tmp = -(-d_m) * Math.sqrt(((1.0 / h) / l));
    	} else {
    		tmp = (Math.sqrt((h / l)) * -d_m) / h;
    	}
    	return tmp;
    }
    
    d_m = math.fabs(d)
    def code(d_m, h, l, M, D):
    	t_0 = (math.pow((d_m / h), (1.0 / 2.0)) * math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l)))
    	tmp = 0
    	if t_0 <= -2e-242:
    		tmp = (d_m * -math.sqrt((1.0 / (((h * h) * h) * l)))) * h
    	elif t_0 <= math.inf:
    		tmp = -(-d_m) * math.sqrt(((1.0 / h) / l))
    	else:
    		tmp = (math.sqrt((h / l)) * -d_m) / h
    	return tmp
    
    d_m = abs(d)
    function code(d_m, h, l, M, D)
    	t_0 = Float64(Float64((Float64(d_m / h) ^ Float64(1.0 / 2.0)) * (Float64(d_m / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d_m)) ^ 2.0)) * Float64(h / l))))
    	tmp = 0.0
    	if (t_0 <= -2e-242)
    		tmp = Float64(Float64(d_m * Float64(-sqrt(Float64(1.0 / Float64(Float64(Float64(h * h) * h) * l))))) * h);
    	elseif (t_0 <= Inf)
    		tmp = Float64(Float64(-Float64(-d_m)) * sqrt(Float64(Float64(1.0 / h) / l)));
    	else
    		tmp = Float64(Float64(sqrt(Float64(h / l)) * Float64(-d_m)) / h);
    	end
    	return tmp
    end
    
    d_m = abs(d);
    function tmp_2 = code(d_m, h, l, M, D)
    	t_0 = (((d_m / h) ^ (1.0 / 2.0)) * ((d_m / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d_m)) ^ 2.0)) * (h / l)));
    	tmp = 0.0;
    	if (t_0 <= -2e-242)
    		tmp = (d_m * -sqrt((1.0 / (((h * h) * h) * l)))) * h;
    	elseif (t_0 <= Inf)
    		tmp = -(-d_m) * sqrt(((1.0 / h) / l));
    	else
    		tmp = (sqrt((h / l)) * -d_m) / h;
    	end
    	tmp_2 = tmp;
    end
    
    d_m = N[Abs[d], $MachinePrecision]
    code[d$95$m_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[(N[Power[N[(d$95$m / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d$95$m / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -2e-242], N[(N[(d$95$m * (-N[Sqrt[N[(1.0 / N[(N[(N[(h * h), $MachinePrecision] * h), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] * h), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[((-(-d$95$m)) * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * (-d$95$m)), $MachinePrecision] / h), $MachinePrecision]]]]
    
    \begin{array}{l}
    d_m = \left|d\right|
    
    \\
    \begin{array}{l}
    t_0 := \left({\left(\frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d\_m}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
    \mathbf{if}\;t\_0 \leq -2 \cdot 10^{-242}:\\
    \;\;\;\;\left(d\_m \cdot \left(-\sqrt{\frac{1}{\left(\left(h \cdot h\right) \cdot h\right) \cdot \ell}}\right)\right) \cdot h\\
    
    \mathbf{elif}\;t\_0 \leq \infty:\\
    \;\;\;\;\left(-\left(-d\_m\right)\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\_m\right)}{h}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -2e-242

      1. Initial program 35.8%

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

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

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

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

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

        \[\leadsto \left(\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{{h}^{3} \cdot \ell}}\right) \cdot h \]
      6. Step-by-step derivation
        1. sqrt-pow2N/A

          \[\leadsto \left(\left(d \cdot {-1}^{\left(\frac{2}{2}\right)}\right) \cdot \sqrt{\frac{1}{{h}^{3} \cdot \ell}}\right) \cdot h \]
        2. metadata-evalN/A

          \[\leadsto \left(\left(d \cdot {-1}^{1}\right) \cdot \sqrt{\frac{1}{{h}^{3} \cdot \ell}}\right) \cdot h \]
        3. metadata-evalN/A

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

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

          \[\leadsto \left(d \cdot \left(-1 \cdot \sqrt{\frac{1}{{h}^{3} \cdot \ell}}\right)\right) \cdot h \]
        6. mul-1-negN/A

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

          \[\leadsto \left(d \cdot \left(-\sqrt{\frac{1}{{h}^{3} \cdot \ell}}\right)\right) \cdot h \]
        8. pow3N/A

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

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

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

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

          \[\leadsto \left(d \cdot \left(-\sqrt{\frac{1}{\left(\left(h \cdot h\right) \cdot h\right) \cdot \ell}}\right)\right) \cdot h \]
        13. lift-sqrt.f6417.9

          \[\leadsto \left(d \cdot \left(-\sqrt{\frac{1}{\left(\left(h \cdot h\right) \cdot h\right) \cdot \ell}}\right)\right) \cdot h \]
      7. Applied rewrites17.9%

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

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

      1. Initial program 35.8%

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

        \[\leadsto \color{blue}{-1 \cdot \left(\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      3. Step-by-step derivation
        1. mul-1-negN/A

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

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

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

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

          \[\leadsto -\left(d \cdot {-1}^{1}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
        6. metadata-evalN/A

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

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

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

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

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

          \[\leadsto -\left(-1 \cdot d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
        12. lower-*.f6443.1

          \[\leadsto -\left(-1 \cdot d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
      4. Applied rewrites43.1%

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

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

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

          \[\leadsto \mathsf{neg}\left(\left(-1 \cdot d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\right) \]
        4. distribute-lft-neg-inN/A

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

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

          \[\leadsto \left(\mathsf{neg}\left(d \cdot {-1}^{1}\right)\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
        7. metadata-evalN/A

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

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

          \[\leadsto \left(\mathsf{neg}\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
        10. lift-/.f64N/A

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

          \[\leadsto \left(\mathsf{neg}\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
        12. *-commutativeN/A

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

          \[\leadsto \left(\mathsf{neg}\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)\right) \cdot \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \]
        14. sqrt-pow2N/A

          \[\leadsto \left(\mathsf{neg}\left(d \cdot {-1}^{\left(\frac{2}{2}\right)}\right)\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
        15. metadata-evalN/A

          \[\leadsto \left(\mathsf{neg}\left(d \cdot {-1}^{1}\right)\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
        16. metadata-evalN/A

          \[\leadsto \left(\mathsf{neg}\left(d \cdot -1\right)\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
        17. *-commutativeN/A

          \[\leadsto \left(\mathsf{neg}\left(-1 \cdot d\right)\right) \cdot \sqrt{\frac{\color{blue}{1}}{h \cdot \ell}} \]
        18. mul-1-negN/A

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

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

          \[\leadsto \left(-\left(-d\right)\right) \cdot \sqrt{\frac{\color{blue}{1}}{h \cdot \ell}} \]
      6. Applied rewrites43.1%

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

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

          \[\leadsto \left(-\left(-d\right)\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
        3. *-commutativeN/A

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

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

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

          \[\leadsto \left(-\left(-d\right)\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}} \]
      8. Applied rewrites43.4%

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

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

      1. Initial program 35.8%

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

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

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

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

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

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

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(d \cdot {-1}^{\left(\frac{2}{2}\right)}\right)}{h} \]
        3. metadata-evalN/A

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(d \cdot {-1}^{1}\right)}{h} \]
        4. metadata-evalN/A

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

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(-1 \cdot d\right)}{h} \]
        6. mul-1-negN/A

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(\mathsf{neg}\left(d\right)\right)}{h} \]
        7. lift-neg.f64N/A

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

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\right)}{h} \]
        9. lift-sqrt.f64N/A

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\right)}{h} \]
        10. lift-/.f6425.0

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\right)}{h} \]
      7. Applied rewrites25.0%

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

    Alternative 13: 43.3% accurate, 0.5× speedup?

    \[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} t_0 := \left({\left(\frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d\_m}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\ t_1 := -\left(-d\_m\right)\\ \mathbf{if}\;t\_0 \leq -2 \cdot 10^{-242}:\\ \;\;\;\;t\_1 \cdot \left(-\sqrt{\frac{1}{\ell \cdot h}}\right)\\ \mathbf{elif}\;t\_0 \leq \infty:\\ \;\;\;\;t\_1 \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\_m\right)}{h}\\ \end{array} \end{array} \]
    d_m = (fabs.f64 d)
    (FPCore (d_m h l M D)
     :precision binary64
     (let* ((t_0
             (*
              (* (pow (/ d_m h) (/ 1.0 2.0)) (pow (/ d_m l) (/ 1.0 2.0)))
              (-
               1.0
               (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d_m)) 2.0)) (/ h l)))))
            (t_1 (- (- d_m))))
       (if (<= t_0 -2e-242)
         (* t_1 (- (sqrt (/ 1.0 (* l h)))))
         (if (<= t_0 INFINITY)
           (* t_1 (sqrt (/ (/ 1.0 h) l)))
           (/ (* (sqrt (/ h l)) (- d_m)) h)))))
    d_m = fabs(d);
    double code(double d_m, double h, double l, double M, double D) {
    	double t_0 = (pow((d_m / h), (1.0 / 2.0)) * pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l)));
    	double t_1 = -(-d_m);
    	double tmp;
    	if (t_0 <= -2e-242) {
    		tmp = t_1 * -sqrt((1.0 / (l * h)));
    	} else if (t_0 <= ((double) INFINITY)) {
    		tmp = t_1 * sqrt(((1.0 / h) / l));
    	} else {
    		tmp = (sqrt((h / l)) * -d_m) / h;
    	}
    	return tmp;
    }
    
    d_m = Math.abs(d);
    public static double code(double d_m, double h, double l, double M, double D) {
    	double t_0 = (Math.pow((d_m / h), (1.0 / 2.0)) * Math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l)));
    	double t_1 = -(-d_m);
    	double tmp;
    	if (t_0 <= -2e-242) {
    		tmp = t_1 * -Math.sqrt((1.0 / (l * h)));
    	} else if (t_0 <= Double.POSITIVE_INFINITY) {
    		tmp = t_1 * Math.sqrt(((1.0 / h) / l));
    	} else {
    		tmp = (Math.sqrt((h / l)) * -d_m) / h;
    	}
    	return tmp;
    }
    
    d_m = math.fabs(d)
    def code(d_m, h, l, M, D):
    	t_0 = (math.pow((d_m / h), (1.0 / 2.0)) * math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l)))
    	t_1 = -(-d_m)
    	tmp = 0
    	if t_0 <= -2e-242:
    		tmp = t_1 * -math.sqrt((1.0 / (l * h)))
    	elif t_0 <= math.inf:
    		tmp = t_1 * math.sqrt(((1.0 / h) / l))
    	else:
    		tmp = (math.sqrt((h / l)) * -d_m) / h
    	return tmp
    
    d_m = abs(d)
    function code(d_m, h, l, M, D)
    	t_0 = Float64(Float64((Float64(d_m / h) ^ Float64(1.0 / 2.0)) * (Float64(d_m / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d_m)) ^ 2.0)) * Float64(h / l))))
    	t_1 = Float64(-Float64(-d_m))
    	tmp = 0.0
    	if (t_0 <= -2e-242)
    		tmp = Float64(t_1 * Float64(-sqrt(Float64(1.0 / Float64(l * h)))));
    	elseif (t_0 <= Inf)
    		tmp = Float64(t_1 * sqrt(Float64(Float64(1.0 / h) / l)));
    	else
    		tmp = Float64(Float64(sqrt(Float64(h / l)) * Float64(-d_m)) / h);
    	end
    	return tmp
    end
    
    d_m = abs(d);
    function tmp_2 = code(d_m, h, l, M, D)
    	t_0 = (((d_m / h) ^ (1.0 / 2.0)) * ((d_m / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d_m)) ^ 2.0)) * (h / l)));
    	t_1 = -(-d_m);
    	tmp = 0.0;
    	if (t_0 <= -2e-242)
    		tmp = t_1 * -sqrt((1.0 / (l * h)));
    	elseif (t_0 <= Inf)
    		tmp = t_1 * sqrt(((1.0 / h) / l));
    	else
    		tmp = (sqrt((h / l)) * -d_m) / h;
    	end
    	tmp_2 = tmp;
    end
    
    d_m = N[Abs[d], $MachinePrecision]
    code[d$95$m_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[(N[Power[N[(d$95$m / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d$95$m / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = (-(-d$95$m))}, If[LessEqual[t$95$0, -2e-242], N[(t$95$1 * (-N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(t$95$1 * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * (-d$95$m)), $MachinePrecision] / h), $MachinePrecision]]]]]
    
    \begin{array}{l}
    d_m = \left|d\right|
    
    \\
    \begin{array}{l}
    t_0 := \left({\left(\frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d\_m}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
    t_1 := -\left(-d\_m\right)\\
    \mathbf{if}\;t\_0 \leq -2 \cdot 10^{-242}:\\
    \;\;\;\;t\_1 \cdot \left(-\sqrt{\frac{1}{\ell \cdot h}}\right)\\
    
    \mathbf{elif}\;t\_0 \leq \infty:\\
    \;\;\;\;t\_1 \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\_m\right)}{h}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -2e-242

      1. Initial program 35.8%

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

        \[\leadsto \color{blue}{-1 \cdot \left(\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      3. Step-by-step derivation
        1. mul-1-negN/A

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

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

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

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

          \[\leadsto -\left(d \cdot {-1}^{1}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
        6. metadata-evalN/A

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

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

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

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

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

          \[\leadsto -\left(-1 \cdot d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
        12. lower-*.f6443.1

          \[\leadsto -\left(-1 \cdot d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
      4. Applied rewrites43.1%

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

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

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

          \[\leadsto \mathsf{neg}\left(\left(-1 \cdot d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\right) \]
        4. distribute-lft-neg-inN/A

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

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

          \[\leadsto \left(\mathsf{neg}\left(d \cdot {-1}^{1}\right)\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
        7. metadata-evalN/A

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

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

          \[\leadsto \left(\mathsf{neg}\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
        10. lift-/.f64N/A

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

          \[\leadsto \left(\mathsf{neg}\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
        12. *-commutativeN/A

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

          \[\leadsto \left(\mathsf{neg}\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)\right) \cdot \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \]
        14. sqrt-pow2N/A

          \[\leadsto \left(\mathsf{neg}\left(d \cdot {-1}^{\left(\frac{2}{2}\right)}\right)\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
        15. metadata-evalN/A

          \[\leadsto \left(\mathsf{neg}\left(d \cdot {-1}^{1}\right)\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
        16. metadata-evalN/A

          \[\leadsto \left(\mathsf{neg}\left(d \cdot -1\right)\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
        17. *-commutativeN/A

          \[\leadsto \left(\mathsf{neg}\left(-1 \cdot d\right)\right) \cdot \sqrt{\frac{\color{blue}{1}}{h \cdot \ell}} \]
        18. mul-1-negN/A

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

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

          \[\leadsto \left(-\left(-d\right)\right) \cdot \sqrt{\frac{\color{blue}{1}}{h \cdot \ell}} \]
      6. Applied rewrites43.1%

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

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

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

          \[\leadsto \left(-\left(-d\right)\right) \cdot \left(\sqrt{\frac{1}{h \cdot \ell}} \cdot {-1}^{1}\right) \]
        3. metadata-evalN/A

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

          \[\leadsto \left(-\left(-d\right)\right) \cdot \left(-1 \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
        5. mul-1-negN/A

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

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

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

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

          \[\leadsto \left(-\left(-d\right)\right) \cdot \left(-\sqrt{\frac{1}{\ell \cdot h}}\right) \]
        10. lift-*.f6410.6

          \[\leadsto \left(-\left(-d\right)\right) \cdot \left(-\sqrt{\frac{1}{\ell \cdot h}}\right) \]
      9. Applied rewrites10.6%

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

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

      1. Initial program 35.8%

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

        \[\leadsto \color{blue}{-1 \cdot \left(\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      3. Step-by-step derivation
        1. mul-1-negN/A

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

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

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

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

          \[\leadsto -\left(d \cdot {-1}^{1}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
        6. metadata-evalN/A

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

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

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

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

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

          \[\leadsto -\left(-1 \cdot d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
        12. lower-*.f6443.1

          \[\leadsto -\left(-1 \cdot d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
      4. Applied rewrites43.1%

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

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

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

          \[\leadsto \mathsf{neg}\left(\left(-1 \cdot d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\right) \]
        4. distribute-lft-neg-inN/A

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

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

          \[\leadsto \left(\mathsf{neg}\left(d \cdot {-1}^{1}\right)\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
        7. metadata-evalN/A

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

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

          \[\leadsto \left(\mathsf{neg}\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
        10. lift-/.f64N/A

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

          \[\leadsto \left(\mathsf{neg}\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
        12. *-commutativeN/A

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

          \[\leadsto \left(\mathsf{neg}\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)\right) \cdot \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \]
        14. sqrt-pow2N/A

          \[\leadsto \left(\mathsf{neg}\left(d \cdot {-1}^{\left(\frac{2}{2}\right)}\right)\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
        15. metadata-evalN/A

          \[\leadsto \left(\mathsf{neg}\left(d \cdot {-1}^{1}\right)\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
        16. metadata-evalN/A

          \[\leadsto \left(\mathsf{neg}\left(d \cdot -1\right)\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
        17. *-commutativeN/A

          \[\leadsto \left(\mathsf{neg}\left(-1 \cdot d\right)\right) \cdot \sqrt{\frac{\color{blue}{1}}{h \cdot \ell}} \]
        18. mul-1-negN/A

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

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

          \[\leadsto \left(-\left(-d\right)\right) \cdot \sqrt{\frac{\color{blue}{1}}{h \cdot \ell}} \]
      6. Applied rewrites43.1%

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

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

          \[\leadsto \left(-\left(-d\right)\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
        3. *-commutativeN/A

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

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

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

          \[\leadsto \left(-\left(-d\right)\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}} \]
      8. Applied rewrites43.4%

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

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

      1. Initial program 35.8%

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

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

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

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

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

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

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(d \cdot {-1}^{\left(\frac{2}{2}\right)}\right)}{h} \]
        3. metadata-evalN/A

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(d \cdot {-1}^{1}\right)}{h} \]
        4. metadata-evalN/A

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

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(-1 \cdot d\right)}{h} \]
        6. mul-1-negN/A

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(\mathsf{neg}\left(d\right)\right)}{h} \]
        7. lift-neg.f64N/A

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

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\right)}{h} \]
        9. lift-sqrt.f64N/A

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\right)}{h} \]
        10. lift-/.f6425.0

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\right)}{h} \]
      7. Applied rewrites25.0%

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

    Alternative 14: 43.1% accurate, 5.2× speedup?

    \[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} \mathbf{if}\;\ell \leq 6.8 \cdot 10^{-208}:\\ \;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\_m\right)}{h}\\ \mathbf{else}:\\ \;\;\;\;\left(-\left(-d\_m\right)\right) \cdot \frac{1}{\sqrt{\ell \cdot h}}\\ \end{array} \end{array} \]
    d_m = (fabs.f64 d)
    (FPCore (d_m h l M D)
     :precision binary64
     (if (<= l 6.8e-208)
       (/ (* (sqrt (/ h l)) (- d_m)) h)
       (* (- (- d_m)) (/ 1.0 (sqrt (* l h))))))
    d_m = fabs(d);
    double code(double d_m, double h, double l, double M, double D) {
    	double tmp;
    	if (l <= 6.8e-208) {
    		tmp = (sqrt((h / l)) * -d_m) / h;
    	} else {
    		tmp = -(-d_m) * (1.0 / sqrt((l * h)));
    	}
    	return tmp;
    }
    
    d_m =     private
    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(d_m, h, l, m, d)
    use fmin_fmax_functions
        real(8), intent (in) :: d_m
        real(8), intent (in) :: h
        real(8), intent (in) :: l
        real(8), intent (in) :: m
        real(8), intent (in) :: d
        real(8) :: tmp
        if (l <= 6.8d-208) then
            tmp = (sqrt((h / l)) * -d_m) / h
        else
            tmp = -(-d_m) * (1.0d0 / sqrt((l * h)))
        end if
        code = tmp
    end function
    
    d_m = Math.abs(d);
    public static double code(double d_m, double h, double l, double M, double D) {
    	double tmp;
    	if (l <= 6.8e-208) {
    		tmp = (Math.sqrt((h / l)) * -d_m) / h;
    	} else {
    		tmp = -(-d_m) * (1.0 / Math.sqrt((l * h)));
    	}
    	return tmp;
    }
    
    d_m = math.fabs(d)
    def code(d_m, h, l, M, D):
    	tmp = 0
    	if l <= 6.8e-208:
    		tmp = (math.sqrt((h / l)) * -d_m) / h
    	else:
    		tmp = -(-d_m) * (1.0 / math.sqrt((l * h)))
    	return tmp
    
    d_m = abs(d)
    function code(d_m, h, l, M, D)
    	tmp = 0.0
    	if (l <= 6.8e-208)
    		tmp = Float64(Float64(sqrt(Float64(h / l)) * Float64(-d_m)) / h);
    	else
    		tmp = Float64(Float64(-Float64(-d_m)) * Float64(1.0 / sqrt(Float64(l * h))));
    	end
    	return tmp
    end
    
    d_m = abs(d);
    function tmp_2 = code(d_m, h, l, M, D)
    	tmp = 0.0;
    	if (l <= 6.8e-208)
    		tmp = (sqrt((h / l)) * -d_m) / h;
    	else
    		tmp = -(-d_m) * (1.0 / sqrt((l * h)));
    	end
    	tmp_2 = tmp;
    end
    
    d_m = N[Abs[d], $MachinePrecision]
    code[d$95$m_, h_, l_, M_, D_] := If[LessEqual[l, 6.8e-208], N[(N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * (-d$95$m)), $MachinePrecision] / h), $MachinePrecision], N[((-(-d$95$m)) * N[(1.0 / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
    
    \begin{array}{l}
    d_m = \left|d\right|
    
    \\
    \begin{array}{l}
    \mathbf{if}\;\ell \leq 6.8 \cdot 10^{-208}:\\
    \;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\_m\right)}{h}\\
    
    \mathbf{else}:\\
    \;\;\;\;\left(-\left(-d\_m\right)\right) \cdot \frac{1}{\sqrt{\ell \cdot h}}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if l < 6.8e-208

      1. Initial program 35.8%

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

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

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

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

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

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

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(d \cdot {-1}^{\left(\frac{2}{2}\right)}\right)}{h} \]
        3. metadata-evalN/A

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(d \cdot {-1}^{1}\right)}{h} \]
        4. metadata-evalN/A

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

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(-1 \cdot d\right)}{h} \]
        6. mul-1-negN/A

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(\mathsf{neg}\left(d\right)\right)}{h} \]
        7. lift-neg.f64N/A

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

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\right)}{h} \]
        9. lift-sqrt.f64N/A

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\right)}{h} \]
        10. lift-/.f6425.0

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\right)}{h} \]
      7. Applied rewrites25.0%

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

      if 6.8e-208 < l

      1. Initial program 35.8%

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

        \[\leadsto \color{blue}{-1 \cdot \left(\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      3. Step-by-step derivation
        1. mul-1-negN/A

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

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

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

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

          \[\leadsto -\left(d \cdot {-1}^{1}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
        6. metadata-evalN/A

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

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

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

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

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

          \[\leadsto -\left(-1 \cdot d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
        12. lower-*.f6443.1

          \[\leadsto -\left(-1 \cdot d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
      4. Applied rewrites43.1%

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

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

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

          \[\leadsto \mathsf{neg}\left(\left(-1 \cdot d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\right) \]
        4. distribute-lft-neg-inN/A

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

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

          \[\leadsto \left(\mathsf{neg}\left(d \cdot {-1}^{1}\right)\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
        7. metadata-evalN/A

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

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

          \[\leadsto \left(\mathsf{neg}\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
        10. lift-/.f64N/A

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

          \[\leadsto \left(\mathsf{neg}\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
        12. *-commutativeN/A

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

          \[\leadsto \left(\mathsf{neg}\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)\right) \cdot \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \]
        14. sqrt-pow2N/A

          \[\leadsto \left(\mathsf{neg}\left(d \cdot {-1}^{\left(\frac{2}{2}\right)}\right)\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
        15. metadata-evalN/A

          \[\leadsto \left(\mathsf{neg}\left(d \cdot {-1}^{1}\right)\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
        16. metadata-evalN/A

          \[\leadsto \left(\mathsf{neg}\left(d \cdot -1\right)\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
        17. *-commutativeN/A

          \[\leadsto \left(\mathsf{neg}\left(-1 \cdot d\right)\right) \cdot \sqrt{\frac{\color{blue}{1}}{h \cdot \ell}} \]
        18. mul-1-negN/A

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

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

          \[\leadsto \left(-\left(-d\right)\right) \cdot \sqrt{\frac{\color{blue}{1}}{h \cdot \ell}} \]
      6. Applied rewrites43.1%

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

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

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

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

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

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

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

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

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

          \[\leadsto \left(-\left(-d\right)\right) \cdot \frac{1}{\sqrt{\ell \cdot h}} \]
        10. lift-*.f6443.2

          \[\leadsto \left(-\left(-d\right)\right) \cdot \frac{1}{\sqrt{\ell \cdot h}} \]
      8. Applied rewrites43.2%

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

    Alternative 15: 40.3% accurate, 5.4× speedup?

    \[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} \mathbf{if}\;\ell \leq 6.8 \cdot 10^{-208}:\\ \;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\_m\right)}{h}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{1}{\ell \cdot h}} \cdot d\_m\\ \end{array} \end{array} \]
    d_m = (fabs.f64 d)
    (FPCore (d_m h l M D)
     :precision binary64
     (if (<= l 6.8e-208)
       (/ (* (sqrt (/ h l)) (- d_m)) h)
       (* (sqrt (/ 1.0 (* l h))) d_m)))
    d_m = fabs(d);
    double code(double d_m, double h, double l, double M, double D) {
    	double tmp;
    	if (l <= 6.8e-208) {
    		tmp = (sqrt((h / l)) * -d_m) / h;
    	} else {
    		tmp = sqrt((1.0 / (l * h))) * d_m;
    	}
    	return tmp;
    }
    
    d_m =     private
    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(d_m, h, l, m, d)
    use fmin_fmax_functions
        real(8), intent (in) :: d_m
        real(8), intent (in) :: h
        real(8), intent (in) :: l
        real(8), intent (in) :: m
        real(8), intent (in) :: d
        real(8) :: tmp
        if (l <= 6.8d-208) then
            tmp = (sqrt((h / l)) * -d_m) / h
        else
            tmp = sqrt((1.0d0 / (l * h))) * d_m
        end if
        code = tmp
    end function
    
    d_m = Math.abs(d);
    public static double code(double d_m, double h, double l, double M, double D) {
    	double tmp;
    	if (l <= 6.8e-208) {
    		tmp = (Math.sqrt((h / l)) * -d_m) / h;
    	} else {
    		tmp = Math.sqrt((1.0 / (l * h))) * d_m;
    	}
    	return tmp;
    }
    
    d_m = math.fabs(d)
    def code(d_m, h, l, M, D):
    	tmp = 0
    	if l <= 6.8e-208:
    		tmp = (math.sqrt((h / l)) * -d_m) / h
    	else:
    		tmp = math.sqrt((1.0 / (l * h))) * d_m
    	return tmp
    
    d_m = abs(d)
    function code(d_m, h, l, M, D)
    	tmp = 0.0
    	if (l <= 6.8e-208)
    		tmp = Float64(Float64(sqrt(Float64(h / l)) * Float64(-d_m)) / h);
    	else
    		tmp = Float64(sqrt(Float64(1.0 / Float64(l * h))) * d_m);
    	end
    	return tmp
    end
    
    d_m = abs(d);
    function tmp_2 = code(d_m, h, l, M, D)
    	tmp = 0.0;
    	if (l <= 6.8e-208)
    		tmp = (sqrt((h / l)) * -d_m) / h;
    	else
    		tmp = sqrt((1.0 / (l * h))) * d_m;
    	end
    	tmp_2 = tmp;
    end
    
    d_m = N[Abs[d], $MachinePrecision]
    code[d$95$m_, h_, l_, M_, D_] := If[LessEqual[l, 6.8e-208], N[(N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * (-d$95$m)), $MachinePrecision] / h), $MachinePrecision], N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision]]
    
    \begin{array}{l}
    d_m = \left|d\right|
    
    \\
    \begin{array}{l}
    \mathbf{if}\;\ell \leq 6.8 \cdot 10^{-208}:\\
    \;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\_m\right)}{h}\\
    
    \mathbf{else}:\\
    \;\;\;\;\sqrt{\frac{1}{\ell \cdot h}} \cdot d\_m\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if l < 6.8e-208

      1. Initial program 35.8%

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

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

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

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

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

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

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(d \cdot {-1}^{\left(\frac{2}{2}\right)}\right)}{h} \]
        3. metadata-evalN/A

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(d \cdot {-1}^{1}\right)}{h} \]
        4. metadata-evalN/A

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

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(-1 \cdot d\right)}{h} \]
        6. mul-1-negN/A

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(\mathsf{neg}\left(d\right)\right)}{h} \]
        7. lift-neg.f64N/A

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

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\right)}{h} \]
        9. lift-sqrt.f64N/A

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\right)}{h} \]
        10. lift-/.f6425.0

          \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot \left(-d\right)}{h} \]
      7. Applied rewrites25.0%

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

      if 6.8e-208 < l

      1. Initial program 35.8%

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

        \[\leadsto \color{blue}{-1 \cdot \left(\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      3. Step-by-step derivation
        1. mul-1-negN/A

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

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

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

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

          \[\leadsto -\left(d \cdot {-1}^{1}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
        6. metadata-evalN/A

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

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

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

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

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

          \[\leadsto -\left(-1 \cdot d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
        12. lower-*.f6443.1

          \[\leadsto -\left(-1 \cdot d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
      4. Applied rewrites43.1%

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

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

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

          \[\leadsto \mathsf{neg}\left(\left(-1 \cdot d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\right) \]
        4. distribute-lft-neg-inN/A

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

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

          \[\leadsto \left(\mathsf{neg}\left(d \cdot {-1}^{1}\right)\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
        7. metadata-evalN/A

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

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

          \[\leadsto \left(\mathsf{neg}\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
        10. lift-/.f64N/A

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

          \[\leadsto \left(\mathsf{neg}\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
        12. *-commutativeN/A

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

          \[\leadsto \left(\mathsf{neg}\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)\right) \cdot \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \]
        14. sqrt-pow2N/A

          \[\leadsto \left(\mathsf{neg}\left(d \cdot {-1}^{\left(\frac{2}{2}\right)}\right)\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
        15. metadata-evalN/A

          \[\leadsto \left(\mathsf{neg}\left(d \cdot {-1}^{1}\right)\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
        16. metadata-evalN/A

          \[\leadsto \left(\mathsf{neg}\left(d \cdot -1\right)\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
        17. *-commutativeN/A

          \[\leadsto \left(\mathsf{neg}\left(-1 \cdot d\right)\right) \cdot \sqrt{\frac{\color{blue}{1}}{h \cdot \ell}} \]
        18. mul-1-negN/A

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

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

          \[\leadsto \left(-\left(-d\right)\right) \cdot \sqrt{\frac{\color{blue}{1}}{h \cdot \ell}} \]
      6. Applied rewrites43.1%

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

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

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

          \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(d\right)\right)\right)\right) \cdot \sqrt{\frac{\color{blue}{1}}{\ell \cdot h}} \]
        4. remove-double-negN/A

          \[\leadsto d \cdot \sqrt{\color{blue}{\frac{1}{\ell \cdot h}}} \]
        5. *-commutativeN/A

          \[\leadsto \sqrt{\frac{1}{\ell \cdot h}} \cdot \color{blue}{d} \]
        6. lift-*.f6443.1

          \[\leadsto \sqrt{\frac{1}{\ell \cdot h}} \cdot \color{blue}{d} \]
      8. Applied rewrites43.1%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{\ell \cdot h}} \cdot d} \]
    3. Recombined 2 regimes into one program.
    4. Add Preprocessing

    Alternative 16: 40.3% accurate, 7.7× speedup?

    \[\begin{array}{l} d_m = \left|d\right| \\ \sqrt{\frac{1}{\ell \cdot h}} \cdot d\_m \end{array} \]
    d_m = (fabs.f64 d)
    (FPCore (d_m h l M D) :precision binary64 (* (sqrt (/ 1.0 (* l h))) d_m))
    d_m = fabs(d);
    double code(double d_m, double h, double l, double M, double D) {
    	return sqrt((1.0 / (l * h))) * d_m;
    }
    
    d_m =     private
    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(d_m, h, l, m, d)
    use fmin_fmax_functions
        real(8), intent (in) :: d_m
        real(8), intent (in) :: h
        real(8), intent (in) :: l
        real(8), intent (in) :: m
        real(8), intent (in) :: d
        code = sqrt((1.0d0 / (l * h))) * d_m
    end function
    
    d_m = Math.abs(d);
    public static double code(double d_m, double h, double l, double M, double D) {
    	return Math.sqrt((1.0 / (l * h))) * d_m;
    }
    
    d_m = math.fabs(d)
    def code(d_m, h, l, M, D):
    	return math.sqrt((1.0 / (l * h))) * d_m
    
    d_m = abs(d)
    function code(d_m, h, l, M, D)
    	return Float64(sqrt(Float64(1.0 / Float64(l * h))) * d_m)
    end
    
    d_m = abs(d);
    function tmp = code(d_m, h, l, M, D)
    	tmp = sqrt((1.0 / (l * h))) * d_m;
    end
    
    d_m = N[Abs[d], $MachinePrecision]
    code[d$95$m_, h_, l_, M_, D_] := N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision]
    
    \begin{array}{l}
    d_m = \left|d\right|
    
    \\
    \sqrt{\frac{1}{\ell \cdot h}} \cdot d\_m
    \end{array}
    
    Derivation
    1. Initial program 35.8%

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

      \[\leadsto \color{blue}{-1 \cdot \left(\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    3. Step-by-step derivation
      1. mul-1-negN/A

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

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

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

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

        \[\leadsto -\left(d \cdot {-1}^{1}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      6. metadata-evalN/A

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

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

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

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

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

        \[\leadsto -\left(-1 \cdot d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
      12. lower-*.f6443.1

        \[\leadsto -\left(-1 \cdot d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
    4. Applied rewrites43.1%

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

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

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

        \[\leadsto \mathsf{neg}\left(\left(-1 \cdot d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\right) \]
      4. distribute-lft-neg-inN/A

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

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

        \[\leadsto \left(\mathsf{neg}\left(d \cdot {-1}^{1}\right)\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
      7. metadata-evalN/A

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

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

        \[\leadsto \left(\mathsf{neg}\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
      10. lift-/.f64N/A

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

        \[\leadsto \left(\mathsf{neg}\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)\right) \cdot \sqrt{\frac{1}{\ell \cdot h}} \]
      12. *-commutativeN/A

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

        \[\leadsto \left(\mathsf{neg}\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)\right) \cdot \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \]
      14. sqrt-pow2N/A

        \[\leadsto \left(\mathsf{neg}\left(d \cdot {-1}^{\left(\frac{2}{2}\right)}\right)\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      15. metadata-evalN/A

        \[\leadsto \left(\mathsf{neg}\left(d \cdot {-1}^{1}\right)\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      16. metadata-evalN/A

        \[\leadsto \left(\mathsf{neg}\left(d \cdot -1\right)\right) \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      17. *-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(-1 \cdot d\right)\right) \cdot \sqrt{\frac{\color{blue}{1}}{h \cdot \ell}} \]
      18. mul-1-negN/A

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

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

        \[\leadsto \left(-\left(-d\right)\right) \cdot \sqrt{\frac{\color{blue}{1}}{h \cdot \ell}} \]
    6. Applied rewrites43.1%

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

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

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

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(d\right)\right)\right)\right) \cdot \sqrt{\frac{\color{blue}{1}}{\ell \cdot h}} \]
      4. remove-double-negN/A

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{1}{\ell \cdot h}}} \]
      5. *-commutativeN/A

        \[\leadsto \sqrt{\frac{1}{\ell \cdot h}} \cdot \color{blue}{d} \]
      6. lift-*.f6443.1

        \[\leadsto \sqrt{\frac{1}{\ell \cdot h}} \cdot \color{blue}{d} \]
    8. Applied rewrites43.1%

      \[\leadsto \color{blue}{\sqrt{\frac{1}{\ell \cdot h}} \cdot d} \]
    9. Add Preprocessing

    Reproduce

    ?
    herbie shell --seed 2025131 
    (FPCore (d h l M D)
      :name "Henrywood and Agarwal, Equation (12)"
      :precision binary64
      (* (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0))) (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))