Average Error: 0.3 → 0.4
Time: 22.9s
Precision: 64
\[\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}\]
\[\left(1 + \tan x\right) \cdot \frac{1 - \tan x}{\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\right) \cdot \frac{1 - \tan x}{\mathsf{fma}\left(\tan x, \tan x, 1\right)}
double f(double x) {
        double r290489 = 1.0;
        double r290490 = x;
        double r290491 = tan(r290490);
        double r290492 = r290491 * r290491;
        double r290493 = r290489 - r290492;
        double r290494 = r290489 + r290492;
        double r290495 = r290493 / r290494;
        return r290495;
}

double f(double x) {
        double r290496 = 1.0;
        double r290497 = x;
        double r290498 = tan(r290497);
        double r290499 = r290496 + r290498;
        double r290500 = r290496 - r290498;
        double r290501 = fma(r290498, r290498, r290496);
        double r290502 = r290500 / r290501;
        double r290503 = r290499 * r290502;
        return r290503;
}

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 *-un-lft-identity0.3

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

    \[\leadsto \frac{\color{blue}{\sqrt{1} \cdot \sqrt{1}} - \tan x \cdot \tan x}{1 \cdot \left(1 + \tan x \cdot \tan x\right)}\]
  5. Applied difference-of-squares0.4

    \[\leadsto \frac{\color{blue}{\left(\sqrt{1} + \tan x\right) \cdot \left(\sqrt{1} - \tan x\right)}}{1 \cdot \left(1 + \tan x \cdot \tan x\right)}\]
  6. Applied times-frac0.4

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

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

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

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

Reproduce

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