Average Error: 30.9 → 19.5
Time: 1.3m
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.1698992286277704 \cdot 10^{+117}:\\ \;\;\;\;\frac{\log im \cdot \log base}{\log base \cdot \log base}\\ \mathbf{if}\;-im \le -2.231579376785681 \cdot 10^{-151}:\\ \;\;\;\;\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) \cdot \frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right)}{{\left(\log base\right)}^{3} \cdot \left(\log base \cdot \log base\right)}\\ \mathbf{if}\;-im \le -6.881902407889931 \cdot 10^{-256}:\\ \;\;\;\;\frac{\log \left(-re\right)}{\log base}\\ \mathbf{if}\;-im \le 1.2438568886807185 \cdot 10^{-239}:\\ \;\;\;\;\frac{\log re}{\log base}\\ \mathbf{if}\;-im \le 7.254179725874578 \cdot 10^{-99}:\\ \;\;\;\;\frac{\log \left(-re\right)}{\log base}\\ \mathbf{if}\;-im \le 3.5193712444255694 \cdot 10^{+54}:\\ \;\;\;\;\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) \cdot \frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right)}{{\left(\log base\right)}^{3} \cdot \left(\log base \cdot \log base\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log \left(-im\right)}{\frac{\log base}{1}}\\ \end{array}\]

Error

Bits error versus re

Bits error versus im

Bits error versus base

Derivation

  1. Split input into 5 regimes
  2. if (- im) < -3.1698992286277704e+117

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

      \[\leadsto \frac{\log \color{blue}{im} \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0}\]
    3. Applied simplify8.2

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

    if -3.1698992286277704e+117 < (- im) < -2.231579376785681e-151 or 7.254179725874578e-99 < (- im) < 3.5193712444255694e+54

    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 -2.231579376785681e-151 < (- im) < -6.881902407889931e-256 or 1.2438568886807185e-239 < (- im) < 7.254179725874578e-99

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

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

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

    if -6.881902407889931e-256 < (- im) < 1.2438568886807185e-239

    1. Initial program 31.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 32.4

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

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

    if 3.5193712444255694e+54 < (- im)

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

      \[\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/43.7

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

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

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

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

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;-im \le -3.1698992286277704 \cdot 10^{+117}:\\ \;\;\;\;\frac{\log im \cdot \log base}{\log base \cdot \log base}\\ \mathbf{if}\;-im \le -2.231579376785681 \cdot 10^{-151}:\\ \;\;\;\;\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) \cdot \frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right)}{{\left(\log base\right)}^{3} \cdot \left(\log base \cdot \log base\right)}\\ \mathbf{if}\;-im \le -6.881902407889931 \cdot 10^{-256}:\\ \;\;\;\;\frac{\log \left(-re\right)}{\log base}\\ \mathbf{if}\;-im \le 1.2438568886807185 \cdot 10^{-239}:\\ \;\;\;\;\frac{\log re}{\log base}\\ \mathbf{if}\;-im \le 7.254179725874578 \cdot 10^{-99}:\\ \;\;\;\;\frac{\log \left(-re\right)}{\log base}\\ \mathbf{if}\;-im \le 3.5193712444255694 \cdot 10^{+54}:\\ \;\;\;\;\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) \cdot \frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right)}{{\left(\log base\right)}^{3} \cdot \left(\log base \cdot \log base\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log \left(-im\right)}{\frac{\log base}{1}}\\ \end{array}}\]

Runtime

Time bar (total: 1.3m)Debug logProfile

herbie shell --seed '#(1070609872 3456127585 2380521889 2328837196 1765472538 734540918)' 
(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))))