Average Error: 0.3 → 0.3
Time: 2.1m
Precision: 64
\[\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}\]
\[\frac{1 - \tan x \cdot \tan x}{\mathsf{fma}\left(\left(\tan x\right), \left(\tan x\right), 1\right)}\]
\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}
\frac{1 - \tan x \cdot \tan x}{\mathsf{fma}\left(\left(\tan x\right), \left(\tan x\right), 1\right)}
double f(double x) {
        double r5014025 = 1.0;
        double r5014026 = x;
        double r5014027 = tan(r5014026);
        double r5014028 = r5014027 * r5014027;
        double r5014029 = r5014025 - r5014028;
        double r5014030 = r5014025 + r5014028;
        double r5014031 = r5014029 / r5014030;
        return r5014031;
}

double f(double x) {
        double r5014032 = 1.0;
        double r5014033 = x;
        double r5014034 = tan(r5014033);
        double r5014035 = r5014034 * r5014034;
        double r5014036 = r5014032 - r5014035;
        double r5014037 = fma(r5014034, r5014034, r5014032);
        double r5014038 = r5014036 / r5014037;
        return r5014038;
}

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{\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. Using strategy rm
  6. Applied flip-+0.3

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

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

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

    \[\leadsto \frac{\left(1 \cdot 1 - \tan x \cdot \tan x\right) \cdot \left(1 - \tan x\right)}{\color{blue}{\mathsf{fma}\left(\left(\tan x \cdot \tan x\right), \left(1 - \tan x\right), \left(1 - \tan x\right)\right)}}\]
  10. Using strategy rm
  11. Applied associate-/l*0.3

    \[\leadsto \color{blue}{\frac{1 \cdot 1 - \tan x \cdot \tan x}{\frac{\mathsf{fma}\left(\left(\tan x \cdot \tan x\right), \left(1 - \tan x\right), \left(1 - \tan x\right)\right)}{1 - \tan x}}}\]
  12. Simplified0.3

    \[\leadsto \frac{1 \cdot 1 - \tan x \cdot \tan x}{\color{blue}{\mathsf{fma}\left(\left(\tan x\right), \left(\tan x\right), 1\right)}}\]
  13. Final simplification0.3

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

Reproduce

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