Average Error: 12.9 → 2.1
Time: 2.6s
Precision: binary64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;x \le -3.2196791400107588 \cdot 10^{-49} \lor \neg \left(x \le 3.42631398661744908 \cdot 10^{-131}\right):\\ \;\;\;\;x + x \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;x + \left(x \cdot y\right) \cdot \frac{1}{z}\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;x \le -3.2196791400107588 \cdot 10^{-49} \lor \neg \left(x \le 3.42631398661744908 \cdot 10^{-131}\right):\\
\;\;\;\;x + x \cdot \frac{y}{z}\\

\mathbf{else}:\\
\;\;\;\;x + \left(x \cdot y\right) \cdot \frac{1}{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 (((x <= -3.2196791400107588e-49) || !(x <= 3.426313986617449e-131))) {
		VAR = ((double) (x + ((double) (x * ((double) (y / z))))));
	} else {
		VAR = ((double) (x + ((double) (((double) (x * y)) * ((double) (1.0 / 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.9
Target3.0
Herbie2.1
\[\frac{x}{\frac{z}{y + z}}\]

Derivation

  1. Split input into 2 regimes
  2. if x < -3.2196791400107588e-49 or 3.42631398661744908e-131 < x

    1. Initial program 17.0

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

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

    if -3.2196791400107588e-49 < x < 3.42631398661744908e-131

    1. Initial program 6.9

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

      \[\leadsto \color{blue}{x + x \cdot \frac{y}{z}}\]
    3. Using strategy rm
    4. Applied div-inv7.0

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

      \[\leadsto x + \color{blue}{\left(x \cdot y\right) \cdot \frac{1}{z}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification2.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -3.2196791400107588 \cdot 10^{-49} \lor \neg \left(x \le 3.42631398661744908 \cdot 10^{-131}\right):\\ \;\;\;\;x + x \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;x + \left(x \cdot y\right) \cdot \frac{1}{z}\\ \end{array}\]

Reproduce

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