Average Error: 0.3 → 0.4
Time: 19.4s
Precision: 64
\[\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}\]
\[\mathsf{expm1}\left(\log \left(e^{\mathsf{log1p}\left(\frac{\mathsf{fma}\left(-\tan x, \tan x, 1\right)}{\mathsf{fma}\left(\tan x, \tan x, 1\right)}\right)}\right)\right)\]
\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}
\mathsf{expm1}\left(\log \left(e^{\mathsf{log1p}\left(\frac{\mathsf{fma}\left(-\tan x, \tan x, 1\right)}{\mathsf{fma}\left(\tan x, \tan x, 1\right)}\right)}\right)\right)
double f(double x) {
        double r19882 = 1.0;
        double r19883 = x;
        double r19884 = tan(r19883);
        double r19885 = r19884 * r19884;
        double r19886 = r19882 - r19885;
        double r19887 = r19882 + r19885;
        double r19888 = r19886 / r19887;
        return r19888;
}

double f(double x) {
        double r19889 = x;
        double r19890 = tan(r19889);
        double r19891 = -r19890;
        double r19892 = 1.0;
        double r19893 = fma(r19891, r19890, r19892);
        double r19894 = fma(r19890, r19890, r19892);
        double r19895 = r19893 / r19894;
        double r19896 = log1p(r19895);
        double r19897 = exp(r19896);
        double r19898 = log(r19897);
        double r19899 = expm1(r19898);
        return r19899;
}

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. Using strategy rm
  10. Applied add-log-exp0.4

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

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

Reproduce

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