Average Error: 0.3 → 0.4
Time: 21.3s
Precision: 64
\[\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}\]
\[\frac{1}{\mathsf{fma}\left(\tan x, \tan x, 1\right)} \cdot \left(1 - \tan x \cdot \tan x\right)\]
\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}
\frac{1}{\mathsf{fma}\left(\tan x, \tan x, 1\right)} \cdot \left(1 - \tan x \cdot \tan x\right)
double f(double x) {
        double r18396 = 1.0;
        double r18397 = x;
        double r18398 = tan(r18397);
        double r18399 = r18398 * r18398;
        double r18400 = r18396 - r18399;
        double r18401 = r18396 + r18399;
        double r18402 = r18400 / r18401;
        return r18402;
}

double f(double x) {
        double r18403 = 1.0;
        double r18404 = x;
        double r18405 = tan(r18404);
        double r18406 = 1.0;
        double r18407 = fma(r18405, r18405, r18406);
        double r18408 = r18403 / r18407;
        double r18409 = r18405 * r18405;
        double r18410 = r18406 - r18409;
        double r18411 = r18408 * r18410;
        return r18411;
}

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. Simplified0.3

    \[\leadsto \color{blue}{\frac{1 - \tan x \cdot \tan x}{\mathsf{fma}\left(\tan x, \tan x, 1\right)}}\]
  3. Using strategy rm
  4. Applied clear-num0.4

    \[\leadsto \color{blue}{\frac{1}{\frac{\mathsf{fma}\left(\tan x, \tan x, 1\right)}{1 - \tan x \cdot \tan x}}}\]
  5. Using strategy rm
  6. Applied div-inv0.4

    \[\leadsto \frac{1}{\color{blue}{\mathsf{fma}\left(\tan x, \tan x, 1\right) \cdot \frac{1}{1 - \tan x \cdot \tan x}}}\]
  7. Applied add-cube-cbrt0.4

    \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{\mathsf{fma}\left(\tan x, \tan x, 1\right) \cdot \frac{1}{1 - \tan x \cdot \tan x}}\]
  8. Applied times-frac0.4

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

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

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

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

Reproduce

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