Average Error: 59.8 → 29.2
Time: 15.0s
Precision: binary64
\[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
\[\begin{array}{l} t_0 := {\left(\frac{D}{d}\right)}^{2}\\ \mathbf{if}\;D \cdot D \leq 10^{-268}:\\ \;\;\;\;\frac{c0 \cdot \mathsf{fma}\left(0.5, w \cdot \frac{t_0}{\frac{\frac{c0}{M}}{M \cdot h}}, 0\right)}{w \cdot 2}\\ \mathbf{elif}\;D \cdot D \leq 5 \cdot 10^{+30}:\\ \;\;\;\;\left(M \cdot M\right) \cdot \frac{D \cdot \left(D \cdot 0.25\right)}{\frac{d}{\frac{h}{d}}}\\ \mathbf{elif}\;D \cdot D \leq 2 \cdot 10^{+68}:\\ \;\;\;\;\frac{c0}{w \cdot 2} \cdot \left(\left(\frac{d}{D} \cdot \frac{d}{D}\right) \cdot \left(2 \cdot \frac{c0}{w \cdot h}\right)\right)\\ \mathbf{elif}\;D \cdot D \leq 10^{+257}:\\ \;\;\;\;0.25 \cdot \frac{{D}^{2} \cdot \left(h \cdot {M}^{2}\right)}{{d}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\left(c0 \cdot \mathsf{fma}\left(0.5, \frac{\left(w \cdot t_0\right) \cdot \left(M \cdot \left(M \cdot h\right)\right)}{c0}, 0\right)\right) \cdot \frac{1}{w \cdot 2}\\ \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (*
  (/ c0 (* 2.0 w))
  (+
   (/ (* c0 (* d d)) (* (* w h) (* D D)))
   (sqrt
    (-
     (*
      (/ (* c0 (* d d)) (* (* w h) (* D D)))
      (/ (* c0 (* d d)) (* (* w h) (* D D))))
     (* M M))))))
(FPCore (c0 w h D d M)
 :precision binary64
 (let* ((t_0 (pow (/ D d) 2.0)))
   (if (<= (* D D) 1e-268)
     (/ (* c0 (fma 0.5 (* w (/ t_0 (/ (/ c0 M) (* M h)))) 0.0)) (* w 2.0))
     (if (<= (* D D) 5e+30)
       (* (* M M) (/ (* D (* D 0.25)) (/ d (/ h d))))
       (if (<= (* D D) 2e+68)
         (* (/ c0 (* w 2.0)) (* (* (/ d D) (/ d D)) (* 2.0 (/ c0 (* w h)))))
         (if (<= (* D D) 1e+257)
           (* 0.25 (/ (* (pow D 2.0) (* h (pow M 2.0))) (pow d 2.0)))
           (*
            (* c0 (fma 0.5 (/ (* (* w t_0) (* M (* M h))) c0) 0.0))
            (/ 1.0 (* w 2.0)))))))))
double code(double c0, double w, double h, double D, double d, double M) {
	return (c0 / (2.0 * w)) * (((c0 * (d * d)) / ((w * h) * (D * D))) + sqrt(((((c0 * (d * d)) / ((w * h) * (D * D))) * ((c0 * (d * d)) / ((w * h) * (D * D)))) - (M * M))));
}
double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = pow((D / d), 2.0);
	double tmp;
	if ((D * D) <= 1e-268) {
		tmp = (c0 * fma(0.5, (w * (t_0 / ((c0 / M) / (M * h)))), 0.0)) / (w * 2.0);
	} else if ((D * D) <= 5e+30) {
		tmp = (M * M) * ((D * (D * 0.25)) / (d / (h / d)));
	} else if ((D * D) <= 2e+68) {
		tmp = (c0 / (w * 2.0)) * (((d / D) * (d / D)) * (2.0 * (c0 / (w * h))));
	} else if ((D * D) <= 1e+257) {
		tmp = 0.25 * ((pow(D, 2.0) * (h * pow(M, 2.0))) / pow(d, 2.0));
	} else {
		tmp = (c0 * fma(0.5, (((w * t_0) * (M * (M * h))) / c0), 0.0)) * (1.0 / (w * 2.0));
	}
	return tmp;
}
function code(c0, w, h, D, d, M)
	return Float64(Float64(c0 / Float64(2.0 * w)) * Float64(Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D))) + sqrt(Float64(Float64(Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D))) * Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D)))) - Float64(M * M)))))
