Average Error: 0.3 → 0.4
Time: 5.0s
Precision: 64
\[\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}\]
\[\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}\right)\right)\]
\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}
\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}\right)\right)
double f(double x) {
        double r11629 = 1.0;
        double r11630 = x;
        double r11631 = tan(r11630);
        double r11632 = r11631 * r11631;
        double r11633 = r11629 - r11632;
        double r11634 = r11629 + r11632;
        double r11635 = r11633 / r11634;
        return r11635;
}

double f(double x) {
        double r11636 = 1.0;
        double r11637 = x;
        double r11638 = tan(r11637);
        double r11639 = r11638 * r11638;
        double r11640 = r11636 - r11639;
        double r11641 = r11636 + r11639;
        double r11642 = r11640 / r11641;
        double r11643 = log1p(r11642);
        double r11644 = expm1(r11643);
        return r11644;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 0.3

    \[\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}\]
  2. Using strategy rm
  3. Applied expm1-log1p-u0.4

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

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

Reproduce

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