Average Error: 0.3 → 0.4
Time: 15.4s
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 r20478 = 1.0;
        double r20479 = x;
        double r20480 = tan(r20479);
        double r20481 = r20480 * r20480;
        double r20482 = r20478 - r20481;
        double r20483 = r20478 + r20481;
        double r20484 = r20482 / r20483;
        return r20484;
}

double f(double x) {
        double r20485 = 1.0;
        double r20486 = x;
        double r20487 = sin(r20486);
        double r20488 = 2.0;
        double r20489 = pow(r20487, r20488);
        double r20490 = cos(r20486);
        double r20491 = pow(r20490, r20488);
        double r20492 = r20489 / r20491;
        double r20493 = r20485 - r20492;
        double r20494 = log1p(r20491);
        double r20495 = expm1(r20494);
        double r20496 = r20489 / r20495;
        double r20497 = r20496 + r20485;
        double r20498 = r20493 / r20497;
        return r20498;
}

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