Average Error: 0.3 → 0.4
Time: 22.2s
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 r18304 = 1.0;
        double r18305 = x;
        double r18306 = tan(r18305);
        double r18307 = r18306 * r18306;
        double r18308 = r18304 - r18307;
        double r18309 = r18304 + r18307;
        double r18310 = r18308 / r18309;
        return r18310;
}

double f(double x) {
        double r18311 = 1.0;
        double r18312 = x;
        double r18313 = tan(r18312);
        double r18314 = r18313 * r18313;
        double r18315 = r18311 - r18314;
        double r18316 = 1.0;
        double r18317 = fma(r18313, r18313, r18311);
        double r18318 = r18316 / r18317;
        double r18319 = r18315 * r18318;
        return r18319;
}

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 clear-num0.4

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

    \[\leadsto \frac{1}{\frac{\mathsf{fma}\left(\tan x, \tan x, 1\right)}{\color{blue}{\frac{1 \cdot 1 - \left(\tan x \cdot \tan x\right) \cdot \left(\tan x \cdot \tan x\right)}{1 + \tan x \cdot \tan x}}}}\]
  7. Applied associate-/r/0.5

    \[\leadsto \frac{1}{\color{blue}{\frac{\mathsf{fma}\left(\tan x, \tan x, 1\right)}{1 \cdot 1 - \left(\tan x \cdot \tan x\right) \cdot \left(\tan x \cdot \tan x\right)} \cdot \left(1 + \tan x \cdot \tan x\right)}}\]
  8. Applied add-cube-cbrt0.5

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

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

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

    \[\leadsto \left(1 - \tan x \cdot \tan x\right) \cdot \color{blue}{\frac{1}{\mathsf{fma}\left(\tan x, \tan x, 1\right)}}\]
  12. 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 2019325 +o rules:numerics
(FPCore (x)
  :name "Trigonometry B"
  :precision binary64
  (/ (- 1 (* (tan x) (tan x))) (+ 1 (* (tan x) (tan x)))))