Average Error: 30.5 → 16.8
Time: 4.1s
Precision: 64
Internal Precision: 128
\[\log \left(\sqrt{re \cdot re + im \cdot im}\right)\]
\[\begin{array}{l} \mathbf{if}\;re \le -1.4267439596555745 \cdot 10^{+71}:\\ \;\;\;\;\log \left(-re\right)\\ \mathbf{elif}\;re \le 2.0482039862590654 \cdot 10^{+83}:\\ \;\;\;\;\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.4267439596555745e+71

    1. Initial program 46.3

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

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

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

    if -1.4267439596555745e+71 < re < 2.0482039862590654e+83

    1. Initial program 21.1

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

    if 2.0482039862590654e+83 < re

    1. Initial program 47.5

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

      \[\leadsto \color{blue}{-\log \left(\frac{1}{re}\right)}\]
    3. Simplified9.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \le -1.4267439596555745 \cdot 10^{+71}:\\ \;\;\;\;\log \left(-re\right)\\ \mathbf{elif}\;re \le 2.0482039862590654 \cdot 10^{+83}:\\ \;\;\;\;\log \left(\sqrt{im \cdot im + re \cdot re}\right)\\ \mathbf{else}:\\ \;\;\;\;\log re\\ \end{array}\]

Runtime

Time bar (total: 4.1s)Debug logProfile

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