Average Error: 30.3 → 16.8
Time: 20.1s
Precision: 64
\[\sqrt{x \cdot x + z \cdot z} \cdot \tan p\]
\[\begin{array}{l} \mathbf{if}\;x \le -4.353106847248220765480981116455688638575 \cdot 10^{93}:\\ \;\;\;\;\left(-x\right) \cdot \tan p\\ \mathbf{elif}\;x \le 7.787518790332474151078073108624317463486 \cdot 10^{-195}:\\ \;\;\;\;\sin p \cdot \frac{\sqrt{x \cdot x + z \cdot z}}{\cos p}\\ \mathbf{elif}\;x \le 4.105107772534906852048313709346834005589 \cdot 10^{-137}:\\ \;\;\;\;z \cdot \tan p\\ \mathbf{elif}\;x \le 6.007290885134199302953120100178715433948 \cdot 10^{89}:\\ \;\;\;\;\sin p \cdot \frac{\sqrt{x \cdot x + z \cdot z}}{\cos p}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \tan p\\ \end{array}\]
\sqrt{x \cdot x + z \cdot z} \cdot \tan p
\begin{array}{l}
\mathbf{if}\;x \le -4.353106847248220765480981116455688638575 \cdot 10^{93}:\\
\;\;\;\;\left(-x\right) \cdot \tan p\\

\mathbf{elif}\;x \le 7.787518790332474151078073108624317463486 \cdot 10^{-195}:\\
\;\;\;\;\sin p \cdot \frac{\sqrt{x \cdot x + z \cdot z}}{\cos p}\\

\mathbf{elif}\;x \le 4.105107772534906852048313709346834005589 \cdot 10^{-137}:\\
\;\;\;\;z \cdot \tan p\\

\mathbf{elif}\;x \le 6.007290885134199302953120100178715433948 \cdot 10^{89}:\\
\;\;\;\;\sin p \cdot \frac{\sqrt{x \cdot x + z \cdot z}}{\cos p}\\

\mathbf{else}:\\
\;\;\;\;x \cdot \tan p\\

\end{array}
double f(double x, double z, double p) {
        double r3458518 = x;
        double r3458519 = r3458518 * r3458518;
        double r3458520 = z;
        double r3458521 = r3458520 * r3458520;
        double r3458522 = r3458519 + r3458521;
        double r3458523 = sqrt(r3458522);
        double r3458524 = p;
        double r3458525 = tan(r3458524);
        double r3458526 = r3458523 * r3458525;
        return r3458526;
}

double f(double x, double z, double p) {
        double r3458527 = x;
        double r3458528 = -4.353106847248221e+93;
        bool r3458529 = r3458527 <= r3458528;
        double r3458530 = -r3458527;
        double r3458531 = p;
        double r3458532 = tan(r3458531);
        double r3458533 = r3458530 * r3458532;
        double r3458534 = 7.787518790332474e-195;
        bool r3458535 = r3458527 <= r3458534;
        double r3458536 = sin(r3458531);
        double r3458537 = r3458527 * r3458527;
        double r3458538 = z;
        double r3458539 = r3458538 * r3458538;
        double r3458540 = r3458537 + r3458539;
        double r3458541 = sqrt(r3458540);
        double r3458542 = cos(r3458531);
        double r3458543 = r3458541 / r3458542;
        double r3458544 = r3458536 * r3458543;
        double r3458545 = 4.105107772534907e-137;
        bool r3458546 = r3458527 <= r3458545;
        double r3458547 = r3458538 * r3458532;
        double r3458548 = 6.007290885134199e+89;
        bool r3458549 = r3458527 <= r3458548;
        double r3458550 = r3458527 * r3458532;
        double r3458551 = r3458549 ? r3458544 : r3458550;
        double r3458552 = r3458546 ? r3458547 : r3458551;
        double r3458553 = r3458535 ? r3458544 : r3458552;
        double r3458554 = r3458529 ? r3458533 : r3458553;
        return r3458554;
}

Error

Bits error versus x

Bits error versus z

Bits error versus p

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 4 regimes
  2. if x < -4.353106847248221e+93

    1. Initial program 49.4

      \[\sqrt{x \cdot x + z \cdot z} \cdot \tan p\]
    2. Taylor expanded around -inf 10.5

      \[\leadsto \color{blue}{\left(-1 \cdot x\right)} \cdot \tan p\]
    3. Simplified10.5

      \[\leadsto \color{blue}{\left(-x\right)} \cdot \tan p\]

    if -4.353106847248221e+93 < x < 7.787518790332474e-195 or 4.105107772534907e-137 < x < 6.007290885134199e+89

    1. Initial program 19.3

      \[\sqrt{x \cdot x + z \cdot z} \cdot \tan p\]
    2. Using strategy rm
    3. Applied tan-quot19.3

      \[\leadsto \sqrt{x \cdot x + z \cdot z} \cdot \color{blue}{\frac{\sin p}{\cos p}}\]
    4. Applied associate-*r/19.3

      \[\leadsto \color{blue}{\frac{\sqrt{x \cdot x + z \cdot z} \cdot \sin p}{\cos p}}\]
    5. Simplified19.3

      \[\leadsto \frac{\color{blue}{\sin p \cdot \sqrt{x \cdot x + z \cdot z}}}{\cos p}\]
    6. Using strategy rm
    7. Applied *-un-lft-identity19.3

      \[\leadsto \frac{\sin p \cdot \sqrt{x \cdot x + z \cdot z}}{\color{blue}{1 \cdot \cos p}}\]
    8. Applied times-frac19.3

      \[\leadsto \color{blue}{\frac{\sin p}{1} \cdot \frac{\sqrt{x \cdot x + z \cdot z}}{\cos p}}\]
    9. Simplified19.3

      \[\leadsto \color{blue}{\sin p} \cdot \frac{\sqrt{x \cdot x + z \cdot z}}{\cos p}\]

    if 7.787518790332474e-195 < x < 4.105107772534907e-137

    1. Initial program 23.1

      \[\sqrt{x \cdot x + z \cdot z} \cdot \tan p\]
    2. Taylor expanded around 0 34.7

      \[\leadsto \color{blue}{z} \cdot \tan p\]

    if 6.007290885134199e+89 < x

    1. Initial program 49.0

      \[\sqrt{x \cdot x + z \cdot z} \cdot \tan p\]
    2. Taylor expanded around inf 10.8

      \[\leadsto \color{blue}{x} \cdot \tan p\]
  3. Recombined 4 regimes into one program.
  4. Final simplification16.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -4.353106847248220765480981116455688638575 \cdot 10^{93}:\\ \;\;\;\;\left(-x\right) \cdot \tan p\\ \mathbf{elif}\;x \le 7.787518790332474151078073108624317463486 \cdot 10^{-195}:\\ \;\;\;\;\sin p \cdot \frac{\sqrt{x \cdot x + z \cdot z}}{\cos p}\\ \mathbf{elif}\;x \le 4.105107772534906852048313709346834005589 \cdot 10^{-137}:\\ \;\;\;\;z \cdot \tan p\\ \mathbf{elif}\;x \le 6.007290885134199302953120100178715433948 \cdot 10^{89}:\\ \;\;\;\;\sin p \cdot \frac{\sqrt{x \cdot x + z \cdot z}}{\cos p}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \tan p\\ \end{array}\]

Reproduce

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