Average Error: 15.3 → 0.4
Time: 12.9s
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 r133448 = N;
        double r133449 = 1.0;
        double r133450 = r133448 + r133449;
        double r133451 = atan(r133450);
        double r133452 = atan(r133448);
        double r133453 = r133451 - r133452;
        return r133453;
}

double f(double N) {
        double r133454 = 1.0;
        double r133455 = N;
        double r133456 = r133455 + r133454;
        double r133457 = 1.0;
        double r133458 = fma(r133455, r133456, r133457);
        double r133459 = atan2(r133454, r133458);
        return r133459;
}

Error

Bits error versus N

Target

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

Derivation

  1. Initial program 15.3

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

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

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

Reproduce

herbie shell --seed 2020042 +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)))