Average Error: 0.3 → 0.4
Time: 18.6s
Precision: 64
\[\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}\]
\[\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1 - \tan x \cdot \tan x}{\mathsf{fma}\left(\tan x, \tan x, 1\right)}\right)\right)\]
\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}
\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1 - \tan x \cdot \tan x}{\mathsf{fma}\left(\tan x, \tan x, 1\right)}\right)\right)
double f(double x) {
        double r22693 = 1.0;
        double r22694 = x;
        double r22695 = tan(r22694);
        double r22696 = r22695 * r22695;
        double r22697 = r22693 - r22696;
        double r22698 = r22693 + r22696;
        double r22699 = r22697 / r22698;
        return r22699;
}

double f(double x) {
        double r22700 = 1.0;
        double r22701 = x;
        double r22702 = tan(r22701);
        double r22703 = r22702 * r22702;
        double r22704 = r22700 - r22703;
        double r22705 = fma(r22702, r22702, r22700);
        double r22706 = r22704 / r22705;
        double r22707 = log1p(r22706);
        double r22708 = expm1(r22707);
        return r22708;
}

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

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

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

Reproduce

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