Average Error: 30.5 → 17.1
Time: 59.1s
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 -1.333147985288499 \cdot 10^{+154}:\\ \;\;\;\;-\frac{\log \left(\sqrt[3]{\frac{-1}{re}} \cdot \sqrt[3]{\frac{-1}{re}}\right) + \log \left({\left(\frac{-1}{re}\right)}^{\frac{1}{3}}\right)}{\log base}\\ \mathbf{elif}\;im \le -8.31460784410292 \cdot 10^{+24}:\\ \;\;\;\;\frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\log base}\\ \mathbf{elif}\;im \le -1.3427627976320813 \cdot 10^{-66}:\\ \;\;\;\;\frac{-\left(\log \left(\sqrt[3]{\frac{-1}{re}} \cdot \sqrt[3]{\frac{-1}{re}}\right) + \log \left(\sqrt[3]{\frac{-1}{re}}\right)\right)}{\log base}\\ \mathbf{elif}\;im \le -6.166530788934726 \cdot 10^{-99}:\\ \;\;\;\;\frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\log base}\\ \mathbf{elif}\;im \le 1.5500116738073017 \cdot 10^{-159}:\\ \;\;\;\;-\frac{\log \left(\sqrt[3]{\frac{-1}{re}} \cdot \sqrt[3]{\frac{-1}{re}}\right) + \log \left({\left(\frac{-1}{re}\right)}^{\frac{1}{3}}\right)}{\log base}\\ \mathbf{elif}\;im \le 1.7905907614419087 \cdot 10^{+61}:\\ \;\;\;\;\frac{\log \left(\sqrt{im \cdot im + re \cdot re}\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 4 regimes
  2. if im < -1.333147985288499e+154 or -6.166530788934726e-99 < im < 1.5500116738073017e-159

    1. Initial program 36.9

      \[\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. Simplified36.9

      \[\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. Simplified20.2

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

      \[\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-prod20.2

      \[\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/320.2

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

    if -1.333147985288499e+154 < im < -8.31460784410292e+24 or -1.3427627976320813e-66 < im < -6.166530788934726e-99 or 1.5500116738073017e-159 < im < 1.7905907614419087e+61

    1. Initial program 15.4

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

      \[\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-frac15.3

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

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

    if -8.31460784410292e+24 < im < -1.3427627976320813e-66

    1. Initial program 16.7

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

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

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

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

      \[\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}\]

    if 1.7905907614419087e+61 < im

    1. Initial program 45.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. Simplified45.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 11.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \le -1.333147985288499 \cdot 10^{+154}:\\ \;\;\;\;-\frac{\log \left(\sqrt[3]{\frac{-1}{re}} \cdot \sqrt[3]{\frac{-1}{re}}\right) + \log \left({\left(\frac{-1}{re}\right)}^{\frac{1}{3}}\right)}{\log base}\\ \mathbf{elif}\;im \le -8.31460784410292 \cdot 10^{+24}:\\ \;\;\;\;\frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\log base}\\ \mathbf{elif}\;im \le -1.3427627976320813 \cdot 10^{-66}:\\ \;\;\;\;\frac{-\left(\log \left(\sqrt[3]{\frac{-1}{re}} \cdot \sqrt[3]{\frac{-1}{re}}\right) + \log \left(\sqrt[3]{\frac{-1}{re}}\right)\right)}{\log base}\\ \mathbf{elif}\;im \le -6.166530788934726 \cdot 10^{-99}:\\ \;\;\;\;\frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\log base}\\ \mathbf{elif}\;im \le 1.5500116738073017 \cdot 10^{-159}:\\ \;\;\;\;-\frac{\log \left(\sqrt[3]{\frac{-1}{re}} \cdot \sqrt[3]{\frac{-1}{re}}\right) + \log \left({\left(\frac{-1}{re}\right)}^{\frac{1}{3}}\right)}{\log base}\\ \mathbf{elif}\;im \le 1.7905907614419087 \cdot 10^{+61}:\\ \;\;\;\;\frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\log base}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log im}{\log base}\\ \end{array}\]

Reproduce

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