Average Error: 0.3 → 0.4
Time: 4.9s
Precision: 64
\[\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}\]
\[\frac{1 - \frac{{\left(\sin x\right)}^{2}}{{\left(\cos x\right)}^{2}}}{\frac{{\left(\sin x\right)}^{2}}{\mathsf{log1p}\left(\mathsf{expm1}\left({\left(\cos x\right)}^{2}\right)\right)} + 1}\]
\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}
\frac{1 - \frac{{\left(\sin x\right)}^{2}}{{\left(\cos x\right)}^{2}}}{\frac{{\left(\sin x\right)}^{2}}{\mathsf{log1p}\left(\mathsf{expm1}\left({\left(\cos x\right)}^{2}\right)\right)} + 1}
double f(double x) {
        double r9929 = 1.0;
        double r9930 = x;
        double r9931 = tan(r9930);
        double r9932 = r9931 * r9931;
        double r9933 = r9929 - r9932;
        double r9934 = r9929 + r9932;
        double r9935 = r9933 / r9934;
        return r9935;
}

double f(double x) {
        double r9936 = 1.0;
        double r9937 = x;
        double r9938 = sin(r9937);
        double r9939 = 2.0;
        double r9940 = pow(r9938, r9939);
        double r9941 = cos(r9937);
        double r9942 = pow(r9941, r9939);
        double r9943 = r9940 / r9942;
        double r9944 = r9936 - r9943;
        double r9945 = expm1(r9942);
        double r9946 = log1p(r9945);
        double r9947 = r9940 / r9946;
        double r9948 = r9947 + r9936;
        double r9949 = r9944 / r9948;
        return r9949;
}

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 tan-quot0.4

    \[\leadsto \frac{1 - \tan x \cdot \color{blue}{\frac{\sin x}{\cos x}}}{1 + \tan x \cdot \tan x}\]
  4. Applied associate-*r/0.4

    \[\leadsto \frac{1 - \color{blue}{\frac{\tan x \cdot \sin x}{\cos x}}}{1 + \tan x \cdot \tan x}\]
  5. Taylor expanded around inf 0.4

    \[\leadsto \color{blue}{\frac{1 - \frac{{\left(\sin x\right)}^{2}}{{\left(\cos x\right)}^{2}}}{\frac{{\left(\sin x\right)}^{2}}{{\left(\cos x\right)}^{2}} + 1}}\]
  6. Using strategy rm
  7. Applied log1p-expm1-u0.4

    \[\leadsto \frac{1 - \frac{{\left(\sin x\right)}^{2}}{{\left(\cos x\right)}^{2}}}{\frac{{\left(\sin x\right)}^{2}}{\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left({\left(\cos x\right)}^{2}\right)\right)}} + 1}\]
  8. Final simplification0.4

    \[\leadsto \frac{1 - \frac{{\left(\sin x\right)}^{2}}{{\left(\cos x\right)}^{2}}}{\frac{{\left(\sin x\right)}^{2}}{\mathsf{log1p}\left(\mathsf{expm1}\left({\left(\cos x\right)}^{2}\right)\right)} + 1}\]

Reproduce

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