Average Error: 30.6 → 17.7
Time: 3.5m
Precision: 64
Internal Precision: 384
\[\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 -3.199482901517817 \cdot 10^{+36}:\\ \;\;\;\;\frac{\log \left(-im\right)}{\frac{\log base}{1}}\\ \mathbf{if}\;im \le -2.8975425347560925 \cdot 10^{-167}:\\ \;\;\;\;\frac{1}{\sqrt{\log base \cdot \log base}} \cdot \frac{\log base \cdot \log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\sqrt{\log base \cdot \log base}}\\ \mathbf{if}\;im \le -5.603537170979241 \cdot 10^{-284}:\\ \;\;\;\;\frac{\log re}{\log base}\\ \mathbf{if}\;im \le 2.265839395145225 \cdot 10^{+72}:\\ \;\;\;\;\frac{1}{\sqrt{\log base \cdot \log base}} \cdot \frac{\log base \cdot \log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\sqrt{\log base \cdot \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 < -3.199482901517817e+36

    1. Initial program 41.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. Using strategy rm
    3. Applied add-cbrt-cube41.4

      \[\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}} + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0}\]
    4. Applied add-cbrt-cube41.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} + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0}\]
    5. Applied cbrt-unprod41.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)}} + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0}\]
    6. Applied simplify41.4

      \[\leadsto \frac{\sqrt[3]{\color{blue}{{\left(\log base \cdot \log \left(\sqrt{im \cdot im + re \cdot re}\right)\right)}^{3}}} + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0}\]
    7. Taylor expanded around -inf 11.9

      \[\leadsto \frac{\sqrt[3]{{\left(\log base \cdot \log \color{blue}{\left(-1 \cdot im\right)}\right)}^{3}} + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0}\]
    8. Applied simplify11.7

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

    if -3.199482901517817e+36 < im < -2.8975425347560925e-167 or -5.603537170979241e-284 < im < 2.265839395145225e+72

    1. Initial program 20.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. Using strategy rm
    3. Applied add-sqr-sqrt20.1

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\color{blue}{\sqrt{\log base \cdot \log base + 0 \cdot 0} \cdot \sqrt{\log base \cdot \log base + 0 \cdot 0}}}\]
    4. Applied *-un-lft-identity20.1

      \[\leadsto \frac{\color{blue}{1 \cdot \left(\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0\right)}}{\sqrt{\log base \cdot \log base + 0 \cdot 0} \cdot \sqrt{\log base \cdot \log base + 0 \cdot 0}}\]
    5. Applied times-frac20.1

      \[\leadsto \color{blue}{\frac{1}{\sqrt{\log base \cdot \log base + 0 \cdot 0}} \cdot \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\sqrt{\log base \cdot \log base + 0 \cdot 0}}}\]
    6. Applied simplify20.1

      \[\leadsto \color{blue}{\frac{1}{\sqrt{\log base \cdot \log base}}} \cdot \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\sqrt{\log base \cdot \log base + 0 \cdot 0}}\]
    7. Applied simplify20.1

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

    if -2.8975425347560925e-167 < im < -5.603537170979241e-284

    1. Initial program 30.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. Taylor expanded around inf 34.9

      \[\leadsto \frac{\color{blue}{\log \left(\frac{1}{re}\right) \cdot \log \left(\frac{1}{base}\right)} + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0}\]
    3. Applied simplify34.9

      \[\leadsto \color{blue}{1 \cdot \frac{\log re}{\log base}}\]

    if 2.265839395145225e+72 < im

    1. Initial program 45.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. Taylor expanded around 0 10.0

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

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;im \le -3.199482901517817 \cdot 10^{+36}:\\ \;\;\;\;\frac{\log \left(-im\right)}{\frac{\log base}{1}}\\ \mathbf{if}\;im \le -2.8975425347560925 \cdot 10^{-167}:\\ \;\;\;\;\frac{1}{\sqrt{\log base \cdot \log base}} \cdot \frac{\log base \cdot \log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\sqrt{\log base \cdot \log base}}\\ \mathbf{if}\;im \le -5.603537170979241 \cdot 10^{-284}:\\ \;\;\;\;\frac{\log re}{\log base}\\ \mathbf{if}\;im \le 2.265839395145225 \cdot 10^{+72}:\\ \;\;\;\;\frac{1}{\sqrt{\log base \cdot \log base}} \cdot \frac{\log base \cdot \log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\sqrt{\log base \cdot \log base}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log im}{\log base}\\ \end{array}}\]

Runtime

Time bar (total: 3.5m)Debug logProfile

herbie shell --seed '#(1070578969 3140398606 632207097 462683394 1189254563 964980650)' 
(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))))