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

Error

Bits error versus N

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 15.6

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

    \[\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. Taylor expanded around 0 0.4

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

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

Reproduce

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

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

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

Details

Time bar (total: 8.5s)Debug log

sample94.0ms

Algorithm
intervals
Results
87×48.0ms(body real 1280)
138×15.0ms(body real 80)
19×9.0ms(body real 640)
256×6.0ms(pre true 80)
3.0ms(body real 320)
1.0ms(body real 160)

simplify8.0ms

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

prune12.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 12.4b

localize30.0ms

Local error

Found 2 expressions with local error:

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

rewrite10.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
8.0ms
(- (atan (+ N 1)) (atan N))
1.0ms
(atan (+ N 1))

series30.0ms

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

simplify148.0ms

Counts
12 → 28
Calls
12 calls:
Slowest
40.0ms
(+ 1 (* (+ N 1) N))
28.0ms
(/ (exp (atan (+ N 1))) (exp (atan N)))
16.0ms
(- (+ N 1) N)
10.0ms
(- (sqrt (atan (+ N 1))) (sqrt (atan N)))
9.0ms
(- (atan (+ N 1)) (atan N))

prune382.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 0.9b

localize23.0ms

Local error

Found 2 expressions with local error:

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

rewrite7.0ms

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

series45.0ms

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

simplify278.0ms

Counts
10 → 26
Calls
10 calls:
Slowest
135.0ms
(* (- (* N N) (* 1 1)) N)
28.0ms
(atan2 1 (+ N (+ (pow N 2) 1)))
27.0ms
(* (+ (pow N 3) (pow 1 3)) N)
27.0ms
(atan2 1 (+ N (+ (pow N 2) 1)))
27.0ms
(atan2 1 (+ N (+ (pow N 2) 1)))

prune358.0ms

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0.8b

localize34.0ms

Local error

Found 2 expressions with local error:

0.9b
(atan2 1 (+ N (+ (pow N 2) 1)))
0.0b
(+ N (+ (pow N 2) 1))

rewrite7.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-+
associate-+r+
+-commutative
Counts
2 → 18
Calls
2 calls:
Slowest
6.0ms
(+ N (+ (pow N 2) 1))
0.0ms
(atan2 1 (+ N (+ (pow N 2) 1)))

series21.0ms

Counts
2 → 6
Calls
2 calls:
Slowest
15.0ms
(+ N (+ (pow N 2) 1))
5.0ms
(atan2 1 (+ N (+ (pow N 2) 1)))

simplify167.0ms

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

prune355.0ms

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0.8b

localize38.0ms

Local error

Found 4 expressions with local error:

16.9b
(cbrt (* (+ N 1) N))
16.9b
(cbrt (* (+ N 1) N))
16.9b
(cbrt (* (+ N 1) N))
0.9b
(atan2 1 (+ 1 (* (* (cbrt (* (+ N 1) N)) (cbrt (* (+ N 1) N))) (cbrt (* (+ N 1) N)))))

rewrite12.0ms

Algorithm
rewrite-expression-head
Rules
associate-*l/
cbrt-div
add-log-exp
add-cube-cbrt
add-exp-log
add-cbrt-cube
*-un-lft-identity
pow1
add-sqr-sqrt
flip-+
pow1/3
flip3-+
cbrt-prod
Counts
4 → 40
Calls
4 calls:
Slowest
4.0ms
(cbrt (* (+ N 1) N))
4.0ms
(cbrt (* (+ N 1) N))
4.0ms
(cbrt (* (+ N 1) N))
0.0ms
(atan2 1 (+ 1 (* (* (cbrt (* (+ N 1) N)) (cbrt (* (+ N 1) N))) (cbrt (* (+ N 1) N)))))

series257.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
85.0ms
(cbrt (* (+ N 1) N))
82.0ms
(cbrt (* (+ N 1) N))
80.0ms
(cbrt (* (+ N 1) N))
10.0ms
(atan2 1 (+ 1 (* (* (cbrt (* (+ N 1) N)) (cbrt (* (+ N 1) N))) (cbrt (* (+ N 1) N)))))

simplify2.0s

Counts
21 → 52
Calls
21 calls:
Slowest
290.0ms
(- (+ (* (cbrt -1) (exp (* 1/3 (- (log -1) (* 2 (log (/ -1 N))))))) (* 1/3 (/ (* (cbrt -1) (exp (* 1/3 (- (log -1) (* 2 (log (/ -1 N))))))) N))) (* 1/9 (/ (* (cbrt -1) (exp (* 1/3 (- (log -1) (* 2 (log (/ -1 N))))))) (pow N 2))))
261.0ms
(- (+ (* (cbrt -1) (exp (* 1/3 (- (log -1) (* 2 (log (/ -1 N))))))) (* 1/3 (/ (* (cbrt -1) (exp (* 1/3 (- (log -1) (* 2 (log (/ -1 N))))))) N))) (* 1/9 (/ (* (cbrt -1) (exp (* 1/3 (- (log -1) (* 2 (log (/ -1 N))))))) (pow N 2))))
256.0ms
(- (+ (* (cbrt -1) (exp (* 1/3 (- (log -1) (* 2 (log (/ -1 N))))))) (* 1/3 (/ (* (cbrt -1) (exp (* 1/3 (- (log -1) (* 2 (log (/ -1 N))))))) N))) (* 1/9 (/ (* (cbrt -1) (exp (* 1/3 (- (log -1) (* 2 (log (/ -1 N))))))) (pow N 2))))
156.0ms
(cbrt (* (- (* N N) (* 1 1)) N))
155.0ms
(cbrt (* (- (* N N) (* 1 1)) N))

prune933.0ms

Pruning

4 alts after pruning (2 fresh and 2 done)

Merged error: 0.8b

regimes56.0ms

Accuracy

0% (0.0b remaining)

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

bsearch2.0ms

end0.0ms

sample3.2s

Algorithm
intervals
Results
2836×2.0s(body real 1280)
3971×489.0ms(body real 80)
690×285.0ms(body real 640)
8000×173.0ms(pre true 80)
339×109.0ms(body real 320)
164×38.0ms(body real 160)