Average Error: 31.8 → 12.2
Time: 7.9s
Precision: 64
Internal precision: 128
\[\log \left(\sqrt{re \cdot re + im \cdot im}\right)\]
\[\begin{array}{l} \mathbf{if}\;im \le -3.1392156119995164 \cdot 10^{+40}:\\ \;\;\;\;\log \left(-im\right)\\ \mathbf{if}\;im \le 5.8170505962259145 \cdot 10^{+31}:\\ \;\;\;\;\log \left(\sqrt{{im}^2 + {re}^2}\right)\\ \mathbf{else}:\\ \;\;\;\;\log im\\ \end{array}\]

Error

Bits error versus re

Bits error versus im

Derivation

  1. Split input into 3 regimes.
  2. if im < -3.1392156119995164e+40

    1. Initial program 45.7

      \[\log \left(\sqrt{re \cdot re + im \cdot im}\right)\]
    2. Applied simplify 45.7

      \[\leadsto \color{blue}{\log \left(\sqrt{{im}^2 + {re}^2}\right)}\]
    3. Applied taylor 0

      \[\leadsto \log \left(-1 \cdot im\right)\]
    4. Taylor expanded around -inf 0

      \[\leadsto \log \color{blue}{\left(-1 \cdot im\right)}\]
    5. Applied simplify 0

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

    if -3.1392156119995164e+40 < im < 5.8170505962259145e+31

    1. Initial program 21.9

      \[\log \left(\sqrt{re \cdot re + im \cdot im}\right)\]
    2. Applied simplify 21.9

      \[\leadsto \color{blue}{\log \left(\sqrt{{im}^2 + {re}^2}\right)}\]

    if 5.8170505962259145e+31 < im

    1. Initial program 42.5

      \[\log \left(\sqrt{re \cdot re + im \cdot im}\right)\]
    2. Applied simplify 42.5

      \[\leadsto \color{blue}{\log \left(\sqrt{{im}^2 + {re}^2}\right)}\]
    3. Applied taylor 0

      \[\leadsto \log im\]
    4. Taylor expanded around inf 0

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

Runtime

Time bar (total: 7.9s) Debug log

Please include this information when filing a bug report:

herbie --seed '#(1223212368 681115741 519175933 3070294417 3186843951 2418817505)'
(FPCore (re im)
  :name "math.log/1 on complex, real part"
  (log (sqrt (+ (* re re) (* im im)))))