Average Error: 0.3 → 0.4
Time: 1.2m
Precision: 64
\[\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}\]
\[\frac{1 + \tan x}{\frac{1 + \tan x \cdot \tan x}{1 - \tan x}}\]
\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}
\frac{1 + \tan x}{\frac{1 + \tan x \cdot \tan x}{1 - \tan x}}
double f(double x) {
        double r3023146 = 1.0;
        double r3023147 = x;
        double r3023148 = tan(r3023147);
        double r3023149 = r3023148 * r3023148;
        double r3023150 = r3023146 - r3023149;
        double r3023151 = r3023146 + r3023149;
        double r3023152 = r3023150 / r3023151;
        return r3023152;
}

double f(double x) {
        double r3023153 = 1.0;
        double r3023154 = x;
        double r3023155 = tan(r3023154);
        double r3023156 = r3023153 + r3023155;
        double r3023157 = r3023155 * r3023155;
        double r3023158 = r3023153 + r3023157;
        double r3023159 = r3023153 - r3023155;
        double r3023160 = r3023158 / r3023159;
        double r3023161 = r3023156 / r3023160;
        return r3023161;
}

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 *-un-lft-identity0.3

    \[\leadsto \frac{\color{blue}{1 \cdot 1} - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}\]
  4. Applied difference-of-squares0.4

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

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

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

Reproduce

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