Average Error: 31.4 → 18.3
Time: 4.0s
Precision: 64
Internal Precision: 576
\[\log \left(\sqrt{re \cdot re + im \cdot im}\right)\]
\[\begin{array}{l} \mathbf{if}\;re \le -4.1606882319204325 \cdot 10^{+81}:\\ \;\;\;\;\log \left(-re\right)\\ \mathbf{elif}\;re \le -7.220768591101605 \cdot 10^{-173}:\\ \;\;\;\;\log \left(\sqrt{im \cdot im + re \cdot re}\right)\\ \mathbf{elif}\;re \le 5.283325772797005 \cdot 10^{-145}:\\ \;\;\;\;\log im\\ \mathbf{elif}\;re \le 7.812026660088089 \cdot 10^{+57}:\\ \;\;\;\;\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 4 regimes
  2. if re < -4.1606882319204325e+81

    1. Initial program 48.3

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

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

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

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

    if -4.1606882319204325e+81 < re < -7.220768591101605e-173 or 5.283325772797005e-145 < re < 7.812026660088089e+57

    1. Initial program 16.8

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

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

    if -7.220768591101605e-173 < re < 5.283325772797005e-145

    1. Initial program 29.9

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

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

      \[\leadsto \log \color{blue}{im}\]

    if 7.812026660088089e+57 < re

    1. Initial program 44.4

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \le -4.1606882319204325 \cdot 10^{+81}:\\ \;\;\;\;\log \left(-re\right)\\ \mathbf{elif}\;re \le -7.220768591101605 \cdot 10^{-173}:\\ \;\;\;\;\log \left(\sqrt{im \cdot im + re \cdot re}\right)\\ \mathbf{elif}\;re \le 5.283325772797005 \cdot 10^{-145}:\\ \;\;\;\;\log im\\ \mathbf{elif}\;re \le 7.812026660088089 \cdot 10^{+57}:\\ \;\;\;\;\log \left(\sqrt{im \cdot im + re \cdot re}\right)\\ \mathbf{else}:\\ \;\;\;\;\log re\\ \end{array}\]

Runtime

Time bar (total: 4.0s)Debug logProfile

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