Average Error: 0.3 → 0.4
Time: 19.5s
Precision: 64
\[\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}\]
\[\left(1 - \tan x \cdot \tan x\right) \cdot \frac{1}{\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 \cdot \tan x\right) \cdot \frac{1}{\mathsf{fma}\left(\tan x, \tan x, 1\right)}
double f(double x) {
        double r19558 = 1.0;
        double r19559 = x;
        double r19560 = tan(r19559);
        double r19561 = r19560 * r19560;
        double r19562 = r19558 - r19561;
        double r19563 = r19558 + r19561;
        double r19564 = r19562 / r19563;
        return r19564;
}

double f(double x) {
        double r19565 = 1.0;
        double r19566 = x;
        double r19567 = tan(r19566);
        double r19568 = r19567 * r19567;
        double r19569 = r19565 - r19568;
        double r19570 = 1.0;
        double r19571 = fma(r19567, r19567, r19565);
        double r19572 = r19570 / r19571;
        double r19573 = r19569 * r19572;
        return r19573;
}

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 div-inv0.4

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

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

Reproduce

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