Average Error: 1.3 → 0.1
Time: 25.6s
Precision: 64
Internal Precision: 128
\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
\[\begin{array}{l} \mathbf{if}\;x \le -2.1690543199597533 \cdot 10^{+36}:\\ \;\;\;\;\left|\frac{4 + x}{y} - \frac{x}{\frac{y}{z}}\right|\\ \mathbf{elif}\;x \le 1.087461731140344 \cdot 10^{-19}:\\ \;\;\;\;\left|\frac{\left(4 + x\right) - z \cdot x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|(z \cdot \left(-\frac{x}{y}\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

Derivation

  1. Split input into 3 regimes
  2. if x < -2.1690543199597533e+36

    1. Initial program 0.1

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
    2. Initial simplification0.1

      \[\leadsto \left|\frac{4 + x}{y} - \frac{x}{\frac{y}{z}}\right|\]

    if -2.1690543199597533e+36 < x < 1.087461731140344e-19

    1. Initial program 2.0

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

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

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

    if 1.087461731140344e-19 < x

    1. Initial program 0.1

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

      \[\leadsto \left|\color{blue}{\sqrt{\frac{x + 4}{y}} \cdot \sqrt{\frac{x + 4}{y}}} - \frac{x}{y} \cdot z\right|\]
    4. Applied prod-diff30.2

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -2.1690543199597533 \cdot 10^{+36}:\\ \;\;\;\;\left|\frac{4 + x}{y} - \frac{x}{\frac{y}{z}}\right|\\ \mathbf{elif}\;x \le 1.087461731140344 \cdot 10^{-19}:\\ \;\;\;\;\left|\frac{\left(4 + x\right) - z \cdot x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|(z \cdot \left(-\frac{x}{y}\right) + \left(\frac{4}{y} + \frac{x}{y}\right))_*\right|\\ \end{array}\]

Reproduce

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

Details

Time bar (total: 21.8s)Debug log

start53.0ms

Algorithm
intervals

setup57.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 0.1b

localize17.0ms

Local error

Found 3 expressions with local error:

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

rewrite12.0ms

Algorithm
rewrite-expression-head
Counts
3 → 56
Calls

3 calls. Slowest were:

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

series60.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

26.0ms
(- (/ (+ x 4) y) (* (/ x y) z))
19.0ms
(/ (+ x 4) y)
15.0ms
(* (/ x y) z)

simplify1.1s

Counts
31 → 65
Calls

31 calls. Slowest were:

214.0ms
(fma (+ x 4) (/ 1 y) (- (* z (/ x y))))
124.0ms
(- (* (+ x 4) y) (* y (* x z)))
108.0ms
(- (+ (/ x y) (* 4 (/ 1 y))) (/ (* x z) y))

prune783.0ms

Pruning

6 alts after pruning (6 fresh and 0 done)

Merged error: 0.0b

localize28.0ms

Local error

Found 3 expressions with local error:

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

rewrite10.0ms

Algorithm
rewrite-expression-head
Counts
3 → 75
Calls

3 calls. Slowest were:

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

series69.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

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

simplify5.1s

Counts
66 → 84
Calls

66 calls. Slowest were:

246.0ms
(fma (- (/ 1 (/ y x))) z (* (/ 1 (/ y x)) z))
239.0ms
(fma (+ 4 x) (/ 1 y) (- (* (/ z (/ y x)) 1)))
238.0ms
(fma (- (/ 1 (/ y x))) z (* (/ 1 (/ y x)) z))

prune1.5s

Pruning

6 alts after pruning (5 fresh and 1 done)

Merged error: 0.0b

localize32.0ms

Local error

Found 2 expressions with local error:

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

rewrite8.0ms

Algorithm
rewrite-expression-head
Counts
2 → 30
Calls

2 calls. Slowest were:

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

series72.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

51.0ms
(fma z (- (/ x y)) (+ (/ x y) (/ 4 y)))
21.0ms
(+ (/ x y) (/ 4 y))

simplify333.0ms

Counts
14 → 36
Calls

14 calls. Slowest were:

101.0ms
(- (+ (/ x y) (* 4 (/ 1 y))) (/ (* x z) y))
86.0ms
(- (+ (/ x y) (* 4 (/ 1 y))) (/ (* x z) y))
68.0ms
(- (+ (/ x y) (* 4 (/ 1 y))) (/ (* x z) y))

prune516.0ms

Pruning

6 alts after pruning (4 fresh and 2 done)

Merged error: 0.0b

localize27.0ms

Local error

Found 4 expressions with local error:

3.9b
(/ (/ y x) z)
0.5b
(/ 1 (/ (/ y x) z))
0.0b
(/ (+ 4 x) y)
0.0b
(- (/ (+ 4 x) y) (/ 1 (/ (/ y x) z)))

rewrite26.0ms

Algorithm
rewrite-expression-head
Counts
4 → 96
Calls

4 calls. Slowest were:

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

series90.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

36.0ms
(- (/ (+ 4 x) y) (/ 1 (/ (/ y x) z)))
21.0ms
(/ (/ y x) z)
19.0ms
(/ (+ 4 x) y)
15.0ms
(/ 1 (/ (/ y x) z))

simplify10.3s

Counts
73 → 108
Calls

73 calls. Slowest were:

709.0ms
(fma (+ 4 x) (/ 1 y) (- (* z (/ 1 (/ y x)))))
421.0ms
(fma (+ 4 x) (/ 1 y) (- (* (/ 1 (/ (/ y x) z)) 1)))
412.0ms
(fma (+ 4 x) (/ 1 y) (- (* (sqrt (/ 1 (/ (/ y x) z))) (sqrt (/ 1 (/ (/ y x) z))))))

prune1.2s

Pruning

5 alts after pruning (3 fresh and 2 done)

Merged error: 0.0b

regimes201.0ms

Accuracy

92.6% (0.1b remaining)

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

bsearch116.0ms