Average Error: 0.3 → 0.4
Time: 8.0s
Precision: 64
\[\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}\]
\[\frac{1}{\frac{\mathsf{fma}\left(\tan x, \tan x, 1\right)}{1 - \frac{\tan x \cdot \sin x}{\cos x}}}\]
\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}
\frac{1}{\frac{\mathsf{fma}\left(\tan x, \tan x, 1\right)}{1 - \frac{\tan x \cdot \sin x}{\cos x}}}
double f(double x) {
        double r12961 = 1.0;
        double r12962 = x;
        double r12963 = tan(r12962);
        double r12964 = r12963 * r12963;
        double r12965 = r12961 - r12964;
        double r12966 = r12961 + r12964;
        double r12967 = r12965 / r12966;
        return r12967;
}

double f(double x) {
        double r12968 = 1.0;
        double r12969 = x;
        double r12970 = tan(r12969);
        double r12971 = 1.0;
        double r12972 = fma(r12970, r12970, r12971);
        double r12973 = sin(r12969);
        double r12974 = r12970 * r12973;
        double r12975 = cos(r12969);
        double r12976 = r12974 / r12975;
        double r12977 = r12971 - r12976;
        double r12978 = r12972 / r12977;
        double r12979 = r12968 / r12978;
        return r12979;
}

Error

Bits error versus x

Derivation

  1. Initial program 0.3

    \[\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}\]
  2. Using strategy rm
  3. Applied tan-quot0.4

    \[\leadsto \frac{1 - \tan x \cdot \color{blue}{\frac{\sin x}{\cos x}}}{1 + \tan x \cdot \tan x}\]
  4. Applied associate-*r/0.4

    \[\leadsto \frac{1 - \color{blue}{\frac{\tan x \cdot \sin x}{\cos x}}}{1 + \tan x \cdot \tan x}\]
  5. Using strategy rm
  6. Applied clear-num0.4

    \[\leadsto \color{blue}{\frac{1}{\frac{1 + \tan x \cdot \tan x}{1 - \frac{\tan x \cdot \sin x}{\cos x}}}}\]
  7. Simplified0.4

    \[\leadsto \frac{1}{\color{blue}{\frac{\mathsf{fma}\left(\tan x, \tan x, 1\right)}{1 - \frac{\tan x \cdot \sin x}{\cos x}}}}\]
  8. Final simplification0.4

    \[\leadsto \frac{1}{\frac{\mathsf{fma}\left(\tan x, \tan x, 1\right)}{1 - \frac{\tan x \cdot \sin x}{\cos x}}}\]

Reproduce

herbie shell --seed 2020046 +o rules:numerics
(FPCore (x)
  :name "Trigonometry B"
  :precision binary64
  (/ (- 1 (* (tan x) (tan x))) (+ 1 (* (tan x) (tan x)))))