Average Error: 30.2 → 7.8
Time: 18.6s
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 r1285776 = x;
        double r1285777 = atan(r1285776);
        double r1285778 = z;
        double r1285779 = r1285777 + r1285778;
        double r1285780 = tan(r1285779);
        return r1285780;
}

double f(double x, double z) {
        double r1285781 = z;
        double r1285782 = -5.127387873861142e-23;
        bool r1285783 = r1285781 <= r1285782;
        double r1285784 = 4.291367477449918e-45;
        bool r1285785 = r1285781 <= r1285784;
        double r1285786 = !r1285785;
        bool r1285787 = r1285783 || r1285786;
        double r1285788 = x;
        double r1285789 = atan(r1285788);
        double r1285790 = tan(r1285789);
        double r1285791 = tan(r1285781);
        double r1285792 = r1285790 + r1285791;
        double r1285793 = 1.0;
        double r1285794 = r1285790 * r1285791;
        double r1285795 = r1285794 * r1285794;
        double r1285796 = r1285793 - r1285795;
        double r1285797 = r1285792 / r1285796;
        double r1285798 = r1285793 + r1285794;
        double r1285799 = r1285797 * r1285798;
        double r1285800 = r1285788 + r1285791;
        double r1285801 = r1285793 - r1285794;
        double r1285802 = r1285800 / r1285801;
        double r1285803 = r1285787 ? r1285799 : r1285802;
        return r1285803;
}

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)))