Average Error: 59.7 → 23.8
Time: 15.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 := {\left(D \cdot M\right)}^{2}\\ \mathbf{if}\;d \cdot d \leq 0:\\ \;\;\;\;h \cdot \left(\left(D \cdot \frac{D}{d}\right) \cdot \left(\frac{0.25}{d} \cdot \left(M \cdot M\right)\right)\right)\\ \mathbf{elif}\;d \cdot d \leq 2 \cdot 10^{+279}:\\ \;\;\;\;0.25 \cdot \frac{t_0}{\frac{d}{\frac{h}{d}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.25}{d} \cdot \frac{t_0}{\frac{d}{h}}\\ \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 M) 2.0)))
   (if (<= (* d d) 0.0)
     (* h (* (* D (/ D d)) (* (/ 0.25 d) (* M M))))
     (if (<= (* d d) 2e+279)
       (* 0.25 (/ t_0 (/ d (/ h d))))
       (* (/ 0.25 d) (/ t_0 (/ d h)))))))
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 * M), 2.0);
	double tmp;
	if ((d * d) <= 0.0) {
		tmp = h * ((D * (D / d)) * ((0.25 / d) * (M * M)));
	} else if ((d * d) <= 2e+279) {
		tmp = 0.25 * (t_0 / (d / (h / d)));
	} else {
		tmp = (0.25 / d) * (t_0 / (d / h));
	}
	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) :: t_0
    real(8) :: tmp
    t_0 = (d * m) ** 2.0d0
    if ((d_1 * d_1) <= 0.0d0) then
        tmp = h * ((d * (d / d_1)) * ((0.25d0 / d_1) * (m * m)))
    else if ((d_1 * d_1) <= 2d+279) then
        tmp = 0.25d0 * (t_0 / (d_1 / (h / d_1)))
    else
        tmp = (0.25d0 / d_1) * (t_0 / (d_1 / h))
    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 t_0 = Math.pow((D * M), 2.0);
	double tmp;
	if ((d * d) <= 0.0) {
		tmp = h * ((D * (D / d)) * ((0.25 / d) * (M * M)));
	} else if ((d * d) <= 2e+279) {
		tmp = 0.25 * (t_0 / (d / (h / d)));
	} else {
		tmp = (0.25 / d) * (t_0 / (d / h));
	}
	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):
	t_0 = math.pow((D * M), 2.0)
	tmp = 0
	if (d * d) <= 0.0:
		tmp = h * ((D * (D / d)) * ((0.25 / d) * (M * M)))
	elif (d * d) <= 2e+279:
		tmp = 0.25 * (t_0 / (d / (h / d)))
	else:
		tmp = (0.25 / d) * (t_0 / (d / h))
	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 * M) ^ 2.0
	tmp = 0.0
	if (Float64(d * d) <= 0.0)
		tmp = Float64(h * Float64(Float64(D * Float64(D / d)) * Float64(Float64(0.25 / d) * Float64(M * M))));
	elseif (Float64(d * d) <= 2e+279)
		tmp = Float64(0.25 * Float64(t_0 / Float64(d / Float64(h / d))));
	else
		tmp = Float64(Float64(0.25 / d) * Float64(t_0 / Float64(d / h)));
	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)
	t_0 = (D * M) ^ 2.0;
	tmp = 0.0;
	if ((d * d) <= 0.0)
		tmp = h * ((D * (D / d)) * ((0.25 / d) * (M * M)));
	elseif ((d * d) <= 2e+279)
		tmp = 0.25 * (t_0 / (d / (h / d)));
	else
		tmp = (0.25 / d) * (t_0 / (d / h));
	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_] := Block[{t$95$0 = N[Power[N[(D * M), $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[N[(d * d), $MachinePrecision], 0.0], N[(h * N[(N[(D * N[(D / d), $MachinePrecision]), $MachinePrecision] * N[(N[(0.25 / d), $MachinePrecision] * N[(M * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(d * d), $MachinePrecision], 2e+279], N[(0.25 * N[(t$95$0 / N[(d / N[(h / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.25 / d), $MachinePrecision] * N[(t$95$0 / N[(d / h), $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(D \cdot M\right)}^{2}\\
\mathbf{if}\;d \cdot d \leq 0:\\
\;\;\;\;h \cdot \left(\left(D \cdot \frac{D}{d}\right) \cdot \left(\frac{0.25}{d} \cdot \left(M \cdot M\right)\right)\right)\\

\mathbf{elif}\;d \cdot d \leq 2 \cdot 10^{+279}:\\
\;\;\;\;0.25 \cdot \frac{t_0}{\frac{d}{\frac{h}{d}}}\\

\mathbf{else}:\\
\;\;\;\;\frac{0.25}{d} \cdot \frac{t_0}{\frac{d}{h}}\\


\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 (*.f64 d d) < 0.0

    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 64.0

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

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

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

      \[\leadsto \color{blue}{\frac{0.25}{d} \cdot \left(\left(\frac{h}{d} \cdot \left(D \cdot D\right)\right) \cdot \left(M \cdot M\right)\right)} \]
    6. Taylor expanded in d around 0 64.0

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

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

    if 0.0 < (*.f64 d d) < 2.00000000000000012e279

    1. Initial program 55.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 40.2

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

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

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

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

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

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

    if 2.00000000000000012e279 < (*.f64 d d)

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \cdot d \leq 0:\\ \;\;\;\;h \cdot \left(\left(D \cdot \frac{D}{d}\right) \cdot \left(\frac{0.25}{d} \cdot \left(M \cdot M\right)\right)\right)\\ \mathbf{elif}\;d \cdot d \leq 2 \cdot 10^{+279}:\\ \;\;\;\;0.25 \cdot \frac{{\left(D \cdot M\right)}^{2}}{\frac{d}{\frac{h}{d}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.25}{d} \cdot \frac{{\left(D \cdot M\right)}^{2}}{\frac{d}{h}}\\ \end{array} \]

Reproduce

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