Average Error: 30.2 → 7.8
Time: 18.9s
Precision: 64
\[\tan \left(\tan^{-1} x + z\right)\]
\[\begin{array}{l} \mathbf{if}\;z \le -5.127387873861141807934827997447987211596 \cdot 10^{-23} \lor \neg \left(z \le 4.291367477449918134219884650765870230149 \cdot 10^{-45}\right):\\ \;\;\;\;\frac{\tan \left(\tan^{-1} x\right) + \tan z}{1 - \left(\tan \left(\tan^{-1} x\right) \cdot \tan z\right) \cdot \left(\tan \left(\tan^{-1} x\right) \cdot \tan z\right)} \cdot \left(1 + \tan \left(\tan^{-1} x\right) \cdot \tan z\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x + \tan z}{1 - \tan \left(\tan^{-1} x\right) \cdot \tan z}\\ \end{array}\]
\tan \left(\tan^{-1} x + z\right)
\begin{array}{l}
\mathbf{if}\;z \le -5.127387873861141807934827997447987211596 \cdot 10^{-23} \lor \neg \left(z \le 4.291367477449918134219884650765870230149 \cdot 10^{-45}\right):\\
\;\;\;\;\frac{\tan \left(\tan^{-1} x\right) + \tan z}{1 - \left(\tan \left(\tan^{-1} x\right) \cdot \tan z\right) \cdot \left(\tan \left(\tan^{-1} x\right) \cdot \tan z\right)} \cdot \left(1 + \tan \left(\tan^{-1} x\right) \cdot \tan z\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{x + \tan z}{1 - \tan \left(\tan^{-1} x\right) \cdot \tan z}\\

\end{array}
double f(double x, double z) {
        double r1263490 = x;
        double r1263491 = atan(r1263490);
        double r1263492 = z;
        double r1263493 = r1263491 + r1263492;
        double r1263494 = tan(r1263493);
        return r1263494;
}

double f(double x, double z) {
        double r1263495 = z;
        double r1263496 = -5.127387873861142e-23;
        bool r1263497 = r1263495 <= r1263496;
        double r1263498 = 4.291367477449918e-45;
        bool r1263499 = r1263495 <= r1263498;
        double r1263500 = !r1263499;
        bool r1263501 = r1263497 || r1263500;
        double r1263502 = x;
        double r1263503 = atan(r1263502);
        double r1263504 = tan(r1263503);
        double r1263505 = tan(r1263495);
        double r1263506 = r1263504 + r1263505;
        double r1263507 = 1.0;
        double r1263508 = r1263504 * r1263505;
        double r1263509 = r1263508 * r1263508;
        double r1263510 = r1263507 - r1263509;
        double r1263511 = r1263506 / r1263510;
        double r1263512 = r1263507 + r1263508;
        double r1263513 = r1263511 * r1263512;
        double r1263514 = r1263502 + r1263505;
        double r1263515 = r1263507 - r1263508;
        double r1263516 = r1263514 / r1263515;
        double r1263517 = r1263501 ? r1263513 : r1263516;
        return r1263517;
}

Error

Bits error versus x

Bits error versus z

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if z < -5.127387873861142e-23 or 4.291367477449918e-45 < z

    1. Initial program 30.4

      \[\tan \left(\tan^{-1} x + z\right)\]
    2. Using strategy rm
    3. Applied tan-sum2.4

      \[\leadsto \color{blue}{\frac{\tan \left(\tan^{-1} x\right) + \tan z}{1 - \tan \left(\tan^{-1} x\right) \cdot \tan z}}\]
    4. Using strategy rm
    5. Applied flip--2.4

      \[\leadsto \frac{\tan \left(\tan^{-1} x\right) + \tan z}{\color{blue}{\frac{1 \cdot 1 - \left(\tan \left(\tan^{-1} x\right) \cdot \tan z\right) \cdot \left(\tan \left(\tan^{-1} x\right) \cdot \tan z\right)}{1 + \tan \left(\tan^{-1} x\right) \cdot \tan z}}}\]
    6. Applied associate-/r/2.4

      \[\leadsto \color{blue}{\frac{\tan \left(\tan^{-1} x\right) + \tan z}{1 \cdot 1 - \left(\tan \left(\tan^{-1} x\right) \cdot \tan z\right) \cdot \left(\tan \left(\tan^{-1} x\right) \cdot \tan z\right)} \cdot \left(1 + \tan \left(\tan^{-1} x\right) \cdot \tan z\right)}\]
    7. Simplified2.4

      \[\leadsto \color{blue}{\frac{\tan \left(\tan^{-1} x\right) + \tan z}{1 - \left(\tan \left(\tan^{-1} x\right) \cdot \tan z\right) \cdot \left(\tan \left(\tan^{-1} x\right) \cdot \tan z\right)}} \cdot \left(1 + \tan \left(\tan^{-1} x\right) \cdot \tan z\right)\]

    if -5.127387873861142e-23 < z < 4.291367477449918e-45

    1. Initial program 30.1

      \[\tan \left(\tan^{-1} x + z\right)\]
    2. Using strategy rm
    3. Applied tan-sum30.1

      \[\leadsto \color{blue}{\frac{\tan \left(\tan^{-1} x\right) + \tan z}{1 - \tan \left(\tan^{-1} x\right) \cdot \tan z}}\]
    4. Using strategy rm
    5. Applied tan-atan14.3

      \[\leadsto \frac{\color{blue}{x} + \tan z}{1 - \tan \left(\tan^{-1} x\right) \cdot \tan z}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification7.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -5.127387873861141807934827997447987211596 \cdot 10^{-23} \lor \neg \left(z \le 4.291367477449918134219884650765870230149 \cdot 10^{-45}\right):\\ \;\;\;\;\frac{\tan \left(\tan^{-1} x\right) + \tan z}{1 - \left(\tan \left(\tan^{-1} x\right) \cdot \tan z\right) \cdot \left(\tan \left(\tan^{-1} x\right) \cdot \tan z\right)} \cdot \left(1 + \tan \left(\tan^{-1} x\right) \cdot \tan z\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x + \tan z}{1 - \tan \left(\tan^{-1} x\right) \cdot \tan z}\\ \end{array}\]

Reproduce

herbie shell --seed 1 
(FPCore (x z)
  :name "tan(atan(x)+z)"
  :precision binary64
  (tan (+ (atan x) z)))