Average Error: 14.9 → 0.4
Time: 5.2s
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

Original14.9
Target0.4
Herbie0.4
\[\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.6

    \[\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 -inf 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 2019022 
(FPCore (N)
  :name "2atan (example 3.5)"

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

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

Details

Time bar (total: 4.6s)Debug log

sample46.0ms

Algorithm
intervals
Results
22.0ms80×body1280valid
8.0ms132×body80valid
5.0ms25×body640valid
2.0ms15×body320valid
1.0msbody160valid

simplify8.0ms

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

prune8.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 15.6b

localize22.0ms

Local error

Found 1 expressions with local error:

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

rewrite8.0ms

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

series30.0ms

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

simplify119.0ms

Counts
9 → 18
Calls
9 calls:
Slowest
33.0ms
(+ 1 (* (+ N 1) N))
25.0ms
(/ (exp (atan (+ N 1))) (exp (atan N)))
14.0ms
(- (+ N 1) N)
10.0ms
(- (sqrt (atan (+ N 1))) (sqrt (atan N)))
8.0ms
(- (atan (+ N 1)) (atan N))

prune142.0ms

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0.1b

localize8.0ms

Local error

Found 2 expressions with local error:

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

rewrite3.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
2.0ms
(* (+ N 1) N)
0.0ms
(atan2 1 (+ 1 (* (+ N 1) N)))

series34.0ms

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

simplify193.0ms

Counts
10 → 26
Calls
10 calls:
Slowest
71.0ms
(* (- (* N N) (* 1 1)) N)
25.0ms
(atan2 1 (+ N (+ (pow N 2) 1)))
25.0ms
(atan2 1 (+ N (+ (pow N 2) 1)))
22.0ms
(* (+ (pow N 3) (pow 1 3)) N)
21.0ms
(atan2 1 (+ N (+ (pow N 2) 1)))

prune190.0ms

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0.1b

localize24.0ms

Local error

Found 2 expressions with local error:

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

rewrite6.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
5.0ms
(+ N (+ (pow N 2) 1))
0.0ms
(atan2 1 (+ N (+ (pow N 2) 1)))

series17.0ms

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

simplify141.0ms

Counts
6 → 24
Calls
6 calls:
Slowest
28.0ms
(atan2 1 (+ N (+ (pow N 2) 1)))
24.0ms
(atan2 1 (+ N (+ (pow N 2) 1)))
24.0ms
(atan2 1 (+ N (+ (pow N 2) 1)))
22.0ms
(+ N (+ (pow N 2) 1))
21.0ms
(+ N (+ (pow N 2) 1))

prune186.0ms

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0.1b

localize9.0ms

Local error

Found 4 expressions with local error:

14.0b
(sqrt (atan2 1 (+ 1 (* (+ N 1) N))))
14.0b
(sqrt (atan2 1 (+ 1 (* (+ N 1) N))))
0.6b
(* (sqrt (atan2 1 (+ 1 (* (+ N 1) N)))) (sqrt (atan2 1 (+ 1 (* (+ N 1) N)))))
0.1b
(atan2 1 (+ 1 (* (+ N 1) N)))

rewrite7.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
5.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)))

series39.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
21.0ms
(sqrt (atan2 1 (+ 1 (* (+ N 1) N))))
13.0ms
(sqrt (atan2 1 (+ 1 (* (+ N 1) N))))
3.0ms
(* (sqrt (atan2 1 (+ 1 (* (+ N 1) N)))) (sqrt (atan2 1 (+ 1 (* (+ N 1) N)))))
2.0ms
(atan2 1 (+ 1 (* (+ N 1) N)))

simplify1.0s

Counts
42 → 73
Calls
42 calls:
Slowest
44.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))))))
43.0ms
(sqrt (* (cbrt (atan2 1 (+ 1 (* (+ N 1) N)))) (cbrt (atan2 1 (+ 1 (* (+ N 1) N))))))
41.0ms
(sqrt (sqrt (atan2 1 (+ 1 (* (+ N 1) N)))))
41.0ms
(sqrt (sqrt (atan2 1 (+ 1 (* (+ N 1) N)))))
40.0ms
(cbrt (sqrt (atan2 1 (+ 1 (* (+ N 1) N)))))

prune618.0ms

Pruning

6 alts after pruning (4 fresh and 2 done)

Merged error: 0.1b

regimes61.0ms

Accuracy

0% (0.0b remaining)

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

bsearch2.0ms

end0.0ms

sample1.7s

Algorithm
intervals
Results
901.0ms2786×body1280valid
328.0ms4072×body80valid
220.0ms640×body640valid
64.0ms320×body320valid
54.0ms182×body160valid