Average Error: 1.6 → 0.2
Time: 12.1s
Precision: 64
Internal Precision: 128
\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
\[\begin{array}{l} \mathbf{if}\;\left|\frac{4 + x}{y} - \frac{x}{y} \cdot z\right| \le 8.264253464590168 \cdot 10^{-142}:\\ \;\;\;\;\left|\left(\frac{x}{y} + \frac{4}{y}\right) - x \cdot \frac{z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{4 + x}{y} - \frac{x}{y} \cdot z\right|\\ \end{array}\]

Error

Bits error versus x

Bits error versus y

Bits error versus z

Derivation

  1. Split input into 2 regimes
  2. if (fabs (- (/ (+ x 4) y) (* (/ x y) z))) < 8.264253464590168e-142

    1. Initial program 7.3

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
    2. Taylor expanded around 0 0.1

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

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

    if 8.264253464590168e-142 < (fabs (- (/ (+ x 4) y) (* (/ x y) z)))

    1. Initial program 0.3

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.2

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

Reproduce

herbie shell --seed 2019050 
(FPCore (x y z)
  :name "fabs fraction 1"
  (fabs (- (/ (+ x 4) y) (* (/ x y) z))))