Average Error: 26.5 → 16.6
Time: 48.7s
Precision: binary64
Cost: 40392
\[ \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 := \frac{M}{2} \cdot \frac{D}{d}\\ t_1 := \sqrt{-d}\\ \mathbf{if}\;d \leq -1 \cdot 10^{-30}:\\ \;\;\;\;\left(\frac{t_1}{\sqrt{-h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - \frac{{t_0}^{2} \cdot \left(h \cdot 0.5\right)}{\ell}\right)\\ \mathbf{elif}\;d \leq 0:\\ \;\;\;\;\left({\left(\frac{d}{h}\right)}^{0.5} \cdot \frac{t_1}{\sqrt{-\ell}}\right) \cdot \left(1 - {\left(\sqrt{\frac{h}{\ell}} \cdot \left(t_0 \cdot \sqrt{0.5}\right)\right)}^{2}\right)\\ \mathbf{elif}\;d \leq 10^{+55}:\\ \;\;\;\;\frac{\frac{d}{\sqrt{\ell}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\left(0.5 \cdot \frac{M \cdot D}{d}\right)}^{2} \cdot -0.5\right)\right)}{\sqrt{h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\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 (* (/ M 2.0) (/ D d))) (t_1 (sqrt (- d))))
   (if (<= d -1e-30)
     (*
      (* (/ t_1 (sqrt (- h))) (sqrt (/ d l)))
      (- 1.0 (/ (* (pow t_0 2.0) (* h 0.5)) l)))
     (if (<= d 0.0)
       (*
        (* (pow (/ d h) 0.5) (/ t_1 (sqrt (- l))))
        (- 1.0 (pow (* (sqrt (/ h l)) (* t_0 (sqrt 0.5))) 2.0)))
       (if (<= d 1e+55)
         (/
          (*
           (/ d (sqrt l))
           (+ 1.0 (* (/ h l) (* (pow (* 0.5 (/ (* M D) d)) 2.0) -0.5))))
          (sqrt h))
         (* d (* (pow l -0.5) (pow h -0.5))))))))
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 = (M / 2.0) * (D / d);
	double t_1 = sqrt(-d);
	double tmp;
	if (d <= -1e-30) {
		tmp = ((t_1 / sqrt(-h)) * sqrt((d / l))) * (1.0 - ((pow(t_0, 2.0) * (h * 0.5)) / l));
	} else if (d <= 0.0) {
		tmp = (pow((d / h), 0.5) * (t_1 / sqrt(-l))) * (1.0 - pow((sqrt((h / l)) * (t_0 * sqrt(0.5))), 2.0));
	} else if (d <= 1e+55) {
		tmp = ((d / sqrt(l)) * (1.0 + ((h / l) * (pow((0.5 * ((M * D) / d)), 2.0) * -0.5)))) / sqrt(h);
	} else {
		tmp = d * (pow(l, -0.5) * pow(h, -0.5));
	}
	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 = (m / 2.0d0) * (d_1 / d)
    t_1 = sqrt(-d)
    if (d <= (-1d-30)) then
        tmp = ((t_1 / sqrt(-h)) * sqrt((d / l))) * (1.0d0 - (((t_0 ** 2.0d0) * (h * 0.5d0)) / l))
    else if (d <= 0.0d0) then
        tmp = (((d / h) ** 0.5d0) * (t_1 / sqrt(-l))) * (1.0d0 - ((sqrt((h / l)) * (t_0 * sqrt(0.5d0))) ** 2.0d0))
    else if (d <= 1d+55) then
        tmp = ((d / sqrt(l)) * (1.0d0 + ((h / l) * (((0.5d0 * ((m * d_1) / d)) ** 2.0d0) * (-0.5d0))))) / sqrt(h)
    else
        tmp = d * ((l ** (-0.5d0)) * (h ** (-0.5d0)))
    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 = (M / 2.0) * (D / d);
	double t_1 = Math.sqrt(-d);
	double tmp;
	if (d <= -1e-30) {
		tmp = ((t_1 / Math.sqrt(-h)) * Math.sqrt((d / l))) * (1.0 - ((Math.pow(t_0, 2.0) * (h * 0.5)) / l));
	} else if (d <= 0.0) {
		tmp = (Math.pow((d / h), 0.5) * (t_1 / Math.sqrt(-l))) * (1.0 - Math.pow((Math.sqrt((h / l)) * (t_0 * Math.sqrt(0.5))), 2.0));
	} else if (d <= 1e+55) {
		tmp = ((d / Math.sqrt(l)) * (1.0 + ((h / l) * (Math.pow((0.5 * ((M * D) / d)), 2.0) * -0.5)))) / Math.sqrt(h);
	} else {
		tmp = d * (Math.pow(l, -0.5) * Math.pow(h, -0.5));
	}
	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 = (M / 2.0) * (D / d)
	t_1 = math.sqrt(-d)
	tmp = 0
	if d <= -1e-30:
		tmp = ((t_1 / math.sqrt(-h)) * math.sqrt((d / l))) * (1.0 - ((math.pow(t_0, 2.0) * (h * 0.5)) / l))
	elif d <= 0.0:
		tmp = (math.pow((d / h), 0.5) * (t_1 / math.sqrt(-l))) * (1.0 - math.pow((math.sqrt((h / l)) * (t_0 * math.sqrt(0.5))), 2.0))
	elif d <= 1e+55:
		tmp = ((d / math.sqrt(l)) * (1.0 + ((h / l) * (math.pow((0.5 * ((M * D) / d)), 2.0) * -0.5)))) / math.sqrt(h)
	else:
		tmp = d * (math.pow(l, -0.5) * math.pow(h, -0.5))
	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(Float64(M / 2.0) * Float64(D / d))
	t_1 = sqrt(Float64(-d))
	tmp = 0.0
	if (d <= -1e-30)
		tmp = Float64(Float64(Float64(t_1 / sqrt(Float64(-h))) * sqrt(Float64(d / l))) * Float64(1.0 - Float64(Float64((t_0 ^ 2.0) * Float64(h * 0.5)) / l)));
	elseif (d <= 0.0)
		tmp = Float64(Float64((Float64(d / h) ^ 0.5) * Float64(t_1 / sqrt(Float64(-l)))) * Float64(1.0 - (Float64(sqrt(Float64(h / l)) * Float64(t_0 * sqrt(0.5))) ^ 2.0)));
	elseif (d <= 1e+55)
		tmp = Float64(Float64(Float64(d / sqrt(l)) * Float64(1.0 + Float64(Float64(h / l) * Float64((Float64(0.5 * Float64(Float64(M * D) / d)) ^ 2.0) * -0.5)))) / sqrt(h));
	else
		tmp = Float64(d * Float64((l ^ -0.5) * (h ^ -0.5)));
	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 = (M / 2.0) * (D / d);
	t_1 = sqrt(-d);
	tmp = 0.0;
	if (d <= -1e-30)
		tmp = ((t_1 / sqrt(-h)) * sqrt((d / l))) * (1.0 - (((t_0 ^ 2.0) * (h * 0.5)) / l));
	elseif (d <= 0.0)
		tmp = (((d / h) ^ 0.5) * (t_1 / sqrt(-l))) * (1.0 - ((sqrt((h / l)) * (t_0 * sqrt(0.5))) ^ 2.0));
	elseif (d <= 1e+55)
		tmp = ((d / sqrt(l)) * (1.0 + ((h / l) * (((0.5 * ((M * D) / d)) ^ 2.0) * -0.5)))) / sqrt(h);
	else
		tmp = d * ((l ^ -0.5) * (h ^ -0.5));
	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[(N[(M / 2.0), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[(-d)], $MachinePrecision]}, If[LessEqual[d, -1e-30], N[(N[(N[(t$95$1 / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[t$95$0, 2.0], $MachinePrecision] * N[(h * 0.5), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 0.0], N[(N[(N[Power[N[(d / h), $MachinePrecision], 0.5], $MachinePrecision] * N[(t$95$1 / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[Power[N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * N[(t$95$0 * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1e+55], N[(N[(N[(d / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(N[Power[N[(0.5 * N[(N[(M * D), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[l, -0.5], $MachinePrecision] * N[Power[h, -0.5], $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 := \frac{M}{2} \cdot \frac{D}{d}\\
t_1 := \sqrt{-d}\\
\mathbf{if}\;d \leq -1 \cdot 10^{-30}:\\
\;\;\;\;\left(\frac{t_1}{\sqrt{-h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - \frac{{t_0}^{2} \cdot \left(h \cdot 0.5\right)}{\ell}\right)\\

\mathbf{elif}\;d \leq 0:\\
\;\;\;\;\left({\left(\frac{d}{h}\right)}^{0.5} \cdot \frac{t_1}{\sqrt{-\ell}}\right) \cdot \left(1 - {\left(\sqrt{\frac{h}{\ell}} \cdot \left(t_0 \cdot \sqrt{0.5}\right)\right)}^{2}\right)\\

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

\mathbf{else}:\\
\;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 4 regimes
  2. if d < -1e-30

    1. Initial program 22.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. Applied egg-rr22.1

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

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

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

    if -1e-30 < d < 0.0

    1. Initial program 33.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. Applied egg-rr26.9

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

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

    if 0.0 < d < 1.00000000000000001e55

    1. Initial program 27.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. Applied egg-rr27.2

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

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

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

    if 1.00000000000000001e55 < d

    1. Initial program 24.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 inf 17.7

      \[\leadsto \color{blue}{\sqrt{\frac{1}{\ell \cdot h}} \cdot d} \]
    3. Applied egg-rr29.7

      \[\leadsto \color{blue}{{\left({\left(\frac{\frac{1}{\ell}}{h}\right)}^{1.5}\right)}^{0.3333333333333333}} \cdot d \]
    4. Taylor expanded in l around 0 30.2

      \[\leadsto {\color{blue}{\left(e^{1.5 \cdot \left(-1 \cdot \log \ell + \log \left(\frac{1}{h}\right)\right)}\right)}}^{0.3333333333333333} \cdot d \]
    5. Simplified29.7

      \[\leadsto {\color{blue}{\left({\left(\ell \cdot h\right)}^{-1.5}\right)}}^{0.3333333333333333} \cdot d \]
      Proof
      (pow.f64 (*.f64 l h) -3/2): 0 points increase in error, 0 points decrease in error
      (pow.f64 (*.f64 (Rewrite<= rem-exp-log_binary64 (exp.f64 (log.f64 l))) h) -3/2): 159 points increase in error, 33 points decrease in error
      (pow.f64 (*.f64 (exp.f64 (log.f64 l)) (Rewrite<= rem-exp-log_binary64 (exp.f64 (log.f64 h)))) -3/2): 38 points increase in error, 30 points decrease in error
      (pow.f64 (Rewrite<= exp-sum_binary64 (exp.f64 (+.f64 (log.f64 l) (log.f64 h)))) -3/2): 20 points increase in error, 23 points decrease in error
      (pow.f64 (exp.f64 (Rewrite<= +-commutative_binary64 (+.f64 (log.f64 h) (log.f64 l)))) -3/2): 0 points increase in error, 0 points decrease in error
      (pow.f64 (exp.f64 (+.f64 (log.f64 h) (log.f64 l))) (Rewrite<= metadata-eval (*.f64 -1 3/2))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= exp-prod_binary64 (exp.f64 (*.f64 (+.f64 (log.f64 h) (log.f64 l)) (*.f64 -1 3/2)))): 16 points increase in error, 23 points decrease in error
      (exp.f64 (*.f64 (+.f64 (log.f64 h) (log.f64 l)) (Rewrite=> metadata-eval -3/2))): 0 points increase in error, 0 points decrease in error
      (exp.f64 (*.f64 (+.f64 (log.f64 h) (log.f64 l)) (Rewrite<= metadata-eval (neg.f64 3/2)))): 0 points increase in error, 0 points decrease in error
      (exp.f64 (Rewrite<= distribute-rgt-neg-in_binary64 (neg.f64 (*.f64 (+.f64 (log.f64 h) (log.f64 l)) 3/2)))): 0 points increase in error, 0 points decrease in error
      (exp.f64 (Rewrite<= distribute-lft-neg-out_binary64 (*.f64 (neg.f64 (+.f64 (log.f64 h) (log.f64 l))) 3/2))): 0 points increase in error, 0 points decrease in error
      (exp.f64 (*.f64 (Rewrite<= distribute-neg-out_binary64 (+.f64 (neg.f64 (log.f64 h)) (neg.f64 (log.f64 l)))) 3/2)): 0 points increase in error, 0 points decrease in error
      (exp.f64 (*.f64 (+.f64 (Rewrite<= log-rec_binary64 (log.f64 (/.f64 1 h))) (neg.f64 (log.f64 l))) 3/2)): 0 points increase in error, 1 points decrease in error
      (exp.f64 (*.f64 (+.f64 (log.f64 (/.f64 1 h)) (Rewrite<= log-rec_binary64 (log.f64 (/.f64 1 l)))) 3/2)): 0 points increase in error, 0 points decrease in error
      (exp.f64 (*.f64 (Rewrite<= +-commutative_binary64 (+.f64 (log.f64 (/.f64 1 l)) (log.f64 (/.f64 1 h)))) 3/2)): 0 points increase in error, 0 points decrease in error
      (exp.f64 (*.f64 (+.f64 (Rewrite=> log-rec_binary64 (neg.f64 (log.f64 l))) (log.f64 (/.f64 1 h))) 3/2)): 0 points increase in error, 0 points decrease in error
      (exp.f64 (*.f64 (+.f64 (Rewrite<= mul-1-neg_binary64 (*.f64 -1 (log.f64 l))) (log.f64 (/.f64 1 h))) 3/2)): 0 points increase in error, 0 points decrease in error
      (exp.f64 (Rewrite<= *-commutative_binary64 (*.f64 3/2 (+.f64 (*.f64 -1 (log.f64 l)) (log.f64 (/.f64 1 h)))))): 0 points increase in error, 0 points decrease in error
    6. Applied egg-rr7.4

      \[\leadsto \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \cdot d \]
  3. Recombined 4 regimes into one program.
  4. Final simplification16.6

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

Alternatives

Alternative 1
Error20.0
Cost27660
\[\begin{array}{l} t_0 := {\left(\frac{d}{h}\right)}^{0.5}\\ t_1 := {\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \left(h \cdot 0.5\right)\\ t_2 := \sqrt{-d}\\ t_3 := \left(\frac{t_2}{\sqrt{-h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - \frac{t_1}{\ell}\right)\\ \mathbf{if}\;\ell \leq -1 \cdot 10^{+215}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;\ell \leq -1 \cdot 10^{+80}:\\ \;\;\;\;\left(t_0 \cdot \frac{t_2}{\sqrt{-\ell}}\right) \cdot \left(1 + \left(M \cdot \left(M \cdot \frac{\frac{D}{\frac{d}{D}}}{\frac{\ell}{\frac{h}{d}}}\right)\right) \cdot -0.125\right)\\ \mathbf{elif}\;\ell \leq -1 \cdot 10^{-115}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;\ell \leq 10^{-45}:\\ \;\;\;\;\left(t_0 \cdot \frac{1}{\sqrt{\frac{\ell}{d}}}\right) \cdot \left(1 - \frac{1}{\frac{\ell}{t_1}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{d}{\sqrt{\ell}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\left(0.5 \cdot \frac{M \cdot D}{d}\right)}^{2} \cdot -0.5\right)\right)}{\sqrt{h}}\\ \end{array} \]
Alternative 2
Error16.9
Cost27528
\[\begin{array}{l} t_0 := \sqrt{-d}\\ \mathbf{if}\;d \leq -1 \cdot 10^{-30}:\\ \;\;\;\;\left(\frac{t_0}{\sqrt{-h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - \frac{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \left(h \cdot 0.5\right)}{\ell}\right)\\ \mathbf{elif}\;d \leq 0:\\ \;\;\;\;\left(\frac{t_0}{\sqrt{-\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 + \frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2}\right)\right)\\ \mathbf{elif}\;d \leq 10^{+55}:\\ \;\;\;\;\frac{\frac{d}{\sqrt{\ell}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\left(0.5 \cdot \frac{M \cdot D}{d}\right)}^{2} \cdot -0.5\right)\right)}{\sqrt{h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \]
Alternative 3
Error19.7
Cost21584
\[\begin{array}{l} t_0 := 1 + \frac{-1}{\frac{\ell}{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \left(h \cdot 0.5\right)}}\\ t_1 := {\left(\frac{d}{h}\right)}^{0.5}\\ \mathbf{if}\;d \leq -1.35 \cdot 10^{+127}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{elif}\;d \leq 1.6 \cdot 10^{-294}:\\ \;\;\;\;t_0 \cdot \left(\sqrt{\frac{d}{\ell}} \cdot t_1\right)\\ \mathbf{elif}\;d \leq 10^{-40}:\\ \;\;\;\;\frac{\frac{d}{\sqrt{\ell}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\left(0.5 \cdot \frac{M \cdot D}{d}\right)}^{2} \cdot -0.5\right)\right)}{\sqrt{h}}\\ \mathbf{elif}\;d \leq 10^{+107}:\\ \;\;\;\;\left(t_1 \cdot \frac{1}{\sqrt{\frac{\ell}{d}}}\right) \cdot t_0\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \]
Alternative 4
Error19.4
Cost21328
\[\begin{array}{l} t_0 := \sqrt{\frac{d}{\ell}}\\ t_1 := \sqrt{\frac{d}{h}}\\ \mathbf{if}\;d \leq -1.35 \cdot 10^{+127}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{elif}\;d \leq 1.6 \cdot 10^{-294}:\\ \;\;\;\;\left(1 - \frac{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \left(h \cdot 0.5\right)}{\ell}\right) \cdot \left(t_0 \cdot t_1\right)\\ \mathbf{elif}\;d \leq 10^{-40}:\\ \;\;\;\;\frac{\frac{d}{\sqrt{\ell}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\left(0.5 \cdot \frac{M \cdot D}{d}\right)}^{2} \cdot -0.5\right)\right)}{\sqrt{h}}\\ \mathbf{elif}\;d \leq 10^{+60}:\\ \;\;\;\;t_1 \cdot \left(t_0 \cdot \mathsf{fma}\left(-0.125, h \cdot \left(M \cdot \frac{D}{\frac{d}{\frac{D}{d} \cdot \frac{M}{\ell}}}\right), 1\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \]
Alternative 5
Error19.4
Cost21328
\[\begin{array}{l} t_0 := \sqrt{\frac{d}{\ell}}\\ \mathbf{if}\;d \leq -1.35 \cdot 10^{+127}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{elif}\;d \leq 1.6 \cdot 10^{-294}:\\ \;\;\;\;\left(1 + \frac{-1}{\frac{\ell}{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \left(h \cdot 0.5\right)}}\right) \cdot \left(t_0 \cdot {\left(\frac{d}{h}\right)}^{0.5}\right)\\ \mathbf{elif}\;d \leq 10^{-40}:\\ \;\;\;\;\frac{\frac{d}{\sqrt{\ell}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\left(0.5 \cdot \frac{M \cdot D}{d}\right)}^{2} \cdot -0.5\right)\right)}{\sqrt{h}}\\ \mathbf{elif}\;d \leq 10^{+60}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(t_0 \cdot \mathsf{fma}\left(-0.125, h \cdot \left(M \cdot \frac{D}{\frac{d}{\frac{D}{d} \cdot \frac{M}{\ell}}}\right), 1\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \]
Alternative 6
Error19.7
Cost21264
\[\begin{array}{l} t_0 := \left(1 - \frac{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \left(h \cdot 0.5\right)}{\ell}\right) \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right)\\ \mathbf{if}\;d \leq -1.35 \cdot 10^{+127}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{elif}\;d \leq 1.6 \cdot 10^{-294}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 10^{-40}:\\ \;\;\;\;\frac{\frac{d}{\sqrt{\ell}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\left(0.5 \cdot \frac{M \cdot D}{d}\right)}^{2} \cdot -0.5\right)\right)}{\sqrt{h}}\\ \mathbf{elif}\;d \leq 10^{+107}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \]
Alternative 7
Error22.9
Cost21004
\[\begin{array}{l} \mathbf{if}\;d \leq -1.35 \cdot 10^{+127}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{elif}\;d \leq 0:\\ \;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot {\left(\frac{d}{h}\right)}^{0.5}\right) \cdot \left(1 - \frac{\left(M \cdot M\right) \cdot \left(\frac{h}{d} \cdot \frac{D \cdot 0.125}{\frac{d}{D}}\right)}{\ell}\right)\\ \mathbf{elif}\;d \leq 10^{+55}:\\ \;\;\;\;\frac{\frac{d}{\sqrt{\ell}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\left(0.5 \cdot \frac{M \cdot D}{d}\right)}^{2} \cdot -0.5\right)\right)}{\sqrt{h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \]
Alternative 8
Error24.5
Cost15120
\[\begin{array}{l} t_0 := \sqrt{\frac{d}{\ell}} \cdot {\left(\frac{d}{h}\right)}^{0.5}\\ t_1 := \left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{if}\;d \leq -1.35 \cdot 10^{+127}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d \leq -1.42 \cdot 10^{-77}:\\ \;\;\;\;\left(1 + \left(M \cdot \left(M \cdot \frac{\frac{D}{\frac{d}{D}}}{\frac{\ell}{\frac{h}{d}}}\right)\right) \cdot -0.125\right) \cdot t_0\\ \mathbf{elif}\;d \leq 2.4 \cdot 10^{-222}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d \leq 1.5 \cdot 10^{-97}:\\ \;\;\;\;t_0 \cdot \left(1 - \frac{\left(M \cdot M\right) \cdot \left(\frac{h}{d} \cdot \frac{D \cdot 0.125}{\frac{d}{D}}\right)}{\ell}\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \]
Alternative 9
Error26.7
Cost14856
\[\begin{array}{l} \mathbf{if}\;d \leq -1.35 \cdot 10^{+127}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{elif}\;d \leq 1.5 \cdot 10^{-97}:\\ \;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot {\left(\frac{d}{h}\right)}^{0.5}\right) \cdot \left(1 - \frac{\left(M \cdot M\right) \cdot \left(\frac{h}{d} \cdot \frac{D \cdot 0.125}{\frac{d}{D}}\right)}{\ell}\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \]
Alternative 10
Error23.6
Cost13512
\[\begin{array}{l} \mathbf{if}\;d \leq -1.35 \cdot 10^{+127}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{elif}\;d \leq 6 \cdot 10^{-230}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \]
Alternative 11
Error24.0
Cost13380
\[\begin{array}{l} \mathbf{if}\;d \leq 6 \cdot 10^{-230}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \]
Alternative 12
Error24.0
Cost13252
\[\begin{array}{l} \mathbf{if}\;d \leq 6 \cdot 10^{-230}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \]
Alternative 13
Error27.3
Cost7044
\[\begin{array}{l} \mathbf{if}\;\ell \leq 2.6 \cdot 10^{-275}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}}\\ \end{array} \]
Alternative 14
Error37.3
Cost6980
\[\begin{array}{l} \mathbf{if}\;d \leq 5 \cdot 10^{-234}:\\ \;\;\;\;\sqrt{\frac{d \cdot d}{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}}\\ \end{array} \]
Alternative 15
Error43.5
Cost6720
\[\frac{d}{\sqrt{h \cdot \ell}} \]

Error

Reproduce

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