Average Error: 8.0 → 0.1
Time: 1.6s
Precision: binary64
\[\frac{x \cdot y}{y + 1}\]
\[\begin{array}{l} \mathbf{if}\;y \leq -1.6455685274748016 \cdot 10^{+32} \lor \neg \left(y \leq 60684360887918.63\right):\\ \;\;\;\;\sqrt{\frac{y}{y + 1}} \cdot \left(x \cdot \sqrt{\frac{y}{y + 1}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot x}{y + 1}\\ \end{array}\]
\frac{x \cdot y}{y + 1}
\begin{array}{l}
\mathbf{if}\;y \leq -1.6455685274748016 \cdot 10^{+32} \lor \neg \left(y \leq 60684360887918.63\right):\\
\;\;\;\;\sqrt{\frac{y}{y + 1}} \cdot \left(x \cdot \sqrt{\frac{y}{y + 1}}\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{y \cdot x}{y + 1}\\

\end{array}
(FPCore (x y) :precision binary64 (/ (* x y) (+ y 1.0)))
(FPCore (x y)
 :precision binary64
 (if (or (<= y -1.6455685274748016e+32) (not (<= y 60684360887918.63)))
   (* (sqrt (/ y (+ y 1.0))) (* x (sqrt (/ y (+ y 1.0)))))
   (/ (* y x) (+ y 1.0))))
double code(double x, double y) {
	return (((double) (x * y)) / ((double) (y + 1.0)));
}
double code(double x, double y) {
	double tmp;
	if (((y <= -1.6455685274748016e+32) || !(y <= 60684360887918.63))) {
		tmp = ((double) (((double) sqrt((y / ((double) (y + 1.0))))) * ((double) (x * ((double) sqrt((y / ((double) (y + 1.0)))))))));
	} else {
		tmp = (((double) (y * x)) / ((double) (y + 1.0)));
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original8.0
Target0.0
Herbie0.1
\[\begin{array}{l} \mathbf{if}\;y < -3693.8482788297247:\\ \;\;\;\;\frac{x}{y \cdot y} - \left(\frac{x}{y} - x\right)\\ \mathbf{elif}\;y < 6799310503.41891:\\ \;\;\;\;\frac{x \cdot y}{y + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y \cdot y} - \left(\frac{x}{y} - x\right)\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if y < -1.6455685274748016e32 or 60684360887918.6328 < y

    1. Initial program Error: 17.3 bits

      \[\frac{x \cdot y}{y + 1}\]
    2. SimplifiedError: 0.0 bits

      \[\leadsto \color{blue}{x \cdot \frac{y}{y + 1}}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrtError: 0.0 bits

      \[\leadsto x \cdot \color{blue}{\left(\sqrt{\frac{y}{y + 1}} \cdot \sqrt{\frac{y}{y + 1}}\right)}\]
    5. Applied associate-*r*Error: 0.0 bits

      \[\leadsto \color{blue}{\left(x \cdot \sqrt{\frac{y}{y + 1}}\right) \cdot \sqrt{\frac{y}{y + 1}}}\]

    if -1.6455685274748016e32 < y < 60684360887918.6328

    1. Initial program Error: 0.1 bits

      \[\frac{x \cdot y}{y + 1}\]
  3. Recombined 2 regimes into one program.
  4. Final simplificationError: 0.1 bits

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.6455685274748016 \cdot 10^{+32} \lor \neg \left(y \leq 60684360887918.63\right):\\ \;\;\;\;\sqrt{\frac{y}{y + 1}} \cdot \left(x \cdot \sqrt{\frac{y}{y + 1}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot x}{y + 1}\\ \end{array}\]

Reproduce

herbie shell --seed 2020204 
(FPCore (x y)
  :name "Diagrams.Trail:splitAtParam  from diagrams-lib-1.3.0.3, B"
  :precision binary64

  :herbie-target
  (if (< y -3693.8482788297247) (- (/ x (* y y)) (- (/ x y) x)) (if (< y 6799310503.41891) (/ (* x y) (+ y 1.0)) (- (/ x (* y y)) (- (/ x y) x))))

  (/ (* x y) (+ y 1.0)))