Average Error: 59.3 → 22.9
Time: 20.6s
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 := \frac{D}{\sqrt[3]{d} \cdot \sqrt[3]{d}}\\ t_1 := 0.25 \cdot \left(t_0 \cdot \left(\frac{D}{\sqrt[3]{d}} \cdot \frac{M \cdot \left(M \cdot h\right)}{d}\right)\right)\\ \mathbf{if}\;M \leq -2.4351434862071375 \cdot 10^{+110}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;M \leq 1.4541904515427528 \cdot 10^{+137}:\\ \;\;\;\;0.25 \cdot \left(t_0 \cdot \left(\left(h \cdot \frac{D}{d}\right) \cdot \frac{M \cdot M}{\sqrt[3]{d}}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \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 (/ D (* (cbrt d) (cbrt d))))
        (t_1 (* 0.25 (* t_0 (* (/ D (cbrt d)) (/ (* M (* M h)) d))))))
   (if (<= M -2.4351434862071375e+110)
     t_1
     (if (<= M 1.4541904515427528e+137)
       (* 0.25 (* t_0 (* (* h (/ D d)) (/ (* M M) (cbrt d)))))
       t_1))))
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 = D / (cbrt(d) * cbrt(d));
	double t_1 = 0.25 * (t_0 * ((D / cbrt(d)) * ((M * (M * h)) / d)));
	double tmp;
	if (M <= -2.4351434862071375e+110) {
		tmp = t_1;
	} else if (M <= 1.4541904515427528e+137) {
		tmp = 0.25 * (t_0 * ((h * (D / d)) * ((M * M) / cbrt(d))));
	} else {
		tmp = t_1;
	}
	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 t_0 = D / (Math.cbrt(d) * Math.cbrt(d));
	double t_1 = 0.25 * (t_0 * ((D / Math.cbrt(d)) * ((M * (M * h)) / d)));
	double tmp;
	if (M <= -2.4351434862071375e+110) {
		tmp = t_1;
	} else if (M <= 1.4541904515427528e+137) {
		tmp = 0.25 * (t_0 * ((h * (D / d)) * ((M * M) / Math.cbrt(d))));
	} else {
		tmp = t_1;
	}
	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 / Float64(cbrt(d) * cbrt(d)))
	t_1 = Float64(0.25 * Float64(t_0 * Float64(Float64(D / cbrt(d)) * Float64(Float64(M * Float64(M * h)) / d))))
	tmp = 0.0
	if (M <= -2.4351434862071375e+110)
		tmp = t_1;
	elseif (M <= 1.4541904515427528e+137)
		tmp = Float64(0.25 * Float64(t_0 * Float64(Float64(h * Float64(D / d)) * Float64(Float64(M * M) / cbrt(d)))));
	else
		tmp = t_1;
	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[(D / N[(N[Power[d, 1/3], $MachinePrecision] * N[Power[d, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.25 * N[(t$95$0 * N[(N[(D / N[Power[d, 1/3], $MachinePrecision]), $MachinePrecision] * N[(N[(M * N[(M * h), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[M, -2.4351434862071375e+110], t$95$1, If[LessEqual[M, 1.4541904515427528e+137], N[(0.25 * N[(t$95$0 * N[(N[(h * N[(D / d), $MachinePrecision]), $MachinePrecision] * N[(N[(M * M), $MachinePrecision] / N[Power[d, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\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 := \frac{D}{\sqrt[3]{d} \cdot \sqrt[3]{d}}\\
t_1 := 0.25 \cdot \left(t_0 \cdot \left(\frac{D}{\sqrt[3]{d}} \cdot \frac{M \cdot \left(M \cdot h\right)}{d}\right)\right)\\
\mathbf{if}\;M \leq -2.4351434862071375 \cdot 10^{+110}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;M \leq 1.4541904515427528 \cdot 10^{+137}:\\
\;\;\;\;0.25 \cdot \left(t_0 \cdot \left(\left(h \cdot \frac{D}{d}\right) \cdot \frac{M \cdot M}{\sqrt[3]{d}}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\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 2 regimes
  2. if M < -2.43514348620713745e110 or 1.4541904515427528e137 < M

    1. Initial program 63.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 58.9

      \[\leadsto \color{blue}{0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}} \]
    3. Applied add-sqr-sqrt_binary6461.3

      \[\leadsto 0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{\color{blue}{\left(\sqrt{d} \cdot \sqrt{d}\right)}}^{2}} \]
    4. Applied unpow-prod-down_binary6461.3

      \[\leadsto 0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{\color{blue}{{\left(\sqrt{d}\right)}^{2} \cdot {\left(\sqrt{d}\right)}^{2}}} \]
    5. Applied times-frac_binary6461.0

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

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

      \[\leadsto 0.25 \cdot \left(\frac{D \cdot D}{d} \cdot \color{blue}{\frac{h \cdot \left(M \cdot M\right)}{d}}\right) \]
    8. Applied add-cube-cbrt_binary6458.1

      \[\leadsto 0.25 \cdot \left(\frac{D \cdot D}{\color{blue}{\left(\sqrt[3]{d} \cdot \sqrt[3]{d}\right) \cdot \sqrt[3]{d}}} \cdot \frac{h \cdot \left(M \cdot M\right)}{d}\right) \]
    9. Applied times-frac_binary6457.4

      \[\leadsto 0.25 \cdot \left(\color{blue}{\left(\frac{D}{\sqrt[3]{d} \cdot \sqrt[3]{d}} \cdot \frac{D}{\sqrt[3]{d}}\right)} \cdot \frac{h \cdot \left(M \cdot M\right)}{d}\right) \]
    10. Applied associate-*l*_binary6457.0

      \[\leadsto 0.25 \cdot \color{blue}{\left(\frac{D}{\sqrt[3]{d} \cdot \sqrt[3]{d}} \cdot \left(\frac{D}{\sqrt[3]{d}} \cdot \frac{h \cdot \left(M \cdot M\right)}{d}\right)\right)} \]
    11. Applied associate-*r*_binary6441.8

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

    if -2.43514348620713745e110 < M < 1.4541904515427528e137

    1. Initial program 58.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 30.2

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

      \[\leadsto 0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{\color{blue}{\left(\sqrt{d} \cdot \sqrt{d}\right)}}^{2}} \]
    4. Applied unpow-prod-down_binary6446.6

      \[\leadsto 0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{\color{blue}{{\left(\sqrt{d}\right)}^{2} \cdot {\left(\sqrt{d}\right)}^{2}}} \]
    5. Applied times-frac_binary6444.8

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

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

      \[\leadsto 0.25 \cdot \left(\frac{D \cdot D}{d} \cdot \color{blue}{\frac{h \cdot \left(M \cdot M\right)}{d}}\right) \]
    8. Applied add-cube-cbrt_binary6426.6

      \[\leadsto 0.25 \cdot \left(\frac{D \cdot D}{\color{blue}{\left(\sqrt[3]{d} \cdot \sqrt[3]{d}\right) \cdot \sqrt[3]{d}}} \cdot \frac{h \cdot \left(M \cdot M\right)}{d}\right) \]
    9. Applied times-frac_binary6423.3

      \[\leadsto 0.25 \cdot \left(\color{blue}{\left(\frac{D}{\sqrt[3]{d} \cdot \sqrt[3]{d}} \cdot \frac{D}{\sqrt[3]{d}}\right)} \cdot \frac{h \cdot \left(M \cdot M\right)}{d}\right) \]
    10. Applied associate-*l*_binary6421.6

      \[\leadsto 0.25 \cdot \color{blue}{\left(\frac{D}{\sqrt[3]{d} \cdot \sqrt[3]{d}} \cdot \left(\frac{D}{\sqrt[3]{d}} \cdot \frac{h \cdot \left(M \cdot M\right)}{d}\right)\right)} \]
    11. Applied add-cube-cbrt_binary6421.6

      \[\leadsto 0.25 \cdot \left(\frac{D}{\sqrt[3]{d} \cdot \sqrt[3]{d}} \cdot \left(\frac{D}{\sqrt[3]{d}} \cdot \frac{h \cdot \left(M \cdot M\right)}{\color{blue}{\left(\sqrt[3]{d} \cdot \sqrt[3]{d}\right) \cdot \sqrt[3]{d}}}\right)\right) \]
    12. Applied times-frac_binary6421.0

      \[\leadsto 0.25 \cdot \left(\frac{D}{\sqrt[3]{d} \cdot \sqrt[3]{d}} \cdot \left(\frac{D}{\sqrt[3]{d}} \cdot \color{blue}{\left(\frac{h}{\sqrt[3]{d} \cdot \sqrt[3]{d}} \cdot \frac{M \cdot M}{\sqrt[3]{d}}\right)}\right)\right) \]
    13. Applied associate-*r*_binary6420.1

      \[\leadsto 0.25 \cdot \left(\frac{D}{\sqrt[3]{d} \cdot \sqrt[3]{d}} \cdot \color{blue}{\left(\left(\frac{D}{\sqrt[3]{d}} \cdot \frac{h}{\sqrt[3]{d} \cdot \sqrt[3]{d}}\right) \cdot \frac{M \cdot M}{\sqrt[3]{d}}\right)}\right) \]
    14. Simplified19.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq -2.4351434862071375 \cdot 10^{+110}:\\ \;\;\;\;0.25 \cdot \left(\frac{D}{\sqrt[3]{d} \cdot \sqrt[3]{d}} \cdot \left(\frac{D}{\sqrt[3]{d}} \cdot \frac{M \cdot \left(M \cdot h\right)}{d}\right)\right)\\ \mathbf{elif}\;M \leq 1.4541904515427528 \cdot 10^{+137}:\\ \;\;\;\;0.25 \cdot \left(\frac{D}{\sqrt[3]{d} \cdot \sqrt[3]{d}} \cdot \left(\left(h \cdot \frac{D}{d}\right) \cdot \frac{M \cdot M}{\sqrt[3]{d}}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.25 \cdot \left(\frac{D}{\sqrt[3]{d} \cdot \sqrt[3]{d}} \cdot \left(\frac{D}{\sqrt[3]{d}} \cdot \frac{M \cdot \left(M \cdot h\right)}{d}\right)\right)\\ \end{array} \]

Reproduce

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