Average Error: 30.4 → 16.7
Time: 26.1s
Precision: 64
Internal Precision: 576
\[\log \left(\sqrt{re \cdot re + im \cdot im}\right)\]
\[\begin{array}{l} \mathbf{if}\;re \le -3.1493118778875895 \cdot 10^{+62}:\\ \;\;\;\;\log \left(-re\right)\\ \mathbf{if}\;re \le 3.1956573321757554 \cdot 10^{+73}:\\ \;\;\;\;\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 < -3.1493118778875895e+62

    1. Initial program 44.7

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

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

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

    if -3.1493118778875895e+62 < re < 3.1956573321757554e+73

    1. Initial program 20.8

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

    if 3.1956573321757554e+73 < re

    1. Initial program 46.8

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

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

Runtime

Time bar (total: 26.1s)Debug logProfile

herbie shell --seed '#(1072743783 989954326 4239155542 3782239461 3602631542 1719177920)' 
(FPCore (re im)
  :name "math.log/1 on complex, real part"
  (log (sqrt (+ (* re re) (* im im)))))