Average Error: 14.4 → 0.3
Time: 8.7s
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

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

Derivation

  1. Initial program 14.4

    \[\tan^{-1} \left(N + 1\right) - \tan^{-1} N\]
  2. Initial simplification14.4

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

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

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

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

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

Reproduce

herbie shell --seed 2018360 +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.1s)Debug log

start63.0ms

Algorithm
intervals

setup23.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 13.1b

localize38.0ms

Local error

Found 2 expressions with local error:

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

rewrite9.0ms

Algorithm
rewrite-expression-head
Counts
2 → 38
Calls

2 calls. Slowest were:

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

series14.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

11.0ms
(- (atan (+ 1 N)) (atan N))
3.0ms
(atan (+ 1 N))

simplify424.0ms

Counts
32 → 44
Calls

32 calls. Slowest were:

39.0ms
(fma (sqrt (atan (+ 1 N))) (sqrt (atan (+ 1 N))) (- (* (sqrt (atan N)) (sqrt (atan N)))))
33.0ms
(fma (* (cbrt (atan (+ 1 N))) (cbrt (atan (+ 1 N)))) (cbrt (atan (+ 1 N))) (- (* (atan N) 1)))
31.0ms
(fma (- (cbrt (atan N))) (* (cbrt (atan N)) (cbrt (atan N))) (* (cbrt (atan N)) (* (cbrt (atan N)) (cbrt (atan N)))))

prune449.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 0.3b

localize22.0ms

Local error

Found 1 expressions with local error:

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

rewrite1.0ms

Algorithm
rewrite-expression-head
Counts
1 → 9
Calls

1 calls. Slowest were:

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

series4.0ms

Counts
1 → 3
Calls

1 calls. Slowest were:

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

simplify65.0ms

Counts
3 → 12
Calls

3 calls. Slowest were:

22.0ms
(atan2 1 (fma N (+ N 1) 1))
22.0ms
(atan2 1 (fma N (+ N 1) 1))
21.0ms
(atan2 1 (fma N (+ N 1) 1))

prune156.0ms

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0.3b

localize15.0ms

Local error

Found 4 expressions with local error:

14.6b
(sqrt (atan2 1 (fma N (+ N 1) 1)))
14.6b
(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.3b
(atan2 1 (fma N (+ N 1) 1))

rewrite14.0ms

Algorithm
rewrite-expression-head
Counts
4 → 69
Calls

4 calls. Slowest were:

9.0ms
(* (sqrt (atan2 1 (fma N (+ N 1) 1))) (sqrt (atan2 1 (fma N (+ N 1) 1))))
2.0ms
(sqrt (atan2 1 (fma N (+ N 1) 1)))
2.0ms
(sqrt (atan2 1 (fma N (+ N 1) 1)))

series45.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

19.0ms
(sqrt (atan2 1 (fma N (+ N 1) 1)))
18.0ms
(sqrt (atan2 1 (fma N (+ N 1) 1)))
4.0ms
(* (sqrt (atan2 1 (fma N (+ N 1) 1))) (sqrt (atan2 1 (fma N (+ N 1) 1))))
3.0ms
(atan2 1 (fma N (+ N 1) 1))

simplify759.0ms

Counts
42 → 81
Calls

42 calls. Slowest were:

40.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)))))
33.0ms
(sqrt (* (cbrt (atan2 1 (fma N (+ N 1) 1))) (cbrt (atan2 1 (fma N (+ N 1) 1)))))
31.0ms
(sqrt (sqrt (atan2 1 (fma N (+ N 1) 1))))

prune898.0ms

Pruning

6 alts after pruning (5 fresh and 1 done)

Merged error: 0.3b

localize17.0ms

Local error

Found 4 expressions with local error:

14.6b
(sqrt (atan2 1 (fma N (+ N 1) 1)))
14.6b
(sqrt (atan2 1 (fma N (+ N 1) 1)))
14.6b
(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))))

rewrite25.0ms

Algorithm
rewrite-expression-head
Counts
4 → 69
Calls

4 calls. Slowest were:

20.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))))
2.0ms
(sqrt (atan2 1 (fma N (+ N 1) 1)))
2.0ms
(sqrt (atan2 1 (fma N (+ N 1) 1)))

series40.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

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

simplify1.1s

Counts
42 → 81
Calls

42 calls. Slowest were:

124.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)))))
86.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)))))
41.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))))

prune917.0ms

Pruning

7 alts after pruning (5 fresh and 2 done)

Merged error: 0.2b

regimes54.0ms

Accuracy

0% (0.0b remaining)

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

bsearch1.0ms