Average Error: 1.5 → 0.3
Time: 12.0s
Precision: 64
Internal Precision: 128
\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
\[\begin{array}{l} \mathbf{if}\;x \le -7.611466246480375 \cdot 10^{+23}:\\ \;\;\;\;\left|\left(\frac{4}{y} + \frac{x}{y}\right) - \frac{x}{y} \cdot z\right|\\ \mathbf{elif}\;x \le 3.259341531603994 \cdot 10^{-105}:\\ \;\;\;\;\left|\frac{4 + x}{y} - \frac{x \cdot z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{4 + x}{y} - \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 3 regimes
  2. if x < -7.611466246480375e+23

    1. Initial program 0.1

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

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

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

    if -7.611466246480375e+23 < x < 3.259341531603994e-105

    1. Initial program 2.4

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

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

    if 3.259341531603994e-105 < x

    1. Initial program 0.7

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

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

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

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

Reproduce

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

Details

Time bar (total: 8.4s)Debug log

start78.0ms

Algorithm
intervals

setup78.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 0.1b

localize36.0ms

Local error

Found 3 expressions with local error:

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

rewrite26.0ms

Algorithm
rewrite-expression-head
Counts
3 → 42
Calls

3 calls. Slowest were:

16.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:

42.0ms
(- (/ (+ x 4) y) (* (/ x y) z))
16.0ms
(/ (+ x 4) y)
15.0ms
(* (/ x y) z)

simplify488.0ms

Counts
20 → 51
Calls

20 calls. Slowest were:

134.0ms
(- (* (+ x 4) y) (* y (* x z)))
71.0ms
(- (+ (/ x y) (* 4 (/ 1 y))) (/ (* x z) y))
68.0ms
(- (+ (/ x y) (* 4 (/ 1 y))) (/ (* x z) y))

prune616.0ms

Pruning

5 alts after pruning (5 fresh and 0 done)

Merged error: 0.0b

localize14.0ms

Local error

Found 3 expressions with local error:

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

rewrite32.0ms

Algorithm
rewrite-expression-head
Counts
3 → 44
Calls

3 calls. Slowest were:

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

series60.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

27.0ms
(- (+ (/ x y) (/ 4 y)) (* (/ x y) z))
18.0ms
(+ (/ x y) (/ 4 y))
15.0ms
(* (/ x y) z)

simplify2.0s

Counts
27 → 53
Calls

27 calls. Slowest were:

634.0ms
(* (+ (* (/ x y) (/ x y)) (- (* (/ 4 y) (/ 4 y)) (* (/ x y) (/ 4 y)))) y)
379.0ms
(- (* (+ (pow (/ x y) 3) (pow (/ 4 y) 3)) y) (* (+ (* (/ x y) (/ x y)) (- (* (/ 4 y) (/ 4 y)) (* (/ x y) (/ 4 y)))) (* x z)))
225.0ms
(- (* (+ (* x y) (* y 4)) y) (* (* y y) (* x z)))

prune592.0ms

Pruning

5 alts after pruning (4 fresh and 1 done)

Merged error: 0.0b

localize10.0ms

Local error

Found 4 expressions with local error:

2.8b
(* (/ x y) z)
0.1b
(/ 1 (/ y (+ x 4)))
0.0b
(/ y (+ x 4))
0.0b
(- (/ 1 (/ y (+ x 4))) (* (/ x y) z))

rewrite8.0ms

Algorithm
rewrite-expression-head
Counts
4 → 61
Calls

4 calls. Slowest were:

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

series116.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

45.0ms
(- (/ 1 (/ y (+ x 4))) (* (/ x y) z))
28.0ms
(/ y (+ x 4))
23.0ms
(/ 1 (/ y (+ x 4)))
20.0ms
(* (/ x y) z)

simplify1.7s

Counts
31 → 73
Calls

31 calls. Slowest were:

469.0ms
(/ (exp (/ 1 (/ y (+ x 4)))) (exp (* (/ x y) z)))
239.0ms
(- (+ (/ y x) (* 16 (/ y (pow x 3)))) (* 4 (/ y (pow x 2))))
229.0ms
(- (+ (* 1/64 (* (pow x 2) y)) (* 1/4 y)) (* 1/16 (* x y)))

prune851.0ms

Pruning

5 alts after pruning (3 fresh and 2 done)

Merged error: 0.0b

localize18.0ms

Local error

Found 3 expressions with local error:

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

rewrite20.0ms

Algorithm
rewrite-expression-head
Counts
3 → 43
Calls

3 calls. Slowest were:

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

series63.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

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

simplify572.0ms

Counts
22 → 52
Calls

22 calls. Slowest were:

77.0ms
(- (+ (/ x y) (* 4 (/ 1 y))) (/ (* x z) y))
76.0ms
(- (* (+ x 4) y) (* y (* x z)))
71.0ms
(- (+ (/ x y) (* 4 (/ 1 y))) (/ (* x z) y))

prune557.0ms

Pruning

5 alts after pruning (2 fresh and 3 done)

Merged error: 0.0b

regimes221.0ms

Accuracy

84.1% (0.2b remaining)

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

bsearch179.0ms