Average Error: 15.4 → 0.4
Time: 11.9s
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

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

Derivation

  1. Initial program 15.4

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

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

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

Reproduce

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

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

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

Details

Time bar (total: 10.7s)Debug log

sample97.0ms

Algorithm
intervals
Results
256×(pre true 80)
126×(body real 80)
98×(body real 1280)
18×(body real 640)
(body real 320)
(body real 160)

simplify10.0ms

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

prune20.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 15.1b

localize29.0ms

Local error

Found 2 expressions with local error:

1.3b
(- (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))

series17.0ms

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

simplify171.0ms

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

prune357.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 0.2b

localize22.0ms

Local error

Found 2 expressions with local error:

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

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

series43.0ms

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

simplify295.0ms

Counts
10 → 26
Calls
10 calls:
Slowest
142.0ms
(* (- (* N N) (* 1 1)) N)
32.0ms
(atan2 1 (+ N (+ (pow N 2) 1)))
30.0ms
(atan2 1 (+ N (+ (pow N 2) 1)))
29.0ms
(atan2 1 (+ N (+ (pow N 2) 1)))
29.0ms
(* (+ (pow N 3) (pow 1 3)) N)

prune340.0ms

Pruning

6 alts after pruning (5 fresh and 1 done)

Merged error: 0.2b

localize17.0ms

Local error

Found 4 expressions with local error:

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

rewrite15.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
11.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)))

series63.0ms

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

simplify1.6s

Counts
42 → 73
Calls
42 calls:
Slowest
79.0ms
(* (* (* (sqrt (atan2 1 (+ 1 (* (+ N 1) N)))) (sqrt (atan2 1 (+ 1 (* (+ N 1) N))))) (sqrt (atan2 1 (+ 1 (* (+ N 1) N))))) (* (* (sqrt (atan2 1 (+ 1 (* (+ N 1) N)))) (sqrt (atan2 1 (+ 1 (* (+ N 1) N))))) (sqrt (atan2 1 (+ 1 (* (+ N 1) N))))))
53.0ms
(+ (log (sqrt (atan2 1 (+ 1 (* (+ N 1) N))))) (log (sqrt (atan2 1 (+ 1 (* (+ N 1) N))))))
53.0ms
(* (cbrt (sqrt (atan2 1 (+ 1 (* (+ N 1) N))))) (cbrt (sqrt (atan2 1 (+ 1 (* (+ N 1) N))))))
53.0ms
(sqrt (* (cbrt (atan2 1 (+ 1 (* (+ N 1) N)))) (cbrt (atan2 1 (+ 1 (* (+ N 1) N))))))
52.0ms
(sqrt (* (cbrt (atan2 1 (+ 1 (* (+ N 1) N)))) (cbrt (atan2 1 (+ 1 (* (+ N 1) N))))))

prune1.1s

Pruning

7 alts after pruning (6 fresh and 1 done)

Merged error: 0.1b

localize27.0ms

Local error

Found 4 expressions with local error:

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

rewrite38.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
33.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))))

series84.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
26.0ms
(sqrt (atan2 1 (+ 1 (* (+ N 1) N))))
25.0ms
(sqrt (atan2 1 (+ 1 (* (+ N 1) N))))
25.0ms
(sqrt (atan2 1 (+ 1 (* (+ N 1) N))))
7.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.9s

Counts
40 → 72
Calls
40 calls:
Slowest
215.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))))))))
194.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))))))))
64.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))))))))
64.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))))))))
63.0ms
(* (sqrt (atan2 1 (+ 1 (* (+ N 1) N)))) (* (sqrt (sqrt (atan2 1 (+ 1 (* (+ N 1) N))))) (sqrt (sqrt (atan2 1 (+ 1 (* (+ N 1) N)))))))

prune1.2s

Pruning

6 alts after pruning (4 fresh and 2 done)

Merged error: 0.1b

regimes72.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.1s

Algorithm
intervals
Results
8000×(pre true 80)
3997×(body real 80)
2871×(body real 1280)
644×(body real 640)
310×(body real 320)
178×(body real 160)