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

Derivation

  1. Initial program 14.8

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

    \[\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 2019016 +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: 6.1s)Debug log

sample54.0ms

Algorithm
intervals
Results
256×(pre true 80)
129×(body real 80)
93×(body real 1280)
16×(body real 640)
10×(body real 320)
(body real 160)

simplify7.0ms

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

prune8.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 15.3b

localize19.0ms

Local error

Found 1 expressions with local error:

1.8b
(- (atan (+ N 1)) (atan N))

rewrite8.0ms

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

series11.0ms

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

simplify379.0ms

Counts
29 → 32
Calls
29 calls:
Slowest
35.0ms
(fma (- (cbrt (atan N))) (* (cbrt (atan N)) (cbrt (atan N))) (* (cbrt (atan N)) (* (cbrt (atan N)) (cbrt (atan N)))))
28.0ms
(+ 1 (* (+ N 1) N))
25.0ms
(fma (* (cbrt (atan (+ N 1))) (cbrt (atan (+ N 1)))) (cbrt (atan (+ N 1))) (- (* (cbrt (atan N)) (* (cbrt (atan N)) (cbrt (atan N))))))
24.0ms
(fma (- (cbrt (atan N))) (* (cbrt (atan N)) (cbrt (atan N))) (* (cbrt (atan N)) (* (cbrt (atan N)) (cbrt (atan N)))))
24.0ms
(fma (- (cbrt (atan N))) (* (cbrt (atan N)) (cbrt (atan N))) (* (cbrt (atan N)) (* (cbrt (atan N)) (cbrt (atan N)))))

prune229.0ms

Pruning

2 alts after pruning (1 fresh and 1 done)

Merged error: 0.1b

localize7.0ms

Local error

Found 1 expressions with local error:

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

rewrite0.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
Counts
1 → 9
Calls
1 calls:
Slowest
0.0ms
(atan2 1 (fma N (+ N 1) 1))

series2.0ms

Counts
1 → 3
Calls
1 calls:
Slowest
2.0ms
(atan2 1 (fma N (+ N 1) 1))

simplify36.0ms

Counts
3 → 12
Calls
3 calls:
Slowest
14.0ms
(atan2 1 (fma N (+ N 1) 1))
11.0ms
(atan2 1 (fma N (+ N 1) 1))
10.0ms
(atan2 1 (fma N (+ N 1) 1))

prune112.0ms

Pruning

4 alts after pruning (2 fresh and 2 done)

Merged error: 0.0b

localize11.0ms

Local error

Found 4 expressions with local error:

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

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

series43.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
18.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))

simplify653.0ms

Counts
42 → 81
Calls
42 calls:
Slowest
37.0ms
(sqrt (* (cbrt (atan2 1 (fma N (+ N 1) 1))) (cbrt (atan2 1 (fma N (+ N 1) 1)))))
31.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)))))
29.0ms
(sqrt (sqrt (atan2 1 (fma N (+ N 1) 1))))
28.0ms
(sqrt (atan2 1 (fma N (+ N 1) 1)))
26.0ms
(sqrt (sqrt (atan2 1 (fma N (+ N 1) 1))))

prune672.0ms

Pruning

6 alts after pruning (3 fresh and 3 done)

Merged error: 0.0b

localize9.0ms

Local error

Found 4 expressions with local error:

14.9b
(sqrt (atan2 1 (fma N (+ N 1) 1)))
14.9b
(sqrt (atan2 1 (fma N (+ N 1) 1)))
14.9b
(sqrt (atan2 1 (fma N (+ N 1) 1)))
0.1b
(* (sqrt (sqrt (atan2 1 (fma N (+ N 1) 1)))) (sqrt (atan2 1 (fma N (+ N 1) 1))))

rewrite13.0ms

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

series196.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
161.0ms
(* (sqrt (sqrt (atan2 1 (fma N (+ N 1) 1)))) (sqrt (atan2 1 (fma N (+ N 1) 1))))
12.0ms
(sqrt (atan2 1 (fma N (+ N 1) 1)))
11.0ms
(sqrt (atan2 1 (fma N (+ N 1) 1)))
11.0ms
(sqrt (atan2 1 (fma N (+ N 1) 1)))

simplify1.0s

Counts
46 → 88
Calls
46 calls:
Slowest
70.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 (atan2 1 (fma N (+ N 1) 1))) (sqrt (atan2 1 (fma N (+ N 1) 1)))) (sqrt (atan2 1 (fma N (+ N 1) 1)))))
38.0ms
(sqrt (sqrt (atan2 1 (fma N (+ N 1) 1))))
36.0ms
(sqrt (* (cbrt (atan2 1 (fma N (+ N 1) 1))) (cbrt (atan2 1 (fma N (+ N 1) 1)))))
34.0ms
(pow (pow (atan2 1 (fma N (+ N 1) 1)) 3) 1/4)
32.0ms
(sqrt (atan2 1 (fma N (+ N 1) 1)))

prune741.0ms

Pruning

7 alts after pruning (3 fresh and 4 done)

Merged error: 0.0b

regimes69.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.8s

Algorithm
intervals
Results
8000×(pre true 80)
4032×(body real 80)
2874×(body real 1280)
631×(body real 640)
297×(body real 320)
166×(body real 160)