Average Error: 1.7 → 1.6
Time: 9.0s
Precision: 64
Internal Precision: 128
\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
\[\begin{array}{l} \mathbf{if}\;y \le 6.423081149410413 \cdot 10^{-35}:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\left(\frac{4}{y} + \frac{x}{y}\right) - \frac{x}{\frac{y}{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 y < 6.423081149410413e-35

    1. Initial program 1.2

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
    2. Using strategy rm
    3. Applied associate-*l/2.4

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

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

    if 6.423081149410413e-35 < y

    1. Initial program 2.6

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
    2. Using strategy rm
    3. Applied associate-*l/5.3

      \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right|\]
    4. Applied sub-div5.3

      \[\leadsto \left|\color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}}\right|\]
    5. Taylor expanded around inf 5.3

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

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

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

Reproduce

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

Details

Time bar (total: 8.4s)Debug log

sample76.0ms

Algorithm
intervals

simplify61.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune12.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 2.6b

localize36.0ms

Local error

Found 3 expressions with local error:

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

rewrite13.0ms

Algorithm
rewrite-expression-head
Counts
3 → 42
Calls

3 calls. Slowest were:

6.0ms
(- (/ (+ x 4) y) (* (/ x y) z))
4.0ms
(* (/ x y) z)
2.0ms
(/ (+ x 4) y)

series72.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

29.0ms
(/ (+ x 4) y)
26.0ms
(- (/ (+ x 4) y) (* (/ x y) z))
17.0ms
(* (/ x y) z)

simplify481.0ms

Counts
20 → 51
Calls

20 calls. Slowest were:

79.0ms
(- (* (+ x 4) y) (* y (* x z)))
77.0ms
(- (+ (/ x y) (* 4 (/ 1 y))) (/ (* x z) y))
75.0ms
(- (+ (/ x y) (* 4 (/ 1 y))) (/ (* x z) y))

prune510.0ms

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0.0b

localize21.0ms

Local error

Found 3 expressions with local error:

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

rewrite41.0ms

Algorithm
rewrite-expression-head
Counts
3 → 44
Calls

3 calls. Slowest were:

32.0ms
(- (+ (/ x y) (/ 4 y)) (* (/ x y) z))
4.0ms
(* (/ x y) z)
3.0ms
(+ (/ x y) (/ 4 y))

series87.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

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

simplify1.5s

Counts
27 → 53
Calls

27 calls. Slowest were:

288.0ms
(- (* (+ (pow (/ x y) 3) (pow (/ 4 y) 3)) y) (* (+ (* (/ x y) (/ x y)) (- (* (/ 4 y) (/ 4 y)) (* (/ x y) (/ 4 y)))) (* x z)))
251.0ms
(* (+ (* (/ x y) (/ x y)) (- (* (/ 4 y) (/ 4 y)) (* (/ x y) (/ 4 y)))) y)
229.0ms
(- (* (- (* (/ x y) (/ x y)) (* (/ 4 y) (/ 4 y))) y) (* (- (/ x y) (/ 4 y)) (* x z)))

prune546.0ms

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0.0b

localize10.0ms

Local error

Found 2 expressions with local error:

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

rewrite11.0ms

Algorithm
rewrite-expression-head
Counts
2 → 29
Calls

2 calls. Slowest were:

7.0ms
(/ (- (+ x 4) (* x z)) y)
3.0ms
(- (+ x 4) (* x z))

series45.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

32.0ms
(/ (- (+ x 4) (* x z)) y)
12.0ms
(- (+ x 4) (* x z))

simplify588.0ms

Counts
12 → 35
Calls

12 calls. Slowest were:

169.0ms
(- (pow (+ x 4) 3) (pow (* x z) 3))
89.0ms
(- (* (+ x 4) (+ x 4)) (* (* x z) (* x z)))
86.0ms
(- (+ (/ x y) (* 4 (/ 1 y))) (/ (* x z) y))

prune357.0ms

Pruning

5 alts after pruning (3 fresh and 2 done)

Merged error: 0b

localize25.0ms

Local error

Found 3 expressions with local error:

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

rewrite27.0ms

Algorithm
rewrite-expression-head
Counts
3 → 49
Calls

3 calls. Slowest were:

23.0ms
(- (+ (/ x y) (/ 4 y)) (/ x (/ y z)))
3.0ms
(+ (/ x y) (/ 4 y))
1.0ms
(/ x (/ y z))

series55.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

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

simplify1.5s

Counts
32 → 58
Calls

32 calls. Slowest were:

310.0ms
(- (* (+ (pow (/ x y) 3) (pow (/ 4 y) 3)) (/ y z)) (* (+ (* (/ x y) (/ x y)) (- (* (/ 4 y) (/ 4 y)) (* (/ x y) (/ 4 y)))) x))
221.0ms
(- (* (+ (* x y) (* y 4)) (/ y z)) (* (* y y) x))
201.0ms
(- (* (- (* (/ x y) (/ x y)) (* (/ 4 y) (/ 4 y))) (/ y z)) (* (- (/ x y) (/ 4 y)) x))

prune602.0ms

Pruning

5 alts after pruning (2 fresh and 3 done)

Merged error: 0b

regimes204.0ms

Accuracy

3.1% (1.6b remaining)

Error of 1.6b against oracle of 0.0b and baseline of 1.7b

bsearch75.0ms

end0.0ms

sample1.6s

Algorithm
intervals