Henrywood and Agarwal, Equation (12)

Percentage Accurate: 35.3% → 71.2%
Time: 6.7s
Alternatives: 3
Speedup: 6.2×

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

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

Initial Program: 35.3% 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: 71.2% accurate, 1.6× speedup?

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

\\
\begin{array}{l}
t_0 := d\_m \cdot \sqrt{\frac{1}{h \cdot \ell}}\\
\mathbf{if}\;M\_m \cdot D\_m \leq 10^{-169}:\\
\;\;\;\;t\_0 \cdot 1\\

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


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

    1. Initial program 35.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. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \left(d \cdot \color{blue}{\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) \]
      2. lower-sqrt.f64N/A

        \[\leadsto \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. lower-/.f64N/A

        \[\leadsto \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) \]
      4. lower-*.f6469.3

        \[\leadsto \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) \]
    4. Applied rewrites69.3%

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

      \[\leadsto \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \cdot \color{blue}{1} \]
    6. Step-by-step derivation
      1. Applied rewrites42.9%

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

      if 1.00000000000000002e-169 < (*.f64 M D)

      1. Initial program 35.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. Step-by-step derivation
        1. lower-*.f64N/A

          \[\leadsto \left(d \cdot \color{blue}{\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) \]
        2. lower-sqrt.f64N/A

          \[\leadsto \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. lower-/.f64N/A

          \[\leadsto \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) \]
        4. lower-*.f6469.3

          \[\leadsto \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) \]
      4. Applied rewrites69.3%

        \[\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) \]
      5. Step-by-step derivation
        1. lift-/.f64N/A

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

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

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

    Alternative 2: 45.4% accurate, 2.5× speedup?

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

      1. Initial program 35.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. Step-by-step derivation
        1. lower-*.f64N/A

          \[\leadsto \left(d \cdot \color{blue}{\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) \]
        2. lower-sqrt.f64N/A

          \[\leadsto \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. lower-/.f64N/A

          \[\leadsto \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) \]
        4. lower-*.f6469.3

          \[\leadsto \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) \]
      4. Applied rewrites69.3%

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

        \[\leadsto \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \cdot \color{blue}{1} \]
      6. Step-by-step derivation
        1. Applied rewrites42.9%

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

        if 1.60000000000000003e235 < (*.f64 M D)

        1. Initial program 35.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 h around inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto h \cdot \left(d \cdot \sqrt{\frac{1}{{h}^{3} \cdot \ell}}\right) \]
          5. lift-pow.f6418.4

            \[\leadsto h \cdot \left(d \cdot \sqrt{\frac{1}{{h}^{3} \cdot \ell}}\right) \]
        10. Applied rewrites18.4%

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

      Alternative 3: 42.9% accurate, 6.2× speedup?

      \[\begin{array}{l} d_m = \left|d\right| \\ M_m = \left|M\right| \\ D_m = \left|D\right| \\ \left(d\_m \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \cdot 1 \end{array} \]
      d_m = (fabs.f64 d)
      M_m = (fabs.f64 M)
      D_m = (fabs.f64 D)
      (FPCore (d_m h l M_m D_m)
       :precision binary64
       (* (* d_m (sqrt (/ 1.0 (* h l)))) 1.0))
      d_m = fabs(d);
      M_m = fabs(M);
      D_m = fabs(D);
      double code(double d_m, double h, double l, double M_m, double D_m) {
      	return (d_m * sqrt((1.0 / (h * l)))) * 1.0;
      }
      
      d_m =     private
      M_m =     private
      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_m, d_m_1)
      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_m
          real(8), intent (in) :: d_m_1
          code = (d_m * sqrt((1.0d0 / (h * l)))) * 1.0d0
      end function
      
      d_m = Math.abs(d);
      M_m = Math.abs(M);
      D_m = Math.abs(D);
      public static double code(double d_m, double h, double l, double M_m, double D_m) {
      	return (d_m * Math.sqrt((1.0 / (h * l)))) * 1.0;
      }
      
      d_m = math.fabs(d)
      M_m = math.fabs(M)
      D_m = math.fabs(D)
      def code(d_m, h, l, M_m, D_m):
      	return (d_m * math.sqrt((1.0 / (h * l)))) * 1.0
      
      d_m = abs(d)
      M_m = abs(M)
      D_m = abs(D)
      function code(d_m, h, l, M_m, D_m)
      	return Float64(Float64(d_m * sqrt(Float64(1.0 / Float64(h * l)))) * 1.0)
      end
      
      d_m = abs(d);
      M_m = abs(M);
      D_m = abs(D);
      function tmp = code(d_m, h, l, M_m, D_m)
      	tmp = (d_m * sqrt((1.0 / (h * l)))) * 1.0;
      end
      
      d_m = N[Abs[d], $MachinePrecision]
      M_m = N[Abs[M], $MachinePrecision]
      D_m = N[Abs[D], $MachinePrecision]
      code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := N[(N[(d$95$m * N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision]
      
      \begin{array}{l}
      d_m = \left|d\right|
      \\
      M_m = \left|M\right|
      \\
      D_m = \left|D\right|
      
      \\
      \left(d\_m \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \cdot 1
      \end{array}
      
      Derivation
      1. Initial program 35.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. Step-by-step derivation
        1. lower-*.f64N/A

          \[\leadsto \left(d \cdot \color{blue}{\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) \]
        2. lower-sqrt.f64N/A

          \[\leadsto \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. lower-/.f64N/A

          \[\leadsto \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) \]
        4. lower-*.f6469.3

          \[\leadsto \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) \]
      4. Applied rewrites69.3%

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

        \[\leadsto \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \cdot \color{blue}{1} \]
      6. Step-by-step derivation
        1. Applied rewrites42.9%

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

        Reproduce

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