Average Error: 31.0 → 16.7
Time: 1.4m
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 -6.349037050259237 \cdot 10^{+117}:\\ \;\;\;\;\frac{\log \left(-im\right)}{\log base}\\ \mathbf{if}\;im \le 1.4071719869222503 \cdot 10^{+129}:\\ \;\;\;\;\frac{1}{\frac{\log base}{\log \left(\sqrt{im \cdot im + re \cdot re}\right)}}\\ \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 3 regimes
  2. if im < -6.349037050259237e+117

    1. Initial program 53.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. Applied simplify53.6

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

      \[\leadsto \frac{\log base \cdot \log \color{blue}{\left(-1 \cdot im\right)}}{\log base \cdot \log base}\]
    4. Applied simplify8.2

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

    if -6.349037050259237e+117 < im < 1.4071719869222503e+129

    1. Initial program 20.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. Applied simplify20.6

      \[\leadsto \color{blue}{\frac{\log base \cdot \log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\log base \cdot \log base}}\]
    3. Using strategy rm
    4. Applied clear-num20.6

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

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

    if 1.4071719869222503e+129 < im

    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. Applied simplify56.2

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

      \[\leadsto \frac{\log base \cdot \log \color{blue}{im}}{\log base \cdot \log base}\]
    4. Applied simplify7.8

      \[\leadsto \color{blue}{\frac{\log im}{\log base}}\]
  3. Recombined 3 regimes into one program.
  4. Removed slow pow expressions.

Runtime

Time bar (total: 1.4m)Debug logProfile

herbie shell --seed '#(1063154770 1824007522 645063331 41291047 494775821 1237684644)' 
(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))))