end
function code(c0, w, h, D, d, M)
	t_0 = Float64(D / d) ^ 2.0
	tmp = 0.0
	if (Float64(D * D) <= 1e-268)
		tmp = Float64(Float64(c0 * fma(0.5, Float64(w * Float64(t_0 / Float64(Float64(c0 / M) / Float64(M * h)))), 0.0)) / Float64(w * 2.0));
	elseif (Float64(D * D) <= 5e+30)
		tmp = Float64(Float64(M * M) * Float64(Float64(D * Float64(D * 0.25)) / Float64(d / Float64(h / d))));
	elseif (Float64(D * D) <= 2e+68)
		tmp = Float64(Float64(c0 / Float64(w * 2.0)) * Float64(Float64(Float64(d / D) * Float64(d / D)) * Float64(2.0 * Float64(c0 / Float64(w * h)))));
	elseif (Float64(D * D) <= 1e+257)
		tmp = Float64(0.25 * Float64(Float64((D ^ 2.0) * Float64(h * (M ^ 2.0))) / (d ^ 2.0)));
	else
		tmp = Float64(Float64(c0 * fma(0.5, Float64(Float64(Float64(w * t_0) * Float64(M * Float64(M * h))) / c0), 0.0)) * Float64(1.0 / Float64(w * 2.0)));
	end
	return tmp
