Average Error: 14.9 → 0.4
Time: 6.3s
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.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. Simplified0.4

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

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

Reproduce

herbie shell --seed 2019022 +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: 5.6s)Debug log

sample51.0ms

Algorithm
intervals
Results
24.0ms80×body1280valid
9.0ms132×body80valid
6.0ms25×body640valid
3.0ms15×body320valid
1.0msbody160valid

simplify8.0ms

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

prune20.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 15.6b

localize11.0ms

Local error

Found 1 expressions with local error:

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

rewrite4.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
4.0ms
(- (atan (+ N 1)) (atan N))

series7.0ms

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

simplify443.0ms

Counts
29 → 32
Calls
29 calls:
Slowest
32.0ms
(fma (sqrt (atan (+ N 1))) (sqrt (atan (+ N 1))) (- (* (sqrt (atan N)) (sqrt (atan N)))))
29.0ms
(fma (- (cbrt (atan N))) (* (cbrt (atan N)) (cbrt (atan N))) (* (cbrt (atan N)) (* (cbrt (atan N)) (cbrt (atan N)))))
29.0ms
(fma (- (cbrt (atan N))) (* (cbrt (atan N)) (cbrt (atan N))) (* (cbrt (atan N)) (* (cbrt (atan N)) (cbrt (atan N)))))
25.0ms
(/ (exp (atan (+ N 1))) (exp (atan N)))
25.0ms
(fma 1 (atan (+ N 1)) (- (* (cbrt (atan N)) (* (cbrt (atan N)) (cbrt (atan N))))))

prune277.0ms

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0.1b

localize12.0ms

Local error

Found 1 expressions with local error:

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

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

series3.0ms

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

simplify49.0ms

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

prune105.0ms

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0.1b

localize6.0ms

Local error

Found 4 expressions with local error:

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

rewrite8.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
5.0ms
(* (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)))
0.0ms
(atan2 1 (fma N (+ N 1) 1))

series31.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
17.0ms
(sqrt (atan2 1 (fma N (+ N 1) 1)))
10.0ms
(sqrt (atan2 1 (fma N (+ N 1) 1)))
2.0ms
(* (sqrt (atan2 1 (fma N (+ N 1) 1))) (sqrt (atan2 1 (fma N (+ N 1) 1))))
2.0ms
(atan2 1 (fma N (+ N 1) 1))

simplify834.0ms

Counts
42 → 81
Calls
42 calls:
Slowest
47.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)))))
39.0ms
(+ (log (sqrt (atan2 1 (fma N (+ N 1) 1)))) (log (sqrt (atan2 1 (fma N (+ N 1) 1)))))
37.0ms
(sqrt (sqrt (atan2 1 (fma N (+ N 1) 1))))
37.0ms
(cbrt (sqrt (atan2 1 (fma N (+ N 1) 1))))
36.0ms
(sqrt (sqrt (atan2 1 (fma N (+ N 1) 1))))

prune558.0ms

Pruning

7 alts after pruning (6 fresh and 1 done)

Merged error: 0.1b

localize9.0ms

Local error

Found 4 expressions with local error:

14.0b
(sqrt (atan2 1 (fma N (+ N 1) 1)))
14.0b
(sqrt (atan2 1 (fma N (+ N 1) 1)))
0.6b
(* (expm1 (log1p (sqrt (atan2 1 (fma N (+ N 1) 1))))) (sqrt (atan2 1 (fma N (+ N 1) 1))))
0.5b
(expm1 (log1p (sqrt (atan2 1 (fma N (+ N 1) 1)))))

rewrite7.0ms

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

series365.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
179.0ms
(* (expm1 (log1p (sqrt (atan2 1 (fma N (+ N 1) 1))))) (sqrt (atan2 1 (fma N (+ N 1) 1))))
156.0ms
(expm1 (log1p (sqrt (atan2 1 (fma N (+ N 1) 1)))))
17.0ms
(sqrt (atan2 1 (fma N (+ N 1) 1)))
12.0ms
(sqrt (atan2 1 (fma N (+ N 1) 1)))

simplify599.0ms

Counts
32 → 73
Calls
32 calls:
Slowest
48.0ms
(* (* (* (expm1 (log1p (sqrt (atan2 1 (fma N (+ N 1) 1))))) (expm1 (log1p (sqrt (atan2 1 (fma N (+ N 1) 1)))))) (expm1 (log1p (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)))))
32.0ms
(+ (log (expm1 (log1p (sqrt (atan2 1 (fma N (+ N 1) 1)))))) (log (sqrt (atan2 1 (fma N (+ N 1) 1)))))
29.0ms
(sqrt (atan2 1 (fma N (+ N 1) 1)))
29.0ms
(sqrt (atan2 1 (fma N (+ N 1) 1)))
28.0ms
(sqrt (expm1 (log1p (sqrt (atan2 1 (fma N (+ N 1) 1))))))

prune601.0ms

Pruning

7 alts after pruning (5 fresh and 2 done)

Merged error: 0.1b

regimes47.0ms

Accuracy

0% (0.0b remaining)

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

bsearch1.0ms

end0.0ms

sample1.5s

Algorithm
intervals
Results
943.0ms2786×body1280valid
281.0ms4072×body80valid
144.0ms640×body640valid
51.0ms320×body320valid
22.0ms182×body160valid