Average Error: 1.6 → 0.3
Time: 10.8s
Precision: 64
Internal Precision: 128
\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
\[\begin{array}{l} \mathbf{if}\;x \le -5.814787734796508 \cdot 10^{+16}:\\ \;\;\;\;\left|\left(\frac{4}{y} + \frac{x}{y}\right) - \frac{1}{\frac{y}{z}} \cdot x\right|\\ \mathbf{elif}\;x \le 1.0751271218473741 \cdot 10^{-90}:\\ \;\;\;\;\left|\frac{\left(4 + x\right) - z \cdot x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\left(\frac{4}{y} + \frac{x}{y}\right) - \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 < -5.814787734796508e+16

    1. Initial program 0.1

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

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

      \[\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.2

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

    if -5.814787734796508e+16 < x < 1.0751271218473741e-90

    1. Initial program 2.7

      \[\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.0751271218473741e-90 < x

    1. Initial program 0.6

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

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

      \[\leadsto \left|\color{blue}{\left(\frac{x}{y} + \frac{4}{y}\right) - \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 -5.814787734796508 \cdot 10^{+16}:\\ \;\;\;\;\left|\left(\frac{4}{y} + \frac{x}{y}\right) - \frac{1}{\frac{y}{z}} \cdot x\right|\\ \mathbf{elif}\;x \le 1.0751271218473741 \cdot 10^{-90}:\\ \;\;\;\;\left|\frac{\left(4 + x\right) - z \cdot x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\left(\frac{4}{y} + \frac{x}{y}\right) - \frac{x}{\frac{y}{z}}\right|\\ \end{array}\]

Reproduce

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

Details

Time bar (total: 10.2s)Debug log

sample58.0ms

Algorithm
intervals
Results
42.0ms328×body80valid

simplify44.0ms

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

prune6.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 1.4b

localize26.0ms

Local error

Found 3 expressions with local error:

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

rewrite20.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
11.0ms
(- (/ (+ x 4) y) (* (/ x y) z))
4.0ms
(/ (+ x 4) y)
4.0ms
(* (/ x y) z)

series70.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
29.0ms
(- (/ (+ x 4) y) (* (/ x y) z))
22.0ms
(/ (+ x 4) y)
18.0ms
(* (/ x y) z)

simplify503.0ms

Counts
20 → 51
Calls
20 calls:
Slowest
95.0ms
(- (* (+ x 4) y) (* y (* x z)))
78.0ms
(- (+ (/ x y) (* 4 (/ 1 y))) (/ (* x z) y))
78.0ms
(- (+ (/ x y) (* 4 (/ 1 y))) (/ (* x z) y))
78.0ms
(- (+ (/ x y) (* 4 (/ 1 y))) (/ (* x z) y))
60.0ms
(/ (exp (/ (+ x 4) y)) (exp (* (/ x y) z)))

prune914.0ms

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0b

localize30.0ms

Local error

Found 3 expressions with local error:

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

rewrite44.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
36.0ms
(- (+ (/ x y) (/ 4 y)) (/ x (/ y z)))
6.0ms
(+ (/ x y) (/ 4 y))
1.0ms
(/ x (/ y z))

series76.0ms

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

simplify1.5s

Counts
32 → 58
Calls
32 calls:
Slowest
333.0ms
(- (* (+ (* x y) (* y 4)) (/ y z)) (* (* y y) x))
228.0ms
(- (* (+ (pow (/ x y) 3) (pow (/ 4 y) 3)) (/ y z)) (* (+ (* (/ x y) (/ x y)) (- (* (/ 4 y) (/ 4 y)) (* (/ x y) (/ 4 y)))) x))
195.0ms
(- (* (- (* (/ x y) (/ x y)) (* (/ 4 y) (/ 4 y))) (/ y z)) (* (- (/ x y) (/ 4 y)) x))
98.0ms
(/ (exp (+ (/ x y) (/ 4 y))) (exp (/ x (/ y z))))
95.0ms
(* (+ (* (/ x y) (/ x y)) (- (* (/ 4 y) (/ 4 y)) (* (/ x y) (/ 4 y)))) (/ y z))

prune593.0ms

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0b

localize21.0ms

Local error

Found 4 expressions with local error:

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

rewrite37.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
29.0ms
(- (+ (/ x y) (/ 4 y)) (* x (/ 1 (/ y z))))
3.0ms
(+ (/ x y) (/ 4 y))
2.0ms
(* x (/ 1 (/ y z)))
1.0ms
(/ 1 (/ y z))

series86.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
42.0ms
(- (+ (/ x y) (/ 4 y)) (* x (/ 1 (/ y z))))
23.0ms
(+ (/ x y) (/ 4 y))
15.0ms
(* x (/ 1 (/ y z)))
6.0ms
(/ 1 (/ y z))

simplify2.5s

Counts
44 → 79
Calls
44 calls:
Slowest
323.0ms
(- (* (+ (* x y) (* y 4)) (/ y z)) (* (* y y) (* x 1)))
293.0ms
(- (* (+ (* x y) (* y 4)) (/ y z)) (* (* y y) x))
250.0ms
(- (* (+ (pow (/ x y) 3) (pow (/ 4 y) 3)) (/ y z)) (* (+ (* (/ x y) (/ x y)) (- (* (/ 4 y) (/ 4 y)) (* (/ x y) (/ 4 y)))) x))
237.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)))
195.0ms
(/ (exp (+ (/ x y) (/ 4 y))) (exp (* x (/ 1 (/ y z)))))

prune797.0ms

Pruning

4 alts after pruning (2 fresh and 2 done)

Merged error: 0b

localize19.0ms

Local error

Found 2 expressions with local error:

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

rewrite20.0ms

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

series65.0ms

Counts
2 → 6
Calls
2 calls:
Slowest
42.0ms
(/ (- (+ x 4) (* x z)) y)
23.0ms
(- (+ x 4) (* x z))

simplify569.0ms

Counts
12 → 35
Calls
12 calls:
Slowest
157.0ms
(- (pow (+ x 4) 3) (pow (* x z) 3))
139.0ms
(- (* (+ x 4) (+ x 4)) (* (* x z) (* x z)))
56.0ms
(- (+ (/ x y) (* 4 (/ 1 y))) (/ (* x z) y))
52.0ms
(- (+ (/ x y) (* 4 (/ 1 y))) (/ (* x z) y))
42.0ms
(- (+ (/ x y) (* 4 (/ 1 y))) (/ (* x z) y))

prune310.0ms

Pruning

4 alts after pruning (1 fresh and 3 done)

Merged error: 0b

regimes286.0ms

Accuracy

91.3% (0.2b remaining)

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

bsearch127.0ms

end0.0ms

sample1.5s

Algorithm
intervals
Results
1.3s10104×body80valid