Average Error: 31.1 → 16.8
Time: 1.0m
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.350005061623872 \cdot 10^{+154}:\\ \;\;\;\;\frac{1}{\frac{\log base \cdot \log base}{\log \left(-re\right) \cdot \log base}}\\ \mathbf{elif}\;im \le -2.998808339031573 \cdot 10^{-73}:\\ \;\;\;\;\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log base}\\ \mathbf{elif}\;im \le 5.750493638946934 \cdot 10^{-114}:\\ \;\;\;\;\frac{\log \left(-re\right)}{\frac{\log base \cdot \log base}{\log base}}\\ \mathbf{elif}\;im \le 3.643193318053519 \cdot 10^{+119}:\\ \;\;\;\;\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\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.350005061623872e+154

    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 50.8

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

      \[\leadsto \frac{\log \color{blue}{\left(-re\right)} \cdot \log base}{\log base \cdot \log base}\]
    5. Using strategy rm
    6. Applied clear-num50.8

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

    if -1.350005061623872e+154 < im < -2.998808339031573e-73 or 5.750493638946934e-114 < im < 3.643193318053519e+119

    1. Initial program 15.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. Simplified15.7

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

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

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

    if -2.998808339031573e-73 < im < 5.750493638946934e-114

    1. Initial program 25.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. Simplified25.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 9.5

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

      \[\leadsto \frac{\log \color{blue}{\left(-re\right)} \cdot \log base}{\log base \cdot \log base}\]
    5. Using strategy rm
    6. Applied associate-/l*9.4

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

    if 3.643193318053519e+119 < im

    1. Initial program 53.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. Simplified53.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 8.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \le -1.350005061623872 \cdot 10^{+154}:\\ \;\;\;\;\frac{1}{\frac{\log base \cdot \log base}{\log \left(-re\right) \cdot \log base}}\\ \mathbf{elif}\;im \le -2.998808339031573 \cdot 10^{-73}:\\ \;\;\;\;\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log base}\\ \mathbf{elif}\;im \le 5.750493638946934 \cdot 10^{-114}:\\ \;\;\;\;\frac{\log \left(-re\right)}{\frac{\log base \cdot \log base}{\log base}}\\ \mathbf{elif}\;im \le 3.643193318053519 \cdot 10^{+119}:\\ \;\;\;\;\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log base}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log im}{\log base}\\ \end{array}\]

Reproduce

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