Average Error: 1.5 → 0.1
Time: 21.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 7.279454430510659 \cdot 10^{+70}:\\ \;\;\;\;\left|\frac{4 + x}{y} - \frac{x}{\frac{y}{z}}\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

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

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

    1. Initial program 2.7

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

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

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

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

      \[\leadsto \left|\left(\frac{4 + x}{y} - \frac{z}{y} \cdot x\right) + \color{blue}{0}\right|\]
    7. Using strategy rm
    8. Applied add-sqr-sqrt31.5

      \[\leadsto \left|\left(\color{blue}{\sqrt{\frac{4 + x}{y}} \cdot \sqrt{\frac{4 + x}{y}}} - \frac{z}{y} \cdot x\right) + 0\right|\]
    9. Applied prod-diff31.5

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

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

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

    if 7.279454430510659e+70 < (fabs (- (/ (+ x 4) y) (* (/ x y) z)))

    1. Initial program 0.1

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

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

Reproduce

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