Average Error: 1.7 → 0.1
Time: 41.9s
Precision: 64
Internal Precision: 320
\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
\[\begin{array}{l} \mathbf{if}\;\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right| \le 1.3661123848892641 \cdot 10^{+306}:\\ \;\;\;\;\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|(\left(x + 4\right) \cdot \left(\frac{1}{y}\right) + \left(-\frac{x}{y} \cdot z\right))_*\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 (/ z y)))) < 1.3661123848892641e+306

    1. Initial program 1.8

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
    2. Using strategy rm
    3. Applied div-inv1.8

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

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

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

    if 1.3661123848892641e+306 < (fabs (- (/ (+ x 4) y) (* x (/ z y))))

    1. Initial program 0.1

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
    2. Using strategy rm
    3. Applied div-inv0.2

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

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

Runtime

Time bar (total: 41.9s)Debug logProfile

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