Average Error: 13.0 → 2.0
Time: 13.3s
Precision: 64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -4.483651780214682313685859092672612032561 \cdot 10^{-120} \lor \neg \left(z \le 3.007853078206601173238028616620457685735 \cdot 10^{-33}\right):\\ \;\;\;\;\frac{x}{\frac{z}{y}} + 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 -4.483651780214682313685859092672612032561 \cdot 10^{-120} \lor \neg \left(z \le 3.007853078206601173238028616620457685735 \cdot 10^{-33}\right):\\
\;\;\;\;\frac{x}{\frac{z}{y}} + x\\

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

\end{array}
double f(double x, double y, double z) {
        double r240308 = x;
        double r240309 = y;
        double r240310 = z;
        double r240311 = r240309 + r240310;
        double r240312 = r240308 * r240311;
        double r240313 = r240312 / r240310;
        return r240313;
}

double f(double x, double y, double z) {
        double r240314 = z;
        double r240315 = -4.483651780214682e-120;
        bool r240316 = r240314 <= r240315;
        double r240317 = 3.0078530782066012e-33;
        bool r240318 = r240314 <= r240317;
        double r240319 = !r240318;
        bool r240320 = r240316 || r240319;
        double r240321 = x;
        double r240322 = y;
        double r240323 = r240314 / r240322;
        double r240324 = r240321 / r240323;
        double r240325 = r240324 + r240321;
        double r240326 = r240321 * r240322;
        double r240327 = r240326 / r240314;
        double r240328 = r240327 + r240321;
        double r240329 = r240320 ? r240325 : r240328;
        return r240329;
}

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

Original13.0
Target3.0
Herbie2.0
\[\frac{x}{\frac{z}{y + z}}\]

Derivation

  1. Split input into 2 regimes
  2. if z < -4.483651780214682e-120 or 3.0078530782066012e-33 < z

    1. Initial program 15.2

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

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

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

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

      \[\leadsto \color{blue}{1 \cdot \left(\frac{x \cdot y}{z} + x\right)}\]
    8. Using strategy rm
    9. Applied associate-/l*0.5

      \[\leadsto 1 \cdot \left(\color{blue}{\frac{x}{\frac{z}{y}}} + x\right)\]

    if -4.483651780214682e-120 < z < 3.0078530782066012e-33

    1. Initial program 8.2

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

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

      \[\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 \color{blue}{1 \cdot \left(\frac{x \cdot y}{z} + x\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification2.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -4.483651780214682313685859092672612032561 \cdot 10^{-120} \lor \neg \left(z \le 3.007853078206601173238028616620457685735 \cdot 10^{-33}\right):\\ \;\;\;\;\frac{x}{\frac{z}{y}} + x\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{z} + x\\ \end{array}\]

Reproduce

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