Average Error: 0.3 → 0.4
Time: 20.5s
Precision: 64
\[\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}\]
\[\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\mathsf{fma}\left(\tan x, -\tan x, 1\right)}{\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{\mathsf{fma}\left(\tan x, -\tan x, 1\right)}{\mathsf{fma}\left(\tan x, \tan x, 1\right)}\right)\right)
double f(double x) {
        double r21175 = 1.0;
        double r21176 = x;
        double r21177 = tan(r21176);
        double r21178 = r21177 * r21177;
        double r21179 = r21175 - r21178;
        double r21180 = r21175 + r21178;
        double r21181 = r21179 / r21180;
        return r21181;
}

double f(double x) {
        double r21182 = x;
        double r21183 = tan(r21182);
        double r21184 = -r21183;
        double r21185 = 1.0;
        double r21186 = fma(r21183, r21184, r21185);
        double r21187 = fma(r21183, r21183, r21185);
        double r21188 = r21186 / r21187;
        double r21189 = log1p(r21188);
        double r21190 = expm1(r21189);
        return r21190;
}

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 *-un-lft-identity0.3

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

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

    \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\tan x, -\tan x, 1\right)}}{\mathsf{fma}\left(\tan x, \tan x, 1\right)}\]
  7. Using strategy rm
  8. Applied expm1-log1p-u0.4

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

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

Reproduce

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