Average Error: 12.3 → 2.2
Time: 2.7s
Precision: binary64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \leq -1.099407840975313 \cdot 10^{-163} \lor \neg \left(z \leq 1.652141365346291 \cdot 10^{+102}\right):\\ \;\;\;\;x + x \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{x \cdot y}{z}\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;z \leq -1.099407840975313 \cdot 10^{-163} \lor \neg \left(z \leq 1.652141365346291 \cdot 10^{+102}\right):\\
\;\;\;\;x + x \cdot \frac{y}{z}\\

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

\end{array}
(FPCore (x y z) :precision binary64 (/ (* x (+ y z)) z))
(FPCore (x y z)
 :precision binary64
 (if (or (<= z -1.099407840975313e-163) (not (<= z 1.652141365346291e+102)))
   (+ x (* x (/ y z)))
   (+ x (/ (* x y) z))))
double code(double x, double y, double z) {
	return (((double) (x * ((double) (y + z)))) / z);
}
double code(double x, double y, double z) {
	double tmp;
	if (((z <= -1.099407840975313e-163) || !(z <= 1.652141365346291e+102))) {
		tmp = ((double) (x + ((double) (x * (y / z)))));
	} else {
		tmp = ((double) (x + (((double) (x * y)) / z)));
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original12.3
Target2.9
Herbie2.2
\[\frac{x}{\frac{z}{y + z}}\]

Derivation

  1. Split input into 2 regimes
  2. if z < -1.09940784097531308e-163 or 1.652141365346291e102 < z

    1. Initial program Error: 15.5 bits

      \[\frac{x \cdot \left(y + z\right)}{z}\]
    2. SimplifiedError: 0.8 bits

      \[\leadsto \color{blue}{x + x \cdot \frac{y}{z}}\]

    if -1.09940784097531308e-163 < z < 1.652141365346291e102

    1. Initial program Error: 7.2 bits

      \[\frac{x \cdot \left(y + z\right)}{z}\]
    2. SimplifiedError: 6.8 bits

      \[\leadsto \color{blue}{x + x \cdot \frac{y}{z}}\]
    3. Using strategy rm
    4. Applied associate-*r/Error: 4.4 bits

      \[\leadsto x + \color{blue}{\frac{x \cdot y}{z}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplificationError: 2.2 bits

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.099407840975313 \cdot 10^{-163} \lor \neg \left(z \leq 1.652141365346291 \cdot 10^{+102}\right):\\ \;\;\;\;x + x \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{x \cdot y}{z}\\ \end{array}\]

Reproduce

herbie shell --seed 2020204 
(FPCore (x y z)
  :name "Numeric.SpecFunctions:choose from math-functions-0.1.5.2"
  :precision binary64

  :herbie-target
  (/ x (/ z (+ y z)))

  (/ (* x (+ y z)) z))