Average Error: 1.7 → 0.2
Time: 56.0s
Precision: 64
Internal Precision: 320
\[\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 -1.0436481794683428 \cdot 10^{+117}:\\ \;\;\;\;\left|\frac{x}{y} \cdot \left(-z\right) + \left(\frac{4}{y} + \frac{x}{y}\right)\right|\\ \mathbf{if}\;\frac{x + 4}{y} - \frac{x}{y} \cdot z \le 1.2185584383561477 \cdot 10^{-92}:\\ \;\;\;\;\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y} \cdot \left(-z\right) + \left(\frac{4}{y} + \frac{x}{y}\right)\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 (- (/ (+ x 4) y) (* (/ x y) z)) < -1.0436481794683428e+117 or 1.2185584383561477e-92 < (- (/ (+ x 4) y) (* (/ x y) z))

    1. Initial program 0.2

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

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

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

    if -1.0436481794683428e+117 < (- (/ (+ x 4) y) (* (/ x y) z)) < 1.2185584383561477e-92

    1. Initial program 3.8

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

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

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

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

Runtime

Time bar (total: 56.0s)Debug logProfile

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