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 r2662456 = 1.0;
        double r2662457 = x;
        double r2662458 = tan(r2662457);
        double r2662459 = r2662458 * r2662458;
        double r2662460 = r2662456 - r2662459;
        double r2662461 = r2662456 + r2662459;
        double r2662462 = r2662460 / r2662461;
        return r2662462;
}

double f(double x) {
        double r2662463 = 1.0;
        double r2662464 = x;
        double r2662465 = tan(r2662464);
        double r2662466 = r2662463 + r2662465;
        double r2662467 = r2662465 * r2662465;
        double r2662468 = r2662463 + r2662467;
        double r2662469 = r2662463 - r2662465;
        double r2662470 = r2662468 / r2662469;
        double r2662471 = r2662466 / r2662470;
        return r2662471;
}

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 +o rules:numerics
(FPCore (x)
  :name "Trigonometry B"
  (/ (- 1 (* (tan x) (tan x))) (+ 1 (* (tan x) (tan x)))))