Average Error: 1.6 → 0.7
Time: 11.1s
Precision: 64
Internal Precision: 128
\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
\[\begin{array}{l} \mathbf{if}\;x \le -3.669195055065622 \cdot 10^{+140} \lor \neg \left(x \le 5.1753847487161616 \cdot 10^{-114}\right):\\ \;\;\;\;\left|(z \cdot \left(-\frac{x}{y}\right) + \left(\frac{x}{y} + \frac{4}{y}\right))_*\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x + 4}{y} - \frac{z \cdot x}{y}\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 x < -3.669195055065622e+140 or 5.1753847487161616e-114 < x

    1. Initial program 0.7

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

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

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

    if -3.669195055065622e+140 < x < 5.1753847487161616e-114

    1. Initial program 2.2

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -3.669195055065622 \cdot 10^{+140} \lor \neg \left(x \le 5.1753847487161616 \cdot 10^{-114}\right):\\ \;\;\;\;\left|(z \cdot \left(-\frac{x}{y}\right) + \left(\frac{x}{y} + \frac{4}{y}\right))_*\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x + 4}{y} - \frac{z \cdot x}{y}\right|\\ \end{array}\]

Reproduce

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

Details

Time bar (total: 10.6s)Debug log

sample45.0ms

Algorithm
intervals

simplify41.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune6.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 2.0b

localize17.0ms

Local error

Found 3 expressions with local error:

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

rewrite19.0ms

Algorithm
rewrite-expression-head
Counts
3 → 56
Calls

3 calls. Slowest were:

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

series98.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

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

simplify1.2s

Counts
31 → 65
Calls

31 calls. Slowest were:

262.0ms
(fma (+ x 4) (/ 1 y) (- (* z (/ x y))))
163.0ms
(- (* (+ x 4) y) (* y (* x z)))
87.0ms
(- (+ (/ x y) (* 4 (/ 1 y))) (/ (* x z) y))

prune647.0ms

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0.0b

localize14.0ms

Local error

Found 2 expressions with local error:

2.0b
(fma z (- (/ x y)) (+ (/ x y) (/ 4 y)))
0.0b
(+ (/ x y) (/ 4 y))

rewrite4.0ms

Algorithm
rewrite-expression-head
Counts
2 → 30
Calls

2 calls. Slowest were:

4.0ms
(+ (/ x y) (/ 4 y))
0.0ms
(fma z (- (/ x y)) (+ (/ x y) (/ 4 y)))

series59.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

44.0ms
(fma z (- (/ x y)) (+ (/ x y) (/ 4 y)))
15.0ms
(+ (/ x y) (/ 4 y))

simplify467.0ms

Counts
14 → 36
Calls

14 calls. Slowest were:

124.0ms
(- (+ (/ x y) (* 4 (/ 1 y))) (/ (* x z) y))
122.0ms
(- (+ (/ x y) (* 4 (/ 1 y))) (/ (* x z) y))
94.0ms
(- (+ (/ x y) (* 4 (/ 1 y))) (/ (* x z) y))

prune398.0ms

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0.0b

localize16.0ms

Local error

Found 4 expressions with local error:

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

rewrite24.0ms

Algorithm
rewrite-expression-head
Counts
4 → 68
Calls

4 calls. Slowest were:

9.0ms
(/ (+ x 4) y)
8.0ms
(- (/ (+ x 4) y) (* x (* (/ 1 y) z)))
3.0ms
(* x (* (/ 1 y) z))

series81.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

28.0ms
(- (/ (+ x 4) y) (* x (* (/ 1 y) z)))
24.0ms
(/ (+ x 4) y)
23.0ms
(* x (* (/ 1 y) z))
6.0ms
(* (/ 1 y) z)

simplify3.3s

Counts
34 → 80
Calls

34 calls. Slowest were:

441.0ms
(fma (sqrt (/ (+ x 4) y)) (sqrt (/ (+ x 4) y)) (- (* (* (/ 1 y) z) x)))
412.0ms
(fma 1 (/ (+ x 4) y) (- (* (* (/ 1 y) z) x)))
378.0ms
(fma (* (cbrt (/ (+ x 4) y)) (cbrt (/ (+ x 4) y))) (cbrt (/ (+ x 4) y)) (- (* (* (/ 1 y) z) x)))

prune809.0ms

Pruning

5 alts after pruning (3 fresh and 2 done)

Merged error: 0.0b

localize22.0ms

Local error

Found 4 expressions with local error:

6.0b
(* x (* (* (cbrt (/ 1 y)) (cbrt (/ 1 y))) (* (cbrt (/ 1 y)) z)))
0.6b
(cbrt (/ 1 y))
0.6b
(cbrt (/ 1 y))
0.6b
(cbrt (/ 1 y))

rewrite38.0ms

Algorithm
rewrite-expression-head
Counts
4 → 63
Calls

4 calls. Slowest were:

34.0ms
(* x (* (* (cbrt (/ 1 y)) (cbrt (/ 1 y))) (* (cbrt (/ 1 y)) z)))
1.0ms
(cbrt (/ 1 y))
1.0ms
(cbrt (/ 1 y))

series1.2s

Counts
4 → 12
Calls

4 calls. Slowest were:

632.0ms
(cbrt (/ 1 y))
273.0ms
(cbrt (/ 1 y))
251.0ms
(cbrt (/ 1 y))
44.0ms
(* x (* (* (cbrt (/ 1 y)) (cbrt (/ 1 y))) (* (cbrt (/ 1 y)) z)))

simplify71.0ms

Counts
35 → 75
Calls

35 calls. Slowest were:

6.0ms
(/ (* x z) y)
5.0ms
(* (* (cbrt y) (cbrt y)) (cbrt y))
5.0ms
(/ (* x z) y)

prune684.0ms

Pruning

5 alts after pruning (3 fresh and 2 done)

Merged error: 0.0b

regimes149.0ms

Accuracy

57.5% (0.7b remaining)

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

bsearch139.0ms

end0.0ms

sample1.1s

Algorithm
intervals