Average Error: 0.3 → 0.4
Time: 22.7s
Precision: 64
\[\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}\]
\[\mathsf{expm1}\left(\log \left(1 + \frac{1 - \tan x \cdot \tan x}{\tan x \cdot \tan x + 1}\right)\right)\]
\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}
\mathsf{expm1}\left(\log \left(1 + \frac{1 - \tan x \cdot \tan x}{\tan x \cdot \tan x + 1}\right)\right)
double f(double x) {
        double r918636 = 1.0;
        double r918637 = x;
        double r918638 = tan(r918637);
        double r918639 = r918638 * r918638;
        double r918640 = r918636 - r918639;
        double r918641 = r918636 + r918639;
        double r918642 = r918640 / r918641;
        return r918642;
}

double f(double x) {
        double r918643 = 1.0;
        double r918644 = x;
        double r918645 = tan(r918644);
        double r918646 = r918645 * r918645;
        double r918647 = r918643 - r918646;
        double r918648 = r918646 + r918643;
        double r918649 = r918647 / r918648;
        double r918650 = r918643 + r918649;
        double r918651 = log(r918650);
        double r918652 = expm1(r918651);
        return r918652;
}

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 log1p-udef0.4

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

    \[\leadsto \mathsf{expm1}\left(\log \left(1 + \frac{1 - \tan x \cdot \tan x}{\tan x \cdot \tan x + 1}\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)))))