Average Error: 0.3 → 0.3
Time: 1.1m
Precision: 64
\[\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}\]
\[\frac{\mathsf{fma}\left(\left(\tan x\right), \left(\tan x\right), -1\right)}{-1 - \tan x \cdot \tan x}\]
\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}
\frac{\mathsf{fma}\left(\left(\tan x\right), \left(\tan x\right), -1\right)}{-1 - \tan x \cdot \tan x}
double f(double x) {
        double r3071684 = 1.0;
        double r3071685 = x;
        double r3071686 = tan(r3071685);
        double r3071687 = r3071686 * r3071686;
        double r3071688 = r3071684 - r3071687;
        double r3071689 = r3071684 + r3071687;
        double r3071690 = r3071688 / r3071689;
        return r3071690;
}

double f(double x) {
        double r3071691 = x;
        double r3071692 = tan(r3071691);
        double r3071693 = -1.0;
        double r3071694 = fma(r3071692, r3071692, r3071693);
        double r3071695 = r3071692 * r3071692;
        double r3071696 = r3071693 - r3071695;
        double r3071697 = r3071694 / r3071696;
        return r3071697;
}

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 frac-2neg0.3

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

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

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

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

Reproduce

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