Average Error: 0.3 → 0.3
Time: 26.2s
Precision: 64
\[\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}\]
\[\frac{\left(1 - \tan x \cdot \tan x\right) + \mathsf{fma}\left(-\tan x, \tan x, \tan x \cdot \tan x\right)}{1 + \tan x \cdot \tan x}\]
\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}
\frac{\left(1 - \tan x \cdot \tan x\right) + \mathsf{fma}\left(-\tan x, \tan x, \tan x \cdot \tan x\right)}{1 + \tan x \cdot \tan x}
double f(double x) {
        double r974607 = 1.0;
        double r974608 = x;
        double r974609 = tan(r974608);
        double r974610 = r974609 * r974609;
        double r974611 = r974607 - r974610;
        double r974612 = r974607 + r974610;
        double r974613 = r974611 / r974612;
        return r974613;
}

double f(double x) {
        double r974614 = 1.0;
        double r974615 = x;
        double r974616 = tan(r974615);
        double r974617 = r974616 * r974616;
        double r974618 = r974614 - r974617;
        double r974619 = -r974616;
        double r974620 = fma(r974619, r974616, r974617);
        double r974621 = r974618 + r974620;
        double r974622 = r974614 + r974617;
        double r974623 = r974621 / r974622;
        return r974623;
}

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 add-sqr-sqrt0.3

    \[\leadsto \frac{\color{blue}{\sqrt{1} \cdot \sqrt{1}} - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}\]
  4. Applied prod-diff0.3

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

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

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

Reproduce

herbie shell --seed 2019174 +o rules:numerics
(FPCore (x)
  :name "Trigonometry B"
  (/ (- 1.0 (* (tan x) (tan x))) (+ 1.0 (* (tan x) (tan x)))))