Average Error: 12.4 → 3.3
Time: 2.3s
Precision: binary64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -5.08146638658676392 \cdot 10^{26}:\\ \;\;\;\;x + \frac{x}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{x \cdot y}{z}\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;z \le -5.08146638658676392 \cdot 10^{26}:\\
\;\;\;\;x + \frac{x}{\frac{z}{y}}\\

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

\end{array}
double code(double x, double y, double z) {
	return ((double) (((double) (x * ((double) (y + z)))) / z));
}
double code(double x, double y, double z) {
	double VAR;
	if ((z <= -5.081466386586764e+26)) {
		VAR = ((double) (x + ((double) (x / ((double) (z / y))))));
	} else {
		VAR = ((double) (x + ((double) (((double) (x * y)) / z))));
	}
	return VAR;
}

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.4
Target3.1
Herbie3.3
\[\frac{x}{\frac{z}{y + z}}\]

Derivation

  1. Split input into 2 regimes
  2. if z < -5.08146638658676392e26

    1. Initial program 18.0

      \[\frac{x \cdot \left(y + z\right)}{z}\]
    2. Simplified0.1

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

      \[\leadsto x + \color{blue}{\frac{x \cdot y}{z}}\]
    5. Using strategy rm
    6. Applied associate-/l*0.1

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

    if -5.08146638658676392e26 < z

    1. Initial program 10.4

      \[\frac{x \cdot \left(y + z\right)}{z}\]
    2. Simplified4.5

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -5.08146638658676392 \cdot 10^{26}:\\ \;\;\;\;x + \frac{x}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{x \cdot y}{z}\\ \end{array}\]

Reproduce

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