Average Error: 0.3 → 0.4
Time: 31.2s
Precision: 64
\[\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}\]
\[\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\left(\sqrt{1} + \tan x\right) \cdot \left(\sqrt{1} - \tan x\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{\left(\sqrt{1} + \tan x\right) \cdot \left(\sqrt{1} - \tan x\right)}{\mathsf{fma}\left(\tan x, \tan x, 1\right)}\right)\right)
double f(double x) {
        double r23451 = 1.0;
        double r23452 = x;
        double r23453 = tan(r23452);
        double r23454 = r23453 * r23453;
        double r23455 = r23451 - r23454;
        double r23456 = r23451 + r23454;
        double r23457 = r23455 / r23456;
        return r23457;
}

double f(double x) {
        double r23458 = 1.0;
        double r23459 = sqrt(r23458);
        double r23460 = x;
        double r23461 = tan(r23460);
        double r23462 = r23459 + r23461;
        double r23463 = r23459 - r23461;
        double r23464 = r23462 * r23463;
        double r23465 = fma(r23461, r23461, r23458);
        double r23466 = r23464 / r23465;
        double r23467 = log1p(r23466);
        double r23468 = expm1(r23467);
        return r23468;
}

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.3

    \[\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. Using strategy rm
  6. Applied add-sqr-sqrt0.3

    \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{1} \cdot \sqrt{1}} - \tan x \cdot \tan x}{\mathsf{fma}\left(\tan x, \tan x, 1\right)}\right)\right)\]
  7. Applied difference-of-squares0.4

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

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

Reproduce

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