Average Error: 59.6 → 20.1
Time: 16.3s
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}\;h \leq 4.0293615430633335 \cdot 10^{-307}:\\ \;\;\;\;0.25 \cdot \frac{\frac{D \cdot M}{d} \cdot \frac{h \cdot M}{\frac{1}{D}}}{d}\\ \mathbf{else}:\\ \;\;\;\;0.25 \cdot {\left(\left(M \cdot \sqrt{h}\right) \cdot \frac{D}{d}\right)}^{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
 (if (<= h 4.0293615430633335e-307)
   (* 0.25 (/ (* (/ (* D M) d) (/ (* h M) (/ 1.0 D))) d))
   (* 0.25 (pow (* (* M (sqrt h)) (/ D 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 (h <= 4.0293615430633335e-307) {
		tmp = 0.25 * ((((D * M) / d) * ((h * M) / (1.0 / D))) / d);
	} else {
		tmp = 0.25 * pow(((M * sqrt(h)) * (D / d)), 2.0);
	}
	return tmp;
}
real(8) function code(c0, w, h, d, d_1, m)
    real(8), intent (in) :: c0
    real(8), intent (in) :: w
    real(8), intent (in) :: h
    real(8), intent (in) :: d
    real(8), intent (in) :: d_1
    real(8), intent (in) :: m
    code = (c0 / (2.0d0 * w)) * (((c0 * (d_1 * d_1)) / ((w * h) * (d * d))) + sqrt(((((c0 * (d_1 * d_1)) / ((w * h) * (d * d))) * ((c0 * (d_1 * d_1)) / ((w * h) * (d * d)))) - (m * m))))
end function
real(8) function code(c0, w, h, d, d_1, m)
    real(8), intent (in) :: c0
    real(8), intent (in) :: w
    real(8), intent (in) :: h
    real(8), intent (in) :: d
    real(8), intent (in) :: d_1
    real(8), intent (in) :: m
    real(8) :: tmp
    if (h <= 4.0293615430633335d-307) then
        tmp = 0.25d0 * ((((d * m) / d_1) * ((h * m) / (1.0d0 / d))) / d_1)
    else
        tmp = 0.25d0 * (((m * sqrt(h)) * (d / d_1)) ** 2.0d0)
    end if
    code = tmp
end function
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 (h <= 4.0293615430633335e-307) {
		tmp = 0.25 * ((((D * M) / d) * ((h * M) / (1.0 / D))) / d);
	} else {
		tmp = 0.25 * Math.pow(((M * Math.sqrt(h)) * (D / d)), 2.0);
	}
	return tmp;
}
def code(c0, w, h, D, d, 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))))
def code(c0, w, h, D, d, M):
	tmp = 0
	if h <= 4.0293615430633335e-307:
		tmp = 0.25 * ((((D * M) / d) * ((h * M) / (1.0 / D))) / d)
	else:
		tmp = 0.25 * math.pow(((M * math.sqrt(h)) * (D / 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 (h <= 4.0293615430633335e-307)
		tmp = Float64(0.25 * Float64(Float64(Float64(Float64(D * M) / d) * Float64(Float64(h * M) / Float64(1.0 / D))) / d));
	else
		tmp = Float64(0.25 * (Float64(Float64(M * sqrt(h)) * Float64(D / d)) ^ 2.0));
	end
	return tmp
end
function tmp = code(c0, w, h, D, d, M)
	tmp = (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))));
end
function tmp_2 = code(c0, w, h, D, d, M)
	tmp = 0.0;
	if (h <= 4.0293615430633335e-307)
		tmp = 0.25 * ((((D * M) / d) * ((h * M) / (1.0 / D))) / d);
	else
		tmp = 0.25 * (((M * sqrt(h)) * (D / d)) ^ 2.0);
	end
	tmp_2 = 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[h, 4.0293615430633335e-307], N[(0.25 * N[(N[(N[(N[(D * M), $MachinePrecision] / d), $MachinePrecision] * N[(N[(h * M), $MachinePrecision] / N[(1.0 / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], N[(0.25 * N[Power[N[(N[(M * N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $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}\;h \leq 4.0293615430633335 \cdot 10^{-307}:\\
\;\;\;\;0.25 \cdot \frac{\frac{D \cdot M}{d} \cdot \frac{h \cdot M}{\frac{1}{D}}}{d}\\

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


\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 h < 4.02936154306333345e-307

    1. Initial program 59.7

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

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

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

      \[\leadsto 0.25 \cdot \left(\color{blue}{\frac{D}{\frac{d}{D} \cdot d}} \cdot \left(M \cdot \left(M \cdot h\right)\right)\right) \]
    5. Applied egg-rr26.3

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

      \[\leadsto 0.25 \cdot \frac{\color{blue}{\frac{D \cdot M}{d} \cdot \frac{M \cdot h}{\frac{1}{D}}}}{d} \]

    if 4.02936154306333345e-307 < h

    1. Initial program 59.6

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;h \leq 4.0293615430633335 \cdot 10^{-307}:\\ \;\;\;\;0.25 \cdot \frac{\frac{D \cdot M}{d} \cdot \frac{h \cdot M}{\frac{1}{D}}}{d}\\ \mathbf{else}:\\ \;\;\;\;0.25 \cdot {\left(\left(M \cdot \sqrt{h}\right) \cdot \frac{D}{d}\right)}^{2}\\ \end{array} \]

Reproduce

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