Average Error: 31.4 → 18.7
Time: 2.6m
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}\;-re \le -4.293140406514086 \cdot 10^{+77}:\\ \;\;\;\;\frac{-\log re}{-\log base}\\ \mathbf{if}\;-re \le -1.098403023428472 \cdot 10^{-166}:\\ \;\;\;\;\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)\\ \mathbf{if}\;-re \le -9.419944556410419 \cdot 10^{-213}:\\ \;\;\;\;\frac{-1}{\log base} \cdot \log \left(\frac{-1}{im}\right)\\ \mathbf{if}\;-re \le -2.9801464241504385 \cdot 10^{-296}:\\ \;\;\;\;\frac{\log im}{\log base}\\ \mathbf{if}\;-re \le 7.886812653323913 \cdot 10^{-243}:\\ \;\;\;\;\frac{-1}{\log base} \cdot \log \left(\frac{-1}{im}\right)\\ \mathbf{if}\;-re \le 3.6614599245693435 \cdot 10^{-197}:\\ \;\;\;\;\frac{\log im}{\log base}\\ \mathbf{if}\;-re \le 3.259443192543266 \cdot 10^{-155}:\\ \;\;\;\;\frac{-1}{\log base} \cdot \log \left(\frac{-1}{im}\right)\\ \mathbf{if}\;-re \le 5.110421437955086 \cdot 10^{+49}:\\ \;\;\;\;\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)\\ \mathbf{else}:\\ \;\;\;\;\frac{\log \left(-re\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 (- re) < -4.293140406514086e+77

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

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

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

    if -4.293140406514086e+77 < (- re) < -1.098403023428472e-166 or 3.259443192543266e-155 < (- re) < 5.110421437955086e+49

    1. Initial program 16.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. Using strategy rm
    3. Applied flip3-+16.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}{\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/16.1

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

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

    if -1.098403023428472e-166 < (- re) < -9.419944556410419e-213

    1. Initial program 35.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-cube35.6

      \[\leadsto \color{blue}{\sqrt[3]{\left(\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} \cdot \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}\right) \cdot \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}}}\]
    4. Applied simplify35.6

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

      \[\leadsto \sqrt[3]{\color{blue}{{\left(-1 \cdot \frac{\log \left(\frac{-1}{im}\right)}{\log -1 - \log \left(\frac{-1}{base}\right)}\right)}^{3}}}\]
    6. Applied simplify37.3

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

    if -9.419944556410419e-213 < (- re) < -2.9801464241504385e-296 or 7.886812653323913e-243 < (- re) < 3.6614599245693435e-197

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

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

    if -2.9801464241504385e-296 < (- re) < 7.886812653323913e-243 or 3.6614599245693435e-197 < (- re) < 3.259443192543266e-155

    1. Initial program 30.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-cube30.6

      \[\leadsto \color{blue}{\sqrt[3]{\left(\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} \cdot \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}\right) \cdot \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}}}\]
    4. Applied simplify30.6

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

      \[\leadsto \sqrt[3]{\color{blue}{{\left(-1 \cdot \frac{\log \left(\frac{-1}{im}\right)}{\log -1 - \log \left(\frac{-1}{base}\right)}\right)}^{3}}}\]
    6. Applied simplify33.9

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

    if 5.110421437955086e+49 < (- re)

    1. Initial program 44.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 12.1

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

      \[\leadsto \color{blue}{\frac{\log \left(-re\right)}{\log base}}\]
  3. Recombined 6 regimes into one program.

Runtime

Time bar (total: 2.6m)Debug logProfile

herbie shell --seed '#(1070991898 1055468627 4280279443 640792587 928206309 3646738750)' 
(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))))