Average Error: 0.3 → 0.3
Time: 12.9s
Precision: binary64
\[\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x} \]
\[\frac{\mathsf{fma}\left(\tan x, \tan x, -1\right)}{-\mathsf{fma}\left(\tan x, \tan x, 1\right)} \]
\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}
\frac{\mathsf{fma}\left(\tan x, \tan x, -1\right)}{-\mathsf{fma}\left(\tan x, \tan x, 1\right)}
(FPCore (x)
 :precision binary64
 (/ (- 1.0 (* (tan x) (tan x))) (+ 1.0 (* (tan x) (tan x)))))
(FPCore (x)
 :precision binary64
 (/ (fma (tan x) (tan x) -1.0) (- (fma (tan x) (tan x) 1.0))))
double code(double x) {
	return (1.0 - (tan(x) * tan(x))) / (1.0 + (tan(x) * tan(x)));
}
double code(double x) {
	return fma(tan(x), tan(x), -1.0) / -fma(tan(x), tan(x), 1.0);
}

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. Applied frac-2neg_binary640.3

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

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

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

Reproduce

herbie shell --seed 2021275 
(FPCore (x)
  :name "Trigonometry B"
  :precision binary64
  (/ (- 1.0 (* (tan x) (tan x))) (+ 1.0 (* (tan x) (tan x)))))