Average Error: 29.2 → 0.0
Time: 48.5s
Precision: 64
Internal Precision: 128
\[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -6.95166373829725 \cdot 10^{+48} \lor \neg \left(x \le 126507.6676441063\right):\\ \;\;\;\;\left(\frac{-3}{x} - \frac{1}{x \cdot x}\right) + \frac{\frac{-3}{x}}{x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1 - x \cdot 3}{\left(x - 1\right) \cdot \left(1 + x\right)}\\ \end{array}\]

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if x < -6.95166373829725e+48 or 126507.6676441063 < x

    1. Initial program 59.8

      \[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
    2. Using strategy rm
    3. Applied add-cbrt-cube59.8

      \[\leadsto \color{blue}{\sqrt[3]{\left(\frac{x}{x + 1} \cdot \frac{x}{x + 1}\right) \cdot \frac{x}{x + 1}}} - \frac{x + 1}{x - 1}\]
    4. Taylor expanded around inf 0.3

      \[\leadsto \color{blue}{-\left(3 \cdot \frac{1}{{x}^{3}} + \left(\frac{1}{{x}^{2}} + 3 \cdot \frac{1}{x}\right)\right)}\]
    5. Simplified0.0

      \[\leadsto \color{blue}{\left(\frac{-3}{x} - \frac{1}{x \cdot x}\right) + \frac{\frac{-3}{x}}{x \cdot x}}\]

    if -6.95166373829725e+48 < x < 126507.6676441063

    1. Initial program 3.3

      \[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
    2. Using strategy rm
    3. Applied frac-sub3.3

      \[\leadsto \color{blue}{\frac{x \cdot \left(x - 1\right) - \left(x + 1\right) \cdot \left(x + 1\right)}{\left(x + 1\right) \cdot \left(x - 1\right)}}\]
    4. Taylor expanded around -inf 0.0

      \[\leadsto \frac{\color{blue}{-\left(3 \cdot x + 1\right)}}{\left(x + 1\right) \cdot \left(x - 1\right)}\]
    5. Simplified0.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -6.95166373829725 \cdot 10^{+48} \lor \neg \left(x \le 126507.6676441063\right):\\ \;\;\;\;\left(\frac{-3}{x} - \frac{1}{x \cdot x}\right) + \frac{\frac{-3}{x}}{x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1 - x \cdot 3}{\left(x - 1\right) \cdot \left(1 + x\right)}\\ \end{array}\]

Reproduce

herbie shell --seed 2018362 
(FPCore (x)
  :name "Asymptote C"
  (- (/ x (+ x 1)) (/ (+ x 1) (- x 1))))

Details

Time bar (total: 42.9s)Debug log

start136.0ms

Algorithm
intervals

setup26.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 23.8b

localize25.0ms

Local error

Found 3 expressions with local error:

1.6b
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
0.0b
(/ (+ x 1) (- x 1))
0.0b
(/ x (+ x 1))

rewrite19.0ms

Algorithm
rewrite-expression-head
Counts
3 → 62
Calls

3 calls. Slowest were:

11.0ms
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
6.0ms
(/ (+ x 1) (- x 1))
1.0ms
(/ x (+ x 1))

series70.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

46.0ms
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
13.0ms
(/ x (+ x 1))
11.0ms
(/ (+ x 1) (- x 1))

simplify2.1s

Counts
51 → 71
Calls

51 calls. Slowest were:

513.0ms
(- (* x (- x 1)) (* (+ x 1) (+ x 1)))
299.0ms
(/ (* (* (+ x 1) (+ x 1)) (+ x 1)) (* (* (- x 1) (- x 1)) (- x 1)))
253.0ms
(- (+ (* 3 (/ 1 (pow x 3))) (+ (/ 1 (pow x 2)) (* 3 (/ 1 x)))))

prune642.0ms

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0.0b

localize21.0ms

Local error

Found 4 expressions with local error:

23.4b
(cbrt (* (* (/ x (+ x 1)) (/ x (+ x 1))) (/ x (+ x 1))))
1.6b
(- (cbrt (* (* (/ x (+ x 1)) (/ x (+ x 1))) (/ x (+ x 1)))) (/ (+ x 1) (- x 1)))
0.1b
(* (* (/ x (+ x 1)) (/ x (+ x 1))) (/ x (+ x 1)))
0.0b
(* (/ x (+ x 1)) (/ x (+ x 1)))

rewrite37.0ms

Algorithm
rewrite-expression-head
Counts
4 → 103
Calls

4 calls. Slowest were:

12.0ms
(- (cbrt (* (* (/ x (+ x 1)) (/ x (+ x 1))) (/ x (+ x 1)))) (/ (+ x 1) (- x 1)))
11.0ms
(cbrt (* (* (/ x (+ x 1)) (/ x (+ x 1))) (/ x (+ x 1))))
8.0ms
(* (* (/ x (+ x 1)) (/ x (+ x 1))) (/ x (+ x 1)))

series100.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

52.0ms
(- (cbrt (* (* (/ x (+ x 1)) (/ x (+ x 1))) (/ x (+ x 1)))) (/ (+ x 1) (- x 1)))
19.0ms
(cbrt (* (* (/ x (+ x 1)) (/ x (+ x 1))) (/ x (+ x 1))))
16.0ms
(* (* (/ x (+ x 1)) (/ x (+ x 1))) (/ x (+ x 1)))
12.0ms
(* (/ x (+ x 1)) (/ x (+ x 1)))

simplify10.6s

Counts
93 → 115
Calls

93 calls. Slowest were:

892.0ms
(* (* (* (/ x (+ x 1)) (/ x (+ x 1))) (/ x (+ x 1))) (* (* (/ x (+ x 1)) (/ x (+ x 1))) (/ x (+ x 1))))
526.0ms
(- (* (cbrt (* (* x x) x)) (- x 1)) (* (cbrt (* (* (+ x 1) (+ x 1)) (+ x 1))) (+ x 1)))
485.0ms
(- (* (cbrt (* (* x x) (/ x (+ x 1)))) (- x 1)) (* (cbrt (* (+ x 1) (+ x 1))) (+ x 1)))

prune1.1s

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0.0b

localize33.0ms

Local error

Found 4 expressions with local error:

23.4b
(cbrt (* (* (/ x (+ x 1)) (/ x (+ x 1))) (/ x (+ x 1))))
23.4b
(cbrt (* (* (/ x (+ x 1)) (/ x (+ x 1))) (/ x (+ x 1))))
23.4b
(cbrt (* (* (/ x (+ x 1)) (/ x (+ x 1))) (/ x (+ x 1))))
23.4b
(cbrt (* (* (/ x (+ x 1)) (/ x (+ x 1))) (/ x (+ x 1))))

rewrite27.0ms

Algorithm
rewrite-expression-head
Counts
4 → 68
Calls

4 calls. Slowest were:

9.0ms
(cbrt (* (* (/ x (+ x 1)) (/ x (+ x 1))) (/ x (+ x 1))))
6.0ms
(cbrt (* (* (/ x (+ x 1)) (/ x (+ x 1))) (/ x (+ x 1))))
6.0ms
(cbrt (* (* (/ x (+ x 1)) (/ x (+ x 1))) (/ x (+ x 1))))

series86.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

24.0ms
(cbrt (* (* (/ x (+ x 1)) (/ x (+ x 1))) (/ x (+ x 1))))
22.0ms
(cbrt (* (* (/ x (+ x 1)) (/ x (+ x 1))) (/ x (+ x 1))))
22.0ms
(cbrt (* (* (/ x (+ x 1)) (/ x (+ x 1))) (/ x (+ x 1))))
18.0ms
(cbrt (* (* (/ x (+ x 1)) (/ x (+ x 1))) (/ x (+ x 1))))

simplify2.1s

Counts
44 → 80
Calls

44 calls. Slowest were:

125.0ms
(cbrt (* (* x (/ x (+ x 1))) (/ x (+ x 1))))
124.0ms
(cbrt (* (* (/ x (+ x 1)) (/ x (+ x 1))) x))
120.0ms
(cbrt (* (* (/ x (+ x 1)) x) (/ x (+ x 1))))

prune1.4s

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0.0b

localize20.0ms

Local error

Found 4 expressions with local error:

15.4b
(- (* x (- x 1)) (* (+ x 1) (+ x 1)))
0.0b
(* (+ x 1) (+ x 1))
0.0b
(/ (- (* x (- x 1)) (* (+ x 1) (+ x 1))) (* (+ x 1) (- x 1)))
0.0b
(* x (- x 1))

rewrite24.0ms

Algorithm
rewrite-expression-head
Counts
4 → 129
Calls

4 calls. Slowest were:

12.0ms
(/ (- (* x (- x 1)) (* (+ x 1) (+ x 1))) (* (+ x 1) (- x 1)))
5.0ms
(- (* x (- x 1)) (* (+ x 1) (+ x 1)))
3.0ms
(* (+ x 1) (+ x 1))

series78.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

27.0ms
(* x (- x 1))
24.0ms
(/ (- (* x (- x 1)) (* (+ x 1) (+ x 1))) (* (+ x 1) (- x 1)))
18.0ms
(- (* x (- x 1)) (* (+ x 1) (+ x 1)))
10.0ms
(* (+ x 1) (+ x 1))

simplify22.6s

Counts
125 → 141
Calls

125 calls. Slowest were:

557.0ms
(sqrt (- (* x (- x 1)) (* (+ x 1) (+ x 1))))
526.0ms
(* (- (* x x) (* 1 1)) (+ x 1))
513.0ms
(* (+ x 1) (* (+ (* x x) (- (* 1 1) (* x 1))) (+ (* x x) (- (* 1 1) (* x 1)))))

prune1.5s

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0b

regimes58.0ms

Accuracy

99.9% (0.0b remaining)

Error of 0.0b against oracle of 0.0b and baseline of 15.3b

bsearch147.0ms