Average Error: 0.3 → 0.4
Time: 5.1s
Precision: 64
\[\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}\]
\[\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sqrt{1} + \tan x}{\frac{1 + \tan x \cdot \tan x}{\sqrt{1} - \tan x}}\right)\right)\]
\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}
\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sqrt{1} + \tan x}{\frac{1 + \tan x \cdot \tan x}{\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 expm1(log1p(((sqrt(1.0) + tan(x)) / ((1.0 + (tan(x) * tan(x))) / (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 expm1-log1p-u0.4

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

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

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

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

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

Reproduce

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