Average Error: 0.3 → 0.4
Time: 1.1m
Precision: 64
\[\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}\]
\[\left(1 + \tan x\right) \cdot \frac{1 - \tan x}{\mathsf{fma}\left(\tan x, \tan x, 1\right)}\]
\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}
\left(1 + \tan x\right) \cdot \frac{1 - \tan x}{\mathsf{fma}\left(\tan x, \tan x, 1\right)}
double f(double x) {
        double r701228 = 1.0;
        double r701229 = x;
        double r701230 = tan(r701229);
        double r701231 = r701230 * r701230;
        double r701232 = r701228 - r701231;
        double r701233 = r701228 + r701231;
        double r701234 = r701232 / r701233;
        return r701234;
}

double f(double x) {
        double r701235 = 1.0;
        double r701236 = x;
        double r701237 = tan(r701236);
        double r701238 = r701235 + r701237;
        double r701239 = r701235 - r701237;
        double r701240 = fma(r701237, r701237, r701235);
        double r701241 = r701239 / r701240;
        double r701242 = r701238 * r701241;
        return r701242;
}

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

    \[\leadsto \frac{\color{blue}{1 \cdot 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(1 + \tan x\right) \cdot \left(1 - \tan x\right)}}{1 \cdot \left(1 + \tan x \cdot \tan x\right)}\]
  6. Applied times-frac0.4

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

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

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

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

Reproduce

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