Average Error: 0.3 → 0.4
Time: 4.9s
Precision: 64
\[\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}\]
\[\frac{1 - \frac{{\left(\sin x\right)}^{2}}{{\left(\cos x\right)}^{2}}}{\frac{{\left(\sin x\right)}^{2}}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(\cos x\right)}^{2}\right)\right)} + 1}\]
\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}
\frac{1 - \frac{{\left(\sin x\right)}^{2}}{{\left(\cos x\right)}^{2}}}{\frac{{\left(\sin x\right)}^{2}}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(\cos x\right)}^{2}\right)\right)} + 1}
double f(double x) {
        double r8481 = 1.0;
        double r8482 = x;
        double r8483 = tan(r8482);
        double r8484 = r8483 * r8483;
        double r8485 = r8481 - r8484;
        double r8486 = r8481 + r8484;
        double r8487 = r8485 / r8486;
        return r8487;
}

double f(double x) {
        double r8488 = 1.0;
        double r8489 = x;
        double r8490 = sin(r8489);
        double r8491 = 2.0;
        double r8492 = pow(r8490, r8491);
        double r8493 = cos(r8489);
        double r8494 = pow(r8493, r8491);
        double r8495 = r8492 / r8494;
        double r8496 = r8488 - r8495;
        double r8497 = log1p(r8494);
        double r8498 = expm1(r8497);
        double r8499 = r8492 / r8498;
        double r8500 = r8499 + r8488;
        double r8501 = r8496 / r8500;
        return r8501;
}

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. Taylor expanded around inf 0.4

    \[\leadsto \color{blue}{\frac{1 - \frac{{\left(\sin x\right)}^{2}}{{\left(\cos x\right)}^{2}}}{\frac{{\left(\sin x\right)}^{2}}{{\left(\cos x\right)}^{2}} + 1}}\]
  3. Using strategy rm
  4. Applied expm1-log1p-u0.4

    \[\leadsto \frac{1 - \frac{{\left(\sin x\right)}^{2}}{{\left(\cos x\right)}^{2}}}{\frac{{\left(\sin x\right)}^{2}}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(\cos x\right)}^{2}\right)\right)}} + 1}\]
  5. Final simplification0.4

    \[\leadsto \frac{1 - \frac{{\left(\sin x\right)}^{2}}{{\left(\cos x\right)}^{2}}}{\frac{{\left(\sin x\right)}^{2}}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(\cos x\right)}^{2}\right)\right)} + 1}\]

Reproduce

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