Average Error: 30.1 → 16.6
Time: 5.3s
Precision: 64
Internal Precision: 576
\[\log \left(\sqrt{re \cdot re + im \cdot im}\right)\]
\[\begin{array}{l} \mathbf{if}\;re \le -4.381761495704048 \cdot 10^{+38}:\\ \;\;\;\;\log \left(-re\right)\\ \mathbf{if}\;re \le 6.552373666151888 \cdot 10^{+94}:\\ \;\;\;\;\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 < -4.381761495704048e+38

    1. Initial program 41.3

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

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

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

    if -4.381761495704048e+38 < re < 6.552373666151888e+94

    1. Initial program 20.7

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

    if 6.552373666151888e+94 < re

    1. Initial program 48.3

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

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

Runtime

Time bar (total: 5.3s)Debug logProfile

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