Average Error: 12.6 → 3.1
Time: 2.7s
Precision: 64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -3.551442779203872 \cdot 10^{-29}:\\ \;\;\;\;x \cdot \frac{y + z}{z}\\ \mathbf{elif}\;z \le 1.4526164130838052 \cdot 10^{-279}:\\ \;\;\;\;\frac{x}{z} \cdot \left(y + z\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{y + z}}\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;z \le -3.551442779203872 \cdot 10^{-29}:\\
\;\;\;\;x \cdot \frac{y + z}{z}\\

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

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

\end{array}
double f(double x, double y, double z) {
        double r451132 = x;
        double r451133 = y;
        double r451134 = z;
        double r451135 = r451133 + r451134;
        double r451136 = r451132 * r451135;
        double r451137 = r451136 / r451134;
        return r451137;
}

double f(double x, double y, double z) {
        double r451138 = z;
        double r451139 = -3.551442779203872e-29;
        bool r451140 = r451138 <= r451139;
        double r451141 = x;
        double r451142 = y;
        double r451143 = r451142 + r451138;
        double r451144 = r451143 / r451138;
        double r451145 = r451141 * r451144;
        double r451146 = 1.4526164130838052e-279;
        bool r451147 = r451138 <= r451146;
        double r451148 = r451141 / r451138;
        double r451149 = r451148 * r451143;
        double r451150 = r451138 / r451143;
        double r451151 = r451141 / r451150;
        double r451152 = r451147 ? r451149 : r451151;
        double r451153 = r451140 ? r451145 : r451152;
        return r451153;
}

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

Derivation

  1. Split input into 3 regimes
  2. if z < -3.551442779203872e-29

    1. Initial program 16.9

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

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

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

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

    if -3.551442779203872e-29 < z < 1.4526164130838052e-279

    1. Initial program 8.0

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{y + z}}}\]
    4. Using strategy rm
    5. Applied associate-/r/8.9

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

    if 1.4526164130838052e-279 < z

    1. Initial program 11.8

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -3.551442779203872 \cdot 10^{-29}:\\ \;\;\;\;x \cdot \frac{y + z}{z}\\ \mathbf{elif}\;z \le 1.4526164130838052 \cdot 10^{-279}:\\ \;\;\;\;\frac{x}{z} \cdot \left(y + z\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{y + z}}\\ \end{array}\]

Reproduce

herbie shell --seed 2020018 
(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))