Average Error: 0.3 → 0.4
Time: 10.2s
Precision: 64
\[\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}\]
\[\frac{\mathsf{fma}\left(\tan x, \sqrt{1}, 1\right) + \left(-\tan x\right) \cdot \left(\sqrt{1} + \tan x\right)}{1 + \tan x \cdot \tan x}\]
\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}
\frac{\mathsf{fma}\left(\tan x, \sqrt{1}, 1\right) + \left(-\tan x\right) \cdot \left(\sqrt{1} + \tan x\right)}{1 + \tan x \cdot \tan x}
double f(double x) {
        double r11830 = 1.0;
        double r11831 = x;
        double r11832 = tan(r11831);
        double r11833 = r11832 * r11832;
        double r11834 = r11830 - r11833;
        double r11835 = r11830 + r11833;
        double r11836 = r11834 / r11835;
        return r11836;
}

double f(double x) {
        double r11837 = x;
        double r11838 = tan(r11837);
        double r11839 = 1.0;
        double r11840 = sqrt(r11839);
        double r11841 = fma(r11838, r11840, r11839);
        double r11842 = -r11838;
        double r11843 = r11840 + r11838;
        double r11844 = r11842 * r11843;
        double r11845 = r11841 + r11844;
        double r11846 = r11838 * r11838;
        double r11847 = r11839 + r11846;
        double r11848 = r11845 / r11847;
        return r11848;
}

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 add-sqr-sqrt0.3

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

    \[\leadsto \frac{\color{blue}{\left(\sqrt{1} + \tan x\right) \cdot \left(\sqrt{1} - \tan x\right)}}{1 + \tan x \cdot \tan x}\]
  5. Using strategy rm
  6. Applied sub-neg0.4

    \[\leadsto \frac{\left(\sqrt{1} + \tan x\right) \cdot \color{blue}{\left(\sqrt{1} + \left(-\tan x\right)\right)}}{1 + \tan x \cdot \tan x}\]
  7. Applied distribute-lft-in0.4

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

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

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

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

Reproduce

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