Average Error: 12.5 → 2.0
Time: 11.8s
Precision: 64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -8.53005333076934627 \cdot 10^{-4} \lor \neg \left(z \le 4.3903400335005515 \cdot 10^{-147}\right):\\ \;\;\;\;x \cdot \frac{y}{z} + x\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{z} + x\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;z \le -8.53005333076934627 \cdot 10^{-4} \lor \neg \left(z \le 4.3903400335005515 \cdot 10^{-147}\right):\\
\;\;\;\;x \cdot \frac{y}{z} + x\\

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

\end{array}
double f(double x, double y, double z) {
        double r592742 = x;
        double r592743 = y;
        double r592744 = z;
        double r592745 = r592743 + r592744;
        double r592746 = r592742 * r592745;
        double r592747 = r592746 / r592744;
        return r592747;
}

double f(double x, double y, double z) {
        double r592748 = z;
        double r592749 = -0.0008530053330769346;
        bool r592750 = r592748 <= r592749;
        double r592751 = 4.3903400335005515e-147;
        bool r592752 = r592748 <= r592751;
        double r592753 = !r592752;
        bool r592754 = r592750 || r592753;
        double r592755 = x;
        double r592756 = y;
        double r592757 = r592756 / r592748;
        double r592758 = r592755 * r592757;
        double r592759 = r592758 + r592755;
        double r592760 = r592755 * r592756;
        double r592761 = r592760 / r592748;
        double r592762 = r592761 + r592755;
        double r592763 = r592754 ? r592759 : r592762;
        return r592763;
}

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.0
\[\frac{x}{\frac{z}{y + z}}\]

Derivation

  1. Split input into 2 regimes
  2. if z < -0.0008530053330769346 or 4.3903400335005515e-147 < z

    1. Initial program 14.5

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{z}, y, x\right)}\]
    3. Using strategy rm
    4. Applied fma-udef2.9

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{z}} + x\]
    6. Using strategy rm
    7. Applied *-un-lft-identity5.1

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

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

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

    if -0.0008530053330769346 < z < 4.3903400335005515e-147

    1. Initial program 8.1

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{z}, y, x\right)}\]
    3. Using strategy rm
    4. Applied fma-udef9.1

      \[\leadsto \color{blue}{\frac{x}{z} \cdot y + x}\]
    5. Simplified4.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -8.53005333076934627 \cdot 10^{-4} \lor \neg \left(z \le 4.3903400335005515 \cdot 10^{-147}\right):\\ \;\;\;\;x \cdot \frac{y}{z} + x\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{z} + x\\ \end{array}\]

Reproduce

herbie shell --seed 2020042 +o rules:numerics
(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))