Average Error: 30.5 → 16.8
Time: 11.2s
Precision: 64
Internal Precision: 576
\[\log \left(\sqrt{re \cdot re + im \cdot im}\right)\]
\[\begin{array}{l} \mathbf{if}\;re \le -2.1007836136528924 \cdot 10^{+54}:\\ \;\;\;\;\log \left(-re\right)\\ \mathbf{if}\;re \le 2.1855951413709923 \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.1007836136528924e+54

    1. Initial program 44.1

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

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

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

    if -2.1007836136528924e+54 < re < 2.1855951413709923e+117

    1. Initial program 20.8

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

    if 2.1855951413709923e+117 < re

    1. Initial program 53.6

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

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

Runtime

Time bar (total: 11.2s)Debug logProfile

herbie shell --seed '#(1072967564 1937075727 894099792 790700740 1036514779 1027793188)' 
(FPCore (re im)
  :name "math.log/1 on complex, real part"
  (log (sqrt (+ (* re re) (* im im)))))