Average Error: 30.9 → 18.9
Time: 1.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 -34625.9121643208:\\ \;\;\;\;\frac{\log im}{\log base}\\ \mathbf{if}\;-im \le -2.0111411999041037 \cdot 10^{-266}:\\ \;\;\;\;\sqrt[3]{{\left(\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log base}\right)}^{3}}\\ \mathbf{if}\;-im \le 1.935648111786818 \cdot 10^{-185}:\\ \;\;\;\;\frac{-\log re}{-\log base}\\ \mathbf{if}\;-im \le 4.87642630303326 \cdot 10^{-148}:\\ \;\;\;\;\frac{\log \left(-re\right)}{\log base}\\ \mathbf{if}\;-im \le 1.8643644744390882 \cdot 10^{-122}:\\ \;\;\;\;\frac{-\log re}{-\log base}\\ \mathbf{if}\;-im \le 4.644322376640725 \cdot 10^{+73}:\\ \;\;\;\;\frac{0 \cdot \tan^{-1}_* \frac{im}{re} + \log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\sqrt[3]{{\left(\log base\right)}^{3} \cdot {\left(\log base\right)}^{3}} + 0 \cdot 0}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log \left(-im\right)}{\log base}\\ \end{array}\]

Error

Bits error versus re

Bits error versus im

Bits error versus base

Derivation

  1. Split input into 6 regimes
  2. if (- im) < -34625.9121643208

    1. Initial program 39.2

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

      \[\leadsto \color{blue}{\frac{\log im}{\log base}}\]

    if -34625.9121643208 < (- im) < -2.0111411999041037e-266

    1. Initial program 21.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-cube21.4

      \[\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[3]{\left(\left(\log base \cdot \log base + 0 \cdot 0\right) \cdot \left(\log base \cdot \log base + 0 \cdot 0\right)\right) \cdot \left(\log base \cdot \log base + 0 \cdot 0\right)}}}\]
    4. Applied add-cbrt-cube21.5

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

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

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

    if -2.0111411999041037e-266 < (- im) < 1.935648111786818e-185 or 4.87642630303326e-148 < (- im) < 1.8643644744390882e-122

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

      \[\leadsto \color{blue}{\frac{\log \left(\frac{1}{re}\right)}{\log \left(\frac{1}{base}\right)}}\]
    3. Applied simplify33.7

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

    if 1.935648111786818e-185 < (- im) < 4.87642630303326e-148

    1. Initial program 26.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 -inf 35.9

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

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

    if 1.8643644744390882e-122 < (- im) < 4.644322376640725e+73

    1. Initial program 16.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. Using strategy rm
    3. Applied add-cbrt-cube16.6

      \[\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[3]{\left(\left(\log base \cdot \log base\right) \cdot \left(\log base \cdot \log base\right)\right) \cdot \left(\log base \cdot \log base\right)}} + 0 \cdot 0}\]
    4. Applied simplify16.6

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

    if 4.644322376640725e+73 < (- im)

    1. Initial program 46.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. Using strategy rm
    3. Applied flip3-+46.5

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\color{blue}{\frac{{\left(\log base \cdot \log base\right)}^{3} + {\left(0 \cdot 0\right)}^{3}}{\left(\log base \cdot \log base\right) \cdot \left(\log base \cdot \log base\right) + \left(\left(0 \cdot 0\right) \cdot \left(0 \cdot 0\right) - \left(\log base \cdot \log base\right) \cdot \left(0 \cdot 0\right)\right)}}}\]
    4. Applied associate-/r/46.4

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

      \[\leadsto \color{blue}{\frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right)}{{\left(\log base\right)}^{3} \cdot \left(\log base \cdot \log base\right)}} \cdot \left(\left(\log base \cdot \log base\right) \cdot \left(\log base \cdot \log base\right) + \left(\left(0 \cdot 0\right) \cdot \left(0 \cdot 0\right) - \left(\log base \cdot \log base\right) \cdot \left(0 \cdot 0\right)\right)\right)\]
    6. Taylor expanded around -inf 10.6

      \[\leadsto \frac{\log \color{blue}{\left(-1 \cdot im\right)}}{{\left(\log base\right)}^{3} \cdot \left(\log base \cdot \log base\right)} \cdot \left(\left(\log base \cdot \log base\right) \cdot \left(\log base \cdot \log base\right) + \left(\left(0 \cdot 0\right) \cdot \left(0 \cdot 0\right) - \left(\log base \cdot \log base\right) \cdot \left(0 \cdot 0\right)\right)\right)\]
    7. Applied simplify10.5

      \[\leadsto \color{blue}{1 \cdot \frac{\log \left(-im\right)}{\log base}}\]
  3. Recombined 6 regimes into one program.
  4. Applied simplify18.9

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;-im \le -34625.9121643208:\\ \;\;\;\;\frac{\log im}{\log base}\\ \mathbf{if}\;-im \le -2.0111411999041037 \cdot 10^{-266}:\\ \;\;\;\;\sqrt[3]{{\left(\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log base}\right)}^{3}}\\ \mathbf{if}\;-im \le 1.935648111786818 \cdot 10^{-185}:\\ \;\;\;\;\frac{-\log re}{-\log base}\\ \mathbf{if}\;-im \le 4.87642630303326 \cdot 10^{-148}:\\ \;\;\;\;\frac{\log \left(-re\right)}{\log base}\\ \mathbf{if}\;-im \le 1.8643644744390882 \cdot 10^{-122}:\\ \;\;\;\;\frac{-\log re}{-\log base}\\ \mathbf{if}\;-im \le 4.644322376640725 \cdot 10^{+73}:\\ \;\;\;\;\frac{0 \cdot \tan^{-1}_* \frac{im}{re} + \log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\sqrt[3]{{\left(\log base\right)}^{3} \cdot {\left(\log base\right)}^{3}} + 0 \cdot 0}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log \left(-im\right)}{\log base}\\ \end{array}}\]

Runtime

Time bar (total: 1.5m)Debug logProfile

herbie shell --seed '#(1064397287 3527694221 3797617954 1138343853 2854031332 1153838279)' 
(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))))