Henrywood and Agarwal, Equation (12)

Percentage Accurate: 36.4% → 76.4%
Time: 12.1s
Alternatives: 14
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 14 alternatives:

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

Initial Program: 36.4% 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: 76.4% accurate, 0.4× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} t_0 := \frac{M \cdot D}{d\_m + d\_m}\\ t_1 := {\left(\frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d\_m}{\ell}\right)}^{\left(\frac{1}{2}\right)}\\ t_2 := t\_1 \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\_2 \leq -5 \cdot 10^{-252}:\\ \;\;\;\;t\_1 \cdot \left(1 - \left(\frac{1}{2} \cdot \frac{t\_0 \cdot \left(M \cdot D\right)}{d\_m + d\_m}\right) \cdot \frac{h}{\ell}\right)\\ \mathbf{elif}\;t\_2 \leq \infty:\\ \;\;\;\;\left(\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}} \cdot d\_m\right) \cdot \left(1 - \left(\frac{1}{2} \cdot \left(t\_0 \cdot t\_0\right)\right) \cdot \frac{h}{\ell}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\sqrt{\frac{1}{\ell \cdot h}} \cdot d\_m\right) \cdot \frac{\ell - \frac{0.125}{d\_m} \cdot \frac{\left(M \cdot D\right) \cdot \left(\left(M \cdot D\right) \cdot h\right)}{d\_m}}{\ell}\\ \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 (* (pow (/ d_m h) (/ 1.0 2.0)) (pow (/ d_m l) (/ 1.0 2.0))))
        (t_2
         (*
          t_1
          (-
           1.0
           (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d_m)) 2.0)) (/ h l))))))
   (if (<= t_2 -5e-252)
     (*
      t_1
      (- 1.0 (* (* (/ 1.0 2.0) (/ (* t_0 (* M D)) (+ d_m d_m))) (/ h l))))
     (if (<= t_2 INFINITY)
       (*
        (* (/ (sqrt (/ 1.0 h)) (sqrt l)) d_m)
        (- 1.0 (* (* (/ 1.0 2.0) (* t_0 t_0)) (/ h l))))
       (*
        (* (sqrt (/ 1.0 (* l h))) d_m)
        (/ (- l (* (/ 0.125 d_m) (/ (* (* M D) (* (* M D) h)) d_m))) 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 t_1 = pow((d_m / h), (1.0 / 2.0)) * pow((d_m / l), (1.0 / 2.0));
	double t_2 = t_1 * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l)));
	double tmp;
	if (t_2 <= -5e-252) {
		tmp = t_1 * (1.0 - (((1.0 / 2.0) * ((t_0 * (M * D)) / (d_m + d_m))) * (h / l)));
	} else if (t_2 <= ((double) INFINITY)) {
		tmp = ((sqrt((1.0 / h)) / sqrt(l)) * d_m) * (1.0 - (((1.0 / 2.0) * (t_0 * t_0)) * (h / l)));
	} else {
		tmp = (sqrt((1.0 / (l * h))) * d_m) * ((l - ((0.125 / d_m) * (((M * D) * ((M * D) * h)) / d_m))) / l);
	}
	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 = (M * D) / (d_m + d_m);
	double t_1 = Math.pow((d_m / h), (1.0 / 2.0)) * Math.pow((d_m / l), (1.0 / 2.0));
	double t_2 = t_1 * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l)));
	double tmp;
	if (t_2 <= -5e-252) {
		tmp = t_1 * (1.0 - (((1.0 / 2.0) * ((t_0 * (M * D)) / (d_m + d_m))) * (h / l)));
	} else if (t_2 <= Double.POSITIVE_INFINITY) {
		tmp = ((Math.sqrt((1.0 / h)) / Math.sqrt(l)) * d_m) * (1.0 - (((1.0 / 2.0) * (t_0 * t_0)) * (h / l)));
	} else {
		tmp = (Math.sqrt((1.0 / (l * h))) * d_m) * ((l - ((0.125 / d_m) * (((M * D) * ((M * D) * h)) / d_m))) / l);
	}
	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 = math.pow((d_m / h), (1.0 / 2.0)) * math.pow((d_m / l), (1.0 / 2.0))
	t_2 = t_1 * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l)))
	tmp = 0
	if t_2 <= -5e-252:
		tmp = t_1 * (1.0 - (((1.0 / 2.0) * ((t_0 * (M * D)) / (d_m + d_m))) * (h / l)))
	elif t_2 <= math.inf:
		tmp = ((math.sqrt((1.0 / h)) / math.sqrt(l)) * d_m) * (1.0 - (((1.0 / 2.0) * (t_0 * t_0)) * (h / l)))
	else:
		tmp = (math.sqrt((1.0 / (l * h))) * d_m) * ((l - ((0.125 / d_m) * (((M * D) * ((M * D) * h)) / d_m))) / l)
	return tmp
