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{\left(1 + \tan x\right) \cdot \left(1 - \tan x\right)}{1 + \tan x \cdot \tan x}\]
\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}
\frac{\left(1 + \tan x\right) \cdot \left(1 - \tan x\right)}{1 + \tan x \cdot \tan x}
double f(double x) {
        double r2725161 = 1.0;
        double r2725162 = x;
        double r2725163 = tan(r2725162);
        double r2725164 = r2725163 * r2725163;
        double r2725165 = r2725161 - r2725164;
        double r2725166 = r2725161 + r2725164;
        double r2725167 = r2725165 / r2725166;
        return r2725167;
}

double f(double x) {
        double r2725168 = 1.0;
        double r2725169 = x;
        double r2725170 = tan(r2725169);
        double r2725171 = r2725168 + r2725170;
        double r2725172 = r2725168 - r2725170;
        double r2725173 = r2725171 * r2725172;
        double r2725174 = r2725170 * r2725170;
        double r2725175 = r2725168 + r2725174;
        double r2725176 = r2725173 / r2725175;
        return r2725176;
}

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. Final simplification0.4

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

Reproduce

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