Average Error: 12.5 → 1.7
Time: 2.9s
Precision: 64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -105199849494522.6875 \lor \neg \left(z \le 4.243229654236487123021394252651212684572 \cdot 10^{84}\right):\\ \;\;\;\;\frac{y}{z} \cdot x + 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 -105199849494522.6875 \lor \neg \left(z \le 4.243229654236487123021394252651212684572 \cdot 10^{84}\right):\\
\;\;\;\;\frac{y}{z} \cdot x + x\\

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

\end{array}
double f(double x, double y, double z) {
        double r501107 = x;
        double r501108 = y;
        double r501109 = z;
        double r501110 = r501108 + r501109;
        double r501111 = r501107 * r501110;
        double r501112 = r501111 / r501109;
        return r501112;
}

double f(double x, double y, double z) {
        double r501113 = z;
        double r501114 = -105199849494522.69;
        bool r501115 = r501113 <= r501114;
        double r501116 = 4.243229654236487e+84;
        bool r501117 = r501113 <= r501116;
        double r501118 = !r501117;
        bool r501119 = r501115 || r501118;
        double r501120 = y;
        double r501121 = r501120 / r501113;
        double r501122 = x;
        double r501123 = r501121 * r501122;
        double r501124 = r501123 + r501122;
        double r501125 = r501122 * r501120;
        double r501126 = r501125 / r501113;
        double r501127 = r501126 + r501122;
        double r501128 = r501119 ? r501124 : r501127;
        return r501128;
}

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 < -105199849494522.69 or 4.243229654236487e+84 < z

    1. Initial program 19.0

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

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

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

    if -105199849494522.69 < z < 4.243229654236487e+84

    1. Initial program 6.4

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

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

      \[\leadsto \color{blue}{\frac{y}{z} \cdot x + x}\]
    5. Using strategy rm
    6. Applied add-cube-cbrt7.0

      \[\leadsto \frac{y}{\color{blue}{\left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \sqrt[3]{z}}} \cdot x + x\]
    7. Applied *-un-lft-identity7.0

      \[\leadsto \frac{\color{blue}{1 \cdot y}}{\left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \sqrt[3]{z}} \cdot x + x\]
    8. Applied times-frac7.0

      \[\leadsto \color{blue}{\left(\frac{1}{\sqrt[3]{z} \cdot \sqrt[3]{z}} \cdot \frac{y}{\sqrt[3]{z}}\right)} \cdot x + x\]
    9. Applied associate-*l*3.3

      \[\leadsto \color{blue}{\frac{1}{\sqrt[3]{z} \cdot \sqrt[3]{z}} \cdot \left(\frac{y}{\sqrt[3]{z}} \cdot x\right)} + x\]
    10. Taylor expanded around 0 3.3

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

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

Reproduce

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