Average Error: 15.1 → 0.4
Time: 15.6s
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 r70314 = N;
        double r70315 = 1.0;
        double r70316 = r70314 + r70315;
        double r70317 = atan(r70316);
        double r70318 = atan(r70314);
        double r70319 = r70317 - r70318;
        return r70319;
}

double f(double N) {
        double r70320 = 1.0;
        double r70321 = N;
        double r70322 = r70321 + r70320;
        double r70323 = 1.0;
        double r70324 = fma(r70321, r70322, r70323);
        double r70325 = atan2(r70320, r70324);
        return r70325;
}

Error

Bits error versus N

Target

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

Derivation

  1. Initial program 15.1

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

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

    \[\leadsto \tan^{-1}_* \frac{1 + 0}{\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 2019209 +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)))