Average Error: 31.0 → 19.7
Time: 57.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.0759519200544362 \cdot 10^{+70}:\\ \;\;\;\;\frac{-1}{\frac{\log base}{\log \left(\frac{-1}{re}\right)}}\\ \mathbf{elif}\;im \le -2.0580726795320924 \cdot 10^{-63}:\\ \;\;\;\;\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 41.348623977511316:\\ \;\;\;\;-\frac{\log \left(\frac{-1}{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.0759519200544362e+70

    1. Initial program 44.8

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

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

      \[\leadsto \color{blue}{-\frac{\log \left(\frac{-1}{re}\right)}{\log base}}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity48.2

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

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

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

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

    if -1.0759519200544362e+70 < im < -2.0580726795320924e-63

    1. Initial program 17.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. Simplified17.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 clear-num17.4

      \[\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.0580726795320924e-63 < im < 41.348623977511316

    1. Initial program 23.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. Simplified23.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. Simplified11.4

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

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

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

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

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

    if 41.348623977511316 < im

    1. Initial program 38.8

      \[\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. Simplified38.8

      \[\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 12.9

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \le -1.0759519200544362 \cdot 10^{+70}:\\ \;\;\;\;\frac{-1}{\frac{\log base}{\log \left(\frac{-1}{re}\right)}}\\ \mathbf{elif}\;im \le -2.0580726795320924 \cdot 10^{-63}:\\ \;\;\;\;\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 41.348623977511316:\\ \;\;\;\;-\frac{\log \left(\frac{-1}{re}\right)}{\log base}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log im}{\log base}\\ \end{array}\]

Reproduce

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