Average Error: 12.5 → 1.7
Time: 2.5s
Precision: 64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -1.800990442123997124517400333412962942968 \cdot 10^{-14} \lor \neg \left(z \le 8.110081971156096547419795603121779523406 \cdot 10^{77}\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 -1.800990442123997124517400333412962942968 \cdot 10^{-14} \lor \neg \left(z \le 8.110081971156096547419795603121779523406 \cdot 10^{77}\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 r577742 = x;
        double r577743 = y;
        double r577744 = z;
        double r577745 = r577743 + r577744;
        double r577746 = r577742 * r577745;
        double r577747 = r577746 / r577744;
        return r577747;
}

double f(double x, double y, double z) {
        double r577748 = z;
        double r577749 = -1.800990442123997e-14;
        bool r577750 = r577748 <= r577749;
        double r577751 = 8.110081971156097e+77;
        bool r577752 = r577748 <= r577751;
        double r577753 = !r577752;
        bool r577754 = r577750 || r577753;
        double r577755 = x;
        double r577756 = y;
        double r577757 = r577756 / r577748;
        double r577758 = r577755 * r577757;
        double r577759 = r577758 + r577755;
        double r577760 = r577755 * r577756;
        double r577761 = 1.0;
        double r577762 = r577761 / r577748;
        double r577763 = r577760 * r577762;
        double r577764 = r577763 + r577755;
        double r577765 = r577754 ? r577759 : r577764;
        return r577765;
}

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

Derivation

  1. Split input into 2 regimes
  2. if z < -1.800990442123997e-14 or 8.110081971156097e+77 < z

    1. Initial program 18.2

      \[\frac{x \cdot \left(y + z\right)}{z}\]
    2. Taylor expanded around 0 5.8

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

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

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

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

    if -1.800990442123997e-14 < z < 8.110081971156097e+77

    1. Initial program 6.6

      \[\frac{x \cdot \left(y + z\right)}{z}\]
    2. Taylor expanded around 0 3.4

      \[\leadsto \color{blue}{\frac{x \cdot y}{z} + x}\]
    3. Using strategy rm
    4. Applied div-inv3.4

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -1.800990442123997124517400333412962942968 \cdot 10^{-14} \lor \neg \left(z \le 8.110081971156096547419795603121779523406 \cdot 10^{77}\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 2019362 
(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))