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

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

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

    \[\leadsto \color{blue}{\left(1 - \tan x \cdot \tan x\right) \cdot \frac{1}{1 + \tan x \cdot \tan x}}\]
  4. Using strategy rm
  5. Applied add-sqr-sqrt0.4

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

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

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

    \[\leadsto \left(\sqrt{1} + \tan x\right) \cdot \color{blue}{\frac{\sqrt{1} - \tan x}{\mathsf{fma}\left(\tan x, \tan x, 1\right)}}\]
  9. Using strategy rm
  10. Applied div-sub0.4

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

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

Reproduce

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