Average Error: 31.0 → 19.6
Time: 1.1m
Precision: 64
Internal Precision: 128
\[\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.715659319709163 \cdot 10^{+94}:\\ \;\;\;\;\frac{-1}{\frac{\log base}{\log \left(\frac{-1}{re}\right)}}\\ \mathbf{elif}\;im \le -2.8687470045749877 \cdot 10^{-159}:\\ \;\;\;\;\frac{1}{\frac{\log base \cdot \log base}{\log base \cdot \log \left(\sqrt{im \cdot im + re \cdot re}\right)}}\\ \mathbf{elif}\;im \le 2.700308897202596 \cdot 10^{-161}:\\ \;\;\;\;\frac{-\left(\log \left({\left(\frac{-1}{re}\right)}^{\frac{2}{3}}\right) + \log \left(\sqrt[3]{\frac{-1}{re}}\right)\right)}{\log base}\\ \mathbf{elif}\;im \le 8.603364870559262 \cdot 10^{-60}:\\ \;\;\;\;\frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\log base}\\ \mathbf{elif}\;im \le 3.520671617218434 \cdot 10^{+81}:\\ \;\;\;\;\frac{-\left(\log \left({\left(\frac{-1}{re}\right)}^{\frac{2}{3}}\right) + \log \left(\sqrt[3]{\frac{-1}{re}}\right)\right)}{\log base}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log im}{\log base}\\ \end{array}\]

Error

Bits error versus re

Bits error versus im

Bits error versus base

Derivation

  1. Split input into 5 regimes
  2. if im < -8.715659319709163e+94

    1. Initial program 49.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. Simplified49.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 -inf 62.8

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

      \[\leadsto \color{blue}{-\frac{\log \left(\frac{-1}{re}\right)}{\log base}}\]
    5. Using strategy rm
    6. Applied pow148.4

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

      \[\leadsto -\frac{\color{blue}{1 \cdot \log \left(\frac{-1}{re}\right)}}{\log base}\]
    8. Applied associate-/l*48.4

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

    if -8.715659319709163e+94 < im < -2.8687470045749877e-159

    1. Initial program 15.5

      \[\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. Simplified15.5

      \[\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 clear-num15.5

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

    if -2.8687470045749877e-159 < im < 2.700308897202596e-161 or 8.603364870559262e-60 < im < 3.520671617218434e+81

    1. Initial program 26.6

      \[\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. Simplified26.6

      \[\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. Simplified14.4

      \[\leadsto \color{blue}{-\frac{\log \left(\frac{-1}{re}\right)}{\log base}}\]
    5. Using strategy rm
    6. Applied add-cube-cbrt14.4

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

      \[\leadsto -\frac{\color{blue}{\log \left(\sqrt[3]{\frac{-1}{re}} \cdot \sqrt[3]{\frac{-1}{re}}\right) + \log \left(\sqrt[3]{\frac{-1}{re}}\right)}}{\log base}\]
    8. Using strategy rm
    9. Applied pow1/314.5

      \[\leadsto -\frac{\log \left(\sqrt[3]{\frac{-1}{re}} \cdot \color{blue}{{\left(\frac{-1}{re}\right)}^{\frac{1}{3}}}\right) + \log \left(\sqrt[3]{\frac{-1}{re}}\right)}{\log base}\]
    10. Applied pow1/314.5

      \[\leadsto -\frac{\log \left(\color{blue}{{\left(\frac{-1}{re}\right)}^{\frac{1}{3}}} \cdot {\left(\frac{-1}{re}\right)}^{\frac{1}{3}}\right) + \log \left(\sqrt[3]{\frac{-1}{re}}\right)}{\log base}\]
    11. Applied pow-prod-up14.5

      \[\leadsto -\frac{\log \color{blue}{\left({\left(\frac{-1}{re}\right)}^{\left(\frac{1}{3} + \frac{1}{3}\right)}\right)} + \log \left(\sqrt[3]{\frac{-1}{re}}\right)}{\log base}\]
    12. Simplified14.5

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

      \[\leadsto -\frac{\log \color{blue}{\left(e^{\frac{2}{3} \cdot \left(\log \left(\frac{1}{re}\right) + \log -1\right)}\right)} + \log \left(\sqrt[3]{\frac{-1}{re}}\right)}{\log base}\]
    14. Simplified14.5

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

    if 2.700308897202596e-161 < im < 8.603364870559262e-60

    1. Initial program 14.6

      \[\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. Simplified14.6

      \[\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 times-frac14.5

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

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

    if 3.520671617218434e+81 < im

    1. Initial program 47.1

      \[\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. Simplified47.1

      \[\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.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \le -8.715659319709163 \cdot 10^{+94}:\\ \;\;\;\;\frac{-1}{\frac{\log base}{\log \left(\frac{-1}{re}\right)}}\\ \mathbf{elif}\;im \le -2.8687470045749877 \cdot 10^{-159}:\\ \;\;\;\;\frac{1}{\frac{\log base \cdot \log base}{\log base \cdot \log \left(\sqrt{im \cdot im + re \cdot re}\right)}}\\ \mathbf{elif}\;im \le 2.700308897202596 \cdot 10^{-161}:\\ \;\;\;\;\frac{-\left(\log \left({\left(\frac{-1}{re}\right)}^{\frac{2}{3}}\right) + \log \left(\sqrt[3]{\frac{-1}{re}}\right)\right)}{\log base}\\ \mathbf{elif}\;im \le 8.603364870559262 \cdot 10^{-60}:\\ \;\;\;\;\frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\log base}\\ \mathbf{elif}\;im \le 3.520671617218434 \cdot 10^{+81}:\\ \;\;\;\;\frac{-\left(\log \left({\left(\frac{-1}{re}\right)}^{\frac{2}{3}}\right) + \log \left(\sqrt[3]{\frac{-1}{re}}\right)\right)}{\log base}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log im}{\log base}\\ \end{array}\]

Reproduce

herbie shell --seed 2019068 
(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))))