Average Error: 59.7 → 26.9
Time: 17.9s
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 := h \cdot \left(M \cdot M\right)\\ t_1 := 0.25 \cdot \frac{D \cdot \left(t_0 \cdot \frac{D}{d}\right)}{d}\\ \mathbf{if}\;D \leq -4.031642161132083 \cdot 10^{-277}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_2 := \frac{D \cdot D}{d}\\ \mathbf{if}\;D \leq 4.7072638932713915 \cdot 10^{-121}:\\ \;\;\;\;0.25 \cdot \log \left({\left(e^{t_2}\right)}^{\left(\frac{t_0}{d}\right)}\right)\\ \mathbf{elif}\;D \leq 1.5278585707073579 \cdot 10^{+152}:\\ \;\;\;\;0.25 \cdot \frac{t_2 \cdot \left(M \cdot \left(h \cdot M\right)\right)}{d}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array}\\ \end{array} \]
\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 := h \cdot \left(M \cdot M\right)\\
t_1 := 0.25 \cdot \frac{D \cdot \left(t_0 \cdot \frac{D}{d}\right)}{d}\\
\mathbf{if}\;D \leq -4.031642161132083 \cdot 10^{-277}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_2 := \frac{D \cdot D}{d}\\
\mathbf{if}\;D \leq 4.7072638932713915 \cdot 10^{-121}:\\
\;\;\;\;0.25 \cdot \log \left({\left(e^{t_2}\right)}^{\left(\frac{t_0}{d}\right)}\right)\\

\mathbf{elif}\;D \leq 1.5278585707073579 \cdot 10^{+152}:\\
\;\;\;\;0.25 \cdot \frac{t_2 \cdot \left(M \cdot \left(h \cdot M\right)\right)}{d}\\

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


\end{array}\\


\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 (* h (* M M))) (t_1 (* 0.25 (/ (* D (* t_0 (/ D d))) d))))
   (if (<= D -4.031642161132083e-277)
     t_1
     (let* ((t_2 (/ (* D D) d)))
       (if (<= D 4.7072638932713915e-121)
         (* 0.25 (log (pow (exp t_2) (/ t_0 d))))
         (if (<= D 1.5278585707073579e+152)
           (* 0.25 (/ (* t_2 (* M (* h M))) 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 = h * (M * M);
	double t_1 = 0.25 * ((D * (t_0 * (D / d))) / d);
	double tmp;
	if (D <= -4.031642161132083e-277) {
		tmp = t_1;
	} else {
		double t_2 = (D * D) / d;
		double tmp_1;
		if (D <= 4.7072638932713915e-121) {
			tmp_1 = 0.25 * log(pow(exp(t_2), (t_0 / d)));
		} else if (D <= 1.5278585707073579e+152) {
			tmp_1 = 0.25 * ((t_2 * (M * (h * M))) / d);
		} else {
			tmp_1 = t_1;
		}
		tmp = tmp_1;
	}
	return tmp;
}

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 < -4.03164216113208287e-277 or 1.52785857070735787e152 < D

    1. Initial program 59.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 around -inf 44.9

      \[\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. Simplified46.3

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

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

      \[\leadsto \color{blue}{0.25 \cdot \frac{\left(D \cdot D\right) \cdot \left(\left(M \cdot M\right) \cdot h\right)}{d \cdot d}} \]
    6. Using strategy rm
    7. Applied associate-/r*_binary6437.5

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

      \[\leadsto 0.25 \cdot \frac{\color{blue}{\frac{D \cdot D}{d} \cdot \left(\left(M \cdot M\right) \cdot h\right)}}{d} \]
    9. Using strategy rm
    10. Applied *-un-lft-identity_binary6436.7

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

      \[\leadsto 0.25 \cdot \frac{\color{blue}{\left(\frac{D}{1} \cdot \frac{D}{d}\right)} \cdot \left(\left(M \cdot M\right) \cdot h\right)}{d} \]
    12. Applied associate-*l*_binary6429.6

      \[\leadsto 0.25 \cdot \frac{\color{blue}{\frac{D}{1} \cdot \left(\frac{D}{d} \cdot \left(\left(M \cdot M\right) \cdot h\right)\right)}}{d} \]
    13. Simplified29.6

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

    if -4.03164216113208287e-277 < D < 4.7072638932713915e-121

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

      \[\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. Simplified41.4

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

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

      \[\leadsto \color{blue}{0.25 \cdot \frac{\left(D \cdot D\right) \cdot \left(\left(M \cdot M\right) \cdot h\right)}{d \cdot d}} \]
    6. Using strategy rm
    7. Applied associate-/r*_binary6429.4

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

      \[\leadsto 0.25 \cdot \frac{\color{blue}{\frac{D \cdot D}{d} \cdot \left(\left(M \cdot M\right) \cdot h\right)}}{d} \]
    9. Using strategy rm
    10. Applied add-log-exp_binary6429.8

      \[\leadsto 0.25 \cdot \color{blue}{\log \left(e^{\frac{\frac{D \cdot D}{d} \cdot \left(\left(M \cdot M\right) \cdot h\right)}{d}}\right)} \]
    11. Simplified24.6

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

    if 4.7072638932713915e-121 < D < 1.52785857070735787e152

    1. Initial program 56.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) \]
    2. Taylor expanded around -inf 39.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. Simplified40.5

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

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

      \[\leadsto \color{blue}{0.25 \cdot \frac{\left(D \cdot D\right) \cdot \left(\left(M \cdot M\right) \cdot h\right)}{d \cdot d}} \]
    6. Using strategy rm
    7. Applied associate-/r*_binary6428.7

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

      \[\leadsto 0.25 \cdot \frac{\color{blue}{\frac{D \cdot D}{d} \cdot \left(\left(M \cdot M\right) \cdot h\right)}}{d} \]
    9. Using strategy rm
    10. Applied associate-*l*_binary6423.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;D \leq -4.031642161132083 \cdot 10^{-277}:\\ \;\;\;\;0.25 \cdot \frac{D \cdot \left(\left(h \cdot \left(M \cdot M\right)\right) \cdot \frac{D}{d}\right)}{d}\\ \mathbf{elif}\;D \leq 4.7072638932713915 \cdot 10^{-121}:\\ \;\;\;\;0.25 \cdot \log \left({\left(e^{\frac{D \cdot D}{d}}\right)}^{\left(\frac{h \cdot \left(M \cdot M\right)}{d}\right)}\right)\\ \mathbf{elif}\;D \leq 1.5278585707073579 \cdot 10^{+152}:\\ \;\;\;\;0.25 \cdot \frac{\frac{D \cdot D}{d} \cdot \left(M \cdot \left(h \cdot M\right)\right)}{d}\\ \mathbf{else}:\\ \;\;\;\;0.25 \cdot \frac{D \cdot \left(\left(h \cdot \left(M \cdot M\right)\right) \cdot \frac{D}{d}\right)}{d}\\ \end{array} \]

Reproduce

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