Average Error: 0.3 → 0.4
Time: 6.6s
Precision: 64
\[\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}\]
\[\left(\sqrt{1} + \tan x\right) \cdot \left(\frac{1}{\mathsf{fma}\left(\tan x, \tan x, 1\right)} \cdot \left(\sqrt{1} - \tan x\right)\right)\]
\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}
\left(\sqrt{1} + \tan x\right) \cdot \left(\frac{1}{\mathsf{fma}\left(\tan x, \tan x, 1\right)} \cdot \left(\sqrt{1} - \tan x\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)) * ((1.0 / fma(tan(x), tan(x), 1.0)) * (sqrt(1.0) - tan(x))));
}

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 clear-num0.4

    \[\leadsto \color{blue}{\frac{1}{\frac{1 + \tan x \cdot \tan x}{1 - \tan x \cdot \tan x}}}\]
  4. Simplified0.4

    \[\leadsto \frac{1}{\color{blue}{\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 associate-/r*0.4

    \[\leadsto \color{blue}{\frac{\frac{1}{\mathsf{fma}\left(\tan x, \tan x, 1\right)}}{\frac{1}{1 - \tan x \cdot \tan x}}}\]
  8. Using strategy rm
  9. Applied add-sqr-sqrt0.4

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

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

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

    \[\leadsto \frac{\frac{1}{\mathsf{fma}\left(\tan x, \tan x, 1\right)}}{\color{blue}{\frac{\sqrt{1}}{\sqrt{1} + \tan x} \cdot \frac{\sqrt{1}}{\sqrt{1} - \tan x}}}\]
  14. Applied *-un-lft-identity0.5

    \[\leadsto \frac{\frac{1}{\color{blue}{1 \cdot \mathsf{fma}\left(\tan x, \tan x, 1\right)}}}{\frac{\sqrt{1}}{\sqrt{1} + \tan x} \cdot \frac{\sqrt{1}}{\sqrt{1} - \tan x}}\]
  15. Applied add-sqr-sqrt0.5

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

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

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

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

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

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

Reproduce

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