Average Error: 0.3 → 0.3
Time: 24.3s
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 r644843 = 1.0;
        double r644844 = x;
        double r644845 = tan(r644844);
        double r644846 = r644845 * r644845;
        double r644847 = r644843 - r644846;
        double r644848 = r644843 + r644846;
        double r644849 = r644847 / r644848;
        return r644849;
}

double f(double x) {
        double r644850 = x;
        double r644851 = tan(r644850);
        double r644852 = -r644851;
        double r644853 = r644851 * r644851;
        double r644854 = fma(r644852, r644851, r644853);
        double r644855 = 1.0;
        double r644856 = r644855 - r644853;
        double r644857 = r644854 + r644856;
        double r644858 = r644853 + r644855;
        double r644859 = r644857 / r644858;
        return r644859;
}

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 2019174 +o rules:numerics
(FPCore (x)
  :name "Trigonometry B"
  (/ (- 1.0 (* (tan x) (tan x))) (+ 1.0 (* (tan x) (tan x)))))