Average Error: 31.0 → 16.9
Time: 4.5s
Precision: 64
Internal Precision: 576
\[\log \left(\sqrt{re \cdot re + im \cdot im}\right)\]
\[\begin{array}{l} \mathbf{if}\;re \le -2.4509602360394443 \cdot 10^{+61}:\\ \;\;\;\;\log \left(-re\right)\\ \mathbf{if}\;re \le 1.265500033109213 \cdot 10^{+117}:\\ \;\;\;\;\log \left(\sqrt{re \cdot re + im \cdot im}\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 < -2.4509602360394443e+61

    1. Initial program 45.4

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

      \[\leadsto \log \color{blue}{\left(-1 \cdot re\right)}\]
    3. Applied simplify9.7

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

    if -2.4509602360394443e+61 < re < 1.265500033109213e+117

    1. Initial program 21.1

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

    if 1.265500033109213e+117 < re

    1. Initial program 52.9

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

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

Runtime

Time bar (total: 4.5s)Debug logProfile

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