Average Error: 1.5 → 0.1
Time: 11.8s
Precision: 64
Internal Precision: 128
\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.5293515526480282 \cdot 10^{+26} \lor \neg \left(x \le 6.149818727891566 \cdot 10^{+21}\right):\\ \;\;\;\;\left|\frac{4 + x}{y} - x \cdot \frac{z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{\left(4 + x\right) - z \cdot x}{y}\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 x < -1.5293515526480282e+26 or 6.149818727891566e+21 < x

    1. Initial program 0.1

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

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

      \[\leadsto \left|\color{blue}{(\left(x + 4\right) \cdot \left(\frac{1}{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.1

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

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

    if -1.5293515526480282e+26 < x < 6.149818727891566e+21

    1. Initial program 2.3

      \[\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|\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.5293515526480282 \cdot 10^{+26} \lor \neg \left(x \le 6.149818727891566 \cdot 10^{+21}\right):\\ \;\;\;\;\left|\frac{4 + x}{y} - x \cdot \frac{z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{\left(4 + x\right) - z \cdot x}{y}\right|\\ \end{array}\]

Reproduce

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

Details

Time bar (total: 11.2s)Debug log

sample79.0ms

Algorithm
intervals

simplify50.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune11.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 1.5b

localize29.0ms

Local error

Found 3 expressions with local error:

3.2b
(* (/ 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:

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

series85.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

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

simplify1.2s

Counts
31 → 65
Calls

31 calls. Slowest were:

250.0ms
(fma (+ x 4) (/ 1 y) (- (* z (/ x y))))
154.0ms
(- (* (+ x 4) y) (* y (* x z)))
123.0ms
(- (+ (/ x y) (* 4 (/ 1 y))) (/ (* x z) y))

prune669.0ms

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0b

localize17.0ms

Local error

Found 3 expressions with local error:

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

rewrite64.0ms

Algorithm
rewrite-expression-head
Counts
3 → 64
Calls

3 calls. Slowest were:

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

series88.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

44.0ms
(- (+ (/ x y) (/ 4 y)) (* (/ x y) z))
22.0ms
(* (/ x y) z)
21.0ms
(+ (/ x y) (/ 4 y))

simplify2.8s

Counts
42 → 73
Calls

42 calls. Slowest were:

448.0ms
(fma (/ 1 y) (+ x 4) (- (* z (/ x y))))
318.0ms
(* (+ (* (/ x y) (/ x y)) (- (* (/ 4 y) (/ 4 y)) (* (/ x y) (/ 4 y)))) y)
307.0ms
(fma 1 (+ (/ x y) (/ 4 y)) (- (* z (/ x y))))

prune807.0ms

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0b

localize9.0ms

Local error

Found 1 expressions with local error:

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

rewrite8.0ms

Algorithm
rewrite-expression-head
Counts
1 → 18
Calls

1 calls. Slowest were:

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

series47.0ms

Counts
1 → 3
Calls

1 calls. Slowest were:

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

simplify881.0ms

Counts
8 → 21
Calls

8 calls. Slowest were:

276.0ms
(- (pow (+ x 4) 3) (pow (* x z) 3))
161.0ms
(- (* (+ x 4) (+ x 4)) (* (* x z) (* x z)))
114.0ms
(- (+ (/ x y) (* 4 (/ 1 y))) (/ (* x z) y))

prune186.0ms

Pruning

4 alts after pruning (2 fresh and 2 done)

Merged error: 0b

localize19.0ms

Local error

Found 3 expressions with local error:

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

rewrite12.0ms

Algorithm
rewrite-expression-head
Counts
3 → 56
Calls

3 calls. Slowest were:

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

series62.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

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

simplify1.1s

Counts
31 → 65
Calls

31 calls. Slowest were:

186.0ms
(fma (+ 4 x) (/ 1 y) (- (* x (/ z y))))
147.0ms
(- (* (+ 4 x) y) (* y (* z x)))
97.0ms
(- (+ (/ x y) (* 4 (/ 1 y))) (/ (* x z) y))

prune1.1s

Pruning

4 alts after pruning (1 fresh and 3 done)

Merged error: 0b

regimes114.0ms

Accuracy

92.8% (0.1b remaining)

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

bsearch201.0ms

end0.0ms

sample1.5s

Algorithm
intervals