Average Error: 30.7 → 17.2
Time: 2.1m
Precision: 64
Internal Precision: 576
\[\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 -3.1353783022706244 \cdot 10^{+116}:\\ \;\;\;\;\frac{-\log re}{-\log base}\\ \mathbf{if}\;-re \le -2.017258248459893 \cdot 10^{-241}:\\ \;\;\;\;\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}\;-re \le 3.55906899551254 \cdot 10^{-280}:\\ \;\;\;\;\log \left(\frac{-1}{im}\right) \cdot \frac{-1}{\log base}\\ \mathbf{if}\;-re \le 1.468263309439624 \cdot 10^{+129}:\\ \;\;\;\;\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 \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 4 regimes
  2. if (- re) < -3.1353783022706244e+116

    1. Initial program 52.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 8.3

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

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

    if -3.1353783022706244e+116 < (- re) < -2.017258248459893e-241 or 3.55906899551254e-280 < (- re) < 1.468263309439624e+129

    1. Initial program 19.6

      \[\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-sqrt19.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{\log base \cdot \log base + 0 \cdot 0} \cdot \sqrt{\log base \cdot \log base + 0 \cdot 0}}}\]
    4. Applied *-un-lft-identity19.6

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

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

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

      \[\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.017258248459893e-241 < (- re) < 3.55906899551254e-280

    1. Initial program 30.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 add-log-exp30.2

      \[\leadsto \color{blue}{\log \left(e^{\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)}\]
    4. Applied simplify30.2

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

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

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

    if 1.468263309439624e+129 < (- re)

    1. Initial program 56.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 -inf 8.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 simplify8.0

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

Runtime

Time bar (total: 2.1m)Debug logProfile

herbie shell --seed '#(1071246582 2318319007 2683472949 3810440501 3233274817 2724848749)' 
(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))))