Average Error: 14.3 → 9.0
Time: 16.1s
Precision: binary64
Cost: 46916
\[ \begin{array}{c}[M, D] = \mathsf{sort}([M, D])\\ \end{array} \]
\[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
\[\begin{array}{l} t_0 := {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\\ \mathbf{if}\;t_0 \leq -\infty:\\ \;\;\;\;w0 \cdot {\left({\left(e^{0.25}\right)}^{\left(\mathsf{fma}\left(-2, -\log D, \log \left(\left(\frac{h}{\ell} \cdot \left(\frac{M}{d} \cdot \frac{M}{d}\right)\right) \cdot -0.25\right)\right)\right)}\right)}^{2}\\ \mathbf{elif}\;t_0 \leq \infty:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(\frac{M}{d} \cdot \frac{D}{2}\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \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 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l))))
   (if (<= t_0 (- INFINITY))
     (*
      w0
      (pow
       (pow
        (exp 0.25)
        (fma -2.0 (- (log D)) (log (* (* (/ h l) (* (/ M d) (/ M d))) -0.25))))
       2.0))
     (if (<= t_0 INFINITY)
       (* w0 (sqrt (- 1.0 (* (/ h l) (pow (* (/ M d) (/ D 2.0)) 2.0)))))
       w0))))
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 = pow(((M * D) / (2.0 * d)), 2.0) * (h / l);
	double tmp;
	if (t_0 <= -((double) INFINITY)) {
		tmp = w0 * pow(pow(exp(0.25), fma(-2.0, -log(D), log((((h / l) * ((M / d) * (M / d))) * -0.25)))), 2.0);
	} else if (t_0 <= ((double) INFINITY)) {
		tmp = w0 * sqrt((1.0 - ((h / l) * pow(((M / d) * (D / 2.0)), 2.0))));
	} else {
		tmp = w0;
	}
	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(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l))
	tmp = 0.0
	if (t_0 <= Float64(-Inf))
		tmp = Float64(w0 * ((exp(0.25) ^ fma(-2.0, Float64(-log(D)), log(Float64(Float64(Float64(h / l) * Float64(Float64(M / d) * Float64(M / d))) * -0.25)))) ^ 2.0));
	elseif (t_0 <= Inf)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h / l) * (Float64(Float64(M / d) * Float64(D / 2.0)) ^ 2.0)))));
	else
		tmp = w0;
	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[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(w0 * N[Power[N[Power[N[Exp[0.25], $MachinePrecision], N[(-2.0 * (-N[Log[D], $MachinePrecision]) + N[Log[N[(N[(N[(h / l), $MachinePrecision] * N[(N[(M / d), $MachinePrecision] * N[(M / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(M / d), $MachinePrecision] * N[(D / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0]]]
w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}
\begin{array}{l}
t_0 := {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;w0 \cdot {\left({\left(e^{0.25}\right)}^{\left(\mathsf{fma}\left(-2, -\log D, \log \left(\left(\frac{h}{\ell} \cdot \left(\frac{M}{d} \cdot \frac{M}{d}\right)\right) \cdot -0.25\right)\right)\right)}\right)}^{2}\\

\mathbf{elif}\;t_0 \leq \infty:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(\frac{M}{d} \cdot \frac{D}{2}\right)}^{2}}\\

\mathbf{else}:\\
\;\;\;\;w0\\


\end{array}

Error

Derivation

  1. Split input into 3 regimes
  2. if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)) < -inf.0

    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-rr61.4

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

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

      \[\leadsto w0 \cdot {\color{blue}{\left({\left(e^{0.25}\right)}^{\left(\mathsf{fma}\left(-2, -\log D, \log \left(\left(\frac{h}{\ell} \cdot \left(\frac{M}{d} \cdot \frac{M}{d}\right)\right) \cdot -0.25\right)\right)\right)}\right)}}^{2} \]

    if -inf.0 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)) < +inf.0

    1. Initial program 0.2

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

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

    if +inf.0 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l))

    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 \sqrt{1 - {\color{blue}{\left(\frac{0.5}{d} \cdot \left(M \cdot D\right)\right)}}^{2} \cdot \frac{h}{\ell}} \]
    3. Taylor expanded in d around inf 15.7

      \[\leadsto \color{blue}{w0} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification9.0

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

Alternatives

Alternative 1
Error9.4
Cost21764
\[\begin{array}{l} \mathbf{if}\;w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \leq 5 \cdot 10^{+304}:\\ \;\;\;\;w0 \cdot \sqrt{1 + \left(\frac{0.5}{d} \cdot \left(M \cdot D\right)\right) \cdot \left(\frac{h}{\ell} \cdot \left(\left(M \cdot D\right) \cdot \frac{-0.5}{d}\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]
Alternative 2
Error14.2
Cost8008
\[\begin{array}{l} \mathbf{if}\;M \leq 1.0588607994684581 \cdot 10^{-181}:\\ \;\;\;\;w0\\ \mathbf{elif}\;M \leq 2.8 \cdot 10^{+73}:\\ \;\;\;\;w0 \cdot \sqrt{1 + -0.25 \cdot \frac{\left(M \cdot \left(M \cdot h\right)\right) \cdot \left(D \cdot \frac{D}{d}\right)}{d \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]
Alternative 3
Error14.9
Cost8008
\[\begin{array}{l} \mathbf{if}\;h \leq -6.4 \cdot 10^{+125}:\\ \;\;\;\;w0 \cdot \sqrt{1 + -0.25 \cdot \left(h \cdot \frac{\left(M \cdot D\right) \cdot \left(M \cdot D\right)}{\ell \cdot \left(d \cdot d\right)}\right)}\\ \mathbf{elif}\;h \leq -3.4 \cdot 10^{+16}:\\ \;\;\;\;w0 \cdot \sqrt{1 + -0.25 \cdot \frac{\left(M \cdot \left(M \cdot h\right)\right) \cdot \left(D \cdot \frac{D}{d}\right)}{d \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]
Alternative 4
Error14.0
Cost64
\[w0 \]

Error

Reproduce

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