Average Error: 1.7 → 1.6
Time: 17.2s
Precision: 64
\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
\[\begin{array}{l} \mathbf{if}\;\frac{x + 4}{y} - \frac{x}{y} \cdot z \le -6.838261347152627122776007246540270499153 \cdot 10^{-29}:\\ \;\;\;\;\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\ \end{array}\]
\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|
\begin{array}{l}
\mathbf{if}\;\frac{x + 4}{y} - \frac{x}{y} \cdot z \le -6.838261347152627122776007246540270499153 \cdot 10^{-29}:\\
\;\;\;\;\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\\

\mathbf{else}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\

\end{array}
double f(double x, double y, double z) {
        double r15285 = x;
        double r15286 = 4.0;
        double r15287 = r15285 + r15286;
        double r15288 = y;
        double r15289 = r15287 / r15288;
        double r15290 = r15285 / r15288;
        double r15291 = z;
        double r15292 = r15290 * r15291;
        double r15293 = r15289 - r15292;
        double r15294 = fabs(r15293);
        return r15294;
}

double f(double x, double y, double z) {
        double r15295 = x;
        double r15296 = 4.0;
        double r15297 = r15295 + r15296;
        double r15298 = y;
        double r15299 = r15297 / r15298;
        double r15300 = r15295 / r15298;
        double r15301 = z;
        double r15302 = r15300 * r15301;
        double r15303 = r15299 - r15302;
        double r15304 = -6.838261347152627e-29;
        bool r15305 = r15303 <= r15304;
        double r15306 = fabs(r15303);
        double r15307 = r15295 * r15301;
        double r15308 = r15297 - r15307;
        double r15309 = r15308 / r15298;
        double r15310 = fabs(r15309);
        double r15311 = r15305 ? r15306 : r15310;
        return r15311;
}

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

Derivation

  1. Split input into 2 regimes
  2. if (- (/ (+ x 4.0) y) (* (/ x y) z)) < -6.838261347152627e-29

    1. Initial program 0.1

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

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

    if -6.838261347152627e-29 < (- (/ (+ x 4.0) y) (* (/ x y) z))

    1. Initial program 2.5

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

      \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right|\]
    4. Applied sub-div2.4

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

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

Reproduce

herbie shell --seed 2019315 +o rules:numerics
(FPCore (x y z)
  :name "fabs fraction 1"
  :precision binary64
  (fabs (- (/ (+ x 4) y) (* (/ x y) z))))