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 r10339 = 1.0;
        double r10340 = x;
        double r10341 = tan(r10340);
        double r10342 = r10341 * r10341;
        double r10343 = r10339 - r10342;
        double r10344 = r10339 + r10342;
        double r10345 = r10343 / r10344;
        return r10345;
}

double f(double x) {
        double r10346 = 1.0;
        double r10347 = x;
        double r10348 = sin(r10347);
        double r10349 = 2.0;
        double r10350 = pow(r10348, r10349);
        double r10351 = cos(r10347);
        double r10352 = pow(r10351, r10349);
        double r10353 = r10350 / r10352;
        double r10354 = r10346 - r10353;
        double r10355 = log1p(r10352);
        double r10356 = expm1(r10355);
        double r10357 = r10350 / r10356;
        double r10358 = r10357 + r10346;
        double r10359 = r10354 / r10358;
        return r10359;
}

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 2020025 +o rules:numerics
(FPCore (x)
  :name "Trigonometry B"
  :precision binary64
  (/ (- 1 (* (tan x) (tan x))) (+ 1 (* (tan x) (tan x)))))