Average Error: 4.9 → 4.2
Time: 10.9s
Precision: 64
\[\tan^{-1} \left(\frac{\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}}{w}\right)\]
\[\begin{array}{l} \mathbf{if}\;x \le 3.406858083458242563862410919771944042967 \cdot 10^{163}:\\ \;\;\;\;\tan^{-1} \left(\frac{\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}}{w}\right)\\ \mathbf{else}:\\ \;\;\;\;\tan^{-1} \left(\frac{x}{w}\right)\\ \end{array}\]
\tan^{-1} \left(\frac{\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}}{w}\right)
\begin{array}{l}
\mathbf{if}\;x \le 3.406858083458242563862410919771944042967 \cdot 10^{163}:\\
\;\;\;\;\tan^{-1} \left(\frac{\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}}{w}\right)\\

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

\end{array}
double f(double x, double y, double z, double w) {
        double r632353 = x;
        double r632354 = r632353 * r632353;
        double r632355 = y;
        double r632356 = r632355 * r632355;
        double r632357 = r632354 + r632356;
        double r632358 = z;
        double r632359 = r632358 * r632358;
        double r632360 = r632357 + r632359;
        double r632361 = sqrt(r632360);
        double r632362 = w;
        double r632363 = r632361 / r632362;
        double r632364 = atan(r632363);
        return r632364;
}

double f(double x, double y, double z, double w) {
        double r632365 = x;
        double r632366 = 3.4068580834582426e+163;
        bool r632367 = r632365 <= r632366;
        double r632368 = r632365 * r632365;
        double r632369 = y;
        double r632370 = r632369 * r632369;
        double r632371 = r632368 + r632370;
        double r632372 = z;
        double r632373 = r632372 * r632372;
        double r632374 = r632371 + r632373;
        double r632375 = sqrt(r632374);
        double r632376 = w;
        double r632377 = r632375 / r632376;
        double r632378 = atan(r632377);
        double r632379 = r632365 / r632376;
        double r632380 = atan(r632379);
        double r632381 = r632367 ? r632378 : r632380;
        return r632381;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus w

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if x < 3.4068580834582426e+163

    1. Initial program 4.5

      \[\tan^{-1} \left(\frac{\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}}{w}\right)\]

    if 3.4068580834582426e+163 < x

    1. Initial program 7.6

      \[\tan^{-1} \left(\frac{\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}}{w}\right)\]
    2. Taylor expanded around inf 2.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le 3.406858083458242563862410919771944042967 \cdot 10^{163}:\\ \;\;\;\;\tan^{-1} \left(\frac{\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}}{w}\right)\\ \mathbf{else}:\\ \;\;\;\;\tan^{-1} \left(\frac{x}{w}\right)\\ \end{array}\]

Reproduce

herbie shell --seed 1 
(FPCore (x y z w)
  :name "atan(sqrt(x * x + y * y + z * z) / w)"
  :precision binary64
  (atan (/ (sqrt (+ (+ (* x x) (* y y)) (* z z))) w)))