Average Error: 0.3 → 0.4
Time: 8.3s
Precision: 64
\[\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}\]
\[\frac{1}{\mathsf{fma}\left(\tan x, \tan x, 1\right)} - \frac{\tan x}{\frac{\mathsf{fma}\left(\tan x, \tan x, 1\right)}{\tan x}}\]
\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}
\frac{1}{\mathsf{fma}\left(\tan x, \tan x, 1\right)} - \frac{\tan x}{\frac{\mathsf{fma}\left(\tan x, \tan x, 1\right)}{\tan x}}
double f(double x) {
        double r21926 = 1.0;
        double r21927 = x;
        double r21928 = tan(r21927);
        double r21929 = r21928 * r21928;
        double r21930 = r21926 - r21929;
        double r21931 = r21926 + r21929;
        double r21932 = r21930 / r21931;
        return r21932;
}

double f(double x) {
        double r21933 = 1.0;
        double r21934 = x;
        double r21935 = tan(r21934);
        double r21936 = fma(r21935, r21935, r21933);
        double r21937 = r21933 / r21936;
        double r21938 = r21936 / r21935;
        double r21939 = r21935 / r21938;
        double r21940 = r21937 - r21939;
        return r21940;
}

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 div-sub0.4

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

    \[\leadsto \color{blue}{\frac{1}{\mathsf{fma}\left(\tan x, \tan x, 1\right)}} - \frac{\tan x \cdot \tan x}{1 + \tan x \cdot \tan x}\]
  5. Simplified0.4

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

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

Reproduce

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