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

Error

Bits error versus N

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 14.7

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

    \[\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. Final simplification0.3

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

Reproduce

herbie shell --seed 2019018 
(FPCore (N)
  :name "2atan (example 3.5)"

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

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

Details

Time bar (total: 7.0s)Debug log

sample64.0ms

Algorithm
intervals
Results
31.0ms81×body1280valid
10.0ms122×body80valid
10.0ms32×body640valid
3.0ms12×body320valid
2.0msbody160valid

simplify8.0ms

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

prune9.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 18.9b

localize22.0ms

Local error

Found 2 expressions with local error:

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

rewrite8.0ms

Algorithm
rewrite-expression-head
Rules
add-log-exp
*-un-lft-identity
add-sqr-sqrt
add-cube-cbrt
add-exp-log
add-cbrt-cube
pow1
difference-of-squares
distribute-lft-out--
flip--
diff-atan
diff-log
flip3--
sub-neg
Counts
2 → 22
Calls
2 calls:
Slowest
7.0ms
(- (atan (+ N 1)) (atan N))
1.0ms
(atan (+ N 1))

series29.0ms

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

simplify96.0ms

Counts
12 → 28
Calls
12 calls:
Slowest
17.0ms
(+ 1 (* (+ N 1) N))
13.0ms
(/ (exp (atan (+ N 1))) (exp (atan N)))
9.0ms
(- (sqrt (atan (+ N 1))) (sqrt (atan N)))
8.0ms
(- (atan (+ N 1)) (atan N))
8.0ms
(- (atan (+ N 1)) (atan N))

prune234.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 0.2b

localize8.0ms

Local error

Found 2 expressions with local error:

0.2b
(atan2 1 (+ 1 (* (+ N 1) N)))
0.0b
(+ 1 (* (+ N 1) N))

rewrite1.0ms

Algorithm
rewrite-expression-head
Rules
add-log-exp
add-cube-cbrt
add-exp-log
add-cbrt-cube
*-un-lft-identity
pow1
add-sqr-sqrt
flip-+
flip3-+
+-commutative
Counts
2 → 17
Calls
2 calls:
Slowest
1.0ms
(+ 1 (* (+ N 1) N))
0.0ms
(atan2 1 (+ 1 (* (+ N 1) N)))

series10.0ms

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

simplify145.0ms

Counts
6 → 23
Calls
6 calls:
Slowest
28.0ms
(atan2 1 (+ N (+ (pow N 2) 1)))
26.0ms
(atan2 1 (+ N (+ (pow N 2) 1)))
23.0ms
(+ N (+ (pow N 2) 1))
23.0ms
(+ N (+ (pow N 2) 1))
23.0ms
(atan2 1 (+ N (+ (pow N 2) 1)))

prune141.0ms

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0.2b

localize7.0ms

Local error

Found 4 expressions with local error:

12.6b
(sqrt (atan2 1 (+ 1 (* (+ N 1) N))))
12.6b
(sqrt (atan2 1 (+ 1 (* (+ N 1) N))))
0.6b
(* (sqrt (atan2 1 (+ 1 (* (+ N 1) N)))) (sqrt (atan2 1 (+ 1 (* (+ N 1) N)))))
0.2b
(atan2 1 (+ 1 (* (+ N 1) N)))

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
pow-prod-up
pow-prod-down
rem-sqrt-square
cbrt-unprod
*-commutative
prod-exp
sqrt-unprod
pow-plus
rem-square-sqrt
pow2
Counts
4 → 61
Calls
4 calls:
Slowest
9.0ms
(* (sqrt (atan2 1 (+ 1 (* (+ N 1) N)))) (sqrt (atan2 1 (+ 1 (* (+ N 1) N)))))
1.0ms
(sqrt (atan2 1 (+ 1 (* (+ N 1) N))))
1.0ms
(sqrt (atan2 1 (+ 1 (* (+ N 1) N))))
0.0ms
(atan2 1 (+ 1 (* (+ N 1) N)))

series52.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
22.0ms
(sqrt (atan2 1 (+ 1 (* (+ N 1) N))))
20.0ms
(sqrt (atan2 1 (+ 1 (* (+ N 1) N))))
5.0ms
(* (sqrt (atan2 1 (+ 1 (* (+ N 1) N)))) (sqrt (atan2 1 (+ 1 (* (+ N 1) N)))))
4.0ms
(atan2 1 (+ 1 (* (+ N 1) N)))

simplify1.1s

Counts
42 → 73
Calls
42 calls:
Slowest
44.0ms
(* (cbrt (sqrt (atan2 1 (+ 1 (* (+ N 1) N))))) (cbrt (sqrt (atan2 1 (+ 1 (* (+ N 1) N))))))
44.0ms
(sqrt (* (cbrt (atan2 1 (+ 1 (* (+ N 1) N)))) (cbrt (atan2 1 (+ 1 (* (+ N 1) N))))))
44.0ms
(sqrt (sqrt (atan2 1 (+ 1 (* (+ N 1) N)))))
42.0ms
(sqrt (sqrt (atan2 1 (+ 1 (* (+ N 1) N)))))
42.0ms
(sqrt (sqrt (atan2 1 (+ 1 (* (+ N 1) N)))))

prune723.0ms

Pruning

6 alts after pruning (4 fresh and 2 done)

Merged error: 0.1b

localize20.0ms

Local error

Found 4 expressions with local error:

12.6b
(sqrt (atan2 1 (+ 1 (* (+ N 1) N))))
12.6b
(sqrt (atan2 1 (+ 1 (* (+ N 1) N))))
12.6b
(sqrt (atan2 1 (+ 1 (* (+ N 1) N))))
0.6b
(* (sqrt (atan2 1 (+ 1 (* (+ N 1) N)))) (* (sqrt (sqrt (atan2 1 (+ 1 (* (+ N 1) N))))) (sqrt (sqrt (atan2 1 (+ 1 (* (+ N 1) N)))))))

rewrite34.0ms

Algorithm
rewrite-expression-head
Rules
12×sqrt-prod
12×add-sqr-sqrt
10×pow1
add-cube-cbrt
add-exp-log
add-cbrt-cube
*-un-lft-identity
pow1/2
associate-*l*
pow-prod-down
add-log-exp
cbrt-unprod
prod-exp
rem-sqrt-square
pow-prod-up
sqrt-unprod
*-commutative
associate-*r*
Counts
4 → 60
Calls
4 calls:
Slowest
29.0ms
(* (sqrt (atan2 1 (+ 1 (* (+ N 1) N)))) (* (sqrt (sqrt (atan2 1 (+ 1 (* (+ N 1) N))))) (sqrt (sqrt (atan2 1 (+ 1 (* (+ N 1) N)))))))
1.0ms
(sqrt (atan2 1 (+ 1 (* (+ N 1) N))))
1.0ms
(sqrt (atan2 1 (+ 1 (* (+ N 1) N))))
1.0ms
(sqrt (atan2 1 (+ 1 (* (+ N 1) N))))

series67.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
21.0ms
(sqrt (atan2 1 (+ 1 (* (+ N 1) N))))
21.0ms
(sqrt (atan2 1 (+ 1 (* (+ N 1) N))))
19.0ms
(sqrt (atan2 1 (+ 1 (* (+ N 1) N))))
5.0ms
(* (sqrt (atan2 1 (+ 1 (* (+ N 1) N)))) (* (sqrt (sqrt (atan2 1 (+ 1 (* (+ N 1) N))))) (sqrt (sqrt (atan2 1 (+ 1 (* (+ N 1) N)))))))

simplify1.5s

Counts
40 → 72
Calls
40 calls:
Slowest
168.0ms
(* (* (* (sqrt (atan2 1 (+ 1 (* (+ N 1) N)))) (sqrt (atan2 1 (+ 1 (* (+ N 1) N))))) (sqrt (atan2 1 (+ 1 (* (+ N 1) N))))) (* (* (* (sqrt (sqrt (atan2 1 (+ 1 (* (+ N 1) N))))) (sqrt (sqrt (atan2 1 (+ 1 (* (+ N 1) N)))))) (* (sqrt (sqrt (atan2 1 (+ 1 (* (+ N 1) N))))) (sqrt (sqrt (atan2 1 (+ 1 (* (+ N 1) N))))))) (* (sqrt (sqrt (atan2 1 (+ 1 (* (+ N 1) N))))) (sqrt (sqrt (atan2 1 (+ 1 (* (+ N 1) N))))))))
162.0ms
(* (* (* (sqrt (atan2 1 (+ 1 (* (+ N 1) N)))) (sqrt (atan2 1 (+ 1 (* (+ N 1) N))))) (sqrt (atan2 1 (+ 1 (* (+ N 1) N))))) (* (* (* (sqrt (sqrt (atan2 1 (+ 1 (* (+ N 1) N))))) (sqrt (sqrt (atan2 1 (+ 1 (* (+ N 1) N)))))) (sqrt (sqrt (atan2 1 (+ 1 (* (+ N 1) N)))))) (* (* (sqrt (sqrt (atan2 1 (+ 1 (* (+ N 1) N))))) (sqrt (sqrt (atan2 1 (+ 1 (* (+ N 1) N)))))) (sqrt (sqrt (atan2 1 (+ 1 (* (+ N 1) N))))))))
55.0ms
(+ (log (sqrt (atan2 1 (+ 1 (* (+ N 1) N))))) (log (* (sqrt (sqrt (atan2 1 (+ 1 (* (+ N 1) N))))) (sqrt (sqrt (atan2 1 (+ 1 (* (+ N 1) N))))))))
54.0ms
(+ (log (sqrt (atan2 1 (+ 1 (* (+ N 1) N))))) (+ (log (sqrt (sqrt (atan2 1 (+ 1 (* (+ N 1) N)))))) (log (sqrt (sqrt (atan2 1 (+ 1 (* (+ N 1) N))))))))
54.0ms
(* (sqrt (atan2 1 (+ 1 (* (+ N 1) N)))) (* (sqrt (sqrt (atan2 1 (+ 1 (* (+ N 1) N))))) (sqrt (sqrt (atan2 1 (+ 1 (* (+ N 1) N)))))))

prune788.0ms

Pruning

7 alts after pruning (4 fresh and 3 done)

Merged error: 0.1b

regimes54.0ms

Accuracy

0% (0.0b remaining)

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

bsearch1.0ms

end0.0ms

sample2.0s

Algorithm
intervals
Results
1.4s2786×body1280valid
242.0ms4114×body80valid
178.0ms602×body640valid
64.0ms166×body160valid
58.0ms332×body320valid