Average Error: 1.7 → 0.9
Time: 13.3s
Precision: 64
Internal Precision: 128
\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.1906865176555539 \cdot 10^{+188}:\\ \;\;\;\;\left|\frac{1}{\frac{y}{4 + x}} - \frac{x}{y} \cdot z\right|\\ \mathbf{elif}\;x \le 1.6862382786712306 \cdot 10^{-82}:\\ \;\;\;\;\left|\frac{\left(4 + x\right) - x \cdot z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\left(\frac{x}{y} + \frac{4}{y}\right) - \frac{1}{\frac{y}{z}} \cdot x\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 < -1.1906865176555539e+188

    1. Initial program 0.1

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
    2. Using strategy rm
    3. Applied *-un-lft-identity0.1

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

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

    if -1.1906865176555539e+188 < x < 1.6862382786712306e-82

    1. Initial program 2.2

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

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

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

    if 1.6862382786712306e-82 < x

    1. Initial program 0.9

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

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

      \[\leadsto \left|\color{blue}{\left(\frac{x}{y} + \frac{4}{y}\right) - \frac{x}{\frac{y}{z}}}\right|\]
    4. Using strategy rm
    5. Applied div-inv0.8

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.1906865176555539 \cdot 10^{+188}:\\ \;\;\;\;\left|\frac{1}{\frac{y}{4 + x}} - \frac{x}{y} \cdot z\right|\\ \mathbf{elif}\;x \le 1.6862382786712306 \cdot 10^{-82}:\\ \;\;\;\;\left|\frac{\left(4 + x\right) - x \cdot z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\left(\frac{x}{y} + \frac{4}{y}\right) - \frac{1}{\frac{y}{z}} \cdot x\right|\\ \end{array}\]

Reproduce

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

Details

Time bar (total: 12.7s)Debug log

sample76.0ms

Algorithm
intervals
Results
313×(pre true 80)
313×(body real 80)

simplify49.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
49.0ms
(fabs (- (/ (+ x 4) y) (* (/ x y) z)))

prune13.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 1.7b

localize49.0ms

Local error

Found 3 expressions with local error:

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

rewrite22.0ms

Algorithm
rewrite-expression-head
Rules
add-log-exp
add-cube-cbrt
*-un-lft-identity
add-sqr-sqrt
associate-*l*
associate-/l*
add-exp-log
associate-*l/
add-cbrt-cube
pow1
associate-/l/
div-inv
sub-div
flip--
flip-+
frac-sub
*-commutative
diff-log
flip3--
flip3-+
frac-2neg
sub-neg
clear-num
Counts
3 → 42
Calls
3 calls:
Slowest
12.0ms
(- (/ (+ x 4) y) (* (/ x y) z))
5.0ms
(/ (+ x 4) y)
5.0ms
(* (/ x y) z)

series83.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
42.0ms
(- (/ (+ x 4) y) (* (/ x y) z))
25.0ms
(* (/ x y) z)
15.0ms
(/ (+ x 4) y)

simplify528.0ms

Counts
20 → 51
Calls
20 calls:
Slowest
133.0ms
(- (* (+ x 4) y) (* y (* x z)))
81.0ms
(- (+ (/ x y) (* 4 (/ 1 y))) (/ (* x z) y))
76.0ms
(- (+ (/ x y) (* 4 (/ 1 y))) (/ (* x z) y))
64.0ms
(- (+ (/ x y) (* 4 (/ 1 y))) (/ (* x z) y))
30.0ms
(/ (exp (/ (+ x 4) y)) (exp (* (/ x y) z)))

prune673.0ms

Pruning

5 alts after pruning (5 fresh and 0 done)

Merged error: 0b

localize22.0ms

Local error

Found 4 expressions with local error:

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

rewrite17.0ms

Algorithm
rewrite-expression-head
Rules
associate-/r*
add-cube-cbrt
*-un-lft-identity
add-sqr-sqrt
add-log-exp
associate-/r/
add-exp-log
pow1
div-inv
associate-*l*
add-cbrt-cube
flip-+
associate-*l/
flip3-+
frac-2neg
clear-num
inv-pow
flip--
pow-flip
frac-sub
*-commutative
diff-log
flip3--
sub-neg
rec-exp
Counts
4 → 61
Calls
4 calls:
Slowest
9.0ms
(- (/ 1 (/ y (+ x 4))) (* (/ x y) z))
4.0ms
(* (/ x y) z)
2.0ms
(/ 1 (/ y (+ x 4)))
1.0ms
(/ y (+ x 4))

series112.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
47.0ms
(- (/ 1 (/ y (+ x 4))) (* (/ x y) z))
24.0ms
(* (/ x y) z)
22.0ms
(/ 1 (/ y (+ x 4)))
19.0ms
(/ y (+ x 4))

simplify2.0s

Counts
31 → 73
Calls
31 calls:
Slowest
523.0ms
(- (* 1 y) (* (/ y (+ x 4)) (* x z)))
395.0ms
(/ (exp (/ 1 (/ y (+ x 4)))) (exp (* (/ x y) z)))
263.0ms
(- (+ (/ y x) (* 16 (/ y (pow x 3)))) (* 4 (/ y (pow x 2))))
230.0ms
(- (+ (/ y x) (* 16 (/ y (pow x 3)))) (* 4 (/ y (pow x 2))))
205.0ms
(- (+ (* 1/64 (* (pow x 2) y)) (* 1/4 y)) (* 1/16 (* x y)))

prune836.0ms

Pruning

5 alts after pruning (4 fresh and 1 done)

Merged error: 0b

localize32.0ms

Local error

Found 3 expressions with local error:

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

rewrite48.0ms

Algorithm
rewrite-expression-head
Rules
11×*-un-lft-identity
10×add-log-exp
add-sqr-sqrt
div-inv
add-cube-cbrt
associate-/r*
frac-sub
add-exp-log
add-cbrt-cube
pow1
distribute-lft-out--
distribute-lft-out
flip-+
frac-add
diff-log
flip3-+
sum-log
difference-of-squares
flip--
associate-/r/
associate--l+
flip3--
distribute-rgt-out
frac-2neg
sub-neg
clear-num
+-commutative
Counts
3 → 49
Calls
3 calls:
Slowest
39.0ms
(- (+ (/ x y) (/ 4 y)) (/ x (/ y z)))
7.0ms
(+ (/ x y) (/ 4 y))
1.0ms
(/ x (/ y z))

series93.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
45.0ms
(- (+ (/ x y) (/ 4 y)) (/ x (/ y z)))
24.0ms
(/ x (/ y z))
23.0ms
(+ (/ x y) (/ 4 y))

simplify1.5s

Counts
32 → 58
Calls
32 calls:
Slowest
259.0ms
(- (* (+ (* x y) (* y 4)) (/ y z)) (* (* y y) x))
221.0ms
(- (* (- (* (/ x y) (/ x y)) (* (/ 4 y) (/ 4 y))) (/ y z)) (* (- (/ x y) (/ 4 y)) x))
178.0ms
(- (* (+ (pow (/ x y) 3) (pow (/ 4 y) 3)) (/ y z)) (* (+ (* (/ x y) (/ x y)) (- (* (/ 4 y) (/ 4 y)) (* (/ x y) (/ 4 y)))) x))
102.0ms
(* (+ (* (/ x y) (/ x y)) (- (* (/ 4 y) (/ 4 y)) (* (/ x y) (/ 4 y)))) (/ y z))
97.0ms
(/ (exp (+ (/ x y) (/ 4 y))) (exp (/ x (/ y z))))

prune594.0ms

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0b

localize16.0ms

Local error

Found 4 expressions with local error:

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

rewrite32.0ms

Algorithm
rewrite-expression-head
Rules
11×add-log-exp
*-un-lft-identity
add-cube-cbrt
frac-sub
add-sqr-sqrt
div-inv
add-exp-log
associate-*r*
pow1
un-div-inv
associate-*r/
add-cbrt-cube
associate-/r*
flip-+
frac-add
flip3-+
associate-/r/
diff-log
sum-log
inv-pow
distribute-lft-out
flip--
pow-flip
*-commutative
associate--l+
flip3--
distribute-rgt-out
frac-2neg
sub-neg
clear-num
rec-exp
+-commutative
Counts
4 → 67
Calls
4 calls:
Slowest
22.0ms
(- (+ (/ x y) (/ 4 y)) (* x (/ 1 (/ y z))))
7.0ms
(+ (/ x y) (/ 4 y))
1.0ms
(* x (/ 1 (/ y z)))
1.0ms
(/ 1 (/ y z))

series80.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
34.0ms
(- (+ (/ x y) (/ 4 y)) (* x (/ 1 (/ y z))))
22.0ms
(* x (/ 1 (/ y z)))
16.0ms
(+ (/ x y) (/ 4 y))
8.0ms
(/ 1 (/ y z))

simplify2.8s

Counts
44 → 79
Calls
44 calls:
Slowest
305.0ms
(- (* (+ (* x y) (* y 4)) (/ y z)) (* (* y y) (* x 1)))
283.0ms
(- (* (+ (pow (/ x y) 3) (pow (/ 4 y) 3)) (/ y z)) (* (+ (* (/ x y) (/ x y)) (- (* (/ 4 y) (/ 4 y)) (* (/ x y) (/ 4 y)))) x))
281.0ms
(- (* (+ (* x y) (* y 4)) (/ y z)) (* (* y y) x))
280.0ms
(- (* (- (* (/ x y) (/ x y)) (* (/ 4 y) (/ 4 y))) (/ y z)) (* (- (/ x y) (/ 4 y)) (* x 1)))
251.0ms
(- (* (+ (pow (/ x y) 3) (pow (/ 4 y) 3)) (/ y z)) (* (+ (* (/ x y) (/ x y)) (- (* (/ 4 y) (/ 4 y)) (* (/ x y) (/ 4 y)))) (* x 1)))

prune953.0ms

Pruning

4 alts after pruning (2 fresh and 2 done)

Merged error: 0b

regimes157.0ms

Accuracy

46.9% (0.9b remaining)

Error of 0.9b against oracle of 0.0b and baseline of 1.8b

bsearch276.0ms

end0.0ms

sample1.6s

Algorithm
intervals
Results
10087×(pre true 80)
10087×(body real 80)