Average Error: 30.5 → 16.7
Time: 3.7s
Precision: 64
Internal Precision: 128
\[\log \left(\sqrt{re \cdot re + im \cdot im}\right)\]
\[\begin{array}{l} \mathbf{if}\;re \le -1.0003660124528674 \cdot 10^{+35}:\\ \;\;\;\;\log \left(-re\right)\\ \mathbf{elif}\;re \le 2.5383188289297656 \cdot 10^{+137}:\\ \;\;\;\;\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.0003660124528674e+35

    1. Initial program 41.1

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

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

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

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

    if -1.0003660124528674e+35 < re < 2.5383188289297656e+137

    1. Initial program 20.8

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

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

    if 2.5383188289297656e+137 < re

    1. Initial program 57.2

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \le -1.0003660124528674 \cdot 10^{+35}:\\ \;\;\;\;\log \left(-re\right)\\ \mathbf{elif}\;re \le 2.5383188289297656 \cdot 10^{+137}:\\ \;\;\;\;\log \left(\sqrt{im \cdot im + re \cdot re}\right)\\ \mathbf{else}:\\ \;\;\;\;\log re\\ \end{array}\]

Runtime

Time bar (total: 3.7s)Debug logProfile

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