Average Error: 30.9 → 17.5
Time: 3.9s
Precision: 64
Internal Precision: 128
\[\log \left(\sqrt{re \cdot re + im \cdot im}\right)\]
\[\begin{array}{l} \mathbf{if}\;re \le -8.739157930024531 \cdot 10^{+82}:\\ \;\;\;\;\log \left(-re\right)\\ \mathbf{elif}\;re \le -2.6401746271055864 \cdot 10^{-185}:\\ \;\;\;\;\log \left(\sqrt{im \cdot im + re \cdot re}\right)\\ \mathbf{elif}\;re \le 1.6510598051339403 \cdot 10^{-137}:\\ \;\;\;\;\log im\\ \mathbf{elif}\;re \le 8.578878492887041 \cdot 10^{+100}:\\ \;\;\;\;\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 < -8.739157930024531e+82

    1. Initial program 48.2

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

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

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

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

    if -8.739157930024531e+82 < re < -2.6401746271055864e-185 or 1.6510598051339403e-137 < re < 8.578878492887041e+100

    1. Initial program 15.8

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

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

    if -2.6401746271055864e-185 < re < 1.6510598051339403e-137

    1. Initial program 29.8

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

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

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

    if 8.578878492887041e+100 < re

    1. Initial program 49.8

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \le -8.739157930024531 \cdot 10^{+82}:\\ \;\;\;\;\log \left(-re\right)\\ \mathbf{elif}\;re \le -2.6401746271055864 \cdot 10^{-185}:\\ \;\;\;\;\log \left(\sqrt{im \cdot im + re \cdot re}\right)\\ \mathbf{elif}\;re \le 1.6510598051339403 \cdot 10^{-137}:\\ \;\;\;\;\log im\\ \mathbf{elif}\;re \le 8.578878492887041 \cdot 10^{+100}:\\ \;\;\;\;\log \left(\sqrt{im \cdot im + re \cdot re}\right)\\ \mathbf{else}:\\ \;\;\;\;\log re\\ \end{array}\]

Runtime

Time bar (total: 3.9s)Debug logProfile

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