Average Error: 30.1 → 16.6
Time: 3.5s
Precision: 64
Internal Precision: 128
\[\log \left(\sqrt{re \cdot re + im \cdot im}\right)\]
\[\begin{array}{l} \mathbf{if}\;re \le -1.325578441168093 \cdot 10^{+139}:\\ \;\;\;\;\log \left(-re\right)\\ \mathbf{elif}\;re \le 1.5739721825376207 \cdot 10^{+106}:\\ \;\;\;\;\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 < -1.325578441168093e+139

    1. Initial program 58.4

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

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

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

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

    if -1.325578441168093e+139 < re < 1.5739721825376207e+106

    1. Initial program 20.2

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

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

    if 1.5739721825376207e+106 < re

    1. Initial program 50.8

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \le -1.325578441168093 \cdot 10^{+139}:\\ \;\;\;\;\log \left(-re\right)\\ \mathbf{elif}\;re \le 1.5739721825376207 \cdot 10^{+106}:\\ \;\;\;\;\log \left(\sqrt{im \cdot im + re \cdot re}\right)\\ \mathbf{else}:\\ \;\;\;\;\log re\\ \end{array}\]

Runtime

Time bar (total: 3.5s)Debug logProfile

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