Average Error: 0.3 → 0.4
Time: 16.8s
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 r23139 = 1.0;
        double r23140 = x;
        double r23141 = tan(r23140);
        double r23142 = r23141 * r23141;
        double r23143 = r23139 - r23142;
        double r23144 = r23139 + r23142;
        double r23145 = r23143 / r23144;
        return r23145;
}

double f(double x) {
        double r23146 = x;
        double r23147 = tan(r23146);
        double r23148 = -r23147;
        double r23149 = 1.0;
        double r23150 = fma(r23148, r23147, r23149);
        double r23151 = fma(r23147, r23147, r23149);
        double r23152 = r23150 / r23151;
        double r23153 = log1p(r23152);
        double r23154 = exp(r23153);
        double r23155 = log(r23154);
        double r23156 = expm1(r23155);
        return r23156;
}

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{\mathsf{fma}\left(-\tan x, \tan x, 1\right)}{\mathsf{fma}\left(\tan x, \tan x, 1\right)}}\]
  3. Using strategy rm
  4. Applied fma-udef0.3

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

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

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

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

    \[\leadsto \mathsf{expm1}\left(\log \color{blue}{\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 2019194 +o rules:numerics
(FPCore (x)
  :name "Trigonometry B"
  (/ (- 1.0 (* (tan x) (tan x))) (+ 1.0 (* (tan x) (tan x)))))