Average Error: 0.3 → 0.4
Time: 19.1s
Precision: 64
\[\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}\]
\[\left(1 - \tan x \cdot \tan x\right) \cdot \frac{1}{\mathsf{fma}\left(\tan x, \tan x, 1\right)}\]
\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}
\left(1 - \tan x \cdot \tan x\right) \cdot \frac{1}{\mathsf{fma}\left(\tan x, \tan x, 1\right)}
double f(double x) {
        double r19520 = 1.0;
        double r19521 = x;
        double r19522 = tan(r19521);
        double r19523 = r19522 * r19522;
        double r19524 = r19520 - r19523;
        double r19525 = r19520 + r19523;
        double r19526 = r19524 / r19525;
        return r19526;
}

double f(double x) {
        double r19527 = 1.0;
        double r19528 = x;
        double r19529 = tan(r19528);
        double r19530 = r19529 * r19529;
        double r19531 = r19527 - r19530;
        double r19532 = 1.0;
        double r19533 = fma(r19529, r19529, r19527);
        double r19534 = r19532 / r19533;
        double r19535 = r19531 * r19534;
        return r19535;
}

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. Simplified0.3

    \[\leadsto \color{blue}{\frac{1 - \tan x \cdot \tan x}{\mathsf{fma}\left(\tan x, \tan x, 1\right)}}\]
  3. Using strategy rm
  4. Applied div-inv0.4

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

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

Reproduce

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