Average Error: 14.9 → 0.3
Time: 12.1s
Precision: 64
\[\tan^{-1} \left(N + 1\right) - \tan^{-1} N\]
\[\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N + 1, 1\right)}\]
\tan^{-1} \left(N + 1\right) - \tan^{-1} N
\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N + 1, 1\right)}
double f(double N) {
        double r145921 = N;
        double r145922 = 1.0;
        double r145923 = r145921 + r145922;
        double r145924 = atan(r145923);
        double r145925 = atan(r145921);
        double r145926 = r145924 - r145925;
        return r145926;
}

double f(double N) {
        double r145927 = 1.0;
        double r145928 = N;
        double r145929 = r145928 + r145927;
        double r145930 = 1.0;
        double r145931 = fma(r145928, r145929, r145930);
        double r145932 = atan2(r145927, r145931);
        return r145932;
}

Error

Bits error versus N

Target

Original14.9
Target0.3
Herbie0.3
\[\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.8

    \[\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}{0 + 1}}{1 + \left(N + 1\right) \cdot N}\]
  5. Simplified0.3

    \[\leadsto \tan^{-1}_* \frac{0 + 1}{\color{blue}{\mathsf{fma}\left(N, N + 1, 1\right)}}\]
  6. Final simplification0.3

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

Reproduce

herbie shell --seed 2020047 +o rules:numerics
(FPCore (N)
  :name "2atan (example 3.5)"
  :precision binary64

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

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