Average Error: 0.3 → 0.3
Time: 22.6s
Precision: 64
\[\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}\]
\[\frac{\mathsf{fma}\left(-\tan x, \tan x, \tan x \cdot \tan x\right) + \left(1 - \tan x \cdot \tan x\right)}{\tan x \cdot \tan x + 1}\]
\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}
\frac{\mathsf{fma}\left(-\tan x, \tan x, \tan x \cdot \tan x\right) + \left(1 - \tan x \cdot \tan x\right)}{\tan x \cdot \tan x + 1}
double f(double x) {
        double r735008 = 1.0;
        double r735009 = x;
        double r735010 = tan(r735009);
        double r735011 = r735010 * r735010;
        double r735012 = r735008 - r735011;
        double r735013 = r735008 + r735011;
        double r735014 = r735012 / r735013;
        return r735014;
}

double f(double x) {
        double r735015 = x;
        double r735016 = tan(r735015);
        double r735017 = -r735016;
        double r735018 = r735016 * r735016;
        double r735019 = fma(r735017, r735016, r735018);
        double r735020 = 1.0;
        double r735021 = r735020 - r735018;
        double r735022 = r735019 + r735021;
        double r735023 = r735018 + r735020;
        double r735024 = r735022 / r735023;
        return r735024;
}

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{\mathsf{fma}\left(-\tan x, \tan x, \tan x \cdot \tan x\right) + \left(1 - \tan x \cdot \tan x\right)}{\tan x \cdot \tan x + 1}\]

Reproduce

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