d_m = abs(d)
function code(d_m, h, l, M, D)
	t_0 = Float64(Float64(M * D) / Float64(d_m + d_m))
	t_1 = Float64((Float64(d_m / h) ^ Float64(1.0 / 2.0)) * (Float64(d_m / l) ^ Float64(1.0 / 2.0)))
	t_2 = Float64(t_1 * 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_2 <= -5e-252)
		tmp = Float64(t_1 * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * Float64(Float64(t_0 * Float64(M * D)) / Float64(d_m + d_m))) * Float64(h / l))));
	elseif (t_2 <= Inf)
		tmp = Float64(Float64(Float64(sqrt(Float64(1.0 / h)) / sqrt(l)) * d_m) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * Float64(t_0 * t_0)) * Float64(h / l))));
	else
		tmp = Float64(Float64(sqrt(Float64(1.0 / Float64(l * h))) * d_m) * Float64(Float64(l - Float64(Float64(0.125 / d_m) * Float64(Float64(Float64(M * D) * Float64(Float64(M * D) * h)) / d_m))) / 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);
	t_1 = ((d_m / h) ^ (1.0 / 2.0)) * ((d_m / l) ^ (1.0 / 2.0));
	t_2 = t_1 * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d_m)) ^ 2.0)) * (h / l)));
	tmp = 0.0;
	if (t_2 <= -5e-252)
		tmp = t_1 * (1.0 - (((1.0 / 2.0) * ((t_0 * (M * D)) / (d_m + d_m))) * (h / l)));
	elseif (t_2 <= Inf)
		tmp = ((sqrt((1.0 / h)) / sqrt(l)) * d_m) * (1.0 - (((1.0 / 2.0) * (t_0 * t_0)) * (h / l)));
	else
		tmp = (sqrt((1.0 / (l * h))) * d_m) * ((l - ((0.125 / d_m) * (((M * D) * ((M * D) * h)) / d_m))) / 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[(N[(M * D), $MachinePrecision] / N[(d$95$m + d$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = 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]}, Block[{t$95$2 = N[(t$95$1 * 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$2, -5e-252], N[(t$95$1 * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[(N[(t$95$0 * N[(M * D), $MachinePrecision]), $MachinePrecision] / N[(d$95$m + d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, Infinity], N[(N[(N[(N[Sqrt[N[(1.0 / h), $MachinePrecision]], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] * d$95$m), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision] * N[(N[(l - N[(N[(0.125 / d$95$m), $MachinePrecision] * N[(N[(N[(M * D), $MachinePrecision] * N[(N[(M * D), $MachinePrecision] * h), $MachinePrecision]), $MachinePrecision] / d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
d_m = \left|d\right|

\\
\begin{array}{l}
t_0 := \frac{M \cdot D}{d\_m + d\_m}\\
t_1 := {\left(\frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d\_m}{\ell}\right)}^{\left(\frac{1}{2}\right)}\\
t_2 := t\_1 \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\_2 \leq -5 \cdot 10^{-252}:\\
\;\;\;\;t\_1 \cdot \left(1 - \left(\frac{1}{2} \cdot \frac{t\_0 \cdot \left(M \cdot D\right)}{d\_m + d\_m}\right) \cdot \frac{h}{\ell}\right)\\

\mathbf{elif}\;t\_2 \leq \infty:\\
\;\;\;\;\left(\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}} \cdot d\_m\right) \cdot \left(1 - \left(\frac{1}{2} \cdot \left(t\_0 \cdot t\_0\right)\right) \cdot \frac{h}{\ell}\right)\\

\mathbf{else}:\\
\;\;\;\;\left(\sqrt{\frac{1}{\ell \cdot h}} \cdot d\_m\right) \cdot \frac{\ell - \frac{0.125}{d\_m} \cdot \frac{\left(M \cdot D\right) \cdot \left(\left(M \cdot D\right) \cdot h\right)}{d\_m}}{\ell}\\


\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)))) < -5.00000000000000008e-252

    1. Initial program 85.9%

      \[\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. Applied rewrites84.1%

      \[\leadsto \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 \color{blue}{\frac{\frac{M \cdot D}{d + d} \cdot \left(M \cdot D\right)}{d + d}}\right) \cdot \frac{h}{\ell}\right) \]

    if -5.00000000000000008e-252 < (*.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 79.1%

      \[\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. Applied rewrites82.0%

      \[\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) \]
    4. Applied rewrites82.0%

      \[\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}{d + d} \cdot \frac{M \cdot D}{d + d}\right)}\right) \cdot \frac{h}{\ell}\right) \]
    5. Applied rewrites88.8%

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

    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 0.0%

      \[\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. Applied rewrites58.9%

      \[\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) \]
    4. Taylor expanded in l around 0

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

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

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

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

Alternative 2: 76.3% accurate, 0.6× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} t_0 := \frac{M \cdot D}{d\_m + d\_m}\\ \mathbf{if}\;\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) \leq \infty:\\ \;\;\;\;\left(\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}} \cdot d\_m\right) \cdot \left(1 - \left(\frac{1}{2} \cdot \left(t\_0 \cdot t\_0\right)\right) \cdot \frac{h}{\ell}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\sqrt{\frac{1}{\ell \cdot h}} \cdot d\_m\right) \cdot \frac{\ell - \frac{0.125}{d\_m} \cdot \frac{\left(M \cdot D\right) \cdot \left(\left(M \cdot D\right) \cdot h\right)}{d\_m}}{\ell}\\ \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 (<=
        (*
         (* (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))))
        INFINITY)
     (*
      (* (/ (sqrt (/ 1.0 h)) (sqrt l)) d_m)
      (- 1.0 (* (* (/ 1.0 2.0) (* t_0 t_0)) (/ h l))))
     (*
      (* (sqrt (/ 1.0 (* l h))) d_m)
      (/ (- l (* (/ 0.125 d_m) (/ (* (* M D) (* (* M D) h)) d_m))) 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 (((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) INFINITY)) {
		tmp = ((sqrt((1.0 / h)) / sqrt(l)) * d_m) * (1.0 - (((1.0 / 2.0) * (t_0 * t_0)) * (h / l)));
	} else {
		tmp = (sqrt((1.0 / (l * h))) * d_m) * ((l - ((0.125 / d_m) * (((M * D) * ((M * D) * h)) / d_m))) / l);
	}
	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 = (M * D) / (d_m + d_m);
	double tmp;
	if (((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.POSITIVE_INFINITY) {
		tmp = ((Math.sqrt((1.0 / h)) / Math.sqrt(l)) * d_m) * (1.0 - (((1.0 / 2.0) * (t_0 * t_0)) * (h / l)));
	} else {
		tmp = (Math.sqrt((1.0 / (l * h))) * d_m) * ((l - ((0.125 / d_m) * (((M * D) * ((M * D) * h)) / d_m))) / 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 ((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)))) <= math.inf:
		tmp = ((math.sqrt((1.0 / h)) / math.sqrt(l)) * d_m) * (1.0 - (((1.0 / 2.0) * (t_0 * t_0)) * (h / l)))
	else:
		tmp = (math.sqrt((1.0 / (l * h))) * d_m) * ((l - ((0.125 / d_m) * (((M * D) * ((M * D) * h)) / d_m))) / l)
	return tmp
d_m = abs(d)
function code(d_m, h, l, M, D)
	t_0 = Float64(Float64(M * D) / Float64(d_m + d_m))
	tmp = 0.0
	if (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)))) <= Inf)
		tmp = Float64(Float64(Float64(sqrt(Float64(1.0 / h)) / sqrt(l)) * d_m) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * Float64(t_0 * t_0)) * Float64(h / l))));
	else
		tmp = Float64(Float64(sqrt(Float64(1.0 / Float64(l * h))) * d_m) * Float64(Float64(l - Float64(Float64(0.125 / d_m) * Float64(Float64(Float64(M * D) * Float64(Float64(M * D) * h)) / d_m))) / 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 (((((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)))) <= Inf)
		tmp = ((sqrt((1.0 / h)) / sqrt(l)) * d_m) * (1.0 - (((1.0 / 2.0) * (t_0 * t_0)) * (h / l)));
	else
		tmp = (sqrt((1.0 / (l * h))) * d_m) * ((l - ((0.125 / d_m) * (((M * D) * ((M * D) * h)) / d_m))) / 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[(N[(M * D), $MachinePrecision] / N[(d$95$m + d$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[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], Infinity], N[(N[(N[(N[Sqrt[N[(1.0 / h), $MachinePrecision]], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] * d$95$m), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision] * N[(N[(l - N[(N[(0.125 / d$95$m), $MachinePrecision] * N[(N[(N[(M * D), $MachinePrecision] * N[(N[(M * D), $MachinePrecision] * h), $MachinePrecision]), $MachinePrecision] / d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
d_m = \left|d\right|

\\
\begin{array}{l}
t_0 := \frac{M \cdot D}{d\_m + d\_m}\\
\mathbf{if}\;\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) \leq \infty:\\
\;\;\;\;\left(\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}} \cdot d\_m\right) \cdot \left(1 - \left(\frac{1}{2} \cdot \left(t\_0 \cdot t\_0\right)\right) \cdot \frac{h}{\ell}\right)\\

\mathbf{else}:\\
\;\;\;\;\left(\sqrt{\frac{1}{\ell \cdot h}} \cdot d\_m\right) \cdot \frac{\ell - \frac{0.125}{d\_m} \cdot \frac{\left(M \cdot D\right) \cdot \left(\left(M \cdot D\right) \cdot h\right)}{d\_m}}{\ell}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 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)))) < +inf.0

    1. Initial program 81.7%

      \[\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. Applied rewrites80.1%

      \[\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) \]
    4. Applied rewrites80.1%

      \[\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}{d + d} \cdot \frac{M \cdot D}{d + d}\right)}\right) \cdot \frac{h}{\ell}\right) \]
    5. Applied rewrites86.7%

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

    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 0.0%

      \[\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. Applied rewrites58.9%

      \[\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) \]
    4. Taylor expanded in l around 0

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

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

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

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

Alternative 3: 74.8% accurate, 1.9× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} t_0 := \frac{\ell - \frac{0.125}{d\_m} \cdot \frac{\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot h}{d\_m}}{\ell}\\ \mathbf{if}\;\ell \leq 7.5 \cdot 10^{-280}:\\ \;\;\;\;\left(\sqrt{\frac{1}{\ell \cdot h}} \cdot d\_m\right) \cdot t\_0\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}} \cdot d\_m\right) \cdot t\_0\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
(FPCore (d_m h l M D)
 :precision binary64
 (let* ((t_0 (/ (- l (* (/ 0.125 d_m) (/ (* (* (* M D) (* M D)) h) d_m))) l)))
   (if (<= l 7.5e-280)
     (* (* (sqrt (/ 1.0 (* l h))) d_m) t_0)
     (* (* (/ (sqrt (/ 1.0 l)) (sqrt h)) d_m) t_0))))
d_m = fabs(d);
double code(double d_m, double h, double l, double M, double D) {
	double t_0 = (l - ((0.125 / d_m) * ((((M * D) * (M * D)) * h) / d_m))) / l;
	double tmp;
	if (l <= 7.5e-280) {
		tmp = (sqrt((1.0 / (l * h))) * d_m) * t_0;
	} else {
		tmp = ((sqrt((1.0 / l)) / sqrt(h)) * d_m) * t_0;
	}
	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 = (l - ((0.125d0 / d_m) * ((((m * d) * (m * d)) * h) / d_m))) / l
    if (l <= 7.5d-280) then
        tmp = (sqrt((1.0d0 / (l * h))) * d_m) * t_0
    else
        tmp = ((sqrt((1.0d0 / l)) / sqrt(h)) * d_m) * t_0
    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 = (l - ((0.125 / d_m) * ((((M * D) * (M * D)) * h) / d_m))) / l;
	double tmp;
	if (l <= 7.5e-280) {
		tmp = (Math.sqrt((1.0 / (l * h))) * d_m) * t_0;
	} else {
		tmp = ((Math.sqrt((1.0 / l)) / Math.sqrt(h)) * d_m) * t_0;
	}
	return tmp;
}
d_m = math.fabs(d)
def code(d_m, h, l, M, D):
	t_0 = (l - ((0.125 / d_m) * ((((M * D) * (M * D)) * h) / d_m))) / l
	tmp = 0
	if l <= 7.5e-280:
		tmp = (math.sqrt((1.0 / (l * h))) * d_m) * t_0
	else:
		tmp = ((math.sqrt((1.0 / l)) / math.sqrt(h)) * d_m) * t_0
	return tmp
d_m = abs(d)
function code(d_m, h, l, M, D)
	t_0 = Float64(Float64(l - Float64(Float64(0.125 / d_m) * Float64(Float64(Float64(Float64(M * D) * Float64(M * D)) * h) / d_m))) / l)
	tmp = 0.0
	if (l <= 7.5e-280)
		tmp = Float64(Float64(sqrt(Float64(1.0 / Float64(l * h))) * d_m) * t_0);
	else
		tmp = Float64(Float64(Float64(sqrt(Float64(1.0 / l)) / sqrt(h)) * d_m) * t_0);
	end
	return tmp
end
d_m = abs(d);
function tmp_2 = code(d_m, h, l, M, D)
	t_0 = (l - ((0.125 / d_m) * ((((M * D) * (M * D)) * h) / d_m))) / l;
	tmp = 0.0;
	if (l <= 7.5e-280)
		tmp = (sqrt((1.0 / (l * h))) * d_m) * t_0;
	else
		tmp = ((sqrt((1.0 / l)) / sqrt(h)) * d_m) * t_0;
	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[(l - N[(N[(0.125 / d$95$m), $MachinePrecision] * N[(N[(N[(N[(M * D), $MachinePrecision] * N[(M * D), $MachinePrecision]), $MachinePrecision] * h), $MachinePrecision] / d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]}, If[LessEqual[l, 7.5e-280], N[(N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[(N[(N[Sqrt[N[(1.0 / l), $MachinePrecision]], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * d$95$m), $MachinePrecision] * t$95$0), $MachinePrecision]]]
\begin{array}{l}
d_m = \left|d\right|

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < 7.4999999999999999e-280

    1. Initial program 8.7%

      \[\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. Applied rewrites68.7%

      \[\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) \]
    4. Taylor expanded in l around 0

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

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

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

    if 7.4999999999999999e-280 < l

    1. Initial program 65.6%

      \[\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. Applied rewrites67.9%

      \[\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) \]
    4. Taylor expanded in l around 0

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

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

      \[\leadsto \left(\sqrt{\frac{1}{\ell \cdot h}} \cdot d\right) \cdot \frac{\ell - \frac{0.125}{d} \cdot \frac{\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot h}{d}}{\ell} \]
    7. Applied rewrites78.3%

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

Alternative 4: 74.6% accurate, 0.4× 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 := \sqrt{\frac{1}{\ell \cdot h}} \cdot d\_m\\ \mathbf{if}\;t\_0 \leq 5 \cdot 10^{-161}:\\ \;\;\;\;t\_1 \cdot \frac{\ell - \frac{0.125}{d\_m} \cdot \frac{\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot h}{d\_m}}{\ell}\\ \mathbf{elif}\;t\_0 \leq 10^{+130}:\\ \;\;\;\;{\left(\frac{d\_m}{\ell} \cdot \frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot 1\\ \mathbf{else}:\\ \;\;\;\;t\_1 \cdot \frac{\ell - \frac{0.125}{d\_m} \cdot \frac{\left(M \cdot D\right) \cdot \left(\left(M \cdot D\right) \cdot h\right)}{d\_m}}{\ell}\\ \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 (* (sqrt (/ 1.0 (* l h))) d_m)))
   (if (<= t_0 5e-161)
     (* t_1 (/ (- l (* (/ 0.125 d_m) (/ (* (* (* M D) (* M D)) h) d_m))) l))
     (if (<= t_0 1e+130)
       (* (pow (* (/ d_m l) (/ d_m h)) (/ 1.0 2.0)) 1.0)
       (*
        t_1
        (/ (- l (* (/ 0.125 d_m) (/ (* (* M D) (* (* M D) h)) d_m))) l))))))
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 = sqrt((1.0 / (l * h))) * d_m;
	double tmp;
	if (t_0 <= 5e-161) {
		tmp = t_1 * ((l - ((0.125 / d_m) * ((((M * D) * (M * D)) * h) / d_m))) / l);
	} else if (t_0 <= 1e+130) {
		tmp = pow(((d_m / l) * (d_m / h)), (1.0 / 2.0)) * 1.0;
	} else {
		tmp = t_1 * ((l - ((0.125 / d_m) * (((M * D) * ((M * D) * h)) / d_m))) / 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) :: tmp
    t_0 = (((d_m / h) ** (1.0d0 / 2.0d0)) * ((d_m / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d) / (2.0d0 * d_m)) ** 2.0d0)) * (h / l)))
    t_1 = sqrt((1.0d0 / (l * h))) * d_m
    if (t_0 <= 5d-161) then
        tmp = t_1 * ((l - ((0.125d0 / d_m) * ((((m * d) * (m * d)) * h) / d_m))) / l)
    else if (t_0 <= 1d+130) then
        tmp = (((d_m / l) * (d_m / h)) ** (1.0d0 / 2.0d0)) * 1.0d0
    else
        tmp = t_1 * ((l - ((0.125d0 / d_m) * (((m * d) * ((m * d) * h)) / d_m))) / 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 = (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 = Math.sqrt((1.0 / (l * h))) * d_m;
	double tmp;
	if (t_0 <= 5e-161) {
		tmp = t_1 * ((l - ((0.125 / d_m) * ((((M * D) * (M * D)) * h) / d_m))) / l);
	} else if (t_0 <= 1e+130) {
		tmp = Math.pow(((d_m / l) * (d_m / h)), (1.0 / 2.0)) * 1.0;
	} else {
		tmp = t_1 * ((l - ((0.125 / d_m) * (((M * D) * ((M * D) * h)) / d_m))) / l);
	}
	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 = math.sqrt((1.0 / (l * h))) * d_m
	tmp = 0
	if t_0 <= 5e-161:
		tmp = t_1 * ((l - ((0.125 / d_m) * ((((M * D) * (M * D)) * h) / d_m))) / l)
	elif t_0 <= 1e+130:
		tmp = math.pow(((d_m / l) * (d_m / h)), (1.0 / 2.0)) * 1.0
	else:
		tmp = t_1 * ((l - ((0.125 / d_m) * (((M * D) * ((M * D) * h)) / d_m))) / l)
	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(sqrt(Float64(1.0 / Float64(l * h))) * d_m)
	tmp = 0.0
	if (t_0 <= 5e-161)
		tmp = Float64(t_1 * Float64(Float64(l - Float64(Float64(0.125 / d_m) * Float64(Float64(Float64(Float64(M * D) * Float64(M * D)) * h) / d_m))) / l));
	elseif (t_0 <= 1e+130)
		tmp = Float64((Float64(Float64(d_m / l) * Float64(d_m / h)) ^ Float64(1.0 / 2.0)) * 1.0);
	else
		tmp = Float64(t_1 * Float64(Float64(l - Float64(Float64(0.125 / d_m) * Float64(Float64(Float64(M * D) * Float64(Float64(M * D) * h)) / d_m))) / l));
	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 = sqrt((1.0 / (l * h))) * d_m;
	tmp = 0.0;
	if (t_0 <= 5e-161)
		tmp = t_1 * ((l - ((0.125 / d_m) * ((((M * D) * (M * D)) * h) / d_m))) / l);
	elseif (t_0 <= 1e+130)
		tmp = (((d_m / l) * (d_m / h)) ^ (1.0 / 2.0)) * 1.0;
	else
		tmp = t_1 * ((l - ((0.125 / d_m) * (((M * D) * ((M * D) * h)) / d_m))) / 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[(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 = N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision]}, If[LessEqual[t$95$0, 5e-161], N[(t$95$1 * N[(N[(l - N[(N[(0.125 / d$95$m), $MachinePrecision] * N[(N[(N[(N[(M * D), $MachinePrecision] * N[(M * D), $MachinePrecision]), $MachinePrecision] * h), $MachinePrecision] / d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e+130], N[(N[Power[N[(N[(d$95$m / l), $MachinePrecision] * N[(d$95$m / h), $MachinePrecision]), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision], N[(t$95$1 * N[(N[(l - N[(N[(0.125 / d$95$m), $MachinePrecision] * N[(N[(N[(M * D), $MachinePrecision] * N[(N[(M * D), $MachinePrecision] * h), $MachinePrecision]), $MachinePrecision] / d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $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 := \sqrt{\frac{1}{\ell \cdot h}} \cdot d\_m\\
\mathbf{if}\;t\_0 \leq 5 \cdot 10^{-161}:\\
\;\;\;\;t\_1 \cdot \frac{\ell - \frac{0.125}{d\_m} \cdot \frac{\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot h}{d\_m}}{\ell}\\

\mathbf{elif}\;t\_0 \leq 10^{+130}:\\
\;\;\;\;{\left(\frac{d\_m}{\ell} \cdot \frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot 1\\

\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \frac{\ell - \frac{0.125}{d\_m} \cdot \frac{\left(M \cdot D\right) \cdot \left(\left(M \cdot D\right) \cdot h\right)}{d\_m}}{\ell}\\


\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)))) < 4.9999999999999999e-161

    1. Initial program 78.7%

      \[\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. Applied rewrites76.0%

      \[\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) \]
    4. Taylor expanded in l around 0

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

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

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

    if 4.9999999999999999e-161 < (*.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.0000000000000001e130

    1. Initial program 99.0%

      \[\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. Applied rewrites57.6%

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

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

      \[\leadsto {\left(\frac{d}{\ell} \cdot \frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \color{blue}{1} \]
    5. Applied rewrites97.7%

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

    if 1.0000000000000001e130 < (*.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 12.9%

      \[\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. Applied rewrites65.1%

      \[\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) \]
    4. Taylor expanded in l around 0

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

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

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

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

Alternative 5: 74.4% accurate, 0.4× 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(\sqrt{\frac{1}{\ell \cdot h}} \cdot d\_m\right) \cdot \frac{\ell - \frac{0.125}{d\_m} \cdot \frac{\left(M \cdot D\right) \cdot \left(\left(M \cdot D\right) \cdot h\right)}{d\_m}}{\ell}\\ \mathbf{if}\;t\_0 \leq 5 \cdot 10^{-161}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 10^{+130}:\\ \;\;\;\;{\left(\frac{d\_m}{\ell} \cdot \frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot 1\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \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
         (*
          (* (sqrt (/ 1.0 (* l h))) d_m)
          (/ (- l (* (/ 0.125 d_m) (/ (* (* M D) (* (* M D) h)) d_m))) l))))
   (if (<= t_0 5e-161)
     t_1
     (if (<= t_0 1e+130)
       (* (pow (* (/ d_m l) (/ d_m h)) (/ 1.0 2.0)) 1.0)
       t_1))))
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 = (sqrt((1.0 / (l * h))) * d_m) * ((l - ((0.125 / d_m) * (((M * D) * ((M * D) * h)) / d_m))) / l);
	double tmp;
	if (t_0 <= 5e-161) {
		tmp = t_1;
	} else if (t_0 <= 1e+130) {
		tmp = pow(((d_m / l) * (d_m / h)), (1.0 / 2.0)) * 1.0;
	} else {
		tmp = 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 = (((d_m / h) ** (1.0d0 / 2.0d0)) * ((d_m / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d) / (2.0d0 * d_m)) ** 2.0d0)) * (h / l)))
    t_1 = (sqrt((1.0d0 / (l * h))) * d_m) * ((l - ((0.125d0 / d_m) * (((m * d) * ((m * d) * h)) / d_m))) / l)
    if (t_0 <= 5d-161) then
        tmp = t_1
    else if (t_0 <= 1d+130) then
        tmp = (((d_m / l) * (d_m / h)) ** (1.0d0 / 2.0d0)) * 1.0d0
    else
        tmp = 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 = (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 = (Math.sqrt((1.0 / (l * h))) * d_m) * ((l - ((0.125 / d_m) * (((M * D) * ((M * D) * h)) / d_m))) / l);
	double tmp;
	if (t_0 <= 5e-161) {
		tmp = t_1;
	} else if (t_0 <= 1e+130) {
		tmp = Math.pow(((d_m / l) * (d_m / h)), (1.0 / 2.0)) * 1.0;
	} else {
		tmp = t_1;
	}
	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 = (math.sqrt((1.0 / (l * h))) * d_m) * ((l - ((0.125 / d_m) * (((M * D) * ((M * D) * h)) / d_m))) / l)
	tmp = 0
	if t_0 <= 5e-161:
		tmp = t_1
	elif t_0 <= 1e+130:
		tmp = math.pow(((d_m / l) * (d_m / h)), (1.0 / 2.0)) * 1.0
	else:
		tmp = t_1
	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(sqrt(Float64(1.0 / Float64(l * h))) * d_m) * Float64(Float64(l - Float64(Float64(0.125 / d_m) * Float64(Float64(Float64(M * D) * Float64(Float64(M * D) * h)) / d_m))) / l))
	tmp = 0.0
	if (t_0 <= 5e-161)
		tmp = t_1;
	elseif (t_0 <= 1e+130)
		tmp = Float64((Float64(Float64(d_m / l) * Float64(d_m / h)) ^ Float64(1.0 / 2.0)) * 1.0);
	else
		tmp = t_1;
	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 = (sqrt((1.0 / (l * h))) * d_m) * ((l - ((0.125 / d_m) * (((M * D) * ((M * D) * h)) / d_m))) / l);
	tmp = 0.0;
	if (t_0 <= 5e-161)
		tmp = t_1;
	elseif (t_0 <= 1e+130)
		tmp = (((d_m / l) * (d_m / h)) ^ (1.0 / 2.0)) * 1.0;
	else
		tmp = 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[(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 = N[(N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision] * N[(N[(l - N[(N[(0.125 / d$95$m), $MachinePrecision] * N[(N[(N[(M * D), $MachinePrecision] * N[(N[(M * D), $MachinePrecision] * h), $MachinePrecision]), $MachinePrecision] / d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 5e-161], t$95$1, If[LessEqual[t$95$0, 1e+130], N[(N[Power[N[(N[(d$95$m / l), $MachinePrecision] * N[(d$95$m / h), $MachinePrecision]), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision], t$95$1]]]]
\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(\sqrt{\frac{1}{\ell \cdot h}} \cdot d\_m\right) \cdot \frac{\ell - \frac{0.125}{d\_m} \cdot \frac{\left(M \cdot D\right) \cdot \left(\left(M \cdot D\right) \cdot h\right)}{d\_m}}{\ell}\\
\mathbf{if}\;t\_0 \leq 5 \cdot 10^{-161}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_0 \leq 10^{+130}:\\
\;\;\;\;{\left(\frac{d\_m}{\ell} \cdot \frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot 1\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 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)))) < 4.9999999999999999e-161 or 1.0000000000000001e130 < (*.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 29.5%

      \[\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. Applied rewrites67.8%

      \[\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) \]
    4. Taylor expanded in l around 0

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

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

      \[\leadsto \left(\sqrt{\frac{1}{\ell \cdot h}} \cdot d\right) \cdot \frac{\ell - \frac{0.125}{d} \cdot \frac{\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot h}{d}}{\ell} \]
    7. Applied rewrites72.3%

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

    if 4.9999999999999999e-161 < (*.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.0000000000000001e130

    1. Initial program 99.0%

      \[\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. Applied rewrites57.6%

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

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

      \[\leadsto {\left(\frac{d}{\ell} \cdot \frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \color{blue}{1} \]
    5. Applied rewrites97.7%

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

Alternative 6: 57.1% accurate, 1.7× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} t_0 := \left(M \cdot D\right) \cdot \left(M \cdot D\right)\\ t_1 := \sqrt{\frac{1}{\ell \cdot h}} \cdot d\_m\\ \mathbf{if}\;M \cdot D \leq 5 \cdot 10^{-149}:\\ \;\;\;\;\frac{\sqrt{1}}{\sqrt{\ell \cdot h}} \cdot d\_m\\ \mathbf{elif}\;M \cdot D \leq 5 \cdot 10^{+143}:\\ \;\;\;\;t\_1 \cdot \frac{\ell - \frac{0.125}{d\_m} \cdot \left(t\_0 \cdot \frac{h}{d\_m}\right)}{\ell}\\ \mathbf{else}:\\ \;\;\;\;t\_1 \cdot \frac{\frac{-0.125}{d\_m} \cdot \frac{t\_0 \cdot h}{d\_m}}{\ell}\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
(FPCore (d_m h l M D)
 :precision binary64
 (let* ((t_0 (* (* M D) (* M D))) (t_1 (* (sqrt (/ 1.0 (* l h))) d_m)))
   (if (<= (* M D) 5e-149)
     (* (/ (sqrt 1.0) (sqrt (* l h))) d_m)
     (if (<= (* M D) 5e+143)
       (* t_1 (/ (- l (* (/ 0.125 d_m) (* t_0 (/ h d_m)))) l))
       (* t_1 (/ (* (/ -0.125 d_m) (/ (* t_0 h) d_m)) l))))))
d_m = fabs(d);
double code(double d_m, double h, double l, double M, double D) {
	double t_0 = (M * D) * (M * D);
	double t_1 = sqrt((1.0 / (l * h))) * d_m;
	double tmp;
	if ((M * D) <= 5e-149) {
		tmp = (sqrt(1.0) / sqrt((l * h))) * d_m;
	} else if ((M * D) <= 5e+143) {
		tmp = t_1 * ((l - ((0.125 / d_m) * (t_0 * (h / d_m)))) / l);
	} else {
		tmp = t_1 * (((-0.125 / d_m) * ((t_0 * h) / d_m)) / 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) :: tmp
    t_0 = (m * d) * (m * d)
    t_1 = sqrt((1.0d0 / (l * h))) * d_m
    if ((m * d) <= 5d-149) then
        tmp = (sqrt(1.0d0) / sqrt((l * h))) * d_m
    else if ((m * d) <= 5d+143) then
        tmp = t_1 * ((l - ((0.125d0 / d_m) * (t_0 * (h / d_m)))) / l)
    else
        tmp = t_1 * ((((-0.125d0) / d_m) * ((t_0 * h) / d_m)) / 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) * (M * D);
	double t_1 = Math.sqrt((1.0 / (l * h))) * d_m;
	double tmp;
	if ((M * D) <= 5e-149) {
		tmp = (Math.sqrt(1.0) / Math.sqrt((l * h))) * d_m;
	} else if ((M * D) <= 5e+143) {
		tmp = t_1 * ((l - ((0.125 / d_m) * (t_0 * (h / d_m)))) / l);
	} else {
		tmp = t_1 * (((-0.125 / d_m) * ((t_0 * h) / d_m)) / l);
	}
	return tmp;
}
d_m = math.fabs(d)
def code(d_m, h, l, M, D):
	t_0 = (M * D) * (M * D)
	t_1 = math.sqrt((1.0 / (l * h))) * d_m
	tmp = 0
	if (M * D) <= 5e-149:
		tmp = (math.sqrt(1.0) / math.sqrt((l * h))) * d_m
	elif (M * D) <= 5e+143:
		tmp = t_1 * ((l - ((0.125 / d_m) * (t_0 * (h / d_m)))) / l)
	else:
		tmp = t_1 * (((-0.125 / d_m) * ((t_0 * h) / d_m)) / l)
	return tmp
d_m = abs(d)
function code(d_m, h, l, M, D)
	t_0 = Float64(Float64(M * D) * Float64(M * D))
	t_1 = Float64(sqrt(Float64(1.0 / Float64(l * h))) * d_m)
	tmp = 0.0
	if (Float64(M * D) <= 5e-149)
		tmp = Float64(Float64(sqrt(1.0) / sqrt(Float64(l * h))) * d_m);
	elseif (Float64(M * D) <= 5e+143)
		tmp = Float64(t_1 * Float64(Float64(l - Float64(Float64(0.125 / d_m) * Float64(t_0 * Float64(h / d_m)))) / l));
	else
		tmp = Float64(t_1 * Float64(Float64(Float64(-0.125 / d_m) * Float64(Float64(t_0 * h) / d_m)) / l));
	end
	return tmp
end
d_m = abs(d);
function tmp_2 = code(d_m, h, l, M, D)
	t_0 = (M * D) * (M * D);
	t_1 = sqrt((1.0 / (l * h))) * d_m;
	tmp = 0.0;
	if ((M * D) <= 5e-149)
		tmp = (sqrt(1.0) / sqrt((l * h))) * d_m;
	elseif ((M * D) <= 5e+143)
		tmp = t_1 * ((l - ((0.125 / d_m) * (t_0 * (h / d_m)))) / l);
	else
		tmp = t_1 * (((-0.125 / d_m) * ((t_0 * h) / d_m)) / 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[(N[(M * D), $MachinePrecision] * N[(M * D), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision]}, If[LessEqual[N[(M * D), $MachinePrecision], 5e-149], N[(N[(N[Sqrt[1.0], $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * d$95$m), $MachinePrecision], If[LessEqual[N[(M * D), $MachinePrecision], 5e+143], N[(t$95$1 * N[(N[(l - N[(N[(0.125 / d$95$m), $MachinePrecision] * N[(t$95$0 * N[(h / d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(N[(N[(-0.125 / d$95$m), $MachinePrecision] * N[(N[(t$95$0 * h), $MachinePrecision] / d$95$m), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
d_m = \left|d\right|

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

\mathbf{elif}\;M \cdot D \leq 5 \cdot 10^{+143}:\\
\;\;\;\;t\_1 \cdot \frac{\ell - \frac{0.125}{d\_m} \cdot \left(t\_0 \cdot \frac{h}{d\_m}\right)}{\ell}\\

\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \frac{\frac{-0.125}{d\_m} \cdot \frac{t\_0 \cdot h}{d\_m}}{\ell}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 M D) < 4.99999999999999968e-149

    1. Initial program 37.3%

      \[\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}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    3. Applied rewrites50.3%

      \[\leadsto \color{blue}{\sqrt{\frac{1}{\ell \cdot h}} \cdot d} \]
    4. Applied rewrites50.5%

      \[\leadsto \frac{\sqrt{1}}{\sqrt{\ell \cdot h}} \cdot d \]

    if 4.99999999999999968e-149 < (*.f64 M D) < 5.00000000000000012e143

    1. Initial program 34.5%

      \[\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. Applied rewrites67.4%

      \[\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) \]
    4. Taylor expanded in l around 0

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

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

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

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

    if 5.00000000000000012e143 < (*.f64 M D)

    1. Initial program 35.6%

      \[\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. Applied rewrites69.4%

      \[\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) \]
    4. Taylor expanded in l around 0

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

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

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

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

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

Alternative 7: 55.2% accurate, 1.5× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} t_0 := \sqrt{\frac{1}{\ell \cdot h}} \cdot d\_m\\ t_1 := \left(M \cdot D\right) \cdot \left(M \cdot D\right)\\ \mathbf{if}\;M \cdot D \leq 2.5 \cdot 10^{-141}:\\ \;\;\;\;\frac{\sqrt{1}}{\sqrt{\ell \cdot h}} \cdot d\_m\\ \mathbf{elif}\;M \cdot D \leq 10^{+35}:\\ \;\;\;\;t\_0 \cdot \mathsf{fma}\left(\frac{-0.125 \cdot t\_1}{\left(d\_m \cdot d\_m\right) \cdot \ell}, h, 1\right)\\ \mathbf{elif}\;M \cdot D \leq 5 \cdot 10^{+260}:\\ \;\;\;\;\frac{t\_1 \cdot -0.125}{d\_m} \cdot \sqrt{\frac{h}{\left(\ell \cdot \ell\right) \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;t\_0 \cdot \frac{\frac{-0.125}{d\_m} \cdot \frac{t\_1 \cdot h}{d\_m}}{\ell}\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
(FPCore (d_m h l M D)
 :precision binary64
 (let* ((t_0 (* (sqrt (/ 1.0 (* l h))) d_m)) (t_1 (* (* M D) (* M D))))
   (if (<= (* M D) 2.5e-141)
     (* (/ (sqrt 1.0) (sqrt (* l h))) d_m)
     (if (<= (* M D) 1e+35)
       (* t_0 (fma (/ (* -0.125 t_1) (* (* d_m d_m) l)) h 1.0))
       (if (<= (* M D) 5e+260)
         (* (/ (* t_1 -0.125) d_m) (sqrt (/ h (* (* l l) l))))
         (* t_0 (/ (* (/ -0.125 d_m) (/ (* t_1 h) d_m)) l)))))))
d_m = fabs(d);
double code(double d_m, double h, double l, double M, double D) {
	double t_0 = sqrt((1.0 / (l * h))) * d_m;
	double t_1 = (M * D) * (M * D);
	double tmp;
	if ((M * D) <= 2.5e-141) {
		tmp = (sqrt(1.0) / sqrt((l * h))) * d_m;
	} else if ((M * D) <= 1e+35) {
		tmp = t_0 * fma(((-0.125 * t_1) / ((d_m * d_m) * l)), h, 1.0);
	} else if ((M * D) <= 5e+260) {
		tmp = ((t_1 * -0.125) / d_m) * sqrt((h / ((l * l) * l)));
	} else {
		tmp = t_0 * (((-0.125 / d_m) * ((t_1 * h) / d_m)) / l);
	}
	return tmp;
}
d_m = abs(d)
function code(d_m, h, l, M, D)
	t_0 = Float64(sqrt(Float64(1.0 / Float64(l * h))) * d_m)
	t_1 = Float64(Float64(M * D) * Float64(M * D))
	tmp = 0.0
	if (Float64(M * D) <= 2.5e-141)
		tmp = Float64(Float64(sqrt(1.0) / sqrt(Float64(l * h))) * d_m);
	elseif (Float64(M * D) <= 1e+35)
		tmp = Float64(t_0 * fma(Float64(Float64(-0.125 * t_1) / Float64(Float64(d_m * d_m) * l)), h, 1.0));
	elseif (Float64(M * D) <= 5e+260)
		tmp = Float64(Float64(Float64(t_1 * -0.125) / d_m) * sqrt(Float64(h / Float64(Float64(l * l) * l))));
	else
		tmp = Float64(t_0 * Float64(Float64(Float64(-0.125 / d_m) * Float64(Float64(t_1 * h) / d_m)) / l));
	end
	return tmp
end
d_m = N[Abs[d], $MachinePrecision]
code[d$95$m_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision]}, Block[{t$95$1 = N[(N[(M * D), $MachinePrecision] * N[(M * D), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(M * D), $MachinePrecision], 2.5e-141], N[(N[(N[Sqrt[1.0], $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * d$95$m), $MachinePrecision], If[LessEqual[N[(M * D), $MachinePrecision], 1e+35], N[(t$95$0 * N[(N[(N[(-0.125 * t$95$1), $MachinePrecision] / N[(N[(d$95$m * d$95$m), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * h + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(M * D), $MachinePrecision], 5e+260], N[(N[(N[(t$95$1 * -0.125), $MachinePrecision] / d$95$m), $MachinePrecision] * N[Sqrt[N[(h / N[(N[(l * l), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(N[(N[(-0.125 / d$95$m), $MachinePrecision] * N[(N[(t$95$1 * h), $MachinePrecision] / d$95$m), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
d_m = \left|d\right|

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

\mathbf{elif}\;M \cdot D \leq 10^{+35}:\\
\;\;\;\;t\_0 \cdot \mathsf{fma}\left(\frac{-0.125 \cdot t\_1}{\left(d\_m \cdot d\_m\right) \cdot \ell}, h, 1\right)\\

\mathbf{elif}\;M \cdot D \leq 5 \cdot 10^{+260}:\\
\;\;\;\;\frac{t\_1 \cdot -0.125}{d\_m} \cdot \sqrt{\frac{h}{\left(\ell \cdot \ell\right) \cdot \ell}}\\

\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \frac{\frac{-0.125}{d\_m} \cdot \frac{t\_1 \cdot h}{d\_m}}{\ell}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (*.f64 M D) < 2.5e-141

    1. Initial program 37.3%

      \[\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}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    3. Applied rewrites50.3%

      \[\leadsto \color{blue}{\sqrt{\frac{1}{\ell \cdot h}} \cdot d} \]
    4. Applied rewrites50.5%

      \[\leadsto \frac{\sqrt{1}}{\sqrt{\ell \cdot h}} \cdot d \]

    if 2.5e-141 < (*.f64 M D) < 9.9999999999999997e34

    1. Initial program 33.3%

      \[\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. Applied rewrites66.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) \]
    4. Taylor expanded in h around inf

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

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

    if 9.9999999999999997e34 < (*.f64 M D) < 4.9999999999999996e260

    1. Initial program 35.5%

      \[\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. Applied rewrites45.0%

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

    if 4.9999999999999996e260 < (*.f64 M D)

    1. Initial program 36.2%

      \[\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. Applied rewrites69.1%

      \[\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) \]
    4. Taylor expanded in l around 0

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

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

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

      \[\leadsto \left(\sqrt{\frac{1}{\ell \cdot h}} \cdot d\right) \cdot \frac{\frac{-0.125 \cdot \left(\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot h\right)}{d \cdot d}}{\ell} \]
    8. Applied rewrites73.0%

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

Alternative 8: 55.2% accurate, 1.7× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} t_0 := \sqrt{\frac{1}{\ell \cdot h}} \cdot d\_m\\ t_1 := \left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot h\\ \mathbf{if}\;M \cdot D \leq 2.5 \cdot 10^{-141}:\\ \;\;\;\;\frac{\sqrt{1}}{\sqrt{\ell \cdot h}} \cdot d\_m\\ \mathbf{elif}\;M \cdot D \leq 10^{+100}:\\ \;\;\;\;t\_0 \cdot \frac{\mathsf{fma}\left(\frac{t\_1}{d\_m \cdot d\_m}, -0.125, \ell\right)}{\ell}\\ \mathbf{else}:\\ \;\;\;\;t\_0 \cdot \frac{\frac{-0.125}{d\_m} \cdot \frac{t\_1}{d\_m}}{\ell}\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
(FPCore (d_m h l M D)
 :precision binary64
 (let* ((t_0 (* (sqrt (/ 1.0 (* l h))) d_m)) (t_1 (* (* (* M D) (* M D)) h)))
   (if (<= (* M D) 2.5e-141)
     (* (/ (sqrt 1.0) (sqrt (* l h))) d_m)
     (if (<= (* M D) 1e+100)
       (* t_0 (/ (fma (/ t_1 (* d_m d_m)) -0.125 l) l))
       (* t_0 (/ (* (/ -0.125 d_m) (/ t_1 d_m)) l))))))
d_m = fabs(d);
double code(double d_m, double h, double l, double M, double D) {
	double t_0 = sqrt((1.0 / (l * h))) * d_m;
	double t_1 = ((M * D) * (M * D)) * h;
	double tmp;
	if ((M * D) <= 2.5e-141) {
		tmp = (sqrt(1.0) / sqrt((l * h))) * d_m;
	} else if ((M * D) <= 1e+100) {
		tmp = t_0 * (fma((t_1 / (d_m * d_m)), -0.125, l) / l);
	} else {
		tmp = t_0 * (((-0.125 / d_m) * (t_1 / d_m)) / l);
	}
	return tmp;
}
d_m = abs(d)
function code(d_m, h, l, M, D)
	t_0 = Float64(sqrt(Float64(1.0 / Float64(l * h))) * d_m)
	t_1 = Float64(Float64(Float64(M * D) * Float64(M * D)) * h)
	tmp = 0.0
	if (Float64(M * D) <= 2.5e-141)
		tmp = Float64(Float64(sqrt(1.0) / sqrt(Float64(l * h))) * d_m);
	elseif (Float64(M * D) <= 1e+100)
		tmp = Float64(t_0 * Float64(fma(Float64(t_1 / Float64(d_m * d_m)), -0.125, l) / l));
	else
		tmp = Float64(t_0 * Float64(Float64(Float64(-0.125 / d_m) * Float64(t_1 / d_m)) / l));
	end
	return tmp
end
d_m = N[Abs[d], $MachinePrecision]
code[d$95$m_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(M * D), $MachinePrecision] * N[(M * D), $MachinePrecision]), $MachinePrecision] * h), $MachinePrecision]}, If[LessEqual[N[(M * D), $MachinePrecision], 2.5e-141], N[(N[(N[Sqrt[1.0], $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * d$95$m), $MachinePrecision], If[LessEqual[N[(M * D), $MachinePrecision], 1e+100], N[(t$95$0 * N[(N[(N[(t$95$1 / N[(d$95$m * d$95$m), $MachinePrecision]), $MachinePrecision] * -0.125 + l), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(N[(N[(-0.125 / d$95$m), $MachinePrecision] * N[(t$95$1 / d$95$m), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
d_m = \left|d\right|

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

\mathbf{elif}\;M \cdot D \leq 10^{+100}:\\
\;\;\;\;t\_0 \cdot \frac{\mathsf{fma}\left(\frac{t\_1}{d\_m \cdot d\_m}, -0.125, \ell\right)}{\ell}\\

\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \frac{\frac{-0.125}{d\_m} \cdot \frac{t\_1}{d\_m}}{\ell}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 M D) < 2.5e-141

    1. Initial program 37.3%

      \[\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}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    3. Applied rewrites50.3%

      \[\leadsto \color{blue}{\sqrt{\frac{1}{\ell \cdot h}} \cdot d} \]
    4. Applied rewrites50.5%

      \[\leadsto \frac{\sqrt{1}}{\sqrt{\ell \cdot h}} \cdot d \]

    if 2.5e-141 < (*.f64 M D) < 1.00000000000000002e100

    1. Initial program 34.4%

      \[\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. Applied rewrites66.9%

      \[\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) \]
    4. Taylor expanded in l around 0

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

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

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

    if 1.00000000000000002e100 < (*.f64 M D)

    1. Initial program 35.4%

      \[\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. Applied rewrites69.7%

      \[\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) \]
    4. Taylor expanded in l around 0

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

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

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

      \[\leadsto \left(\sqrt{\frac{1}{\ell \cdot h}} \cdot d\right) \cdot \frac{\frac{-0.125 \cdot \left(\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot h\right)}{d \cdot d}}{\ell} \]
    8. Applied rewrites60.3%

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

Alternative 9: 53.7% accurate, 1.7× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} t_0 := \sqrt{\frac{1}{\ell \cdot h}} \cdot d\_m\\ t_1 := \left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot h\\ \mathbf{if}\;M \cdot D \leq 2.5 \cdot 10^{-141}:\\ \;\;\;\;\frac{\sqrt{1}}{\sqrt{\ell \cdot h}} \cdot d\_m\\ \mathbf{elif}\;M \cdot D \leq 10^{+100}:\\ \;\;\;\;t\_0 \cdot \mathsf{fma}\left(-0.125, \frac{t\_1}{\left(d\_m \cdot d\_m\right) \cdot \ell}, 1\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0 \cdot \frac{\frac{-0.125}{d\_m} \cdot \frac{t\_1}{d\_m}}{\ell}\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
(FPCore (d_m h l M D)
 :precision binary64
 (let* ((t_0 (* (sqrt (/ 1.0 (* l h))) d_m)) (t_1 (* (* (* M D) (* M D)) h)))
   (if (<= (* M D) 2.5e-141)
     (* (/ (sqrt 1.0) (sqrt (* l h))) d_m)
     (if (<= (* M D) 1e+100)
       (* t_0 (fma -0.125 (/ t_1 (* (* d_m d_m) l)) 1.0))
       (* t_0 (/ (* (/ -0.125 d_m) (/ t_1 d_m)) l))))))
d_m = fabs(d);
double code(double d_m, double h, double l, double M, double D) {
	double t_0 = sqrt((1.0 / (l * h))) * d_m;
	double t_1 = ((M * D) * (M * D)) * h;
	double tmp;
	if ((M * D) <= 2.5e-141) {
		tmp = (sqrt(1.0) / sqrt((l * h))) * d_m;
	} else if ((M * D) <= 1e+100) {
		tmp = t_0 * fma(-0.125, (t_1 / ((d_m * d_m) * l)), 1.0);
	} else {
		tmp = t_0 * (((-0.125 / d_m) * (t_1 / d_m)) / l);
	}
	return tmp;
}
d_m = abs(d)
function code(d_m, h, l, M, D)
	t_0 = Float64(sqrt(Float64(1.0 / Float64(l * h))) * d_m)
	t_1 = Float64(Float64(Float64(M * D) * Float64(M * D)) * h)
	tmp = 0.0
	if (Float64(M * D) <= 2.5e-141)
		tmp = Float64(Float64(sqrt(1.0) / sqrt(Float64(l * h))) * d_m);
	elseif (Float64(M * D) <= 1e+100)
		tmp = Float64(t_0 * fma(-0.125, Float64(t_1 / Float64(Float64(d_m * d_m) * l)), 1.0));
	else
		tmp = Float64(t_0 * Float64(Float64(Float64(-0.125 / d_m) * Float64(t_1 / d_m)) / l));
	end
	return tmp
end
d_m = N[Abs[d], $MachinePrecision]
code[d$95$m_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(M * D), $MachinePrecision] * N[(M * D), $MachinePrecision]), $MachinePrecision] * h), $MachinePrecision]}, If[LessEqual[N[(M * D), $MachinePrecision], 2.5e-141], N[(N[(N[Sqrt[1.0], $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * d$95$m), $MachinePrecision], If[LessEqual[N[(M * D), $MachinePrecision], 1e+100], N[(t$95$0 * N[(-0.125 * N[(t$95$1 / N[(N[(d$95$m * d$95$m), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(N[(N[(-0.125 / d$95$m), $MachinePrecision] * N[(t$95$1 / d$95$m), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
d_m = \left|d\right|

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

\mathbf{elif}\;M \cdot D \leq 10^{+100}:\\
\;\;\;\;t\_0 \cdot \mathsf{fma}\left(-0.125, \frac{t\_1}{\left(d\_m \cdot d\_m\right) \cdot \ell}, 1\right)\\

\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \frac{\frac{-0.125}{d\_m} \cdot \frac{t\_1}{d\_m}}{\ell}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 M D) < 2.5e-141

    1. Initial program 37.3%

      \[\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}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    3. Applied rewrites50.3%

      \[\leadsto \color{blue}{\sqrt{\frac{1}{\ell \cdot h}} \cdot d} \]
    4. Applied rewrites50.5%

      \[\leadsto \frac{\sqrt{1}}{\sqrt{\ell \cdot h}} \cdot d \]

    if 2.5e-141 < (*.f64 M D) < 1.00000000000000002e100

    1. Initial program 34.4%

      \[\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. Applied rewrites66.9%

      \[\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) \]
    4. Taylor expanded in d around inf

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

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

    if 1.00000000000000002e100 < (*.f64 M D)

    1. Initial program 35.4%

      \[\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. Applied rewrites69.7%

      \[\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) \]
    4. Taylor expanded in l around 0

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

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

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

      \[\leadsto \left(\sqrt{\frac{1}{\ell \cdot h}} \cdot d\right) \cdot \frac{\frac{-0.125 \cdot \left(\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot h\right)}{d \cdot d}}{\ell} \]
    8. Applied rewrites60.3%

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

Alternative 10: 51.9% accurate, 1.7× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} t_0 := \left(M \cdot D\right) \cdot \left(M \cdot D\right)\\ \mathbf{if}\;M \cdot D \leq 4 \cdot 10^{+30}:\\ \;\;\;\;\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot d\_m\\ \mathbf{elif}\;M \cdot D \leq 5 \cdot 10^{+260}:\\ \;\;\;\;\frac{t\_0 \cdot -0.125}{d\_m} \cdot \sqrt{\frac{h}{\left(\ell \cdot \ell\right) \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;\left(\sqrt{\frac{1}{\ell \cdot h}} \cdot d\_m\right) \cdot \frac{\frac{-0.125}{d\_m} \cdot \frac{t\_0 \cdot h}{d\_m}}{\ell}\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
(FPCore (d_m h l M D)
 :precision binary64
 (let* ((t_0 (* (* M D) (* M D))))
   (if (<= (* M D) 4e+30)
     (* (sqrt (/ (/ 1.0 h) l)) d_m)
     (if (<= (* M D) 5e+260)
       (* (/ (* t_0 -0.125) d_m) (sqrt (/ h (* (* l l) l))))
       (*
        (* (sqrt (/ 1.0 (* l h))) d_m)
        (/ (* (/ -0.125 d_m) (/ (* t_0 h) d_m)) l))))))
d_m = fabs(d);
double code(double d_m, double h, double l, double M, double D) {
	double t_0 = (M * D) * (M * D);
	double tmp;
	if ((M * D) <= 4e+30) {
		tmp = sqrt(((1.0 / h) / l)) * d_m;
	} else if ((M * D) <= 5e+260) {
		tmp = ((t_0 * -0.125) / d_m) * sqrt((h / ((l * l) * l)));
	} else {
		tmp = (sqrt((1.0 / (l * h))) * d_m) * (((-0.125 / d_m) * ((t_0 * h) / d_m)) / 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) * (m * d)
    if ((m * d) <= 4d+30) then
        tmp = sqrt(((1.0d0 / h) / l)) * d_m
    else if ((m * d) <= 5d+260) then
        tmp = ((t_0 * (-0.125d0)) / d_m) * sqrt((h / ((l * l) * l)))
    else
        tmp = (sqrt((1.0d0 / (l * h))) * d_m) * ((((-0.125d0) / d_m) * ((t_0 * h) / d_m)) / 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) * (M * D);
	double tmp;
	if ((M * D) <= 4e+30) {
		tmp = Math.sqrt(((1.0 / h) / l)) * d_m;
	} else if ((M * D) <= 5e+260) {
		tmp = ((t_0 * -0.125) / d_m) * Math.sqrt((h / ((l * l) * l)));
	} else {
		tmp = (Math.sqrt((1.0 / (l * h))) * d_m) * (((-0.125 / d_m) * ((t_0 * h) / d_m)) / l);
	}
	return tmp;
}
d_m = math.fabs(d)
def code(d_m, h, l, M, D):
	t_0 = (M * D) * (M * D)
	tmp = 0
	if (M * D) <= 4e+30:
		tmp = math.sqrt(((1.0 / h) / l)) * d_m
	elif (M * D) <= 5e+260:
		tmp = ((t_0 * -0.125) / d_m) * math.sqrt((h / ((l * l) * l)))
	else:
		tmp = (math.sqrt((1.0 / (l * h))) * d_m) * (((-0.125 / d_m) * ((t_0 * h) / d_m)) / l)
	return tmp
d_m = abs(d)
function code(d_m, h, l, M, D)
	t_0 = Float64(Float64(M * D) * Float64(M * D))
	tmp = 0.0
	if (Float64(M * D) <= 4e+30)
		tmp = Float64(sqrt(Float64(Float64(1.0 / h) / l)) * d_m);
	elseif (Float64(M * D) <= 5e+260)
		tmp = Float64(Float64(Float64(t_0 * -0.125) / d_m) * sqrt(Float64(h / Float64(Float64(l * l) * l))));
	else
		tmp = Float64(Float64(sqrt(Float64(1.0 / Float64(l * h))) * d_m) * Float64(Float64(Float64(-0.125 / d_m) * Float64(Float64(t_0 * h) / d_m)) / l));
	end
	return tmp
end
d_m = abs(d);
function tmp_2 = code(d_m, h, l, M, D)
	t_0 = (M * D) * (M * D);
	tmp = 0.0;
	if ((M * D) <= 4e+30)
		tmp = sqrt(((1.0 / h) / l)) * d_m;
	elseif ((M * D) <= 5e+260)
		tmp = ((t_0 * -0.125) / d_m) * sqrt((h / ((l * l) * l)));
	else
		tmp = (sqrt((1.0 / (l * h))) * d_m) * (((-0.125 / d_m) * ((t_0 * h) / d_m)) / 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[(N[(M * D), $MachinePrecision] * N[(M * D), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(M * D), $MachinePrecision], 4e+30], N[(N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision], If[LessEqual[N[(M * D), $MachinePrecision], 5e+260], N[(N[(N[(t$95$0 * -0.125), $MachinePrecision] / d$95$m), $MachinePrecision] * N[Sqrt[N[(h / N[(N[(l * l), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision] * N[(N[(N[(-0.125 / d$95$m), $MachinePrecision] * N[(N[(t$95$0 * h), $MachinePrecision] / d$95$m), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
d_m = \left|d\right|

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

\mathbf{elif}\;M \cdot D \leq 5 \cdot 10^{+260}:\\
\;\;\;\;\frac{t\_0 \cdot -0.125}{d\_m} \cdot \sqrt{\frac{h}{\left(\ell \cdot \ell\right) \cdot \ell}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 M D) < 4.0000000000000001e30

    1. Initial program 36.6%

      \[\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}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    3. Applied rewrites50.5%

      \[\leadsto \color{blue}{\sqrt{\frac{1}{\ell \cdot h}} \cdot d} \]
    4. Applied rewrites50.9%

      \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot d \]

    if 4.0000000000000001e30 < (*.f64 M D) < 4.9999999999999996e260

    1. Initial program 35.7%

      \[\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. Applied rewrites44.9%

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

    if 4.9999999999999996e260 < (*.f64 M D)

    1. Initial program 36.2%

      \[\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. Applied rewrites69.1%

      \[\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) \]
    4. Taylor expanded in l around 0

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

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

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

      \[\leadsto \left(\sqrt{\frac{1}{\ell \cdot h}} \cdot d\right) \cdot \frac{\frac{-0.125 \cdot \left(\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot h\right)}{d \cdot d}}{\ell} \]
    8. Applied rewrites73.0%

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

Alternative 11: 50.8% accurate, 2.5× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} \mathbf{if}\;M \cdot D \leq 4 \cdot 10^{+30}:\\ \;\;\;\;\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot d\_m\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot -0.125}{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) 4e+30)
   (* (sqrt (/ (/ 1.0 h) l)) d_m)
   (* (/ (* (* (* M D) (* M D)) -0.125) 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) <= 4e+30) {
		tmp = sqrt(((1.0 / h) / l)) * d_m;
	} else {
		tmp = ((((M * D) * (M * D)) * -0.125) / 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) <= 4d+30) then
        tmp = sqrt(((1.0d0 / h) / l)) * d_m
    else
        tmp = ((((m * d) * (m * d)) * (-0.125d0)) / 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) <= 4e+30) {
		tmp = Math.sqrt(((1.0 / h) / l)) * d_m;
	} else {
		tmp = ((((M * D) * (M * D)) * -0.125) / 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) <= 4e+30:
		tmp = math.sqrt(((1.0 / h) / l)) * d_m
	else:
		tmp = ((((M * D) * (M * D)) * -0.125) / 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) <= 4e+30)
		tmp = Float64(sqrt(Float64(Float64(1.0 / h) / l)) * d_m);
	else
		tmp = Float64(Float64(Float64(Float64(Float64(M * D) * Float64(M * D)) * -0.125) / 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) <= 4e+30)
		tmp = sqrt(((1.0 / h) / l)) * d_m;
	else
		tmp = ((((M * D) * (M * D)) * -0.125) / 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], 4e+30], N[(N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision], N[(N[(N[(N[(N[(M * D), $MachinePrecision] * N[(M * D), $MachinePrecision]), $MachinePrecision] * -0.125), $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 4 \cdot 10^{+30}:\\
\;\;\;\;\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot d\_m\\

\mathbf{else}:\\
\;\;\;\;\frac{\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot -0.125}{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) < 4.0000000000000001e30

    1. Initial program 36.6%

      \[\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}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    3. Applied rewrites50.5%

      \[\leadsto \color{blue}{\sqrt{\frac{1}{\ell \cdot h}} \cdot d} \]
    4. Applied rewrites50.9%

      \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot d \]

    if 4.0000000000000001e30 < (*.f64 M D)

    1. Initial program 35.9%

      \[\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. Applied rewrites50.3%

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

Alternative 12: 47.1% accurate, 0.9× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} \mathbf{if}\;\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) \leq -5 \cdot 10^{-252}:\\ \;\;\;\;\sqrt{\frac{1}{\ell \cdot h}} \cdot \left(-d\_m\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot d\_m\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
(FPCore (d_m h l M D)
 :precision binary64
 (if (<=
      (*
       (* (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))))
      -5e-252)
   (* (sqrt (/ 1.0 (* l h))) (- d_m))
   (* (sqrt (/ (/ 1.0 h) l)) d_m)))
d_m = fabs(d);
double code(double d_m, double h, double l, double M, double D) {
	double tmp;
	if (((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)))) <= -5e-252) {
		tmp = sqrt((1.0 / (l * h))) * -d_m;
	} else {
		tmp = sqrt(((1.0 / h) / l)) * 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 (((((d_m / h) ** (1.0d0 / 2.0d0)) * ((d_m / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d) / (2.0d0 * d_m)) ** 2.0d0)) * (h / l)))) <= (-5d-252)) then
        tmp = sqrt((1.0d0 / (l * h))) * -d_m
    else
        tmp = sqrt(((1.0d0 / h) / l)) * 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 (((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)))) <= -5e-252) {
		tmp = Math.sqrt((1.0 / (l * h))) * -d_m;
	} else {
		tmp = Math.sqrt(((1.0 / h) / l)) * d_m;
	}
	return tmp;
}
d_m = math.fabs(d)
def code(d_m, h, l, M, D):
	tmp = 0
	if ((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)))) <= -5e-252:
		tmp = math.sqrt((1.0 / (l * h))) * -d_m
	else:
		tmp = math.sqrt(((1.0 / h) / l)) * d_m
	return tmp
d_m = abs(d)
function code(d_m, h, l, M, D)
	tmp = 0.0
	if (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)))) <= -5e-252)
		tmp = Float64(sqrt(Float64(1.0 / Float64(l * h))) * Float64(-d_m));
	else
		tmp = Float64(sqrt(Float64(Float64(1.0 / h) / l)) * d_m);
	end
	return tmp
end
d_m = abs(d);
function tmp_2 = code(d_m, h, l, M, D)
	tmp = 0.0;
	if (((((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)))) <= -5e-252)
		tmp = sqrt((1.0 / (l * h))) * -d_m;
	else
		tmp = sqrt(((1.0 / h) / l)) * d_m;
	end
	tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
code[d$95$m_, h_, l_, M_, D_] := If[LessEqual[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], -5e-252], N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-d$95$m)), $MachinePrecision], N[(N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision]]
\begin{array}{l}
d_m = \left|d\right|

\\
\begin{array}{l}
\mathbf{if}\;\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) \leq -5 \cdot 10^{-252}:\\
\;\;\;\;\sqrt{\frac{1}{\ell \cdot h}} \cdot \left(-d\_m\right)\\

\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot d\_m\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 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)))) < -5.00000000000000008e-252

    1. Initial program 85.9%

      \[\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 l around -inf

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

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

    if -5.00000000000000008e-252 < (*.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 26.1%

      \[\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}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    3. Applied rewrites51.9%

      \[\leadsto \color{blue}{\sqrt{\frac{1}{\ell \cdot h}} \cdot d} \]
    4. Applied rewrites52.3%

      \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot d \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 13: 43.5% accurate, 7.4× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot d\_m \end{array} \]
d_m = (fabs.f64 d)
(FPCore (d_m h l M D) :precision binary64 (* (sqrt (/ (/ 1.0 h) l)) d_m))
d_m = fabs(d);
double code(double d_m, double h, double l, double M, double D) {
	return sqrt(((1.0 / h) / l)) * 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 / h) / l)) * 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 / h) / l)) * d_m;
}
d_m = math.fabs(d)
def code(d_m, h, l, M, D):
	return math.sqrt(((1.0 / h) / l)) * d_m
d_m = abs(d)
function code(d_m, h, l, M, D)
	return Float64(sqrt(Float64(Float64(1.0 / h) / l)) * d_m)
end
d_m = abs(d);
function tmp = code(d_m, h, l, M, D)
	tmp = sqrt(((1.0 / h) / l)) * d_m;
end
d_m = N[Abs[d], $MachinePrecision]
code[d$95$m_, h_, l_, M_, D_] := N[(N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision]
\begin{array}{l}
d_m = \left|d\right|

\\
\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot d\_m
\end{array}
Derivation
  1. Initial program 36.4%

    \[\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}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  3. Applied rewrites43.2%

    \[\leadsto \color{blue}{\sqrt{\frac{1}{\ell \cdot h}} \cdot d} \]
  4. Applied rewrites43.5%

    \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot d \]
  5. Add Preprocessing

Alternative 14: 43.2% 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 36.4%

    \[\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}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  3. Applied rewrites43.2%

    \[\leadsto \color{blue}{\sqrt{\frac{1}{\ell \cdot h}} \cdot d} \]
  4. Add Preprocessing

Reproduce

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