Average Error: 12.7 → 0.5
Time: 1.9s
Precision: 64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(y + z\right)}{z} = -\infty:\\ \;\;\;\;\frac{y}{z} \cdot x + x\\ \mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \le -1.0314680212794926 \cdot 10^{32}:\\ \;\;\;\;\frac{x \cdot \left(y + z\right)}{z}\\ \mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \le 1.415297450444849 \cdot 10^{-62}:\\ \;\;\;\;\frac{y}{z} \cdot x + x\\ \mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \le 4.86321352565209049 \cdot 10^{263}:\\ \;\;\;\;\left(y \cdot x\right) \cdot \frac{1}{z} + x\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z} \cdot x + x\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot \left(y + z\right)}{z} = -\infty:\\
\;\;\;\;\frac{y}{z} \cdot x + x\\

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

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

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

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

\end{array}
double f(double x, double y, double z) {
        double r412359 = x;
        double r412360 = y;
        double r412361 = z;
        double r412362 = r412360 + r412361;
        double r412363 = r412359 * r412362;
        double r412364 = r412363 / r412361;
        return r412364;
}

double f(double x, double y, double z) {
        double r412365 = x;
        double r412366 = y;
        double r412367 = z;
        double r412368 = r412366 + r412367;
        double r412369 = r412365 * r412368;
        double r412370 = r412369 / r412367;
        double r412371 = -inf.0;
        bool r412372 = r412370 <= r412371;
        double r412373 = r412366 / r412367;
        double r412374 = r412373 * r412365;
        double r412375 = r412374 + r412365;
        double r412376 = -1.0314680212794926e+32;
        bool r412377 = r412370 <= r412376;
        double r412378 = 1.415297450444849e-62;
        bool r412379 = r412370 <= r412378;
        double r412380 = 4.8632135256520905e+263;
        bool r412381 = r412370 <= r412380;
        double r412382 = r412366 * r412365;
        double r412383 = 1.0;
        double r412384 = r412383 / r412367;
        double r412385 = r412382 * r412384;
        double r412386 = r412385 + r412365;
        double r412387 = r412381 ? r412386 : r412375;
        double r412388 = r412379 ? r412375 : r412387;
        double r412389 = r412377 ? r412370 : r412388;
        double r412390 = r412372 ? r412375 : r412389;
        return r412390;
}

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

Derivation

  1. Split input into 3 regimes
  2. if (/ (* x (+ y z)) z) < -inf.0 or -1.0314680212794926e+32 < (/ (* x (+ y z)) z) < 1.415297450444849e-62 or 4.8632135256520905e+263 < (/ (* x (+ y z)) z)

    1. Initial program 21.8

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

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

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

    if -inf.0 < (/ (* x (+ y z)) z) < -1.0314680212794926e+32

    1. Initial program 0.2

      \[\frac{x \cdot \left(y + z\right)}{z}\]

    if 1.415297450444849e-62 < (/ (* x (+ y z)) z) < 4.8632135256520905e+263

    1. Initial program 0.3

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

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

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

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

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

      \[\leadsto y \cdot \color{blue}{\frac{x}{z}} + x\]
    9. Using strategy rm
    10. Applied div-inv4.9

      \[\leadsto y \cdot \color{blue}{\left(x \cdot \frac{1}{z}\right)} + x\]
    11. Applied associate-*r*0.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(y + z\right)}{z} = -\infty:\\ \;\;\;\;\frac{y}{z} \cdot x + x\\ \mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \le -1.0314680212794926 \cdot 10^{32}:\\ \;\;\;\;\frac{x \cdot \left(y + z\right)}{z}\\ \mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \le 1.415297450444849 \cdot 10^{-62}:\\ \;\;\;\;\frac{y}{z} \cdot x + x\\ \mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \le 4.86321352565209049 \cdot 10^{263}:\\ \;\;\;\;\left(y \cdot x\right) \cdot \frac{1}{z} + x\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z} \cdot x + x\\ \end{array}\]

Reproduce

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