Average Error: 59.9 → 27.7
Time: 17.0s
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)\\ \mathbf{if}\;D \leq -9.879018091396131 \cdot 10^{+131}:\\ \;\;\;\;0.25 \cdot \frac{\frac{D}{\frac{\frac{d}{t_0}}{D}}}{d}\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_1 := 0.25 \cdot \frac{\left(D \cdot D\right) \cdot \frac{M \cdot \left(h \cdot M\right)}{d}}{d}\\ \mathbf{if}\;D \leq -1.57845886360931 \cdot 10^{-173}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_2 := \frac{t_0}{d}\\ \mathbf{if}\;D \leq -1.9928696319416464 \cdot 10^{-212}:\\ \;\;\;\;0.25 \cdot \frac{D \cdot \left(D \cdot t_2\right)}{d}\\ \mathbf{elif}\;D \leq 1.5268851672651507 \cdot 10^{-148}:\\ \;\;\;\;0.25 \cdot \log \left({\left(e^{t_2}\right)}^{\left(\frac{D \cdot D}{d}\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array}\\ \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)\\
\mathbf{if}\;D \leq -9.879018091396131 \cdot 10^{+131}:\\
\;\;\;\;0.25 \cdot \frac{\frac{D}{\frac{\frac{d}{t_0}}{D}}}{d}\\

\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_1 := 0.25 \cdot \frac{\left(D \cdot D\right) \cdot \frac{M \cdot \left(h \cdot M\right)}{d}}{d}\\
\mathbf{if}\;D \leq -1.57845886360931 \cdot 10^{-173}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;D \leq 1.5268851672651507 \cdot 10^{-148}:\\
\;\;\;\;0.25 \cdot \log \left({\left(e^{t_2}\right)}^{\left(\frac{D \cdot D}{d}\right)}\right)\\

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


\end{array}\\


\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))))
   (if (<= D -9.879018091396131e+131)
     (* 0.25 (/ (/ D (/ (/ d t_0) D)) d))
     (let* ((t_1 (* 0.25 (/ (* (* D D) (/ (* M (* h M)) d)) d))))
       (if (<= D -1.57845886360931e-173)
         t_1
         (let* ((t_2 (/ t_0 d)))
           (if (<= D -1.9928696319416464e-212)
             (* 0.25 (/ (* D (* D t_2)) d))
             (if (<= D 1.5268851672651507e-148)
               (* 0.25 (log (pow (exp t_2) (/ (* D D) 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 tmp;
	if (D <= -9.879018091396131e+131) {
		tmp = 0.25 * ((D / ((d / t_0) / D)) / d);
	} else {
		double t_1 = 0.25 * (((D * D) * ((M * (h * M)) / d)) / d);
		double tmp_1;
		if (D <= -1.57845886360931e-173) {
			tmp_1 = t_1;
		} else {
			double t_2 = t_0 / d;
			double tmp_2;
			if (D <= -1.9928696319416464e-212) {
				tmp_2 = 0.25 * ((D * (D * t_2)) / d);
			} else if (D <= 1.5268851672651507e-148) {
				tmp_2 = 0.25 * log(pow(exp(t_2), ((D * D) / d)));
			} else {
				tmp_2 = t_1;
			}
			tmp_1 = tmp_2;
		}
		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 4 regimes
  2. if D < -9.8790180913961314e131

    1. Initial program 62.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 around -inf 61.4

      \[\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. Simplified61.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 60.4

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

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

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

      \[\leadsto 0.25 \cdot \frac{\color{blue}{\left(D \cdot D\right) \cdot \frac{h \cdot \left(M \cdot M\right)}{d}}}{d} \]
    9. Using strategy rm
    10. Applied clear-num_binary6460.4

      \[\leadsto 0.25 \cdot \frac{\left(D \cdot D\right) \cdot \color{blue}{\frac{1}{\frac{d}{h \cdot \left(M \cdot M\right)}}}}{d} \]
    11. Applied un-div-inv_binary6460.4

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

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

    if -9.8790180913961314e131 < D < -1.57845886360931e-173 or 1.52688516726515065e-148 < D

    1. Initial program 57.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 41.4

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

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

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

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

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

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

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

    if -1.57845886360931e-173 < D < -1.992869631941646e-212

    1. Initial program 64.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 38.6

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

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

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

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

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

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

    if -1.992869631941646e-212 < D < 1.52688516726515065e-148

    1. Initial program 63.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 around -inf 40.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. Simplified42.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 34.1

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;D \leq -9.879018091396131 \cdot 10^{+131}:\\ \;\;\;\;0.25 \cdot \frac{\frac{D}{\frac{\frac{d}{h \cdot \left(M \cdot M\right)}}{D}}}{d}\\ \mathbf{elif}\;D \leq -1.57845886360931 \cdot 10^{-173}:\\ \;\;\;\;0.25 \cdot \frac{\left(D \cdot D\right) \cdot \frac{M \cdot \left(h \cdot M\right)}{d}}{d}\\ \mathbf{elif}\;D \leq -1.9928696319416464 \cdot 10^{-212}:\\ \;\;\;\;0.25 \cdot \frac{D \cdot \left(D \cdot \frac{h \cdot \left(M \cdot M\right)}{d}\right)}{d}\\ \mathbf{elif}\;D \leq 1.5268851672651507 \cdot 10^{-148}:\\ \;\;\;\;0.25 \cdot \log \left({\left(e^{\frac{h \cdot \left(M \cdot M\right)}{d}}\right)}^{\left(\frac{D \cdot D}{d}\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;0.25 \cdot \frac{\left(D \cdot D\right) \cdot \frac{M \cdot \left(h \cdot M\right)}{d}}{d}\\ \end{array} \]

Reproduce

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