Average Error: 12.3 → 2.1
Time: 17.5s
Precision: 64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -8.075781138440941892154872470930892635259 \cdot 10^{-16} \lor \neg \left(z \le 2.717641103527439173532310107215917032371 \cdot 10^{-184}\right):\\ \;\;\;\;x \cdot \frac{y}{z} + x\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot y\right) \cdot \frac{1}{z} + x\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;z \le -8.075781138440941892154872470930892635259 \cdot 10^{-16} \lor \neg \left(z \le 2.717641103527439173532310107215917032371 \cdot 10^{-184}\right):\\
\;\;\;\;x \cdot \frac{y}{z} + x\\

\mathbf{else}:\\
\;\;\;\;\left(x \cdot y\right) \cdot \frac{1}{z} + x\\

\end{array}
double f(double x, double y, double z) {
        double r281776 = x;
        double r281777 = y;
        double r281778 = z;
        double r281779 = r281777 + r281778;
        double r281780 = r281776 * r281779;
        double r281781 = r281780 / r281778;
        return r281781;
}

double f(double x, double y, double z) {
        double r281782 = z;
        double r281783 = -8.075781138440942e-16;
        bool r281784 = r281782 <= r281783;
        double r281785 = 2.717641103527439e-184;
        bool r281786 = r281782 <= r281785;
        double r281787 = !r281786;
        bool r281788 = r281784 || r281787;
        double r281789 = x;
        double r281790 = y;
        double r281791 = r281790 / r281782;
        double r281792 = r281789 * r281791;
        double r281793 = r281792 + r281789;
        double r281794 = r281789 * r281790;
        double r281795 = 1.0;
        double r281796 = r281795 / r281782;
        double r281797 = r281794 * r281796;
        double r281798 = r281797 + r281789;
        double r281799 = r281788 ? r281793 : r281798;
        return r281799;
}

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.3
Target3.2
Herbie2.1
\[\frac{x}{\frac{z}{y + z}}\]

Derivation

  1. Split input into 2 regimes
  2. if z < -8.075781138440942e-16 or 2.717641103527439e-184 < z

    1. Initial program 14.2

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

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

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

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

    if -8.075781138440942e-16 < z < 2.717641103527439e-184

    1. Initial program 7.6

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

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

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

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

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

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

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

Reproduce

herbie shell --seed 2019325 +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))