Average Error: 0.3 → 0.4
Time: 5.5s
Precision: 64
\[\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}\]
\[\frac{1}{1 + \frac{\tan x \cdot \sin x}{\cos x}} - \frac{\tan x \cdot \tan x}{1 + \tan x \cdot \tan x}\]
\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}
\frac{1}{1 + \frac{\tan x \cdot \sin x}{\cos x}} - \frac{\tan x \cdot \tan x}{1 + \tan x \cdot \tan x}
double f(double x) {
        double r12807 = 1.0;
        double r12808 = x;
        double r12809 = tan(r12808);
        double r12810 = r12809 * r12809;
        double r12811 = r12807 - r12810;
        double r12812 = r12807 + r12810;
        double r12813 = r12811 / r12812;
        return r12813;
}

double f(double x) {
        double r12814 = 1.0;
        double r12815 = x;
        double r12816 = tan(r12815);
        double r12817 = sin(r12815);
        double r12818 = r12816 * r12817;
        double r12819 = cos(r12815);
        double r12820 = r12818 / r12819;
        double r12821 = r12814 + r12820;
        double r12822 = r12814 / r12821;
        double r12823 = r12816 * r12816;
        double r12824 = r12814 + r12823;
        double r12825 = r12823 / r12824;
        double r12826 = r12822 - r12825;
        return r12826;
}

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-sub0.4

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

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

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

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

Reproduce

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