Average Error: 59.6 → 19.3
Time: 15.8s
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} \mathbf{if}\;d \leq 2.380894459195274 \cdot 10^{-262}:\\ \;\;\;\;0.25 \cdot \left(h \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}\right)\\ \mathbf{elif}\;d \leq 4.188188085536091 \cdot 10^{-178}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\left(\frac{d}{D} \cdot \frac{d}{D}\right) \cdot \frac{c0}{h \cdot w}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.25 \cdot \left(h \cdot {\left(\frac{{\left(\sqrt[3]{M}\right)}^{2}}{d} \cdot \frac{\sqrt[3]{M}}{\frac{1}{D}}\right)}^{2}\right)\\ \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
 (if (<= d 2.380894459195274e-262)
   (* 0.25 (* h (pow (* D (/ M d)) 2.0)))
   (if (<= d 4.188188085536091e-178)
     (* (/ c0 (* 2.0 w)) (* 2.0 (* (* (/ d D) (/ d D)) (/ c0 (* h w)))))
     (*
      0.25
      (* h (pow (* (/ (pow (cbrt M) 2.0) d) (/ (cbrt M) (/ 1.0 D))) 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 tmp;
	if (d <= 2.380894459195274e-262) {
		tmp = 0.25 * (h * pow((D * (M / d)), 2.0));
	} else if (d <= 4.188188085536091e-178) {
		tmp = (c0 / (2.0 * w)) * (2.0 * (((d / D) * (d / D)) * (c0 / (h * w))));
	} else {
		tmp = 0.25 * (h * pow(((pow(cbrt(M), 2.0) / d) * (cbrt(M) / (1.0 / D))), 2.0));
	}
	return tmp;
}
public static 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))) + Math.sqrt(((((c0 * (d * d)) / ((w * h) * (D * D))) * ((c0 * (d * d)) / ((w * h) * (D * D)))) - (M * M))));
}
public static double code(double c0, double w, double h, double D, double d, double M) {
	double tmp;
	if (d <= 2.380894459195274e-262) {
		tmp = 0.25 * (h * Math.pow((D * (M / d)), 2.0));
	} else if (d <= 4.188188085536091e-178) {
		tmp = (c0 / (2.0 * w)) * (2.0 * (((d / D) * (d / D)) * (c0 / (h * w))));
	} else {
		tmp = 0.25 * (h * Math.pow(((Math.pow(Math.cbrt(M), 2.0) / d) * (Math.cbrt(M) / (1.0 / D))), 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)
	tmp = 0.0
	if (d <= 2.380894459195274e-262)
		tmp = Float64(0.25 * Float64(h * (Float64(D * Float64(M / d)) ^ 2.0)));
	elseif (d <= 4.188188085536091e-178)
		tmp = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(2.0 * Float64(Float64(Float64(d / D) * Float64(d / D)) * Float64(c0 / Float64(h * w)))));
	else
		tmp = Float64(0.25 * Float64(h * (Float64(Float64((cbrt(M) ^ 2.0) / d) * Float64(cbrt(M) / Float64(1.0 / D))) ^ 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_] := If[LessEqual[d, 2.380894459195274e-262], N[(0.25 * N[(h * N[Power[N[(D * N[(M / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 4.188188085536091e-178], N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(2.0 * N[(N[(N[(d / D), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision] * N[(c0 / N[(h * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.25 * N[(h * N[Power[N[(N[(N[Power[N[Power[M, 1/3], $MachinePrecision], 2.0], $MachinePrecision] / d), $MachinePrecision] * N[(N[Power[M, 1/3], $MachinePrecision] / N[(1.0 / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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}
\mathbf{if}\;d \leq 2.380894459195274 \cdot 10^{-262}:\\
\;\;\;\;0.25 \cdot \left(h \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}\right)\\

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

\mathbf{else}:\\
\;\;\;\;0.25 \cdot \left(h \cdot {\left(\frac{{\left(\sqrt[3]{M}\right)}^{2}}{d} \cdot \frac{\sqrt[3]{M}}{\frac{1}{D}}\right)}^{2}\right)\\


\end{array}

Error

Bits error versus c0

Bits error versus w

Bits error versus h

Bits error versus D

Bits error versus d

Bits error versus M

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if d < 2.3808944591952741e-262

    1. Initial program 59.9

      \[\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 35.3

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

      \[\leadsto \color{blue}{0.25 \cdot \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \left(\left(M \cdot M\right) \cdot h\right)\right)} \]
    4. Applied egg-rr19.2

      \[\leadsto 0.25 \cdot \color{blue}{\left(0 + h \cdot {\left(\frac{D}{d} \cdot M\right)}^{2}\right)} \]
    5. Taylor expanded in D around 0 19.4

      \[\leadsto 0.25 \cdot \left(0 + h \cdot {\color{blue}{\left(\frac{D \cdot M}{d}\right)}}^{2}\right) \]
    6. Simplified19.3

      \[\leadsto 0.25 \cdot \left(0 + h \cdot {\color{blue}{\left(\frac{M}{\frac{d}{D}}\right)}}^{2}\right) \]
    7. Applied egg-rr19.2

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

    if 2.3808944591952741e-262 < d < 4.18818808553609102e-178

    1. Initial program 62.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 62.7

      \[\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. Simplified44.9

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

    if 4.18818808553609102e-178 < d

    1. Initial program 59.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 31.7

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

      \[\leadsto \color{blue}{0.25 \cdot \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \left(\left(M \cdot M\right) \cdot h\right)\right)} \]
    4. Applied egg-rr18.0

      \[\leadsto 0.25 \cdot \color{blue}{\left(0 + h \cdot {\left(\frac{D}{d} \cdot M\right)}^{2}\right)} \]
    5. Taylor expanded in D around 0 17.9

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

      \[\leadsto 0.25 \cdot \left(0 + h \cdot {\color{blue}{\left(\frac{M}{\frac{d}{D}}\right)}}^{2}\right) \]
    7. Applied egg-rr17.8

      \[\leadsto 0.25 \cdot \left(0 + h \cdot {\color{blue}{\left(\frac{{\left(\sqrt[3]{M}\right)}^{2}}{d} \cdot \frac{\sqrt[3]{M}}{\frac{1}{D}}\right)}}^{2}\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification19.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq 2.380894459195274 \cdot 10^{-262}:\\ \;\;\;\;0.25 \cdot \left(h \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}\right)\\ \mathbf{elif}\;d \leq 4.188188085536091 \cdot 10^{-178}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\left(\frac{d}{D} \cdot \frac{d}{D}\right) \cdot \frac{c0}{h \cdot w}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.25 \cdot \left(h \cdot {\left(\frac{{\left(\sqrt[3]{M}\right)}^{2}}{d} \cdot \frac{\sqrt[3]{M}}{\frac{1}{D}}\right)}^{2}\right)\\ \end{array} \]

Reproduce

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