Average Error: 0.3 → 0.4
Time: 8.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}}{{\left(\cos x\right)}^{2}} + 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}}{{\left(\cos x\right)}^{2}} + 1}
double f(double x) {
        double r13719 = 1.0;
        double r13720 = x;
        double r13721 = tan(r13720);
        double r13722 = r13721 * r13721;
        double r13723 = r13719 - r13722;
        double r13724 = r13719 + r13722;
        double r13725 = r13723 / r13724;
        return r13725;
}

double f(double x) {
        double r13726 = 1.0;
        double r13727 = x;
        double r13728 = sin(r13727);
        double r13729 = 2.0;
        double r13730 = pow(r13728, r13729);
        double r13731 = cos(r13727);
        double r13732 = pow(r13731, r13729);
        double r13733 = r13730 / r13732;
        double r13734 = r13726 - r13733;
        double r13735 = r13733 + r13726;
        double r13736 = r13734 / r13735;
        return r13736;
}

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

    \[\leadsto \color{blue}{\frac{1 - \tan x \cdot \tan x}{\mathsf{fma}\left(\tan x, \tan x, 1\right)}}\]
  3. 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}}\]
  4. Final simplification0.4

    \[\leadsto \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}\]

Reproduce

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