Average Error: 0.3 → 1.1
Time: 16.2s
Precision: 64
\[\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}\]
\[\frac{\log \left(e^{1} \cdot e^{\left(-\tan x\right) \cdot \tan x}\right)}{\mathsf{fma}\left(\tan x, \tan x, 1\right)}\]
\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}
\frac{\log \left(e^{1} \cdot e^{\left(-\tan x\right) \cdot \tan x}\right)}{\mathsf{fma}\left(\tan x, \tan x, 1\right)}
double f(double x) {
        double r23445 = 1.0;
        double r23446 = x;
        double r23447 = tan(r23446);
        double r23448 = r23447 * r23447;
        double r23449 = r23445 - r23448;
        double r23450 = r23445 + r23448;
        double r23451 = r23449 / r23450;
        return r23451;
}

double f(double x) {
        double r23452 = 1.0;
        double r23453 = exp(r23452);
        double r23454 = x;
        double r23455 = tan(r23454);
        double r23456 = -r23455;
        double r23457 = r23456 * r23455;
        double r23458 = exp(r23457);
        double r23459 = r23453 * r23458;
        double r23460 = log(r23459);
        double r23461 = fma(r23455, r23455, r23452);
        double r23462 = r23460 / r23461;
        return r23462;
}

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 add-log-exp1.0

    \[\leadsto \frac{\color{blue}{\log \left(e^{\mathsf{fma}\left(-\tan x, \tan x, 1\right)}\right)}}{\mathsf{fma}\left(\tan x, \tan x, 1\right)}\]
  5. Using strategy rm
  6. Applied fma-udef1.0

    \[\leadsto \frac{\log \left(e^{\color{blue}{\left(-\tan x\right) \cdot \tan x + 1}}\right)}{\mathsf{fma}\left(\tan x, \tan x, 1\right)}\]
  7. Applied exp-sum1.1

    \[\leadsto \frac{\log \color{blue}{\left(e^{\left(-\tan x\right) \cdot \tan x} \cdot e^{1}\right)}}{\mathsf{fma}\left(\tan x, \tan x, 1\right)}\]
  8. Final simplification1.1

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

Reproduce

herbie shell --seed 2019195 +o rules:numerics
(FPCore (x)
  :name "Trigonometry B"
  (/ (- 1.0 (* (tan x) (tan x))) (+ 1.0 (* (tan x) (tan x)))))