Average Error: 15.3 → 0.4
Time: 5.9s
Precision: 64
Internal Precision: 128
\[\tan^{-1} \left(N + 1\right) - \tan^{-1} N\]
\[\tan^{-1}_* \frac{1}{(N \cdot \left(N + 1\right) + 1)_*}\]

Error

Bits error versus N

Target

Original15.3
Target0.4
Herbie0.4
\[\tan^{-1} \left(\frac{1}{1 + N \cdot \left(N + 1\right)}\right)\]

Derivation

  1. Initial program 15.3

    \[\tan^{-1} \left(N + 1\right) - \tan^{-1} N\]
  2. Using strategy rm
  3. Applied diff-atan14.2

    \[\leadsto \color{blue}{\tan^{-1}_* \frac{\left(N + 1\right) - N}{1 + \left(N + 1\right) \cdot N}}\]
  4. Simplified0.4

    \[\leadsto \tan^{-1}_* \frac{\color{blue}{1}}{1 + \left(N + 1\right) \cdot N}\]
  5. Simplified0.4

    \[\leadsto \tan^{-1}_* \frac{1}{\color{blue}{(N \cdot \left(N + 1\right) + 1)_*}}\]
  6. Final simplification0.4

    \[\leadsto \tan^{-1}_* \frac{1}{(N \cdot \left(N + 1\right) + 1)_*}\]

Reproduce

herbie shell --seed 2019005 +o rules:numerics
(FPCore (N)
  :name "2atan (example 3.5)"

  :herbie-target
  (atan (/ 1 (+ 1 (* N (+ N 1)))))

  (- (atan (+ N 1)) (atan N)))

Details

Time bar (total: 5.4s)Debug log

sample52.0ms

Algorithm
intervals

simplify8.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

8.0ms
(- (atan (+ N 1)) (atan N))

prune9.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 14.9b

localize22.0ms

Local error

Found 2 expressions with local error:

1.2b
(- (atan (+ N 1)) (atan N))
0.0b
(atan (+ N 1))

rewrite9.0ms

Algorithm
rewrite-expression-head
Counts
2 → 38
Calls

2 calls. Slowest were:

7.0ms
(- (atan (+ N 1)) (atan N))
1.0ms
(atan (+ N 1))

series12.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

10.0ms
(- (atan (+ N 1)) (atan N))
2.0ms
(atan (+ N 1))

simplify467.0ms

Counts
32 → 44
Calls

32 calls. Slowest were:

34.0ms
(fma 1 (atan (+ N 1)) (- (* (atan N) 1)))
30.0ms
(fma (- (cbrt (atan N))) (* (cbrt (atan N)) (cbrt (atan N))) (* (cbrt (atan N)) (* (cbrt (atan N)) (cbrt (atan N)))))
29.0ms
(fma (- (cbrt (atan N))) (* (cbrt (atan N)) (cbrt (atan N))) (* (cbrt (atan N)) (* (cbrt (atan N)) (cbrt (atan N)))))

prune304.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 0.2b

localize7.0ms

Local error

Found 1 expressions with local error:

0.2b
(atan2 1 (fma N (+ N 1) 1))

rewrite0.0ms

Algorithm
rewrite-expression-head
Counts
1 → 9
Calls

1 calls. Slowest were:

0.0ms
(atan2 1 (fma N (+ N 1) 1))

series2.0ms

Counts
1 → 3
Calls

1 calls. Slowest were:

2.0ms
(atan2 1 (fma N (+ N 1) 1))

simplify36.0ms

Counts
3 → 12
Calls

3 calls. Slowest were:

12.0ms
(atan2 1 (fma N (+ N 1) 1))
12.0ms
(atan2 1 (fma N (+ N 1) 1))
10.0ms
(atan2 1 (fma N (+ N 1) 1))

prune100.0ms

Pruning

5 alts after pruning (4 fresh and 1 done)

Merged error: 0.2b

localize6.0ms

Local error

Found 4 expressions with local error:

14.5b
(sqrt (atan2 1 (fma N (+ N 1) 1)))
14.5b
(sqrt (atan2 1 (fma N (+ N 1) 1)))
0.6b
(* (sqrt (atan2 1 (fma N (+ N 1) 1))) (sqrt (atan2 1 (fma N (+ N 1) 1))))
0.2b
(atan2 1 (fma N (+ N 1) 1))

rewrite7.0ms

Algorithm
rewrite-expression-head
Counts
4 → 69
Calls

4 calls. Slowest were:

5.0ms
(* (sqrt (atan2 1 (fma N (+ N 1) 1))) (sqrt (atan2 1 (fma N (+ N 1) 1))))
1.0ms
(sqrt (atan2 1 (fma N (+ N 1) 1)))
1.0ms
(sqrt (atan2 1 (fma N (+ N 1) 1)))

series27.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

12.0ms
(sqrt (atan2 1 (fma N (+ N 1) 1)))
11.0ms
(sqrt (atan2 1 (fma N (+ N 1) 1)))
2.0ms
(* (sqrt (atan2 1 (fma N (+ N 1) 1))) (sqrt (atan2 1 (fma N (+ N 1) 1))))
2.0ms
(atan2 1 (fma N (+ N 1) 1))

