Average Error: 0.3 → 0.4
Time: 5.7s
Precision: 64
\[\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}\]
\[\frac{1 - \sqrt{\frac{\tan x \cdot \sin x}{\cos x}} \cdot \sqrt{\frac{\tan x \cdot \sin x}{\cos x}}}{1 + \tan x \cdot \tan x}\]
\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}
\frac{1 - \sqrt{\frac{\tan x \cdot \sin x}{\cos x}} \cdot \sqrt{\frac{\tan x \cdot \sin x}{\cos x}}}{1 + \tan x \cdot \tan x}
double f(double x) {
        double r14622 = 1.0;
        double r14623 = x;
        double r14624 = tan(r14623);
        double r14625 = r14624 * r14624;
        double r14626 = r14622 - r14625;
        double r14627 = r14622 + r14625;
        double r14628 = r14626 / r14627;
        return r14628;
}

double f(double x) {
        double r14629 = 1.0;
        double r14630 = x;
        double r14631 = tan(r14630);
        double r14632 = sin(r14630);
        double r14633 = r14631 * r14632;
        double r14634 = cos(r14630);
        double r14635 = r14633 / r14634;
        double r14636 = sqrt(r14635);
        double r14637 = r14636 * r14636;
        double r14638 = r14629 - r14637;
        double r14639 = r14631 * r14631;
        double r14640 = r14629 + r14639;
        double r14641 = r14638 / r14640;
        return r14641;
}

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 tan-quot0.4

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

    \[\leadsto \frac{1 - \color{blue}{\frac{\tan x \cdot \sin x}{\cos x}}}{1 + \tan x \cdot \tan x}\]
  5. Using strategy rm
  6. Applied add-sqr-sqrt0.4

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

    \[\leadsto \frac{1 - \sqrt{\frac{\tan x \cdot \sin x}{\cos x}} \cdot \sqrt{\frac{\tan x \cdot \sin x}{\cos x}}}{1 + \tan x \cdot \tan x}\]

Reproduce

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