Average Error: 31.0 → 16.9
Time: 3.5s
Precision: 64
Internal Precision: 320
\[\log \left(\sqrt{re \cdot re + im \cdot im}\right)\]
\[\begin{array}{l} \mathbf{if}\;re \le -3.610399303455259 \cdot 10^{+148}:\\ \;\;\;\;\log \left(-re\right)\\ \mathbf{elif}\;re \le -6.20700690207667 \cdot 10^{-281}:\\ \;\;\;\;\log \left(\sqrt{im \cdot im + re \cdot re}\right)\\ \mathbf{elif}\;re \le 7.216380782199052 \cdot 10^{-165}:\\ \;\;\;\;\log im\\ \mathbf{elif}\;re \le 1.846191714804349 \cdot 10^{+118}:\\ \;\;\;\;\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 < -3.610399303455259e+148

    1. Initial program 60.3

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

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

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

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

    if -3.610399303455259e+148 < re < -6.20700690207667e-281 or 7.216380782199052e-165 < re < 1.846191714804349e+118

    1. Initial program 17.7

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

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

    if -6.20700690207667e-281 < re < 7.216380782199052e-165

    1. Initial program 31.2

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

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

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

    if 1.846191714804349e+118 < re

    1. Initial program 54.1

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \le -3.610399303455259 \cdot 10^{+148}:\\ \;\;\;\;\log \left(-re\right)\\ \mathbf{elif}\;re \le -6.20700690207667 \cdot 10^{-281}:\\ \;\;\;\;\log \left(\sqrt{im \cdot im + re \cdot re}\right)\\ \mathbf{elif}\;re \le 7.216380782199052 \cdot 10^{-165}:\\ \;\;\;\;\log im\\ \mathbf{elif}\;re \le 1.846191714804349 \cdot 10^{+118}:\\ \;\;\;\;\log \left(\sqrt{im \cdot im + re \cdot re}\right)\\ \mathbf{else}:\\ \;\;\;\;\log re\\ \end{array}\]

Runtime

Time bar (total: 3.5s)Debug logProfile

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