Average Error: 0.3 → 0.4
Time: 7.2s
Precision: 64
\[\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}\]
\[\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{\mathsf{fma}\left(\tan x, \tan x, 1\right)}\right)\right) - \frac{\tan x}{\frac{\mathsf{fma}\left(\tan x, \tan x, 1\right)}{\tan x}}\]
\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}
\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{\mathsf{fma}\left(\tan x, \tan x, 1\right)}\right)\right) - \frac{\tan x}{\frac{\mathsf{fma}\left(\tan x, \tan x, 1\right)}{\tan x}}
double f(double x) {
        double r21458 = 1.0;
        double r21459 = x;
        double r21460 = tan(r21459);
        double r21461 = r21460 * r21460;
        double r21462 = r21458 - r21461;
        double r21463 = r21458 + r21461;
        double r21464 = r21462 / r21463;
        return r21464;
}

double f(double x) {
        double r21465 = 1.0;
        double r21466 = x;
        double r21467 = tan(r21466);
        double r21468 = fma(r21467, r21467, r21465);
        double r21469 = r21465 / r21468;
        double r21470 = expm1(r21469);
        double r21471 = log1p(r21470);
        double r21472 = r21468 / r21467;
        double r21473 = r21467 / r21472;
        double r21474 = r21471 - r21473;
        return r21474;
}

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 log1p-expm1-u0.4

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

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

Reproduce

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