Average Error: 26.7 → 18.6
Time: 15.9s
Precision: binary64
\[ \begin{array}{c}[M, D] = \mathsf{sort}([M, D])\\ \end{array} \]
\[\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) \]
\[\begin{array}{l} t_0 := 1 - \frac{h \cdot \left(0.5 \cdot {\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}\right)}{\ell}\\ t_1 := {\left(\frac{d}{h}\right)}^{0.5}\\ \mathbf{if}\;\ell \leq -1.7821996346274 \cdot 10^{-310}:\\ \;\;\;\;\left(t_1 \cdot \frac{\sqrt{-d}}{\sqrt{-\ell}}\right) \cdot t_0\\ \mathbf{elif}\;\ell \leq 2.7932440493458067 \cdot 10^{-69}:\\ \;\;\;\;t_0 \cdot \left(t_1 \cdot \frac{\sqrt{d}}{\sqrt{\ell}}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(\sqrt{d} \cdot {\left(\frac{1}{h}\right)}^{0.5}\right) \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - \left(0.5 \cdot {\left(\frac{M \cdot D}{d \cdot 2}\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)))))
(FPCore (d h l M D)
 :precision binary64
 (let* ((t_0 (- 1.0 (/ (* h (* 0.5 (pow (* (/ M 2.0) (/ D d)) 2.0))) l)))
        (t_1 (pow (/ d h) 0.5)))
   (if (<= l -1.7821996346274e-310)
     (* (* t_1 (/ (sqrt (- d)) (sqrt (- l)))) t_0)
     (if (<= l 2.7932440493458067e-69)
       (* t_0 (* t_1 (/ (sqrt d) (sqrt l))))
       (*
        (* (* (sqrt d) (pow (/ 1.0 h) 0.5)) (pow (/ d l) 0.5))
        (- 1.0 (* (* 0.5 (pow (/ (* M D) (* d 2.0)) 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)));
}
double code(double d, double h, double l, double M, double D) {
	double t_0 = 1.0 - ((h * (0.5 * pow(((M / 2.0) * (D / d)), 2.0))) / l);
	double t_1 = pow((d / h), 0.5);
	double tmp;
	if (l <= -1.7821996346274e-310) {
		tmp = (t_1 * (sqrt(-d) / sqrt(-l))) * t_0;
	} else if (l <= 2.7932440493458067e-69) {
		tmp = t_0 * (t_1 * (sqrt(d) / sqrt(l)));
	} else {
		tmp = ((sqrt(d) * pow((1.0 / h), 0.5)) * pow((d / l), 0.5)) * (1.0 - ((0.5 * pow(((M * D) / (d * 2.0)), 2.0)) * (h / l)));
	}
	return tmp;
}
real(8) function code(d, h, l, m, d_1)
    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
real(8) function code(d, h, l, m, d_1)
    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
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = 1.0d0 - ((h * (0.5d0 * (((m / 2.0d0) * (d_1 / d)) ** 2.0d0))) / l)
    t_1 = (d / h) ** 0.5d0
    if (l <= (-1.7821996346274d-310)) then
        tmp = (t_1 * (sqrt(-d) / sqrt(-l))) * t_0
    else if (l <= 2.7932440493458067d-69) then
        tmp = t_0 * (t_1 * (sqrt(d) / sqrt(l)))
    else
        tmp = ((sqrt(d) * ((1.0d0 / h) ** 0.5d0)) * ((d / l) ** 0.5d0)) * (1.0d0 - ((0.5d0 * (((m * d_1) / (d * 2.0d0)) ** 2.0d0)) * (h / l)))
    end if
    code = tmp
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)));
}
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = 1.0 - ((h * (0.5 * Math.pow(((M / 2.0) * (D / d)), 2.0))) / l);
	double t_1 = Math.pow((d / h), 0.5);
	double tmp;
	if (l <= -1.7821996346274e-310) {
		tmp = (t_1 * (Math.sqrt(-d) / Math.sqrt(-l))) * t_0;
	} else if (l <= 2.7932440493458067e-69) {
		tmp = t_0 * (t_1 * (Math.sqrt(d) / Math.sqrt(l)));
	} else {
		tmp = ((Math.sqrt(d) * Math.pow((1.0 / h), 0.5)) * Math.pow((d / l), 0.5)) * (1.0 - ((0.5 * Math.pow(((M * D) / (d * 2.0)), 2.0)) * (h / l)));
	}
	return tmp;
}
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)))
def code(d, h, l, M, D):
	t_0 = 1.0 - ((h * (0.5 * math.pow(((M / 2.0) * (D / d)), 2.0))) / l)
	t_1 = math.pow((d / h), 0.5)
	tmp = 0
	if l <= -1.7821996346274e-310:
		tmp = (t_1 * (math.sqrt(-d) / math.sqrt(-l))) * t_0
	elif l <= 2.7932440493458067e-69:
		tmp = t_0 * (t_1 * (math.sqrt(d) / math.sqrt(l)))
	else:
		tmp = ((math.sqrt(d) * math.pow((1.0 / h), 0.5)) * math.pow((d / l), 0.5)) * (1.0 - ((0.5 * math.pow(((M * D) / (d * 2.0)), 2.0)) * (h / l)))
	return tmp
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 code(d, h, l, M, D)
	t_0 = Float64(1.0 - Float64(Float64(h * Float64(0.5 * (Float64(Float64(M / 2.0) * Float64(D / d)) ^ 2.0))) / l))
	t_1 = Float64(d / h) ^ 0.5
	tmp = 0.0
	if (l <= -1.7821996346274e-310)
		tmp = Float64(Float64(t_1 * Float64(sqrt(Float64(-d)) / sqrt(Float64(-l)))) * t_0);
	elseif (l <= 2.7932440493458067e-69)
		tmp = Float64(t_0 * Float64(t_1 * Float64(sqrt(d) / sqrt(l))));
	else
		tmp = Float64(Float64(Float64(sqrt(d) * (Float64(1.0 / h) ^ 0.5)) * (Float64(d / l) ^ 0.5)) * Float64(1.0 - Float64(Float64(0.5 * (Float64(Float64(M * D) / Float64(d * 2.0)) ^ 2.0)) * Float64(h / l))));
	end
	return tmp
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
function tmp_2 = code(d, h, l, M, D)
	t_0 = 1.0 - ((h * (0.5 * (((M / 2.0) * (D / d)) ^ 2.0))) / l);
	t_1 = (d / h) ^ 0.5;
	tmp = 0.0;
	if (l <= -1.7821996346274e-310)
		tmp = (t_1 * (sqrt(-d) / sqrt(-l))) * t_0;
	elseif (l <= 2.7932440493458067e-69)
		tmp = t_0 * (t_1 * (sqrt(d) / sqrt(l)));
	else
		tmp = ((sqrt(d) * ((1.0 / h) ^ 0.5)) * ((d / l) ^ 0.5)) * (1.0 - ((0.5 * (((M * D) / (d * 2.0)) ^ 2.0)) * (h / l)));
	end
	tmp_2 = tmp;
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]
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(1.0 - N[(N[(h * N[(0.5 * N[Power[N[(N[(M / 2.0), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(d / h), $MachinePrecision], 0.5], $MachinePrecision]}, If[LessEqual[l, -1.7821996346274e-310], N[(N[(t$95$1 * N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[l, 2.7932440493458067e-69], N[(t$95$0 * N[(t$95$1 * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Sqrt[d], $MachinePrecision] * N[Power[N[(1.0 / h), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(0.5 * N[Power[N[(N[(M * D), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\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)
\begin{array}{l}
t_0 := 1 - \frac{h \cdot \left(0.5 \cdot {\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}\right)}{\ell}\\
t_1 := {\left(\frac{d}{h}\right)}^{0.5}\\
\mathbf{if}\;\ell \leq -1.7821996346274 \cdot 10^{-310}:\\
\;\;\;\;\left(t_1 \cdot \frac{\sqrt{-d}}{\sqrt{-\ell}}\right) \cdot t_0\\

\mathbf{elif}\;\ell \leq 2.7932440493458067 \cdot 10^{-69}:\\
\;\;\;\;t_0 \cdot \left(t_1 \cdot \frac{\sqrt{d}}{\sqrt{\ell}}\right)\\

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


\end{array}

Error

Bits error versus d

Bits error versus h

Bits error versus l

Bits error versus M

Bits error versus D

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if l < -1.782199634627393e-310

    1. Initial program 26.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. Applied egg-rr26.3

      \[\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 - \color{blue}{\frac{\left(0.5 \cdot {\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}\right) \cdot h}{\ell}}\right) \]
    3. Applied egg-rr20.8

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

    if -1.782199634627393e-310 < l < 2.7932440493458067e-69

    1. Initial program 30.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. Applied egg-rr24.2

      \[\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 - \color{blue}{\frac{\left(0.5 \cdot {\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}\right) \cdot h}{\ell}}\right) \]
    3. Applied egg-rr12.1

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

    if 2.7932440493458067e-69 < l

    1. Initial program 25.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. Applied egg-rr17.9

      \[\leadsto \left(\color{blue}{\left(\sqrt{d} \cdot {\left(\frac{1}{h}\right)}^{0.5}\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) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification18.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1.7821996346274 \cdot 10^{-310}:\\ \;\;\;\;\left({\left(\frac{d}{h}\right)}^{0.5} \cdot \frac{\sqrt{-d}}{\sqrt{-\ell}}\right) \cdot \left(1 - \frac{h \cdot \left(0.5 \cdot {\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}\right)}{\ell}\right)\\ \mathbf{elif}\;\ell \leq 2.7932440493458067 \cdot 10^{-69}:\\ \;\;\;\;\left(1 - \frac{h \cdot \left(0.5 \cdot {\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}\right)}{\ell}\right) \cdot \left({\left(\frac{d}{h}\right)}^{0.5} \cdot \frac{\sqrt{d}}{\sqrt{\ell}}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(\sqrt{d} \cdot {\left(\frac{1}{h}\right)}^{0.5}\right) \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - \left(0.5 \cdot {\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\ \end{array} \]

Reproduce

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