Average Error: 14.9 → 0.3
Time: 6.2s
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.9
Target0.3
Herbie0.3
\[\tan^{-1} \left(\frac{1}{1 + N \cdot \left(N + 1\right)}\right)\]

Derivation

  1. Initial program 14.9

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

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

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

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

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

Reproduce

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

sample71.0ms

Algorithm
intervals

simplify4.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
4.0ms
(- (atan (+ N 1)) (atan N))

prune5.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 16.1b

localize10.0ms

Local error

Found 2 expressions with local error:

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

rewrite5.0ms

Algorithm
rewrite-expression-head
Rules
11×*-un-lft-identity
11×add-sqr-sqrt
add-cube-cbrt
prod-diff
add-log-exp
fma-neg
log1p-expm1-u
add-exp-log
add-cbrt-cube
pow1
expm1-log1p-u
difference-of-squares
distribute-lft-out--
flip--
diff-atan
diff-log
flip3--
sub-neg
Counts
2 → 38
Calls
2 calls:
Slowest
4.0ms
(- (atan (+ N 1)) (atan N))
1.0ms
(atan (+ N 1))

series9.0ms

Counts
2 → 6
Calls
2 calls:
Slowest
7.0ms
(- (atan (+ N 1)) (atan N))
2.0ms
(atan (+ N 1))

simplify535.0ms

Counts
32 → 44
Calls
32 calls:
Slowest
42.0ms
(fma (sqrt (atan (+ N 1))) (sqrt (atan (+ N 1))) (- (* (sqrt (atan N)) (sqrt (atan N)))))
33.0ms
(fma (- (cbrt (atan N))) (* (cbrt (atan N)) (cbrt (atan N))) (* (cbrt (atan N)) (* (cbrt (atan N)) (cbrt (atan N)))))
30.0ms
(fma (- (cbrt (atan N))) (* (cbrt (atan N)) (cbrt (atan N))) (* (cbrt (atan N)) (* (cbrt (atan N)) (cbrt (atan N)))))
30.0ms
(fma 1 (atan (+ N 1)) (- (* (atan N) 1)))
28.0ms
(fma 1 (atan (+ N 1)) (- (* (cbrt (atan N)) (* (cbrt (atan N)) (cbrt (atan N))))))

prune285.0ms

Pruning

2 alts after pruning (1 fresh and 1 done)

Merged error: 0.2b

localize12.0ms

Local error

Found 2 expressions with local error:

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

rewrite1.0ms

Algorithm
rewrite-expression-head
Rules
add-log-exp
log1p-expm1-u
add-cube-cbrt
add-exp-log
add-cbrt-cube
*-un-lft-identity
pow1
expm1-log1p-u
add-sqr-sqrt
fma-udef
Counts
2 → 19
Calls
2 calls:
Slowest
0.0ms
(atan2 1 (fma N (+ N 1) 1))
0.0ms
(fma N (+ N 1) 1)

series21.0ms

Counts
2 → 6
Calls
2 calls:
Slowest
17.0ms
(fma N (+ N 1) 1)
3.0ms
(atan2 1 (fma N (+ N 1) 1))

simplify125.0ms

Counts
6 → 25
Calls
6 calls:
Slowest
30.0ms
(+ N (+ (pow N 2) 1))
20.0ms
(atan2 1 (fma N (+ N 1) 1))
20.0ms
(atan2 1 (fma N (+ N 1) 1))
19.0ms
(atan2 1 (fma N (+ N 1) 1))
19.0ms
(+ N (+ (pow N 2) 1))

prune155.0ms

Pruning

5 alts after pruning (4 fresh and 1 done)

Merged error: 0.2b

localize10.0ms

Local error

Found 4 expressions with local error:

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

rewrite13.0ms

