Average Error: 31.3 → 14.2
Time: 4.0m
Precision: 64
\[e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \sin \left(\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\]
\[\begin{array}{l} \mathbf{if}\;x.re \le -2.1926437389321017 \cdot 10^{-08}:\\ \;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \cdot \sin \left(\log \left(-x.re\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\\ \mathbf{elif}\;x.re \le -3.9968547506010115 \cdot 10^{-223}:\\ \;\;\;\;e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \cdot \sin \left(\log \left(\sqrt{\sqrt[3]{x.re \cdot x.re + x.im \cdot x.im}} \cdot \left|\sqrt[3]{x.re \cdot x.re + x.im \cdot x.im}\right|\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\\ \mathbf{elif}\;x.re \le -8.450724337994202 \cdot 10^{-246}:\\ \;\;\;\;\sin \left(\sqrt{\log \left(-x.re\right) \cdot y.im} \cdot \sqrt{\log \left(-x.re\right) \cdot y.im} + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) \cdot e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\ \mathbf{else}:\\ \;\;\;\;e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \cdot \sin \left(\log \left(\sqrt{\sqrt[3]{x.re \cdot x.re + x.im \cdot x.im}} \cdot \left|\sqrt[3]{x.re \cdot x.re + x.im \cdot x.im}\right|\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\\ \end{array}\]
e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \sin \left(\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)
\begin{array}{l}
\mathbf{if}\;x.re \le -2.1926437389321017 \cdot 10^{-08}:\\
\;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \cdot \sin \left(\log \left(-x.re\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\\

\mathbf{elif}\;x.re \le -3.9968547506010115 \cdot 10^{-223}:\\
\;\;\;\;e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \cdot \sin \left(\log \left(\sqrt{\sqrt[3]{x.re \cdot x.re + x.im \cdot x.im}} \cdot \left|\sqrt[3]{x.re \cdot x.re + x.im \cdot x.im}\right|\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\\

\mathbf{elif}\;x.re \le -8.450724337994202 \cdot 10^{-246}:\\
\;\;\;\;\sin \left(\sqrt{\log \left(-x.re\right) \cdot y.im} \cdot \sqrt{\log \left(-x.re\right) \cdot y.im} + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) \cdot e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\

\mathbf{else}:\\
\;\;\;\;e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \cdot \sin \left(\log \left(\sqrt{\sqrt[3]{x.re \cdot x.re + x.im \cdot x.im}} \cdot \left|\sqrt[3]{x.re \cdot x.re + x.im \cdot x.im}\right|\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\\

\end{array}
double f(double x_re, double x_im, double y_re, double y_im) {
        double r804347 = x_re;
        double r804348 = r804347 * r804347;
        double r804349 = x_im;
        double r804350 = r804349 * r804349;
        double r804351 = r804348 + r804350;
        double r804352 = sqrt(r804351);
        double r804353 = log(r804352);
        double r804354 = y_re;
        double r804355 = r804353 * r804354;
        double r804356 = atan2(r804349, r804347);
        double r804357 = y_im;
        double r804358 = r804356 * r804357;
        double r804359 = r804355 - r804358;
        double r804360 = exp(r804359);
        double r804361 = r804353 * r804357;
        double r804362 = r804356 * r804354;
        double r804363 = r804361 + r804362;
        double r804364 = sin(r804363);
        double r804365 = r804360 * r804364;
        return r804365;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r804366 = x_re;
        double r804367 = -2.1926437389321017e-08;
        bool r804368 = r804366 <= r804367;
        double r804369 = -r804366;
        double r804370 = log(r804369);
        double r804371 = y_re;
        double r804372 = r804370 * r804371;
        double r804373 = y_im;
        double r804374 = x_im;
        double r804375 = atan2(r804374, r804366);
        double r804376 = r804373 * r804375;
        double r804377 = r804372 - r804376;
        double r804378 = exp(r804377);
        double r804379 = r804370 * r804373;
        double r804380 = r804375 * r804371;
        double r804381 = r804379 + r804380;
        double r804382 = sin(r804381);
        double r804383 = r804378 * r804382;
        double r804384 = -3.9968547506010115e-223;
        bool r804385 = r804366 <= r804384;
        double r804386 = r804366 * r804366;
        double r804387 = r804374 * r804374;
        double r804388 = r804386 + r804387;
        double r804389 = sqrt(r804388);
        double r804390 = log(r804389);
        double r804391 = r804390 * r804371;
        double r804392 = r804391 - r804376;
        double r804393 = exp(r804392);
        double r804394 = cbrt(r804388);
        double r804395 = sqrt(r804394);
        double r804396 = fabs(r804394);
        double r804397 = r804395 * r804396;
        double r804398 = log(r804397);
        double r804399 = r804398 * r804373;
        double r804400 = r804399 + r804380;
        double r804401 = sin(r804400);
        double r804402 = r804393 * r804401;
        double r804403 = -8.450724337994202e-246;
        bool r804404 = r804366 <= r804403;
        double r804405 = sqrt(r804379);
        double r804406 = r804405 * r804405;
        double r804407 = r804406 + r804380;
        double r804408 = sin(r804407);
        double r804409 = r804408 * r804393;
        double r804410 = r804404 ? r804409 : r804402;
        double r804411 = r804385 ? r804402 : r804410;
        double r804412 = r804368 ? r804383 : r804411;
        return r804412;
}

Error

Bits error versus x.re

Bits error versus x.im

Bits error versus y.re

Bits error versus y.im

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if x.re < -2.1926437389321017e-08

    1. Initial program 39.2

      \[e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \sin \left(\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\]
    2. Taylor expanded around -inf 15.0

      \[\leadsto e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \sin \left(\log \color{blue}{\left(-1 \cdot x.re\right)} \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\]
    3. Simplified15.0

      \[\leadsto e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \sin \left(\log \color{blue}{\left(-x.re\right)} \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\]
    4. Taylor expanded around -inf 5.4

      \[\leadsto e^{\log \color{blue}{\left(-1 \cdot x.re\right)} \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \sin \left(\log \left(-x.re\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\]
    5. Simplified5.4

      \[\leadsto e^{\log \color{blue}{\left(-x.re\right)} \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \sin \left(\log \left(-x.re\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\]

    if -2.1926437389321017e-08 < x.re < -3.9968547506010115e-223 or -8.450724337994202e-246 < x.re

    1. Initial program 22.1

      \[e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \sin \left(\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\]
    2. Using strategy rm
    3. Applied add-cube-cbrt22.1

      \[\leadsto e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \sin \left(\log \left(\sqrt{\color{blue}{\left(\sqrt[3]{x.re \cdot x.re + x.im \cdot x.im} \cdot \sqrt[3]{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot \sqrt[3]{x.re \cdot x.re + x.im \cdot x.im}}}\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\]
    4. Applied sqrt-prod22.1

      \[\leadsto e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \sin \left(\log \color{blue}{\left(\sqrt{\sqrt[3]{x.re \cdot x.re + x.im \cdot x.im} \cdot \sqrt[3]{x.re \cdot x.re + x.im \cdot x.im}} \cdot \sqrt{\sqrt[3]{x.re \cdot x.re + x.im \cdot x.im}}\right)} \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\]
    5. Simplified22.1

      \[\leadsto e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \sin \left(\log \left(\color{blue}{\left|\sqrt[3]{x.re \cdot x.re + x.im \cdot x.im}\right|} \cdot \sqrt{\sqrt[3]{x.re \cdot x.re + x.im \cdot x.im}}\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\]

    if -3.9968547506010115e-223 < x.re < -8.450724337994202e-246

    1. Initial program 32.6

      \[e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \sin \left(\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\]
    2. Taylor expanded around -inf 20.8

      \[\leadsto e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \sin \left(\log \color{blue}{\left(-1 \cdot x.re\right)} \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\]
    3. Simplified20.8

      \[\leadsto e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \sin \left(\log \color{blue}{\left(-x.re\right)} \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\]
    4. Using strategy rm
    5. Applied add-sqr-sqrt39.9

      \[\leadsto e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \sin \left(\color{blue}{\sqrt{\log \left(-x.re\right) \cdot y.im} \cdot \sqrt{\log \left(-x.re\right) \cdot y.im}} + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\]
  3. Recombined 3 regimes into one program.
  4. Final simplification14.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \le -2.1926437389321017 \cdot 10^{-08}:\\ \;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \cdot \sin \left(\log \left(-x.re\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\\ \mathbf{elif}\;x.re \le -3.9968547506010115 \cdot 10^{-223}:\\ \;\;\;\;e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \cdot \sin \left(\log \left(\sqrt{\sqrt[3]{x.re \cdot x.re + x.im \cdot x.im}} \cdot \left|\sqrt[3]{x.re \cdot x.re + x.im \cdot x.im}\right|\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\\ \mathbf{elif}\;x.re \le -8.450724337994202 \cdot 10^{-246}:\\ \;\;\;\;\sin \left(\sqrt{\log \left(-x.re\right) \cdot y.im} \cdot \sqrt{\log \left(-x.re\right) \cdot y.im} + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) \cdot e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\ \mathbf{else}:\\ \;\;\;\;e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \cdot \sin \left(\log \left(\sqrt{\sqrt[3]{x.re \cdot x.re + x.im \cdot x.im}} \cdot \left|\sqrt[3]{x.re \cdot x.re + x.im \cdot x.im}\right|\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019125 
(FPCore (x.re x.im y.re y.im)
  :name "powComplex, imaginary part"
  (* (exp (- (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re) (* (atan2 x.im x.re) y.im))) (sin (+ (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.im) (* (atan2 x.im x.re) y.re)))))