Average Error: 12.0 → 2.1
Time: 11.6s
Precision: 64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -2.869128326247180131055491464033383801505 \cdot 10^{99} \lor \neg \left(z \le -1.442321906530695273017718499006101704898 \cdot 10^{-263}\right) \land \left(z \le 3.670705713904214514938236895518577498891 \cdot 10^{-228} \lor \neg \left(z \le 1.013639971791185277516860999161516023027 \cdot 10^{-81}\right)\right):\\ \;\;\;\;x \cdot \frac{z + y}{z}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{x \cdot y}{z}\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;z \le -2.869128326247180131055491464033383801505 \cdot 10^{99} \lor \neg \left(z \le -1.442321906530695273017718499006101704898 \cdot 10^{-263}\right) \land \left(z \le 3.670705713904214514938236895518577498891 \cdot 10^{-228} \lor \neg \left(z \le 1.013639971791185277516860999161516023027 \cdot 10^{-81}\right)\right):\\
\;\;\;\;x \cdot \frac{z + y}{z}\\

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

\end{array}
double f(double x, double y, double z) {
        double r346610 = x;
        double r346611 = y;
        double r346612 = z;
        double r346613 = r346611 + r346612;
        double r346614 = r346610 * r346613;
        double r346615 = r346614 / r346612;
        return r346615;
}

double f(double x, double y, double z) {
        double r346616 = z;
        double r346617 = -2.86912832624718e+99;
        bool r346618 = r346616 <= r346617;
        double r346619 = -1.4423219065306953e-263;
        bool r346620 = r346616 <= r346619;
        double r346621 = !r346620;
        double r346622 = 3.6707057139042145e-228;
        bool r346623 = r346616 <= r346622;
        double r346624 = 1.0136399717911853e-81;
        bool r346625 = r346616 <= r346624;
        double r346626 = !r346625;
        bool r346627 = r346623 || r346626;
        bool r346628 = r346621 && r346627;
        bool r346629 = r346618 || r346628;
        double r346630 = x;
        double r346631 = y;
        double r346632 = r346616 + r346631;
        double r346633 = r346632 / r346616;
        double r346634 = r346630 * r346633;
        double r346635 = r346630 * r346631;
        double r346636 = r346635 / r346616;
        double r346637 = r346630 + r346636;
        double r346638 = r346629 ? r346634 : r346637;
        return r346638;
}

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

Derivation

  1. Split input into 2 regimes
  2. if z < -2.86912832624718e+99 or -1.4423219065306953e-263 < z < 3.6707057139042145e-228 or 1.0136399717911853e-81 < z

    1. Initial program 15.8

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

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

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

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

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

    if -2.86912832624718e+99 < z < -1.4423219065306953e-263 or 3.6707057139042145e-228 < z < 1.0136399717911853e-81

    1. Initial program 5.8

      \[\frac{x \cdot \left(y + z\right)}{z}\]
    2. Using strategy rm
    3. Applied associate-/l*4.9

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{y + z}}}\]
    4. Simplified4.9

      \[\leadsto \frac{x}{\color{blue}{\frac{z}{z + y}}}\]
    5. Taylor expanded around 0 2.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -2.869128326247180131055491464033383801505 \cdot 10^{99} \lor \neg \left(z \le -1.442321906530695273017718499006101704898 \cdot 10^{-263}\right) \land \left(z \le 3.670705713904214514938236895518577498891 \cdot 10^{-228} \lor \neg \left(z \le 1.013639971791185277516860999161516023027 \cdot 10^{-81}\right)\right):\\ \;\;\;\;x \cdot \frac{z + y}{z}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{x \cdot y}{z}\\ \end{array}\]

Reproduce

herbie shell --seed 2019194 
(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))