simplify760.0ms

Counts
42 → 81
Calls

42 calls. Slowest were:

48.0ms
(* (* (* (sqrt (atan2 1 (fma N (+ N 1) 1))) (sqrt (atan2 1 (fma N (+ N 1) 1)))) (sqrt (atan2 1 (fma N (+ N 1) 1)))) (* (* (sqrt (atan2 1 (fma N (+ N 1) 1))) (sqrt (atan2 1 (fma N (+ N 1) 1)))) (sqrt (atan2 1 (fma N (+ N 1) 1)))))
34.0ms
(sqrt (* (cbrt (atan2 1 (fma N (+ N 1) 1))) (cbrt (atan2 1 (fma N (+ N 1) 1)))))
33.0ms
(sqrt (cbrt (atan2 1 (fma N (+ N 1) 1))))

prune544.0ms

Pruning

6 alts after pruning (5 fresh and 1 done)

Merged error: 0.1b

localize9.0ms

Local error

Found 4 expressions with local error:

14.5b
(sqrt (atan2 1 (fma N (+ N 1) 1)))
14.5b
(sqrt (atan2 1 (fma N (+ N 1) 1)))
14.5b
(sqrt (atan2 1 (fma N (+ N 1) 1)))
0.6b
(* (* (sqrt (sqrt (atan2 1 (fma N (+ N 1) 1)))) (sqrt (sqrt (atan2 1 (fma N (+ N 1) 1))))) (sqrt (atan2 1 (fma N (+ N 1) 1))))

rewrite21.0ms

Algorithm
rewrite-expression-head
Counts
4 → 69
Calls

4 calls. Slowest were:

15.0ms
(* (* (sqrt (sqrt (atan2 1 (fma N (+ N 1) 1)))) (sqrt (sqrt (atan2 1 (fma N (+ N 1) 1))))) (sqrt (atan2 1 (fma N (+ N 1) 1))))
4.0ms
(sqrt (atan2 1 (fma N (+ N 1) 1)))
1.0ms
(sqrt (atan2 1 (fma N (+ N 1) 1)))

series35.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

11.0ms
(sqrt (atan2 1 (fma N (+ N 1) 1)))
11.0ms
(sqrt (atan2 1 (fma N (+ N 1) 1)))
10.0ms
(sqrt (atan2 1 (fma N (+ N 1) 1)))
3.0ms
(* (* (sqrt (sqrt (atan2 1 (fma N (+ N 1) 1)))) (sqrt (sqrt (atan2 1 (fma N (+ N 1) 1))))) (sqrt (atan2 1 (fma N (+ N 1) 1))))

simplify811.0ms

Counts
42 → 81
Calls

42 calls. Slowest were:

88.0ms
(* (* (* (* (sqrt (sqrt (atan2 1 (fma N (+ N 1) 1)))) (sqrt (sqrt (atan2 1 (fma N (+ N 1) 1))))) (* (sqrt (sqrt (atan2 1 (fma N (+ N 1) 1)))) (sqrt (sqrt (atan2 1 (fma N (+ N 1) 1)))))) (* (sqrt (sqrt (atan2 1 (fma N (+ N 1) 1)))) (sqrt (sqrt (atan2 1 (fma N (+ N 1) 1)))))) (* (* (sqrt (atan2 1 (fma N (+ N 1) 1))) (sqrt (atan2 1 (fma N (+ N 1) 1)))) (sqrt (atan2 1 (fma N (+ N 1) 1)))))
79.0ms
(* (* (* (* (sqrt (sqrt (atan2 1 (fma N (+ N 1) 1)))) (sqrt (sqrt (atan2 1 (fma N (+ N 1) 1))))) (sqrt (sqrt (atan2 1 (fma N (+ N 1) 1))))) (* (* (sqrt (sqrt (atan2 1 (fma N (+ N 1) 1)))) (sqrt (sqrt (atan2 1 (fma N (+ N 1) 1))))) (sqrt (sqrt (atan2 1 (fma N (+ N 1) 1)))))) (* (* (sqrt (atan2 1 (fma N (+ N 1) 1))) (sqrt (atan2 1 (fma N (+ N 1) 1)))) (sqrt (atan2 1 (fma N (+ N 1) 1)))))
27.0ms
(+ (log (* (sqrt (sqrt (atan2 1 (fma N (+ N 1) 1)))) (sqrt (sqrt (atan2 1 (fma N (+ N 1) 1)))))) (log (sqrt (atan2 1 (fma N (+ N 1) 1)))))

prune568.0ms

Pruning

6 alts after pruning (5 fresh and 1 done)

Merged error: 0.1b

regimes33.0ms

Accuracy

0% (0.0b remaining)

Error of 0.4b against oracle of 0.4b and baseline of 0.4b

bsearch1.0ms

end0.0ms

sample1.5s

Algorithm
intervals