Average Error: 59.8 → 25.3
Time: 18.7s
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}\;M \cdot M \leq 1.9404279609949162 \cdot 10^{-293}:\\ \;\;\;\;0.25 \cdot \log \left({\left(e^{\frac{M \cdot M}{d}}\right)}^{\left(\frac{\left(D \cdot D\right) \cdot h}{d}\right)}\right)\\ \mathbf{elif}\;M \cdot M \leq 3.34639803118571 \cdot 10^{+305}:\\ \;\;\;\;0.25 \cdot \frac{\frac{M \cdot M}{d} \cdot \left(D \cdot \left(D \cdot h\right)\right)}{d}\\ \mathbf{else}:\\ \;\;\;\;0.25 \cdot \frac{M \cdot \left(\left(\left(D \cdot D\right) \cdot h\right) \cdot \frac{M}{d}\right)}{d}\\ \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}
\mathbf{if}\;M \cdot M \leq 1.9404279609949162 \cdot 10^{-293}:\\
\;\;\;\;0.25 \cdot \log \left({\left(e^{\frac{M \cdot M}{d}}\right)}^{\left(\frac{\left(D \cdot D\right) \cdot h}{d}\right)}\right)\\

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

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

\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 (<= (* M M) 1.9404279609949162e-293)
   (* 0.25 (log (pow (exp (/ (* M M) d)) (/ (* (* D D) h) d))))
   (if (<= (* M M) 3.34639803118571e+305)
     (* 0.25 (/ (* (/ (* M M) d) (* D (* D h))) d))
     (* 0.25 (/ (* M (* (* (* D D) h) (/ M d))) d)))))
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 ((M * M) <= 1.9404279609949162e-293) {
		tmp = 0.25 * log(pow(exp((M * M) / d), (((D * D) * h) / d)));
	} else if ((M * M) <= 3.34639803118571e+305) {
		tmp = 0.25 * ((((M * M) / d) * (D * (D * h))) / d);
	} else {
		tmp = 0.25 * ((M * (((D * D) * h) * (M / d))) / d);
	}
	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 (*.f64 M M) < 1.94042796099491617e-293

    1. Initial program 56.2

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

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

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

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

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

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

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

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

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

    if 1.94042796099491617e-293 < (*.f64 M M) < 3.34639803118570989e305

    1. Initial program 61.3

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

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

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

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

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

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

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

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

    if 3.34639803118570989e305 < (*.f64 M M)

    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 63.8

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \cdot M \leq 1.9404279609949162 \cdot 10^{-293}:\\ \;\;\;\;0.25 \cdot \log \left({\left(e^{\frac{M \cdot M}{d}}\right)}^{\left(\frac{\left(D \cdot D\right) \cdot h}{d}\right)}\right)\\ \mathbf{elif}\;M \cdot M \leq 3.34639803118571 \cdot 10^{+305}:\\ \;\;\;\;0.25 \cdot \frac{\frac{M \cdot M}{d} \cdot \left(D \cdot \left(D \cdot h\right)\right)}{d}\\ \mathbf{else}:\\ \;\;\;\;0.25 \cdot \frac{M \cdot \left(\left(\left(D \cdot D\right) \cdot h\right) \cdot \frac{M}{d}\right)}{d}\\ \end{array}\]

Reproduce

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