Average Error: 0.8 → 0.5
Time: 11.9s
Precision: 64
\[\frac{\tan^{-1}_* \frac{im}{re}}{\log 10}\]
\[\begin{array}{l} \mathbf{if}\;\frac{\tan^{-1}_* \frac{im}{re}}{\log 10} \le -8.783854077383176606796760781421950863633 \cdot 10^{-38}:\\ \;\;\;\;\sqrt[3]{{\left(\frac{\tan^{-1}_* \frac{im}{re}}{\log 10}\right)}^{3}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\tan^{-1}_* \frac{im}{re}}{\log 10}\right)\right)\\ \end{array}\]
\frac{\tan^{-1}_* \frac{im}{re}}{\log 10}
\begin{array}{l}
\mathbf{if}\;\frac{\tan^{-1}_* \frac{im}{re}}{\log 10} \le -8.783854077383176606796760781421950863633 \cdot 10^{-38}:\\
\;\;\;\;\sqrt[3]{{\left(\frac{\tan^{-1}_* \frac{im}{re}}{\log 10}\right)}^{3}}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\tan^{-1}_* \frac{im}{re}}{\log 10}\right)\right)\\

\end{array}
double f(double re, double im) {
        double r40091 = im;
        double r40092 = re;
        double r40093 = atan2(r40091, r40092);
        double r40094 = 10.0;
        double r40095 = log(r40094);
        double r40096 = r40093 / r40095;
        return r40096;
}

double f(double re, double im) {
        double r40097 = im;
        double r40098 = re;
        double r40099 = atan2(r40097, r40098);
        double r40100 = 10.0;
        double r40101 = log(r40100);
        double r40102 = r40099 / r40101;
        double r40103 = -8.783854077383177e-38;
        bool r40104 = r40102 <= r40103;
        double r40105 = 3.0;
        double r40106 = pow(r40102, r40105);
        double r40107 = cbrt(r40106);
        double r40108 = log1p(r40102);
        double r40109 = expm1(r40108);
        double r40110 = r40104 ? r40107 : r40109;
        return r40110;
}

Error

Bits error versus re

Bits error versus im

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if (/ (atan2 im re) (log 10.0)) < -8.783854077383177e-38

    1. Initial program 1.0

      \[\frac{\tan^{-1}_* \frac{im}{re}}{\log 10}\]
    2. Using strategy rm
    3. Applied add-cbrt-cube1.6

      \[\leadsto \frac{\tan^{-1}_* \frac{im}{re}}{\color{blue}{\sqrt[3]{\left(\log 10 \cdot \log 10\right) \cdot \log 10}}}\]
    4. Applied add-cbrt-cube1.0

      \[\leadsto \frac{\color{blue}{\sqrt[3]{\left(\tan^{-1}_* \frac{im}{re} \cdot \tan^{-1}_* \frac{im}{re}\right) \cdot \tan^{-1}_* \frac{im}{re}}}}{\sqrt[3]{\left(\log 10 \cdot \log 10\right) \cdot \log 10}}\]
    5. Applied cbrt-undiv0.7

      \[\leadsto \color{blue}{\sqrt[3]{\frac{\left(\tan^{-1}_* \frac{im}{re} \cdot \tan^{-1}_* \frac{im}{re}\right) \cdot \tan^{-1}_* \frac{im}{re}}{\left(\log 10 \cdot \log 10\right) \cdot \log 10}}}\]
    6. Simplified0.1

      \[\leadsto \sqrt[3]{\color{blue}{{\left(\frac{\tan^{-1}_* \frac{im}{re}}{\log 10}\right)}^{3}}}\]

    if -8.783854077383177e-38 < (/ (atan2 im re) (log 10.0))

    1. Initial program 0.8

      \[\frac{\tan^{-1}_* \frac{im}{re}}{\log 10}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt0.8

      \[\leadsto \frac{\tan^{-1}_* \frac{im}{re}}{\color{blue}{\sqrt{\log 10} \cdot \sqrt{\log 10}}}\]
    4. Applied *-un-lft-identity0.8

      \[\leadsto \frac{\color{blue}{1 \cdot \tan^{-1}_* \frac{im}{re}}}{\sqrt{\log 10} \cdot \sqrt{\log 10}}\]
    5. Applied times-frac0.8

      \[\leadsto \color{blue}{\frac{1}{\sqrt{\log 10}} \cdot \frac{\tan^{-1}_* \frac{im}{re}}{\sqrt{\log 10}}}\]
    6. Using strategy rm
    7. Applied expm1-log1p-u0.8

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{\sqrt{\log 10}} \cdot \frac{\tan^{-1}_* \frac{im}{re}}{\sqrt{\log 10}}\right)\right)}\]
    8. Simplified0.8

      \[\leadsto \mathsf{expm1}\left(\color{blue}{\mathsf{log1p}\left(\frac{\tan^{-1}_* \frac{im}{re}}{\log 10}\right)}\right)\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\tan^{-1}_* \frac{im}{re}}{\log 10} \le -8.783854077383176606796760781421950863633 \cdot 10^{-38}:\\ \;\;\;\;\sqrt[3]{{\left(\frac{\tan^{-1}_* \frac{im}{re}}{\log 10}\right)}^{3}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\tan^{-1}_* \frac{im}{re}}{\log 10}\right)\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019208 +o rules:numerics
(FPCore (re im)
  :name "math.log10 on complex, imaginary part"
  :precision binary64
  (/ (atan2 im re) (log 10)))