Average Error: 0.3 → 0.4
Time: 1.0m
Precision: 64
\[\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}\]
\[\frac{\mathsf{fma}\left(-\frac{\tan x}{\cos x}, \sin x, \sin x \cdot \frac{\tan x}{\cos x}\right) + \mathsf{fma}\left(1, 1, \frac{\tan x}{\cos x} \cdot \left(-\sin x\right)\right)}{\frac{\sin x \cdot \sin x}{\cos x \cdot \cos x} + 1}\]
\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}
\frac{\mathsf{fma}\left(-\frac{\tan x}{\cos x}, \sin x, \sin x \cdot \frac{\tan x}{\cos x}\right) + \mathsf{fma}\left(1, 1, \frac{\tan x}{\cos x} \cdot \left(-\sin x\right)\right)}{\frac{\sin x \cdot \sin x}{\cos x \cdot \cos x} + 1}
double f(double x) {
        double r662638 = 1.0;
        double r662639 = x;
        double r662640 = tan(r662639);
        double r662641 = r662640 * r662640;
        double r662642 = r662638 - r662641;
        double r662643 = r662638 + r662641;
        double r662644 = r662642 / r662643;
        return r662644;
}

double f(double x) {
        double r662645 = x;
        double r662646 = tan(r662645);
        double r662647 = cos(r662645);
        double r662648 = r662646 / r662647;
        double r662649 = -r662648;
        double r662650 = sin(r662645);
        double r662651 = r662650 * r662648;
        double r662652 = fma(r662649, r662650, r662651);
        double r662653 = 1.0;
        double r662654 = -r662650;
        double r662655 = r662648 * r662654;
        double r662656 = fma(r662653, r662653, r662655);
        double r662657 = r662652 + r662656;
        double r662658 = r662650 * r662650;
        double r662659 = r662647 * r662647;
        double r662660 = r662658 / r662659;
        double r662661 = r662660 + r662653;
        double r662662 = r662657 / r662661;
        return r662662;
}

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 - \color{blue}{\frac{\sin x}{\cos x}} \cdot \tan x}{1 + \tan x \cdot \tan x}\]
  4. Applied associate-*l/0.4

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

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

    \[\leadsto \frac{1 - \color{blue}{\frac{\sin x}{1} \cdot \frac{\tan x}{\cos x}}}{1 + \tan x \cdot \tan x}\]
  8. Applied *-un-lft-identity0.4

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

    \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(1, 1, -\frac{\tan x}{\cos x} \cdot \frac{\sin x}{1}\right) + \mathsf{fma}\left(-\frac{\tan x}{\cos x}, \frac{\sin x}{1}, \frac{\tan x}{\cos x} \cdot \frac{\sin x}{1}\right)}}{1 + \tan x \cdot \tan x}\]
  10. Using strategy rm
  11. Applied tan-quot0.4

    \[\leadsto \frac{\mathsf{fma}\left(1, 1, -\frac{\tan x}{\cos x} \cdot \frac{\sin x}{1}\right) + \mathsf{fma}\left(-\frac{\tan x}{\cos x}, \frac{\sin x}{1}, \frac{\tan x}{\cos x} \cdot \frac{\sin x}{1}\right)}{1 + \tan x \cdot \color{blue}{\frac{\sin x}{\cos x}}}\]
  12. Applied tan-quot0.4

    \[\leadsto \frac{\mathsf{fma}\left(1, 1, -\frac{\tan x}{\cos x} \cdot \frac{\sin x}{1}\right) + \mathsf{fma}\left(-\frac{\tan x}{\cos x}, \frac{\sin x}{1}, \frac{\tan x}{\cos x} \cdot \frac{\sin x}{1}\right)}{1 + \color{blue}{\frac{\sin x}{\cos x}} \cdot \frac{\sin x}{\cos x}}\]
  13. Applied frac-times0.4

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

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

Reproduce

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