end
code[c0_, w_, h_, D_, d_, M_] := N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Sqrt[N[(N[(N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[Power[N[(D / d), $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[N[(D * D), $MachinePrecision], 1e-268], N[(N[(c0 * N[(0.5 * N[(w * N[(t$95$0 / N[(N[(c0 / M), $MachinePrecision] / N[(M * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 0.0), $MachinePrecision]), $MachinePrecision] / N[(w * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(D * D), $MachinePrecision], 5e+30], N[(N[(M * M), $MachinePrecision] * N[(N[(D * N[(D * 0.25), $MachinePrecision]), $MachinePrecision] / N[(d / N[(h / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(D * D), $MachinePrecision], 2e+68], N[(N[(c0 / N[(w * 2.0), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(d / D), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision] * N[(2.0 * N[(c0 / N[(w * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(D * D), $MachinePrecision], 1e+257], N[(0.25 * N[(N[(N[Power[D, 2.0], $MachinePrecision] * N[(h * N[Power[M, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Power[d, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c0 * N[(0.5 * N[(N[(N[(w * t$95$0), $MachinePrecision] * N[(M * N[(M * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c0), $MachinePrecision] + 0.0), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(w * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right)
\begin{array}{l}
t_0 := {\left(\frac{D}{d}\right)}^{2}\\
\mathbf{if}\;D \cdot D \leq 10^{-268}:\\
\;\;\;\;\frac{c0 \cdot \mathsf{fma}\left(0.5, w \cdot \frac{t_0}{\frac{\frac{c0}{M}}{M \cdot h}}, 0\right)}{w \cdot 2}\\

\mathbf{elif}\;D \cdot D \leq 5 \cdot 10^{+30}:\\
\;\;\;\;\left(M \cdot M\right) \cdot \frac{D \cdot \left(D \cdot 0.25\right)}{\frac{d}{\frac{h}{d}}}\\

\mathbf{elif}\;D \cdot D \leq 2 \cdot 10^{+68}:\\
\;\;\;\;\frac{c0}{w \cdot 2} \cdot \left(\left(\frac{d}{D} \cdot \frac{d}{D}\right) \cdot \left(2 \cdot \frac{c0}{w \cdot h}\right)\right)\\

\mathbf{elif}\;D \cdot D \leq 10^{+257}:\\
\;\;\;\;0.25 \cdot \frac{{D}^{2} \cdot \left(h \cdot {M}^{2}\right)}{{d}^{2}}\\

\mathbf{else}:\\
\;\;\;\;\left(c0 \cdot \mathsf{fma}\left(0.5, \frac{\left(w \cdot t_0\right) \cdot \left(M \cdot \left(M \cdot h\right)\right)}{c0}, 0\right)\right) \cdot \frac{1}{w \cdot 2}\\


\end{array}

Error

Derivation

  1. Split input into 5 regimes
  2. if (*.f64 D D) < 9.99999999999999958e-269

    1. Initial program 63.4

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Taylor expanded in c0 around -inf 63.4

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(0.5 \cdot \frac{{D}^{2} \cdot \left(w \cdot \left({M}^{2} \cdot h\right)\right)}{{d}^{2} \cdot c0} + -1 \cdot \left(\left(\frac{{d}^{2}}{{D}^{2} \cdot \left(w \cdot h\right)} + -1 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(w \cdot h\right)}\right) \cdot c0\right)\right)} \]
    3. Simplified32.2

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(0.5, \left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \frac{w}{\frac{c0}{M \cdot \left(M \cdot h\right)}}, c0 \cdot 0\right)} \]
    4. Applied egg-rr26.8

      \[\leadsto \color{blue}{\frac{c0 \cdot \mathsf{fma}\left(0.5, \frac{{\left(\frac{D}{d}\right)}^{2} \cdot w}{\frac{c0}{M \cdot \left(M \cdot h\right)}}, 0\right)}{w \cdot 2}} \]
    5. Applied egg-rr25.9

      \[\leadsto \frac{c0 \cdot \mathsf{fma}\left(0.5, \color{blue}{\frac{w}{1} \cdot \frac{{\left(\frac{D}{d}\right)}^{2}}{\frac{\frac{c0}{M}}{M \cdot h}}}, 0\right)}{w \cdot 2} \]

    if 9.99999999999999958e-269 < (*.f64 D D) < 4.9999999999999998e30

    1. Initial program 56.0

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Taylor expanded in c0 around -inf 56.1

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(0.5 \cdot \frac{{D}^{2} \cdot \left(w \cdot \left({M}^{2} \cdot h\right)\right)}{{d}^{2} \cdot c0} + -1 \cdot \left(\left(\frac{{d}^{2}}{{D}^{2} \cdot \left(w \cdot h\right)} + -1 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(w \cdot h\right)}\right) \cdot c0\right)\right)} \]
    3. Simplified35.4

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(0.5, \left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \frac{w}{\frac{c0}{M \cdot \left(M \cdot h\right)}}, c0 \cdot 0\right)} \]
    4. Applied egg-rr30.5

      \[\leadsto \color{blue}{\frac{c0 \cdot \mathsf{fma}\left(0.5, \frac{{\left(\frac{D}{d}\right)}^{2} \cdot w}{\frac{c0}{M \cdot \left(M \cdot h\right)}}, 0\right)}{w \cdot 2}} \]
    5. Taylor expanded in c0 around 0 29.1

      \[\leadsto \color{blue}{0.25 \cdot \frac{{D}^{2} \cdot \left(h \cdot {M}^{2}\right)}{{d}^{2}}} \]
    6. Simplified26.7

      \[\leadsto \color{blue}{\left(M \cdot M\right) \cdot \frac{D \cdot \left(D \cdot 0.25\right)}{\frac{d}{\frac{h}{d}}}} \]

    if 4.9999999999999998e30 < (*.f64 D D) < 1.99999999999999991e68

    1. Initial program 57.2

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Taylor expanded in c0 around inf 57.9

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(2 \cdot \frac{{d}^{2} \cdot c0}{{D}^{2} \cdot \left(w \cdot h\right)}\right)} \]
    3. Simplified53.7

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(\left(\frac{d}{D} \cdot \frac{d}{D}\right) \cdot \left(\frac{c0}{w \cdot h} \cdot 2\right)\right)} \]

    if 1.99999999999999991e68 < (*.f64 D D) < 1.00000000000000003e257

    1. Initial program 54.8

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Taylor expanded in c0 around -inf 56.0

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(0.5 \cdot \frac{{D}^{2} \cdot \left(w \cdot \left({M}^{2} \cdot h\right)\right)}{{d}^{2} \cdot c0} + -1 \cdot \left(\left(\frac{{d}^{2}}{{D}^{2} \cdot \left(w \cdot h\right)} + -1 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(w \cdot h\right)}\right) \cdot c0\right)\right)} \]
    3. Simplified38.9

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(0.5, \left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \frac{w}{\frac{c0}{M \cdot \left(M \cdot h\right)}}, c0 \cdot 0\right)} \]
    4. Taylor expanded in c0 around 0 34.6

      \[\leadsto \color{blue}{0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}} \]

    if 1.00000000000000003e257 < (*.f64 D D)

    1. Initial program 61.4

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Taylor expanded in c0 around -inf 63.0

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(0.5 \cdot \frac{{D}^{2} \cdot \left(w \cdot \left({M}^{2} \cdot h\right)\right)}{{d}^{2} \cdot c0} + -1 \cdot \left(\left(\frac{{d}^{2}}{{D}^{2} \cdot \left(w \cdot h\right)} + -1 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(w \cdot h\right)}\right) \cdot c0\right)\right)} \]
    3. Simplified39.5

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(0.5, \left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \frac{w}{\frac{c0}{M \cdot \left(M \cdot h\right)}}, c0 \cdot 0\right)} \]
    4. Applied egg-rr36.6

      \[\leadsto \color{blue}{\frac{c0 \cdot \mathsf{fma}\left(0.5, \frac{{\left(\frac{D}{d}\right)}^{2} \cdot w}{\frac{c0}{M \cdot \left(M \cdot h\right)}}, 0\right)}{w \cdot 2}} \]
    5. Applied egg-rr35.7

      \[\leadsto \frac{c0 \cdot \mathsf{fma}\left(0.5, \color{blue}{\frac{1}{c0} \cdot \frac{{\left(\frac{D}{d}\right)}^{2} \cdot w}{\frac{1}{M \cdot \left(M \cdot h\right)}}}, 0\right)}{w \cdot 2} \]
    6. Applied egg-rr35.7

      \[\leadsto \color{blue}{\left(c0 \cdot \mathsf{fma}\left(0.5, \frac{\left({\left(\frac{D}{d}\right)}^{2} \cdot w\right) \cdot \left(M \cdot \left(M \cdot h\right)\right)}{c0}, 0\right)\right) \cdot \frac{1}{2 \cdot w}} \]
  3. Recombined 5 regimes into one program.
  4. Final simplification29.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;D \cdot D \leq 10^{-268}:\\ \;\;\;\;\frac{c0 \cdot \mathsf{fma}\left(0.5, w \cdot \frac{{\left(\frac{D}{d}\right)}^{2}}{\frac{\frac{c0}{M}}{M \cdot h}}, 0\right)}{w \cdot 2}\\ \mathbf{elif}\;D \cdot D \leq 5 \cdot 10^{+30}:\\ \;\;\;\;\left(M \cdot M\right) \cdot \frac{D \cdot \left(D \cdot 0.25\right)}{\frac{d}{\frac{h}{d}}}\\ \mathbf{elif}\;D \cdot D \leq 2 \cdot 10^{+68}:\\ \;\;\;\;\frac{c0}{w \cdot 2} \cdot \left(\left(\frac{d}{D} \cdot \frac{d}{D}\right) \cdot \left(2 \cdot \frac{c0}{w \cdot h}\right)\right)\\ \mathbf{elif}\;D \cdot D \leq 10^{+257}:\\ \;\;\;\;0.25 \cdot \frac{{D}^{2} \cdot \left(h \cdot {M}^{2}\right)}{{d}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\left(c0 \cdot \mathsf{fma}\left(0.5, \frac{\left(w \cdot {\left(\frac{D}{d}\right)}^{2}\right) \cdot \left(M \cdot \left(M \cdot h\right)\right)}{c0}, 0\right)\right) \cdot \frac{1}{w \cdot 2}\\ \end{array} \]

Reproduce

herbie shell --seed 2022209 
(FPCore (c0 w h D d M)
  :name "Henrywood and Agarwal, Equation (13)"
  :precision binary64
  (* (/ c0 (* 2.0 w)) (+ (/ (* c0 (* d d)) (* (* w h) (* D D))) (sqrt (- (* (/ (* c0 (* d d)) (* (* w h) (* D D))) (/ (* c0 (* d d)) (* (* w h) (* D D)))) (* M M))))))