Average Error: 0.3 → 0.4
Time: 19.3s
Precision: 64
\[\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}\]
\[\frac{\sqrt{1} + \tan x}{\frac{\mathsf{fma}\left(\tan x, \tan x, 1\right)}{\sqrt{1} - \tan x}}\]
\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}
\frac{\sqrt{1} + \tan x}{\frac{\mathsf{fma}\left(\tan x, \tan x, 1\right)}{\sqrt{1} - \tan x}}
double f(double x) {
        double r27940 = 1.0;
        double r27941 = x;
        double r27942 = tan(r27941);
        double r27943 = r27942 * r27942;
        double r27944 = r27940 - r27943;
        double r27945 = r27940 + r27943;
        double r27946 = r27944 / r27945;
        return r27946;
}

double f(double x) {
        double r27947 = 1.0;
        double r27948 = sqrt(r27947);
        double r27949 = x;
        double r27950 = tan(r27949);
        double r27951 = r27948 + r27950;
        double r27952 = fma(r27950, r27950, r27947);
        double r27953 = r27948 - r27950;
        double r27954 = r27952 / r27953;
        double r27955 = r27951 / r27954;
        return r27955;
}

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

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

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

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

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

Reproduce

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