Average Error: 14.8 → 0.6
Time: 15.9s
Precision: 64
\[\tan^{-1} \left(N + 1\right) - \tan^{-1} N\]
\[{\left(\sqrt{\sqrt{\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N + 1, 1\right)}}}\right)}^{3} \cdot \sqrt{\sqrt{\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N + 1, 1\right)}}}\]
\tan^{-1} \left(N + 1\right) - \tan^{-1} N
{\left(\sqrt{\sqrt{\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N + 1, 1\right)}}}\right)}^{3} \cdot \sqrt{\sqrt{\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N + 1, 1\right)}}}
double f(double N) {
        double r105571 = N;
        double r105572 = 1.0;
        double r105573 = r105571 + r105572;
        double r105574 = atan(r105573);
        double r105575 = atan(r105571);
        double r105576 = r105574 - r105575;
        return r105576;
}

double f(double N) {
        double r105577 = 1.0;
        double r105578 = N;
        double r105579 = r105578 + r105577;
        double r105580 = 1.0;
        double r105581 = fma(r105578, r105579, r105580);
        double r105582 = atan2(r105577, r105581);
        double r105583 = sqrt(r105582);
        double r105584 = sqrt(r105583);
        double r105585 = 3.0;
        double r105586 = pow(r105584, r105585);
        double r105587 = r105586 * r105584;
        return r105587;
}

Error

Bits error versus N

Target

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

Derivation

  1. Initial program 14.8

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

    \[\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}{\mathsf{fma}\left(N, N + 1, 1\right)}}\]
  6. Using strategy rm
  7. Applied add-sqr-sqrt1.0

    \[\leadsto \color{blue}{\sqrt{\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N + 1, 1\right)}} \cdot \sqrt{\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N + 1, 1\right)}}}\]
  8. Using strategy rm
  9. Applied add-sqr-sqrt1.0

    \[\leadsto \sqrt{\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N + 1, 1\right)}} \cdot \sqrt{\color{blue}{\sqrt{\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N + 1, 1\right)}} \cdot \sqrt{\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N + 1, 1\right)}}}}\]
  10. Applied sqrt-prod0.5

    \[\leadsto \sqrt{\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N + 1, 1\right)}} \cdot \color{blue}{\left(\sqrt{\sqrt{\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N + 1, 1\right)}}} \cdot \sqrt{\sqrt{\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N + 1, 1\right)}}}\right)}\]
  11. Applied associate-*r*1.0

    \[\leadsto \color{blue}{\left(\sqrt{\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N + 1, 1\right)}} \cdot \sqrt{\sqrt{\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N + 1, 1\right)}}}\right) \cdot \sqrt{\sqrt{\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N + 1, 1\right)}}}}\]
  12. Simplified0.6

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

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

Reproduce

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