Average Error: 12.3 → 2.3
Time: 9.1s
Precision: 64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -3.18129059803902563 \cdot 10^{-79} \lor \neg \left(z \le 6.550204375720548 \cdot 10^{-273}\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 -3.18129059803902563 \cdot 10^{-79} \lor \neg \left(z \le 6.550204375720548 \cdot 10^{-273}\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 r439765 = x;
        double r439766 = y;
        double r439767 = z;
        double r439768 = r439766 + r439767;
        double r439769 = r439765 * r439768;
        double r439770 = r439769 / r439767;
        return r439770;
}

double f(double x, double y, double z) {
        double r439771 = z;
        double r439772 = -3.1812905980390256e-79;
        bool r439773 = r439771 <= r439772;
        double r439774 = 6.550204375720548e-273;
        bool r439775 = r439771 <= r439774;
        double r439776 = !r439775;
        bool r439777 = r439773 || r439776;
        double r439778 = x;
        double r439779 = y;
        double r439780 = r439771 / r439779;
        double r439781 = r439778 / r439780;
        double r439782 = r439781 + r439778;
        double r439783 = r439778 * r439779;
        double r439784 = r439783 / r439771;
        double r439785 = r439784 + r439778;
        double r439786 = r439777 ? r439782 : r439785;
        return r439786;
}

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

Derivation

  1. Split input into 2 regimes
  2. if z < -3.1812905980390256e-79 or 6.550204375720548e-273 < z

    1. Initial program 13.0

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

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

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

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

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

    if -3.1812905980390256e-79 < z < 6.550204375720548e-273

    1. Initial program 8.7

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

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

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

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

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

Reproduce

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