Average Error: 31.0 → 18.6
Time: 1.1m
Precision: 64
\[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0}\]
\[\begin{array}{l} \mathbf{if}\;im \le -8.551551215711193 \cdot 10^{+156}:\\ \;\;\;\;\left(-\log \left(\frac{-1}{re}\right)\right) \cdot \sqrt[3]{\frac{1}{\log base \cdot \left(\log base \cdot \log base\right)}}\\ \mathbf{elif}\;im \le -2.108728536359279 \cdot 10^{-15}:\\ \;\;\;\;\sqrt[3]{\left(\frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\log base} \cdot \frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\log base}\right) \cdot \frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\log base}}\\ \mathbf{elif}\;im \le 2.4294881236333897 \cdot 10^{-88}:\\ \;\;\;\;\frac{-\log \left(\frac{-1}{re}\right)}{\log base}\\ \mathbf{elif}\;im \le 0.0192463786380111:\\ \;\;\;\;\frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right) \cdot \log base}{\log \left(\sqrt[3]{base} \cdot \sqrt[3]{base}\right) \cdot \log base + \log base \cdot \log \left(\sqrt[3]{base}\right)}\\ \mathbf{elif}\;im \le 3.5464671902525163 \cdot 10^{+61}:\\ \;\;\;\;\frac{-\log \left(\frac{-1}{re}\right)}{\log base}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log im}{\log base}\\ \end{array}\]
\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0}
\begin{array}{l}
\mathbf{if}\;im \le -8.551551215711193 \cdot 10^{+156}:\\
\;\;\;\;\left(-\log \left(\frac{-1}{re}\right)\right) \cdot \sqrt[3]{\frac{1}{\log base \cdot \left(\log base \cdot \log base\right)}}\\

\mathbf{elif}\;im \le -2.108728536359279 \cdot 10^{-15}:\\
\;\;\;\;\sqrt[3]{\left(\frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\log base} \cdot \frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\log base}\right) \cdot \frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\log base}}\\

\mathbf{elif}\;im \le 2.4294881236333897 \cdot 10^{-88}:\\
\;\;\;\;\frac{-\log \left(\frac{-1}{re}\right)}{\log base}\\

\mathbf{elif}\;im \le 0.0192463786380111:\\
\;\;\;\;\frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right) \cdot \log base}{\log \left(\sqrt[3]{base} \cdot \sqrt[3]{base}\right) \cdot \log base + \log base \cdot \log \left(\sqrt[3]{base}\right)}\\

\mathbf{elif}\;im \le 3.5464671902525163 \cdot 10^{+61}:\\
\;\;\;\;\frac{-\log \left(\frac{-1}{re}\right)}{\log base}\\

\mathbf{else}:\\
\;\;\;\;\frac{\log im}{\log base}\\

\end{array}
double f(double re, double im, double base) {
        double r1405142 = re;
        double r1405143 = r1405142 * r1405142;
        double r1405144 = im;
        double r1405145 = r1405144 * r1405144;
        double r1405146 = r1405143 + r1405145;
        double r1405147 = sqrt(r1405146);
        double r1405148 = log(r1405147);
        double r1405149 = base;
        double r1405150 = log(r1405149);
        double r1405151 = r1405148 * r1405150;
        double r1405152 = atan2(r1405144, r1405142);
        double r1405153 = 0.0;
        double r1405154 = r1405152 * r1405153;
        double r1405155 = r1405151 + r1405154;
        double r1405156 = r1405150 * r1405150;
        double r1405157 = r1405153 * r1405153;
        double r1405158 = r1405156 + r1405157;
        double r1405159 = r1405155 / r1405158;
        return r1405159;
}

double f(double re, double im, double base) {
        double r1405160 = im;
        double r1405161 = -8.551551215711193e+156;
        bool r1405162 = r1405160 <= r1405161;
        double r1405163 = -1.0;
        double r1405164 = re;
        double r1405165 = r1405163 / r1405164;
        double r1405166 = log(r1405165);
        double r1405167 = -r1405166;
        double r1405168 = 1.0;
        double r1405169 = base;
        double r1405170 = log(r1405169);
        double r1405171 = r1405170 * r1405170;
        double r1405172 = r1405170 * r1405171;
        double r1405173 = r1405168 / r1405172;
        double r1405174 = cbrt(r1405173);
        double r1405175 = r1405167 * r1405174;
        double r1405176 = -2.108728536359279e-15;
        bool r1405177 = r1405160 <= r1405176;
        double r1405178 = r1405160 * r1405160;
        double r1405179 = r1405164 * r1405164;
        double r1405180 = r1405178 + r1405179;
        double r1405181 = sqrt(r1405180);
        double r1405182 = log(r1405181);
        double r1405183 = r1405182 / r1405170;
        double r1405184 = r1405183 * r1405183;
        double r1405185 = r1405184 * r1405183;
        double r1405186 = cbrt(r1405185);
        double r1405187 = 2.4294881236333897e-88;
        bool r1405188 = r1405160 <= r1405187;
        double r1405189 = r1405167 / r1405170;
        double r1405190 = 0.0192463786380111;
        bool r1405191 = r1405160 <= r1405190;
        double r1405192 = r1405182 * r1405170;
        double r1405193 = cbrt(r1405169);
        double r1405194 = r1405193 * r1405193;
        double r1405195 = log(r1405194);
        double r1405196 = r1405195 * r1405170;
        double r1405197 = log(r1405193);
        double r1405198 = r1405170 * r1405197;
        double r1405199 = r1405196 + r1405198;
        double r1405200 = r1405192 / r1405199;
        double r1405201 = 3.5464671902525163e+61;
        bool r1405202 = r1405160 <= r1405201;
        double r1405203 = log(r1405160);
        double r1405204 = r1405203 / r1405170;
        double r1405205 = r1405202 ? r1405189 : r1405204;
        double r1405206 = r1405191 ? r1405200 : r1405205;
        double r1405207 = r1405188 ? r1405189 : r1405206;
        double r1405208 = r1405177 ? r1405186 : r1405207;
        double r1405209 = r1405162 ? r1405175 : r1405208;
        return r1405209;
}

