Average Error: 0.3 → 0.4
Time: 7.9s
Precision: 64
\[\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}\]
\[\frac{1}{\mathsf{fma}\left(\tan x, \tan x, 1\right)} - \frac{1}{\mathsf{fma}\left(\tan x, \tan x, 1\right)} \cdot \left(\tan x \cdot \tan x\right)\]
\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}
\frac{1}{\mathsf{fma}\left(\tan x, \tan x, 1\right)} - \frac{1}{\mathsf{fma}\left(\tan x, \tan x, 1\right)} \cdot \left(\tan x \cdot \tan x\right)
double f(double x) {
        double r21801 = 1.0;
        double r21802 = x;
        double r21803 = tan(r21802);
        double r21804 = r21803 * r21803;
        double r21805 = r21801 - r21804;
        double r21806 = r21801 + r21804;
        double r21807 = r21805 / r21806;
        return r21807;
}

double f(double x) {
        double r21808 = 1.0;
        double r21809 = x;
        double r21810 = tan(r21809);
        double r21811 = fma(r21810, r21810, r21808);
        double r21812 = r21808 / r21811;
        double r21813 = 1.0;
        double r21814 = r21813 / r21811;
        double r21815 = r21810 * r21810;
        double r21816 = r21814 * r21815;
        double r21817 = r21812 - r21816;
        return r21817;
}

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 div-sub0.4

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

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

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

    \[\leadsto \frac{1}{\mathsf{fma}\left(\tan x, \tan x, 1\right)} - \frac{\tan x}{\color{blue}{\mathsf{fma}\left(\tan x, \tan x, 1\right) \cdot \frac{1}{\tan x}}}\]
  8. Applied *-un-lft-identity0.5

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

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

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

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

Reproduce

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