Average Error: 0.3 → 0.4
Time: 22.2s
Precision: 64
\[\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}\]
\[\mathsf{expm1}\left(\log \left(e^{\mathsf{log1p}\left(\frac{1 - \tan x \cdot \tan x}{\tan x \cdot \tan x + 1}\right)}\right)\right)\]
\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}
\mathsf{expm1}\left(\log \left(e^{\mathsf{log1p}\left(\frac{1 - \tan x \cdot \tan x}{\tan x \cdot \tan x + 1}\right)}\right)\right)
double f(double x) {
        double r702695 = 1.0;
        double r702696 = x;
        double r702697 = tan(r702696);
        double r702698 = r702697 * r702697;
        double r702699 = r702695 - r702698;
        double r702700 = r702695 + r702698;
        double r702701 = r702699 / r702700;
        return r702701;
}

double f(double x) {
        double r702702 = 1.0;
        double r702703 = x;
        double r702704 = tan(r702703);
        double r702705 = r702704 * r702704;
        double r702706 = r702702 - r702705;
        double r702707 = r702705 + r702702;
        double r702708 = r702706 / r702707;
        double r702709 = log1p(r702708);
        double r702710 = exp(r702709);
        double r702711 = log(r702710);
        double r702712 = expm1(r702711);
        return r702712;
}

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-log-exp0.4

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

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

Reproduce

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