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

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

\mathbf{else}:\\
\;\;\;\;t_0\\


\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 D < -4.5035385606924489e-105 or 1.8910093042920924e-204 < D

    1. Initial program 57.5

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

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

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

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

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

    if -4.5035385606924489e-105 < D < 1.8910093042920924e-204

    1. Initial program 63.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) \]
    2. Taylor expanded in c0 around -inf 32.1

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;D \leq -4.503538560692449 \cdot 10^{-105}:\\ \;\;\;\;0.25 \cdot \left(h \cdot {\left(\frac{D \cdot M}{d}\right)}^{2}\right)\\ \mathbf{elif}\;D \leq 1.8910093042920924 \cdot 10^{-204}:\\ \;\;\;\;0.25 \cdot \frac{{\left(D \cdot M\right)}^{2} \cdot \frac{h}{d}}{d}\\ \mathbf{else}:\\ \;\;\;\;0.25 \cdot \left(h \cdot {\left(\frac{D \cdot M}{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))))))