Average Error: 1.7 → 0.2
Time: 15.5s
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 1.4878547782578144 \cdot 10^{-65}:\\ \;\;\;\;\left|\frac{4 + x}{y} - x \cdot \left(\frac{1}{y} \cdot z\right)\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))) < 1.4878547782578144e-65

    1. Initial program 5.6

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

      \[\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|\]

    if 1.4878547782578144e-65 < (fabs (- (/ (+ x 4) y) (* (/ x y) z)))

    1. Initial program 0.2

      \[\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 1.4878547782578144 \cdot 10^{-65}:\\ \;\;\;\;\left|\frac{4 + x}{y} - x \cdot \left(\frac{1}{y} \cdot z\right)\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{4 + x}{y} - \frac{x}{y} \cdot z\right|\\ \end{array}\]

Reproduce

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

Details

Time bar (total: 15.0s)Debug log

sample74.0ms

Algorithm
intervals

simplify52.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

52.0ms
(fabs (- (/ (+ x 4) y) (* (/ x y) z)))

prune23.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 1.9b

localize37.0ms

Local error

Found 2 expressions with local error:

4.7b
(* (/ x y) z)
0.0b
(- (/ (+ x 4) y) (* (/ x y) z))

rewrite19.0ms

Algorithm
rewrite-expression-head
Counts
2 → 39
Calls

2 calls. Slowest were:

14.0ms
(- (/ (+ x 4) y) (* (/ x y) z))
5.0ms
(* (/ x y) z)

series71.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

46.0ms
(- (/ (+ x 4) y) (* (/ x y) z))
25.0ms
(* (/ x y) z)

simplify1.1s

Counts
24 → 45
Calls

24 calls. Slowest were:

235.0ms
(fma (+ x 4) (/ 1 y) (- (* z (/ x y))))
174.0ms
(- (* (+ x 4) y) (* y (* x z)))
104.0ms
(- (+ (/ x y) (* 4 (/ 1 y))) (/ (* x z) y))

prune500.0ms

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0b

localize11.0ms

Local error

Found 1 expressions with local error:

1.9b
(/ (- (+ x 4) (* x z)) y)

rewrite13.0ms

Algorithm
rewrite-expression-head
Counts
1 → 18
Calls

1 calls. Slowest were:

13.0ms
(/ (- (+ x 4) (* x z)) y)

series47.0ms

Counts
1 → 3
Calls

1 calls. Slowest were:

47.0ms
(/ (- (+ x 4) (* x z)) y)

simplify841.0ms

Counts
8 → 21
Calls

8 calls. Slowest were:

266.0ms
(- (pow (+ x 4) 3) (pow (* x z) 3))
158.0ms
(- (* (+ x 4) (+ x 4)) (* (* x z) (* x z)))
106.0ms
(- (+ (/ x y) (* 4 (/ 1 y))) (/ (* x z) y))

prune187.0ms

Pruning

4 alts after pruning (2 fresh and 2 done)

Merged error: 0b

localize33.0ms

Local error

Found 2 expressions with local error:

4.7b
(/ z (/ y x))
0.0b
(- (/ (+ 4 x) y) (/ z (/ y x)))

rewrite12.0ms

Algorithm
rewrite-expression-head
Counts
2 → 58
Calls

2 calls. Slowest were:

10.0ms
(- (/ (+ 4 x) y) (/ z (/ y x)))
1.0ms
(/ z (/ y x))

series41.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

27.0ms
(- (/ (+ 4 x) y) (/ z (/ y x)))
14.0ms
(/ z (/ y x))

simplify5.2s

Counts
59 → 64
Calls

59 calls. Slowest were:

679.0ms
(fma (- (/ 1 (/ y x))) z (* (/ 1 (/ y x)) z))
337.0ms
(fma 1 (/ (+ 4 x) y) (- (* (/ 1 (/ y x)) z)))
277.0ms
(fma (+ 4 x) (/ 1 y) (- (* (/ z (/ y x)) 1)))

prune747.0ms

Pruning

4 alts after pruning (1 fresh and 3 done)

Merged error: 0b

localize14.0ms

Local error

Found 3 expressions with local error:

8.0b
(* x (* (/ 1 y) z))
0.2b
(* (/ 1 y) z)
0.0b
(- (/ (+ x 4) y) (* x (* (/ 1 y) z)))

rewrite17.0ms

Algorithm
rewrite-expression-head
Counts
3 → 51
Calls

3 calls. Slowest were:

9.0ms
(- (/ (+ x 4) y) (* x (* (/ 1 y) z)))
5.0ms
(* x (* (/ 1 y) z))
2.0ms
(* (/ 1 y) z)

series58.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

27.0ms
(- (/ (+ x 4) y) (* x (* (/ 1 y) z)))
22.0ms
(* x (* (/ 1 y) z))
9.0ms
(* (/ 1 y) z)

simplify3.5s

Counts
27 → 60
Calls

27 calls. Slowest were:

523.0ms
(fma 1 (/ (+ x 4) y) (- (* (* (/ 1 y) z) x)))
408.0ms
(fma (sqrt (/ (+ x 4) y)) (sqrt (/ (+ x 4) y)) (- (* (* (/ 1 y) z) x)))
374.0ms
(fma (* (cbrt (/ (+ x 4) y)) (cbrt (/ (+ x 4) y))) (cbrt (/ (+ x 4) y)) (- (* (* (/ 1 y) z) x)))

prune602.0ms

Pruning

4 alts after pruning (0 fresh and 4 done)

Merged error: 0b

regimes280.0ms

Accuracy

95.5% (0.1b remaining)

Error of 0.2b against oracle of 0.0b and baseline of 3.2b

bsearch4.0ms

end0.0ms

sample1.5s

Algorithm
intervals