Average Error: 13.0 → 2.0
Time: 8.6s
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 r280004 = x;
        double r280005 = y;
        double r280006 = z;
        double r280007 = r280005 + r280006;
        double r280008 = r280004 * r280007;
        double r280009 = r280008 / r280006;
        return r280009;
}

double f(double x, double y, double z) {
        double r280010 = z;
        double r280011 = -4.483651780214682e-120;
        bool r280012 = r280010 <= r280011;
        double r280013 = 3.0078530782066012e-33;
        bool r280014 = r280010 <= r280013;
        double r280015 = !r280014;
        bool r280016 = r280012 || r280015;
        double r280017 = x;
        double r280018 = y;
        double r280019 = r280010 / r280018;
        double r280020 = r280017 / r280019;
        double r280021 = r280020 + r280017;
        double r280022 = r280017 * r280018;
        double r280023 = r280022 / r280010;
        double r280024 = r280023 + r280017;
        double r280025 = r280016 ? r280021 : r280024;
        return r280025;
}

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. Taylor expanded around 0 5.0

      \[\leadsto \color{blue}{\frac{x \cdot y}{z} + x}\]
    3. Using strategy rm
    4. Applied associate-/l*0.5

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

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

    1. Initial program 8.2

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

      \[\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 -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 
(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))