Average Error: 1.6 → 0.1
Time: 16.7s
Precision: 64
Internal Precision: 128
\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
\[\begin{array}{l} \mathbf{if}\;x \le -12092646693085662.0 \lor \neg \left(x \le 653141293.4019859\right):\\ \;\;\;\;\left|(\left(-z\right) \cdot \left(\frac{x}{y}\right) + \left(\frac{4}{y} + \frac{x}{y}\right))_*\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{(x \cdot x + -16)_*}{\left(x - 4\right) \cdot 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 < -12092646693085662.0 or 653141293.4019859 < x

    1. Initial program 0.1

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

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

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

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

    if -12092646693085662.0 < x < 653141293.4019859

    1. Initial program 2.5

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

      \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right|\]
    3. Using strategy rm
    4. Applied flip-+0.1

      \[\leadsto \left|\frac{\color{blue}{\frac{x \cdot x - 4 \cdot 4}{x - 4}}}{y} - \frac{x \cdot z}{y}\right|\]
    5. Applied associate-/l/0.1

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -12092646693085662.0 \lor \neg \left(x \le 653141293.4019859\right):\\ \;\;\;\;\left|(\left(-z\right) \cdot \left(\frac{x}{y}\right) + \left(\frac{4}{y} + \frac{x}{y}\right))_*\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{(x \cdot x + -16)_*}{\left(x - 4\right) \cdot y} - \frac{z \cdot x}{y}\right|\\ \end{array}\]

Reproduce

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

Details

Time bar (total: 13.1s)Debug log

start94.0ms

Algorithm
intervals

setup75.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 0.1b

localize24.0ms

Local error

Found 3 expressions with local error:

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

rewrite24.0ms

Algorithm
rewrite-expression-head
Counts
3 → 56
Calls

3 calls. Slowest were:

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

series74.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

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

simplify1.2s

Counts
31 → 65
Calls

31 calls. Slowest were:

171.0ms
(- (* (+ x 4) y) (* y (* x z)))
118.0ms
(fma (+ x 4) (/ 1 y) (- (* z (/ x y))))
108.0ms
(- (+ (/ x y) (* 4 (/ 1 y))) (/ (* x z) y))

prune845.0ms

Pruning

5 alts after pruning (5 fresh and 0 done)

Merged error: 0.0b

localize20.0ms

Local error

Found 3 expressions with local error:

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

rewrite23.0ms

Algorithm
rewrite-expression-head
Counts
3 → 69
Calls

3 calls. Slowest were:

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

series95.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

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

simplify4.3s

Counts
57 → 78
Calls

57 calls. Slowest were:

365.0ms
(fma (+ x 4) (/ 1 y) (- (* (/ 1 y) (* x z))))
240.0ms
(fma (+ x 4) (/ 1 y) (- (* (/ (* x z) y) 1)))
225.0ms
(fma 1 (/ (+ x 4) y) (- (* (/ 1 y) (* x z))))

prune971.0ms

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0.0b

localize16.0ms

Local error

Found 2 expressions with local error:

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

rewrite7.0ms

Algorithm
rewrite-expression-head
Counts
2 → 30
Calls

2 calls. Slowest were:

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

series83.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

58.0ms
(fma (- z) (/ x y) (+ (/ x y) (/ 4 y)))
24.0ms
(+ (/ x y) (/ 4 y))

simplify348.0ms

Counts
14 → 36
Calls

14 calls. Slowest were:

103.0ms
(- (+ (/ x y) (* 4 (/ 1 y))) (/ (* x z) y))
103.0ms
(- (+ (/ x y) (* 4 (/ 1 y))) (/ (* x z) y))
80.0ms
(- (+ (/ x y) (* 4 (/ 1 y))) (/ (* x z) y))

prune440.0ms

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0.0b

localize15.0ms

Local error

Found 4 expressions with local error:

10.2b
(cbrt (/ x y))
10.2b
(cbrt (/ x y))
10.2b
(cbrt (/ x y))
0.7b
(* (* (cbrt (/ x y)) (cbrt (/ x y))) (* (cbrt (/ x y)) z))

rewrite29.0ms

Algorithm
rewrite-expression-head
Counts
4 → 70
Calls

4 calls. Slowest were:

26.0ms
(* (* (cbrt (/ x y)) (cbrt (/ x y))) (* (cbrt (/ x y)) z))
1.0ms
(cbrt (/ x y))
0.0ms
(cbrt (/ x y))

series277.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

101.0ms
(cbrt (/ x y))
82.0ms
(cbrt (/ x y))
72.0ms
(cbrt (/ x y))
21.0ms
(* (* (cbrt (/ x y)) (cbrt (/ x y))) (* (cbrt (/ x y)) z))

simplify2.9s

Counts
44 → 82
Calls

44 calls. Slowest were:

404.0ms
(* (* (* (* (cbrt (/ x y)) (cbrt (/ x y))) (* (cbrt (/ x y)) (cbrt (/ x y)))) (* (cbrt (/ x y)) (cbrt (/ x y)))) (* (* (* (cbrt (/ x y)) z) (* (cbrt (/ x y)) z)) (* (cbrt (/ x y)) z)))
380.0ms
(exp (* 1/3 (- (log (/ -1 y)) (log (/ -1 x)))))
378.0ms
(exp (* 1/3 (- (log (/ -1 y)) (log (/ -1 x)))))

prune923.0ms

Pruning

4 alts after pruning (2 fresh and 2 done)

Merged error: 0.0b

regimes189.0ms

Accuracy

93.4% (0.1b remaining)

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

bsearch232.0ms