Average Error: 12.5 → 2.0
Time: 11.4s
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 + x \cdot \frac{y}{z}\\ \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 + x \cdot \frac{y}{z}\\

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

\end{array}
double f(double x, double y, double z) {
        double r588592 = x;
        double r588593 = y;
        double r588594 = z;
        double r588595 = r588593 + r588594;
        double r588596 = r588592 * r588595;
        double r588597 = r588596 / r588594;
        return r588597;
}

double f(double x, double y, double z) {
        double r588598 = z;
        double r588599 = -0.0008530053330769346;
        bool r588600 = r588598 <= r588599;
        double r588601 = 4.3903400335005515e-147;
        bool r588602 = r588598 <= r588601;
        double r588603 = !r588602;
        bool r588604 = r588600 || r588603;
        double r588605 = x;
        double r588606 = y;
        double r588607 = r588606 / r588598;
        double r588608 = r588605 * r588607;
        double r588609 = r588605 + r588608;
        double r588610 = r588605 * r588606;
        double r588611 = r588610 / r588598;
        double r588612 = r588611 + r588605;
        double r588613 = r588604 ? r588609 : r588612;
        return r588613;
}

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 associate-/l*0.7

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{y}}} + x\]
    8. Using strategy rm
    9. Applied *-un-lft-identity0.7

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

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

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

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

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

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

      \[\leadsto 1 \cdot \color{blue}{\left(x \cdot \frac{y}{z}\right)} + 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 + x \cdot \frac{y}{z}\\ \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))