Algorithm
rewrite-expression-head
Rules
12×sqrt-prod
12×add-sqr-sqrt
10×add-cube-cbrt
10×*-un-lft-identity
pow1
add-exp-log
associate-*l*
associate-*r*
pow1/2
add-cbrt-cube
add-log-exp
log1p-expm1-u
expm1-log1p-u
pow-prod-up
pow-prod-down
rem-sqrt-square
cbrt-unprod
*-commutative
prod-exp
sqrt-unprod
pow-plus
rem-square-sqrt
pow2
Counts
4 → 69
Calls
4 calls:
Slowest
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)))
1.0ms
(sqrt (atan2 1 (fma N (+ N 1) 1)))
0.0ms
(atan2 1 (fma N (+ N 1) 1))

series48.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
21.0ms
(sqrt (atan2 1 (fma N (+ N 1) 1)))
19.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))))
4.0ms
(atan2 1 (fma N (+ N 1) 1))

simplify786.0ms

Counts
42 → 81
Calls
42 calls:
Slowest
60.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)))))
39.0ms
(sqrt (* (cbrt (atan2 1 (fma N (+ N 1) 1))) (cbrt (atan2 1 (fma N (+ N 1) 1)))))
37.0ms
(sqrt (sqrt (atan2 1 (fma N (+ N 1) 1))))
35.0ms
(sqrt (sqrt (atan2 1 (fma N (+ N 1) 1))))
31.0ms
(cbrt (sqrt (atan2 1 (fma N (+ N 1) 1))))

prune510.0ms

Pruning

5 alts after pruning (3 fresh and 2 done)

Merged error: 0.2b

localize17.0ms

Local error

Found 4 expressions with local error:

13.3b
(cbrt (atan2 1 (fma N (+ N 1) 1)))
13.3b
(cbrt (atan2 1 (fma N (+ N 1) 1)))
13.3b
(cbrt (atan2 1 (fma N (+ N 1) 1)))
12.9b
(sqrt (atan2 1 (fma N (+ N 1) 1)))

rewrite3.0ms

Algorithm
rewrite-expression-head
Rules
add-sqr-sqrt
cbrt-prod
add-cube-cbrt
*-un-lft-identity
add-log-exp
log1p-expm1-u
add-exp-log
add-cbrt-cube
pow1
expm1-log1p-u
sqrt-prod
pow1/3
pow1/2
rem-sqrt-square
Counts
4 → 53
Calls
4 calls:
Slowest
1.0ms
(sqrt (atan2 1 (fma N (+ N 1) 1)))
1.0ms
(cbrt (atan2 1 (fma N (+ N 1) 1)))
1.0ms
(cbrt (atan2 1 (fma N (+ N 1) 1)))
1.0ms
(cbrt (atan2 1 (fma N (+ N 1) 1)))

series516.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
194.0ms
(cbrt (atan2 1 (fma N (+ N 1) 1)))
175.0ms
(cbrt (atan2 1 (fma N (+ N 1) 1)))
136.0ms
(cbrt (atan2 1 (fma N (+ N 1) 1)))
11.0ms
(sqrt (atan2 1 (fma N (+ N 1) 1)))

simplify366.0ms

Counts
25 → 65
Calls
25 calls:
Slowest
21.0ms
(cbrt (* (cbrt (atan2 1 (fma N (+ N 1) 1))) (cbrt (atan2 1 (fma N (+ N 1) 1)))))
20.0ms
(cbrt (sqrt (atan2 1 (fma N (+ N 1) 1))))
20.0ms
(cbrt (* (cbrt (atan2 1 (fma N (+ N 1) 1))) (cbrt (atan2 1 (fma N (+ N 1) 1)))))
20.0ms
(sqrt (* (cbrt (atan2 1 (fma N (+ N 1) 1))) (cbrt (atan2 1 (fma N (+ N 1) 1)))))
19.0ms
(cbrt (* (cbrt (atan2 1 (fma N (+ N 1) 1))) (cbrt (atan2 1 (fma N (+ N 1) 1)))))

prune537.0ms

Pruning

6 alts after pruning (3 fresh and 3 done)

Merged error: 0.2b

regimes33.0ms

Accuracy

0% (0.0b remaining)

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

bsearch1.0ms

end0.0ms

sample1.6s

Algorithm
intervals