Average Error: 12.5 → 2.7
Time: 2.4s
Precision: binary64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \leq -2.4193787838886472 \cdot 10^{-12}:\\ \;\;\;\;x + x \cdot \frac{y}{z}\\ \mathbf{elif}\;z \leq -7.401115730235809 \cdot 10^{-203}:\\ \;\;\;\;x + \left(x \cdot y\right) \cdot \frac{1}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{z + y}}\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;z \leq -2.4193787838886472 \cdot 10^{-12}:\\
\;\;\;\;x + x \cdot \frac{y}{z}\\

\mathbf{elif}\;z \leq -7.401115730235809 \cdot 10^{-203}:\\
\;\;\;\;x + \left(x \cdot y\right) \cdot \frac{1}{z}\\

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

\end{array}
(FPCore (x y z) :precision binary64 (/ (* x (+ y z)) z))
(FPCore (x y z)
 :precision binary64
 (if (<= z -2.4193787838886472e-12)
   (+ x (* x (/ y z)))
   (if (<= z -7.401115730235809e-203)
     (+ x (* (* x y) (/ 1.0 z)))
     (/ x (/ z (+ z y))))))
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 <= -2.4193787838886472e-12)) {
		tmp = ((double) (x + ((double) (x * (y / z)))));
	} else {
		double tmp_1;
		if ((z <= -7.401115730235809e-203)) {
			tmp_1 = ((double) (x + ((double) (((double) (x * y)) * (1.0 / z)))));
		} else {
			tmp_1 = (x / (z / ((double) (z + y))));
		}
		tmp = tmp_1;
	}
	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.5
Target3.2
Herbie2.7
\[\frac{x}{\frac{z}{y + z}}\]

Derivation

  1. Split input into 3 regimes
  2. if z < -2.41937878388864723e-12

    1. Initial program Error: 15.3 bits

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

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

    if -2.41937878388864723e-12 < z < -7.40111573023580882e-203

    1. Initial program Error: 4.6 bits

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

      \[\leadsto \color{blue}{x + x \cdot \frac{y}{z}}\]
    3. Using strategy rm
    4. Applied div-invError: 5.9 bits

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

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

    if -7.40111573023580882e-203 < z

    1. Initial program Error: 13.0 bits

      \[\frac{x \cdot \left(y + z\right)}{z}\]
    2. Using strategy rm
    3. Applied associate-/l*Error: 4.5 bits

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2.4193787838886472 \cdot 10^{-12}:\\ \;\;\;\;x + x \cdot \frac{y}{z}\\ \mathbf{elif}\;z \leq -7.401115730235809 \cdot 10^{-203}:\\ \;\;\;\;x + \left(x \cdot y\right) \cdot \frac{1}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{z + y}}\\ \end{array}\]

Reproduce

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