Average Error: 0.3 → 0.4
Time: 5.3s
Precision: 64
\[\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}\]
\[\left(1 - \frac{\tan x \cdot \sin x}{\cos x}\right) \cdot \frac{1}{1 + \tan x \cdot \tan x}\]
\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}
\left(1 - \frac{\tan x \cdot \sin x}{\cos x}\right) \cdot \frac{1}{1 + \tan x \cdot \tan x}
double f(double x) {
        double r12262 = 1.0;
        double r12263 = x;
        double r12264 = tan(r12263);
        double r12265 = r12264 * r12264;
        double r12266 = r12262 - r12265;
        double r12267 = r12262 + r12265;
        double r12268 = r12266 / r12267;
        return r12268;
}

double f(double x) {
        double r12269 = 1.0;
        double r12270 = x;
        double r12271 = tan(r12270);
        double r12272 = sin(r12270);
        double r12273 = r12271 * r12272;
        double r12274 = cos(r12270);
        double r12275 = r12273 / r12274;
        double r12276 = r12269 - r12275;
        double r12277 = 1.0;
        double r12278 = r12271 * r12271;
        double r12279 = r12269 + r12278;
        double r12280 = r12277 / r12279;
        double r12281 = r12276 * r12280;
        return r12281;
}

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 div-inv0.4

    \[\leadsto \color{blue}{\left(1 - \tan x \cdot \tan x\right) \cdot \frac{1}{1 + \tan x \cdot \tan x}}\]
  4. Using strategy rm
  5. Applied tan-quot0.4

    \[\leadsto \left(1 - \tan x \cdot \color{blue}{\frac{\sin x}{\cos x}}\right) \cdot \frac{1}{1 + \tan x \cdot \tan x}\]
  6. Applied associate-*r/0.4

    \[\leadsto \left(1 - \color{blue}{\frac{\tan x \cdot \sin x}{\cos x}}\right) \cdot \frac{1}{1 + \tan x \cdot \tan x}\]
  7. Final simplification0.4

    \[\leadsto \left(1 - \frac{\tan x \cdot \sin x}{\cos x}\right) \cdot \frac{1}{1 + \tan x \cdot \tan x}\]

Reproduce

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