Average Error: 31.4 → 17.2
Time: 3.8s
Precision: 64
Internal Precision: 320
\[\log \left(\sqrt{re \cdot re + im \cdot im}\right)\]
\[\begin{array}{l} \mathbf{if}\;re \le -5.1510501608275733 \cdot 10^{+120}:\\ \;\;\;\;\log \left(-re\right)\\ \mathbf{elif}\;re \le 6.706260153190329 \cdot 10^{+103}:\\ \;\;\;\;\log \left(\sqrt{im \cdot im + re \cdot re}\right)\\ \mathbf{else}:\\ \;\;\;\;\log re\\ \end{array}\]

Error

Bits error versus re

Bits error versus im

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if re < -5.1510501608275733e+120

    1. Initial program 53.7

      \[\log \left(\sqrt{re \cdot re + im \cdot im}\right)\]
    2. Initial simplification53.7

      \[\leadsto \log \left(\sqrt{re \cdot re + im \cdot im}\right)\]
    3. Taylor expanded around -inf 7.2

      \[\leadsto \log \color{blue}{\left(-1 \cdot re\right)}\]
    4. Simplified7.2

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

    if -5.1510501608275733e+120 < re < 6.706260153190329e+103

    1. Initial program 21.5

      \[\log \left(\sqrt{re \cdot re + im \cdot im}\right)\]
    2. Initial simplification21.5

      \[\leadsto \log \left(\sqrt{re \cdot re + im \cdot im}\right)\]

    if 6.706260153190329e+103 < re

    1. Initial program 50.9

      \[\log \left(\sqrt{re \cdot re + im \cdot im}\right)\]
    2. Initial simplification50.9

      \[\leadsto \log \left(\sqrt{re \cdot re + im \cdot im}\right)\]
    3. Taylor expanded around inf 9.0

      \[\leadsto \log \color{blue}{re}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification17.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \le -5.1510501608275733 \cdot 10^{+120}:\\ \;\;\;\;\log \left(-re\right)\\ \mathbf{elif}\;re \le 6.706260153190329 \cdot 10^{+103}:\\ \;\;\;\;\log \left(\sqrt{im \cdot im + re \cdot re}\right)\\ \mathbf{else}:\\ \;\;\;\;\log re\\ \end{array}\]

Runtime

Time bar (total: 3.8s)Debug logProfile

herbie shell --seed 2018256 
(FPCore (re im)
  :name "math.log/1 on complex, real part"
  (log (sqrt (+ (* re re) (* im im)))))