Average Error: 14.7 → 9.5
Time: 20.3s
Precision: binary64
Cost: 40260
\[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
\[\begin{array}{l} t_0 := \frac{M \cdot D}{2 \cdot d}\\ \mathbf{if}\;t_0 \leq -1 \cdot 10^{+218}:\\ \;\;\;\;w0 \cdot {\left({\left(e^{0.25}\right)}^{\left(\mathsf{fma}\left(-2, \log \left(\frac{-1}{M}\right), \log \left(\left(\frac{h}{\ell} \cdot \left(\frac{D}{d} \cdot \frac{D}{d}\right)\right) \cdot -0.25\right)\right)\right)}\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - h \cdot \left(t_0 \cdot \frac{t_0}{\ell}\right)}\\ \end{array} \]
(FPCore (w0 M D h l d)
 :precision binary64
 (* w0 (sqrt (- 1.0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l))))))
(FPCore (w0 M D h l d)
 :precision binary64
 (let* ((t_0 (/ (* M D) (* 2.0 d))))
   (if (<= t_0 -1e+218)
     (*
      w0
      (pow
       (pow
        (exp 0.25)
        (fma
         -2.0
         (log (/ -1.0 M))
         (log (* (* (/ h l) (* (/ D d) (/ D d))) -0.25))))
       2.0))
     (* w0 (sqrt (- 1.0 (* h (* t_0 (/ t_0 l)))))))))
double code(double w0, double M, double D, double h, double l, double d) {
	return w0 * sqrt((1.0 - (pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
}
double code(double w0, double M, double D, double h, double l, double d) {
	double t_0 = (M * D) / (2.0 * d);
	double tmp;
	if (t_0 <= -1e+218) {
		tmp = w0 * pow(pow(exp(0.25), fma(-2.0, log((-1.0 / M)), log((((h / l) * ((D / d) * (D / d))) * -0.25)))), 2.0);
	} else {
		tmp = w0 * sqrt((1.0 - (h * (t_0 * (t_0 / l)))));
	}
	return tmp;
}
function code(w0, M, D, h, l, d)
	return Float64(w0 * sqrt(Float64(1.0 - Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)))))
end
function code(w0, M, D, h, l, d)
	t_0 = Float64(Float64(M * D) / Float64(2.0 * d))
	tmp = 0.0
	if (t_0 <= -1e+218)
		tmp = Float64(w0 * ((exp(0.25) ^ fma(-2.0, log(Float64(-1.0 / M)), log(Float64(Float64(Float64(h / l) * Float64(Float64(D / d) * Float64(D / d))) * -0.25)))) ^ 2.0));
	else
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(h * Float64(t_0 * Float64(t_0 / l))))));
	end
	return tmp
