Average Error: 0.3 → 0.4
Time: 1.3m
Precision: 64
\[\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}\]
\[\left(\tan x + 1\right) \cdot \frac{1 - \tan x}{(\left(\tan x\right) \cdot \left(\tan x\right) + 1)_*}\]
\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}
\left(\tan x + 1\right) \cdot \frac{1 - \tan x}{(\left(\tan x\right) \cdot \left(\tan x\right) + 1)_*}
double f(double x) {
        double r2705140 = 1.0;
        double r2705141 = x;
        double r2705142 = tan(r2705141);
        double r2705143 = r2705142 * r2705142;
        double r2705144 = r2705140 - r2705143;
        double r2705145 = r2705140 + r2705143;
        double r2705146 = r2705144 / r2705145;
        return r2705146;
}

double f(double x) {
        double r2705147 = x;
        double r2705148 = tan(r2705147);
        double r2705149 = 1.0;
        double r2705150 = r2705148 + r2705149;
        double r2705151 = r2705149 - r2705148;
        double r2705152 = fma(r2705148, r2705148, r2705149);
        double r2705153 = r2705151 / r2705152;
        double r2705154 = r2705150 * r2705153;
        return r2705154;
}

Error

Bits error versus x

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{1 - \tan x \cdot \tan x}{\color{blue}{1 \cdot \left(1 + \tan x \cdot \tan x\right)}}\]
  4. Applied add-sqr-sqrt0.3

    \[\leadsto \frac{\color{blue}{\sqrt{1} \cdot \sqrt{1}} - \tan x \cdot \tan x}{1 \cdot \left(1 + \tan x \cdot \tan x\right)}\]
  5. Applied difference-of-squares0.4

    \[\leadsto \frac{\color{blue}{\left(\sqrt{1} + \tan x\right) \cdot \left(\sqrt{1} - \tan x\right)}}{1 \cdot \left(1 + \tan x \cdot \tan x\right)}\]
  6. Applied times-frac0.4

    \[\leadsto \color{blue}{\frac{\sqrt{1} + \tan x}{1} \cdot \frac{\sqrt{1} - \tan x}{1 + \tan x \cdot \tan x}}\]
  7. Simplified0.4

    \[\leadsto \color{blue}{\left(\tan x + 1\right)} \cdot \frac{\sqrt{1} - \tan x}{1 + \tan x \cdot \tan x}\]
  8. Simplified0.4

    \[\leadsto \left(\tan x + 1\right) \cdot \color{blue}{\frac{1 - \tan x}{(\left(\tan x\right) \cdot \left(\tan x\right) + 1)_*}}\]
  9. Final simplification0.4

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

Reproduce

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