Average Error: 14.9 → 0.3
Time: 7.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 r193166 = N;
        double r193167 = 1.0;
        double r193168 = r193166 + r193167;
        double r193169 = atan(r193168);
        double r193170 = atan(r193166);
        double r193171 = r193169 - r193170;
        return r193171;
}

double f(double N) {
        double r193172 = 1.0;
        double r193173 = N;
        double r193174 = r193173 + r193172;
        double r193175 = 1.0;
        double r193176 = fma(r193173, r193174, r193175);
        double r193177 = atan2(r193172, r193176);
        return r193177;
}

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