Average Error: 12.6 → 3.0
Time: 12.8s
Precision: 64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -1.244096151631290896943813259882212972022 \cdot 10^{-205}:\\ \;\;\;\;x \cdot \frac{z + y}{z}\\ \mathbf{elif}\;z \le 1.123685082691174413471401852132580668372 \cdot 10^{-120}:\\ \;\;\;\;\frac{1}{z} \cdot \left(\left(z + y\right) \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{z + y}{z}\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;z \le -1.244096151631290896943813259882212972022 \cdot 10^{-205}:\\
\;\;\;\;x \cdot \frac{z + y}{z}\\

\mathbf{elif}\;z \le 1.123685082691174413471401852132580668372 \cdot 10^{-120}:\\
\;\;\;\;\frac{1}{z} \cdot \left(\left(z + y\right) \cdot x\right)\\

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

\end{array}
double f(double x, double y, double z) {
        double r24205176 = x;
        double r24205177 = y;
        double r24205178 = z;
        double r24205179 = r24205177 + r24205178;
        double r24205180 = r24205176 * r24205179;
        double r24205181 = r24205180 / r24205178;
        return r24205181;
}

double f(double x, double y, double z) {
        double r24205182 = z;
        double r24205183 = -1.244096151631291e-205;
        bool r24205184 = r24205182 <= r24205183;
        double r24205185 = x;
        double r24205186 = y;
        double r24205187 = r24205182 + r24205186;
        double r24205188 = r24205187 / r24205182;
        double r24205189 = r24205185 * r24205188;
        double r24205190 = 1.1236850826911744e-120;
        bool r24205191 = r24205182 <= r24205190;
        double r24205192 = 1.0;
        double r24205193 = r24205192 / r24205182;
        double r24205194 = r24205187 * r24205185;
        double r24205195 = r24205193 * r24205194;
        double r24205196 = r24205191 ? r24205195 : r24205189;
        double r24205197 = r24205184 ? r24205189 : r24205196;
        return r24205197;
}

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

Derivation

  1. Split input into 2 regimes
  2. if z < -1.244096151631291e-205 or 1.1236850826911744e-120 < z

    1. Initial program 13.1

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

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

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

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

    if -1.244096151631291e-205 < z < 1.1236850826911744e-120

    1. Initial program 10.2

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{y + z}}}\]
    4. Using strategy rm
    5. Applied div-inv11.7

      \[\leadsto \frac{x}{\color{blue}{z \cdot \frac{1}{y + z}}}\]
    6. Applied *-un-lft-identity11.7

      \[\leadsto \frac{\color{blue}{1 \cdot x}}{z \cdot \frac{1}{y + z}}\]
    7. Applied times-frac10.4

      \[\leadsto \color{blue}{\frac{1}{z} \cdot \frac{x}{\frac{1}{y + z}}}\]
    8. Simplified10.4

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -1.244096151631290896943813259882212972022 \cdot 10^{-205}:\\ \;\;\;\;x \cdot \frac{z + y}{z}\\ \mathbf{elif}\;z \le 1.123685082691174413471401852132580668372 \cdot 10^{-120}:\\ \;\;\;\;\frac{1}{z} \cdot \left(\left(z + y\right) \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{z + y}{z}\\ \end{array}\]

Reproduce

herbie shell --seed 2019170 +o rules:numerics
(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))