end
code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1e+218], N[(w0 * N[Power[N[Power[N[Exp[0.25], $MachinePrecision], N[(-2.0 * N[Log[N[(-1.0 / M), $MachinePrecision]], $MachinePrecision] + N[Log[N[(N[(N[(h / l), $MachinePrecision] * N[(N[(D / d), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(h * N[(t$95$0 * N[(t$95$0 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}
\begin{array}{l}
t_0 := \frac{M \cdot D}{2 \cdot d}\\
\mathbf{if}\;t_0 \leq -1 \cdot 10^{+218}:\\
\;\;\;\;w0 \cdot {\left({\left(e^{0.25}\right)}^{\left(\mathsf{fma}\left(-2, \log \left(\frac{-1}{M}\right), \log \left(\left(\frac{h}{\ell} \cdot \left(\frac{D}{d} \cdot \frac{D}{d}\right)\right) \cdot -0.25\right)\right)\right)}\right)}^{2}\\

\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - h \cdot \left(t_0 \cdot \frac{t_0}{\ell}\right)}\\


\end{array}

Error

Derivation

  1. Split input into 2 regimes
  2. if (/.f64 (*.f64 M D) (*.f64 2 d)) < -1.00000000000000008e218

    1. Initial program 64.0

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Applied egg-rr64.0

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

      \[\leadsto w0 \cdot {\color{blue}{\left(e^{0.25 \cdot \left(-2 \cdot \log \left(\frac{-1}{M}\right) + \log \left(-0.25 \cdot \frac{{D}^{2} \cdot h}{{d}^{2} \cdot \ell}\right)\right)}\right)}}^{2} \]
    4. Simplified57.2

      \[\leadsto w0 \cdot {\color{blue}{\left({\left(e^{0.25}\right)}^{\left(\mathsf{fma}\left(-2, \log \left(\frac{-1}{M}\right), \log \left(\left(\frac{h}{\ell} \cdot \left(\frac{D}{d} \cdot \frac{D}{d}\right)\right) \cdot -0.25\right)\right)\right)}\right)}}^{2} \]
      Proof
      (pow.f64 (exp.f64 1/4) (fma.f64 -2 (log.f64 (/.f64 -1 M)) (log.f64 (*.f64 (*.f64 (/.f64 h l) (*.f64 (/.f64 D d) (/.f64 D d))) -1/4)))): 0 points increase in error, 0 points decrease in error
      (pow.f64 (exp.f64 1/4) (fma.f64 -2 (log.f64 (/.f64 -1 M)) (log.f64 (*.f64 (*.f64 (/.f64 h l) (Rewrite<= times-frac_binary64 (/.f64 (*.f64 D D) (*.f64 d d)))) -1/4)))): 25 points increase in error, 4 points decrease in error
      (pow.f64 (exp.f64 1/4) (fma.f64 -2 (log.f64 (/.f64 -1 M)) (log.f64 (*.f64 (*.f64 (/.f64 h l) (/.f64 (Rewrite<= unpow2_binary64 (pow.f64 D 2)) (*.f64 d d))) -1/4)))): 0 points increase in error, 0 points decrease in error
      (pow.f64 (exp.f64 1/4) (fma.f64 -2 (log.f64 (/.f64 -1 M)) (log.f64 (*.f64 (*.f64 (/.f64 h l) (/.f64 (pow.f64 D 2) (Rewrite<= unpow2_binary64 (pow.f64 d 2)))) -1/4)))): 0 points increase in error, 0 points decrease in error
      (pow.f64 (exp.f64 1/4) (fma.f64 -2 (log.f64 (/.f64 -1 M)) (log.f64 (*.f64 (Rewrite<= times-frac_binary64 (/.f64 (*.f64 h (pow.f64 D 2)) (*.f64 l (pow.f64 d 2)))) -1/4)))): 14 points increase in error, 13 points decrease in error
      (pow.f64 (exp.f64 1/4) (fma.f64 -2 (log.f64 (/.f64 -1 M)) (log.f64 (*.f64 (/.f64 (Rewrite<= *-commutative_binary64 (*.f64 (pow.f64 D 2) h)) (*.f64 l (pow.f64 d 2))) -1/4)))): 0 points increase in error, 0 points decrease in error
      (pow.f64 (exp.f64 1/4) (fma.f64 -2 (log.f64 (/.f64 -1 M)) (log.f64 (*.f64 (/.f64 (*.f64 (pow.f64 D 2) h) (Rewrite=> *-commutative_binary64 (*.f64 (pow.f64 d 2) l))) -1/4)))): 0 points increase in error, 0 points decrease in error
      (pow.f64 (exp.f64 1/4) (fma.f64 -2 (log.f64 (/.f64 -1 M)) (log.f64 (*.f64 (/.f64 (*.f64 (pow.f64 D 2) h) (*.f64 (pow.f64 d 2) l)) (Rewrite<= metadata-eval (neg.f64 1/4)))))): 0 points increase in error, 0 points decrease in error
      (pow.f64 (exp.f64 1/4) (fma.f64 -2 (log.f64 (/.f64 -1 M)) (log.f64 (Rewrite<= distribute-rgt-neg-in_binary64 (neg.f64 (*.f64 (/.f64 (*.f64 (pow.f64 D 2) h) (*.f64 (pow.f64 d 2) l)) 1/4)))))): 0 points increase in error, 0 points decrease in error
      (pow.f64 (exp.f64 1/4) (fma.f64 -2 (log.f64 (/.f64 -1 M)) (log.f64 (neg.f64 (Rewrite<= *-commutative_binary64 (*.f64 1/4 (/.f64 (*.f64 (pow.f64 D 2) h) (*.f64 (pow.f64 d 2) l)))))))): 0 points increase in error, 0 points decrease in error
      (pow.f64 (exp.f64 1/4) (Rewrite<= fma-def_binary64 (+.f64 (*.f64 -2 (log.f64 (/.f64 -1 M))) (log.f64 (neg.f64 (*.f64 1/4 (/.f64 (*.f64 (pow.f64 D 2) h) (*.f64 (pow.f64 d 2) l)))))))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= exp-prod_binary64 (exp.f64 (*.f64 1/4 (+.f64 (*.f64 -2 (log.f64 (/.f64 -1 M))) (log.f64 (neg.f64 (*.f64 1/4 (/.f64 (*.f64 (pow.f64 D 2) h) (*.f64 (pow.f64 d 2) l))))))))): 9 points increase in error, 7 points decrease in error

    if -1.00000000000000008e218 < (/.f64 (*.f64 M D) (*.f64 2 d))

    1. Initial program 11.9

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Applied egg-rr8.2

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

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

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\frac{\frac{D \cdot M}{d \cdot 2}}{1} \cdot \frac{\frac{D \cdot M}{d \cdot 2}}{\ell}\right)} \cdot h} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification9.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{M \cdot D}{2 \cdot d} \leq -1 \cdot 10^{+218}:\\ \;\;\;\;w0 \cdot {\left({\left(e^{0.25}\right)}^{\left(\mathsf{fma}\left(-2, \log \left(\frac{-1}{M}\right), \log \left(\left(\frac{h}{\ell} \cdot \left(\frac{D}{d} \cdot \frac{D}{d}\right)\right) \cdot -0.25\right)\right)\right)}\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - h \cdot \left(\frac{M \cdot D}{2 \cdot d} \cdot \frac{\frac{M \cdot D}{2 \cdot d}}{\ell}\right)}\\ \end{array} \]

Alternatives

Alternative 1
Error13.9
Cost8140
\[\begin{array}{l} t_0 := w0 \cdot \sqrt{1 + \frac{-0.25 \cdot \frac{D \cdot \frac{M}{\frac{d}{M \cdot h}}}{\frac{d}{D}}}{\ell}}\\ \mathbf{if}\;M \leq -20500000000000:\\ \;\;\;\;w0\\ \mathbf{elif}\;M \leq -9 \cdot 10^{-78}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;M \leq 1.2739127062031248 \cdot 10^{-160}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error14.1
Cost8140
\[\begin{array}{l} \mathbf{if}\;M \leq -1.95 \cdot 10^{+115}:\\ \;\;\;\;w0 + \left(w0 \cdot -0.125\right) \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}\right)\\ \mathbf{elif}\;M \leq -3 \cdot 10^{-67}:\\ \;\;\;\;w0 \cdot \sqrt{1 + \frac{-0.25 \cdot \frac{D \cdot \left(M \cdot M\right)}{\frac{d}{h} \cdot \frac{d}{D}}}{\ell}}\\ \mathbf{elif}\;M \leq 1.2739127062031248 \cdot 10^{-160}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 + \frac{-0.25 \cdot \frac{D \cdot \frac{M}{\frac{d}{M \cdot h}}}{\frac{d}{D}}}{\ell}}\\ \end{array} \]
Alternative 3
Error9.7
Cost7872
\[\begin{array}{l} t_0 := \frac{M \cdot D}{2 \cdot d}\\ w0 \cdot \sqrt{1 - h \cdot \left(t_0 \cdot \frac{t_0}{\ell}\right)} \end{array} \]
Alternative 4
Error13.9
Cost64
\[w0 \]

Error

Reproduce

herbie shell --seed 2022313 
(FPCore (w0 M D h l d)
  :name "Henrywood and Agarwal, Equation (9a)"
  :precision binary64
  (* w0 (sqrt (- 1.0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l))))))