Error

Bits error versus re

Bits error versus im

Bits error versus base

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 5 regimes
  2. if im < -8.551551215711193e+156

    1. Initial program 62.0

      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0}\]
    2. Simplified62.0

      \[\leadsto \color{blue}{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\log base \cdot \log base}}\]
    3. Taylor expanded around -inf 62.8

      \[\leadsto \color{blue}{-1 \cdot \frac{\log \left(\frac{-1}{re}\right)}{\log -1 - \log \left(\frac{-1}{base}\right)}}\]
    4. Simplified52.2

      \[\leadsto \color{blue}{-\frac{\log \left(\frac{-1}{re}\right)}{\log base}}\]
    5. Taylor expanded around -inf 52.2

      \[\leadsto -\frac{\color{blue}{\log \left(\frac{-1}{re}\right)}}{\log base}\]
    6. Using strategy rm
    7. Applied div-inv52.2

      \[\leadsto -\color{blue}{\log \left(\frac{-1}{re}\right) \cdot \frac{1}{\log base}}\]
    8. Using strategy rm
    9. Applied add-cbrt-cube52.2

      \[\leadsto -\log \left(\frac{-1}{re}\right) \cdot \frac{1}{\color{blue}{\sqrt[3]{\left(\log base \cdot \log base\right) \cdot \log base}}}\]
    10. Applied add-cbrt-cube52.2

      \[\leadsto -\log \left(\frac{-1}{re}\right) \cdot \frac{\color{blue}{\sqrt[3]{\left(1 \cdot 1\right) \cdot 1}}}{\sqrt[3]{\left(\log base \cdot \log base\right) \cdot \log base}}\]
    11. Applied cbrt-undiv52.2

      \[\leadsto -\log \left(\frac{-1}{re}\right) \cdot \color{blue}{\sqrt[3]{\frac{\left(1 \cdot 1\right) \cdot 1}{\left(\log base \cdot \log base\right) \cdot \log base}}}\]
    12. Simplified52.2

      \[\leadsto -\log \left(\frac{-1}{re}\right) \cdot \sqrt[3]{\color{blue}{\frac{1}{\log base \cdot \left(\log base \cdot \log base\right)}}}\]

    if -8.551551215711193e+156 < im < -2.108728536359279e-15

    1. Initial program 18.2

      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0}\]
    2. Simplified18.2

      \[\leadsto \color{blue}{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\log base \cdot \log base}}\]
    3. Using strategy rm
    4. Applied add-cbrt-cube18.4

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\log base \cdot \color{blue}{\sqrt[3]{\left(\log base \cdot \log base\right) \cdot \log base}}}\]
    5. Applied add-cbrt-cube18.6

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\color{blue}{\sqrt[3]{\left(\log base \cdot \log base\right) \cdot \log base}} \cdot \sqrt[3]{\left(\log base \cdot \log base\right) \cdot \log base}}\]
    6. Applied cbrt-unprod18.4

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\color{blue}{\sqrt[3]{\left(\left(\log base \cdot \log base\right) \cdot \log base\right) \cdot \left(\left(\log base \cdot \log base\right) \cdot \log base\right)}}}\]
    7. Applied add-cbrt-cube18.5

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \color{blue}{\sqrt[3]{\left(\log base \cdot \log base\right) \cdot \log base}}}{\sqrt[3]{\left(\left(\log base \cdot \log base\right) \cdot \log base\right) \cdot \left(\left(\log base \cdot \log base\right) \cdot \log base\right)}}\]
    8. Applied add-cbrt-cube18.5

      \[\leadsto \frac{\color{blue}{\sqrt[3]{\left(\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log \left(\sqrt{re \cdot re + im \cdot im}\right)\right) \cdot \log \left(\sqrt{re \cdot re + im \cdot im}\right)}} \cdot \sqrt[3]{\left(\log base \cdot \log base\right) \cdot \log base}}{\sqrt[3]{\left(\left(\log base \cdot \log base\right) \cdot \log base\right) \cdot \left(\left(\log base \cdot \log base\right) \cdot \log base\right)}}\]
    9. Applied cbrt-unprod18.4

      \[\leadsto \frac{\color{blue}{\sqrt[3]{\left(\left(\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log \left(\sqrt{re \cdot re + im \cdot im}\right)\right) \cdot \log \left(\sqrt{re \cdot re + im \cdot im}\right)\right) \cdot \left(\left(\log base \cdot \log base\right) \cdot \log base\right)}}}{\sqrt[3]{\left(\left(\log base \cdot \log base\right) \cdot \log base\right) \cdot \left(\left(\log base \cdot \log base\right) \cdot \log base\right)}}\]
    10. Applied cbrt-undiv18.4

      \[\leadsto \color{blue}{\sqrt[3]{\frac{\left(\left(\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log \left(\sqrt{re \cdot re + im \cdot im}\right)\right) \cdot \log \left(\sqrt{re \cdot re + im \cdot im}\right)\right) \cdot \left(\left(\log base \cdot \log base\right) \cdot \log base\right)}{\left(\left(\log base \cdot \log base\right) \cdot \log base\right) \cdot \left(\left(\log base \cdot \log base\right) \cdot \log base\right)}}}\]
    11. Simplified18.4

      \[\leadsto \sqrt[3]{\color{blue}{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log base} \cdot \left(\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log base} \cdot \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log base}\right)}}\]

    if -2.108728536359279e-15 < im < 2.4294881236333897e-88 or 0.0192463786380111 < im < 3.5464671902525163e+61

    1. Initial program 23.2

      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0}\]
    2. Simplified23.2

      \[\leadsto \color{blue}{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\log base \cdot \log base}}\]
    3. Taylor expanded around -inf 62.8

      \[\leadsto \color{blue}{-1 \cdot \frac{\log \left(\frac{-1}{re}\right)}{\log -1 - \log \left(\frac{-1}{base}\right)}}\]
    4. Simplified13.7

      \[\leadsto \color{blue}{-\frac{\log \left(\frac{-1}{re}\right)}{\log base}}\]
    5. Taylor expanded around -inf 13.7

      \[\leadsto -\frac{\color{blue}{\log \left(\frac{-1}{re}\right)}}{\log base}\]

    if 2.4294881236333897e-88 < im < 0.0192463786380111

    1. Initial program 17.0

      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0}\]
    2. Simplified17.0

      \[\leadsto \color{blue}{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\log base \cdot \log base}}\]
    3. Using strategy rm
    4. Applied add-cube-cbrt17.0

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\log base \cdot \log \color{blue}{\left(\left(\sqrt[3]{base} \cdot \sqrt[3]{base}\right) \cdot \sqrt[3]{base}\right)}}\]
    5. Applied log-prod17.0

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\log base \cdot \color{blue}{\left(\log \left(\sqrt[3]{base} \cdot \sqrt[3]{base}\right) + \log \left(\sqrt[3]{base}\right)\right)}}\]
    6. Applied distribute-rgt-in17.0

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\color{blue}{\log \left(\sqrt[3]{base} \cdot \sqrt[3]{base}\right) \cdot \log base + \log \left(\sqrt[3]{base}\right) \cdot \log base}}\]

    if 3.5464671902525163e+61 < im

    1. Initial program 44.3

      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0}\]
    2. Simplified44.3

      \[\leadsto \color{blue}{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\log base \cdot \log base}}\]
    3. Taylor expanded around 0 10.5

      \[\leadsto \color{blue}{\frac{\log im}{\log base}}\]
  3. Recombined 5 regimes into one program.
  4. Final simplification18.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \le -8.551551215711193 \cdot 10^{+156}:\\ \;\;\;\;\left(-\log \left(\frac{-1}{re}\right)\right) \cdot \sqrt[3]{\frac{1}{\log base \cdot \left(\log base \cdot \log base\right)}}\\ \mathbf{elif}\;im \le -2.108728536359279 \cdot 10^{-15}:\\ \;\;\;\;\sqrt[3]{\left(\frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\log base} \cdot \frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\log base}\right) \cdot \frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\log base}}\\ \mathbf{elif}\;im \le 2.4294881236333897 \cdot 10^{-88}:\\ \;\;\;\;\frac{-\log \left(\frac{-1}{re}\right)}{\log base}\\ \mathbf{elif}\;im \le 0.0192463786380111:\\ \;\;\;\;\frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right) \cdot \log base}{\log \left(\sqrt[3]{base} \cdot \sqrt[3]{base}\right) \cdot \log base + \log base \cdot \log \left(\sqrt[3]{base}\right)}\\ \mathbf{elif}\;im \le 3.5464671902525163 \cdot 10^{+61}:\\ \;\;\;\;\frac{-\log \left(\frac{-1}{re}\right)}{\log base}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log im}{\log base}\\ \end{array}\]

Reproduce

herbie shell --seed 2019124 
(FPCore (re im base)
  :name "math.log/2 on complex, real part"
  (/ (+ (* (log (sqrt (+ (* re re) (* im im)))) (log base)) (* (atan2 im re) 0)) (+ (* (log base) (log base)) (* 0 0))))