Average Error: 1.6 → 0.2
Time: 8.3s
Precision: 64
Internal Precision: 128
\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
\[\begin{array}{l} \mathbf{if}\;x \le -2.25551849996464 \cdot 10^{-47} \lor \neg \left(x \le 3.1941018314886564 \cdot 10^{+37}\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 < -2.25551849996464e-47 or 3.1941018314886564e+37 < x

    1. Initial program 0.2

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

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

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

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

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

    if -2.25551849996464e-47 < x < 3.1941018314886564e+37

    1. Initial program 2.6

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -2.25551849996464 \cdot 10^{-47} \lor \neg \left(x \le 3.1941018314886564 \cdot 10^{+37}\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 2019022 +o rules:numerics
(FPCore (x y z)
  :name "fabs fraction 1"
  (fabs (- (/ (+ x 4) y) (* (/ x y) z))))

Details

Time bar (total: 7.7s)Debug log

sample60.0ms

Algorithm
intervals
Results
43.0ms328×body80valid

simplify47.0ms

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

prune19.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 1.4b

localize17.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)

rewrite12.0ms

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

series74.0ms

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

simplify1.1s

Counts
31 → 65
Calls
31 calls:
Slowest
239.0ms
(fma (+ x 4) (/ 1 y) (- (* z (/ x y))))
155.0ms
(- (* (+ x 4) y) (* y (* x z)))
92.0ms
(- (+ (/ x y) (* 4 (/ 1 y))) (/ (* x z) y))
84.0ms
(- (+ (/ x y) (* 4 (/ 1 y))) (/ (* x z) y))
78.0ms
(- (+ (/ x y) (* 4 (/ 1 y))) (/ (* x z) y))

prune619.0ms

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0b

localize18.0ms

Local error

Found 2 expressions with local error:

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

rewrite4.0ms

Algorithm
rewrite-expression-head
Rules
*-un-lft-identity
add-log-exp
fma-def
div-inv
add-cube-cbrt
add-sqr-sqrt
log1p-expm1-u
add-exp-log
add-cbrt-cube
pow1
expm1-log1p-u
distribute-lft-out
fma-udef
flip-+
frac-add
distribute-rgt-out
flip3-+
sum-log
+-commutative
Counts
2 → 30
Calls
2 calls:
Slowest
4.0ms
(+ (/ x y) (/ 4 y))
0.0ms
(fma z (- (/ x y)) (+ (/ x y) (/ 4 y)))

series64.0ms

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

simplify350.0ms

Counts
14 → 36
Calls
14 calls:
Slowest
102.0ms
(- (+ (/ x y) (* 4 (/ 1 y))) (/ (* x z) y))
101.0ms
(- (+ (/ x y) (* 4 (/ 1 y))) (/ (* x z) y))
62.0ms
(- (+ (/ x y) (* 4 (/ 1 y))) (/ (* x z) y))
17.0ms
(+ (/ x y) (* 4 (/ 1 y)))
14.0ms
(+ (* x y) (* y 4))

prune358.0ms

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0b

localize18.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
Rules
add-cube-cbrt
*-un-lft-identity
add-sqr-sqrt
add-log-exp
div-inv
prod-diff
associate-*l*
fma-neg
associate-/l*
log1p-expm1-u
add-exp-log
associate-*l/
add-cbrt-cube
pow1
expm1-log1p-u
associate-/l/
sub-div
flip--
flip-+
frac-sub
*-commutative
diff-log
flip3--
flip3-+
frac-2neg
sub-neg
clear-num
Counts
3 → 56
Calls
3 calls:
Slowest
7.0ms
(- (/ (+ 4 x) y) (* (/ z y) x))
2.0ms
(* (/ z y) x)
2.0ms
(/ (+ 4 x) y)

series67.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
36.0ms
(- (/ (+ 4 x) y) (* (/ z y) x))
17.0ms
(* (/ z y) x)
14.0ms
(/ (+ 4 x) y)

simplify1.2s

Counts
31 → 65
Calls
31 calls:
Slowest
201.0ms
(fma (+ 4 x) (/ 1 y) (- (* x (/ z y))))
171.0ms
(- (* (+ 4 x) y) (* y (* z x)))
100.0ms
(- (+ (/ x y) (* 4 (/ 1 y))) (/ (* x z) y))
93.0ms
(fma 1 (/ (+ 4 x) y) (- (* x (/ z y))))
93.0ms
(- (+ (/ x y) (* 4 (/ 1 y))) (/ (* x z) y))

prune599.0ms

Pruning

4 alts after pruning (2 fresh and 2 done)

Merged error: 0b

localize12.0ms

Local error

Found 2 expressions with local error:

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

rewrite22.0ms

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

series46.0ms

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

simplify945.0ms

Counts
20 → 45
Calls
20 calls:
Slowest
222.0ms
(- (pow (+ x 4) 3) (pow (* x z) 3))
167.0ms
(- (* (+ x 4) (+ x 4)) (* (* x z) (* x z)))
105.0ms
(- (+ (/ x y) (* 4 (/ 1 y))) (/ (* x z) y))
88.0ms
(- (+ (/ x y) (* 4 (/ 1 y))) (/ (* x z) y))
80.0ms
(- (+ (/ x y) (* 4 (/ 1 y))) (/ (* x z) y))

prune433.0ms

Pruning

4 alts after pruning (1 fresh and 3 done)

Merged error: 0b

regimes142.0ms

Accuracy

91.2% (0.1b remaining)

Error of 0.2b against oracle of 0.0b and baseline of 1.6b

bsearch72.0ms

end0.0ms

sample1.4s

Algorithm
intervals
Results
1.2s10104×body80valid