Average Error: 11.8 → 2.3
Time: 4.7s
Precision: binary64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(y + z\right)}{z} \leq -4.94852375797022 \cdot 10^{+130}:\\ \;\;\;\;\left(y + z\right) \cdot \frac{x}{z}\\ \mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \leq 397704063456036.7 \lor \neg \left(\frac{x \cdot \left(y + z\right)}{z} \leq 9.914216908054568 \cdot 10^{+238}\right):\\ \;\;\;\;x \cdot \left(1 + \frac{y}{z}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{z} \cdot \frac{x}{\frac{1}{y + z}}\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot \left(y + z\right)}{z} \leq -4.94852375797022 \cdot 10^{+130}:\\
\;\;\;\;\left(y + z\right) \cdot \frac{x}{z}\\

\mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \leq 397704063456036.7 \lor \neg \left(\frac{x \cdot \left(y + z\right)}{z} \leq 9.914216908054568 \cdot 10^{+238}\right):\\
\;\;\;\;x \cdot \left(1 + \frac{y}{z}\right)\\

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

\end{array}
(FPCore (x y z) :precision binary64 (/ (* x (+ y z)) z))
(FPCore (x y z)
 :precision binary64
 (if (<= (/ (* x (+ y z)) z) -4.94852375797022e+130)
   (* (+ y z) (/ x z))
   (if (or (<= (/ (* x (+ y z)) z) 397704063456036.7)
           (not (<= (/ (* x (+ y z)) z) 9.914216908054568e+238)))
     (* x (+ 1.0 (/ y z)))
     (* (/ 1.0 z) (/ x (/ 1.0 (+ y z)))))))
double code(double x, double y, double z) {
	return (x * (y + z)) / z;
}
double code(double x, double y, double z) {
	double tmp;
	if (((x * (y + z)) / z) <= -4.94852375797022e+130) {
		tmp = (y + z) * (x / z);
	} else if ((((x * (y + z)) / z) <= 397704063456036.7) || !(((x * (y + z)) / z) <= 9.914216908054568e+238)) {
		tmp = x * (1.0 + (y / z));
	} else {
		tmp = (1.0 / z) * (x / (1.0 / (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

Original11.8
Target2.8
Herbie2.3
\[\frac{x}{\frac{z}{y + z}}\]

Derivation

  1. Split input into 3 regimes
  2. if (/.f64 (*.f64 x (+.f64 y z)) z) < -4.9485237579702195e130

    1. Initial program 26.1

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{y + z}}}\]
    4. Simplified6.3

      \[\leadsto \frac{x}{\color{blue}{\frac{z}{z + y}}}\]
    5. Using strategy rm
    6. Applied associate-/r/_binary64_105957.9

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

    if -4.9485237579702195e130 < (/.f64 (*.f64 x (+.f64 y z)) z) < 397704063456036.688 or 9.91421690805456754e238 < (/.f64 (*.f64 x (+.f64 y z)) z)

    1. Initial program 10.7

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{y + z}}}\]
    4. Simplified1.1

      \[\leadsto \frac{x}{\color{blue}{\frac{z}{z + y}}}\]
    5. Using strategy rm
    6. Applied div-inv_binary64_106461.3

      \[\leadsto \color{blue}{x \cdot \frac{1}{\frac{z}{z + y}}}\]
    7. Simplified1.3

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

    if 397704063456036.688 < (/.f64 (*.f64 x (+.f64 y z)) z) < 9.91421690805456754e238

    1. Initial program 0.2

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{y + z}}}\]
    4. Simplified5.6

      \[\leadsto \frac{x}{\color{blue}{\frac{z}{z + y}}}\]
    5. Using strategy rm
    6. Applied div-inv_binary64_106465.7

      \[\leadsto \frac{x}{\color{blue}{z \cdot \frac{1}{z + y}}}\]
    7. Applied *-un-lft-identity_binary64_106495.7

      \[\leadsto \frac{\color{blue}{1 \cdot x}}{z \cdot \frac{1}{z + y}}\]
    8. Applied times-frac_binary64_106550.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(y + z\right)}{z} \leq -4.94852375797022 \cdot 10^{+130}:\\ \;\;\;\;\left(y + z\right) \cdot \frac{x}{z}\\ \mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \leq 397704063456036.7 \lor \neg \left(\frac{x \cdot \left(y + z\right)}{z} \leq 9.914216908054568 \cdot 10^{+238}\right):\\ \;\;\;\;x \cdot \left(1 + \frac{y}{z}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{z} \cdot \frac{x}{\frac{1}{y + z}}\\ \end{array}\]

Reproduce

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