Average Error: 12.9 → 3.1
Time: 41.0s
Precision: 64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -9.060096809735444000700599295995871436704 \cdot 10^{-285}:\\ \;\;\;\;\frac{y + z}{z} \cdot x\\ \mathbf{elif}\;z \le 2.150336063800679259738105023330353494451 \cdot 10^{-122}:\\ \;\;\;\;\left(x \cdot \left(y + z\right)\right) \cdot \frac{1}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y + z}{z} \cdot x\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;z \le -9.060096809735444000700599295995871436704 \cdot 10^{-285}:\\
\;\;\;\;\frac{y + z}{z} \cdot x\\

\mathbf{elif}\;z \le 2.150336063800679259738105023330353494451 \cdot 10^{-122}:\\
\;\;\;\;\left(x \cdot \left(y + z\right)\right) \cdot \frac{1}{z}\\

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

\end{array}
double f(double x, double y, double z) {
        double r22569771 = x;
        double r22569772 = y;
        double r22569773 = z;
        double r22569774 = r22569772 + r22569773;
        double r22569775 = r22569771 * r22569774;
        double r22569776 = r22569775 / r22569773;
        return r22569776;
}

double f(double x, double y, double z) {
        double r22569777 = z;
        double r22569778 = -9.060096809735444e-285;
        bool r22569779 = r22569777 <= r22569778;
        double r22569780 = y;
        double r22569781 = r22569780 + r22569777;
        double r22569782 = r22569781 / r22569777;
        double r22569783 = x;
        double r22569784 = r22569782 * r22569783;
        double r22569785 = 2.1503360638006793e-122;
        bool r22569786 = r22569777 <= r22569785;
        double r22569787 = r22569783 * r22569781;
        double r22569788 = 1.0;
        double r22569789 = r22569788 / r22569777;
        double r22569790 = r22569787 * r22569789;
        double r22569791 = r22569786 ? r22569790 : r22569784;
        double r22569792 = r22569779 ? r22569784 : r22569791;
        return r22569792;
}

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

Derivation

  1. Split input into 2 regimes
  2. if z < -9.060096809735444e-285 or 2.1503360638006793e-122 < z

    1. Initial program 13.1

      \[\frac{x \cdot \left(y + z\right)}{z}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity13.1

      \[\leadsto \frac{x \cdot \left(y + z\right)}{\color{blue}{1 \cdot z}}\]
    4. Applied times-frac1.9

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

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

    if -9.060096809735444e-285 < z < 2.1503360638006793e-122

    1. Initial program 11.0

      \[\frac{x \cdot \left(y + z\right)}{z}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity11.0

      \[\leadsto \frac{x \cdot \left(y + z\right)}{\color{blue}{1 \cdot z}}\]
    4. Applied times-frac10.9

      \[\leadsto \color{blue}{\frac{x}{1} \cdot \frac{y + z}{z}}\]
    5. Simplified10.9

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -9.060096809735444000700599295995871436704 \cdot 10^{-285}:\\ \;\;\;\;\frac{y + z}{z} \cdot x\\ \mathbf{elif}\;z \le 2.150336063800679259738105023330353494451 \cdot 10^{-122}:\\ \;\;\;\;\left(x \cdot \left(y + z\right)\right) \cdot \frac{1}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y + z}{z} \cdot x\\ \end{array}\]

Reproduce

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

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

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