Average Error: 31.4 → 17.5
Time: 4.0s
Precision: 64
Internal Precision: 128
\[\log \left(\sqrt{re \cdot re + im \cdot im}\right)\]
\[\begin{array}{l} \mathbf{if}\;re \le -1.6412829992478922 \cdot 10^{+138}:\\ \;\;\;\;\log \left(-re\right)\\ \mathbf{elif}\;re \le -3.377774402336158 \cdot 10^{-177}:\\ \;\;\;\;\log \left(\sqrt{im \cdot im + re \cdot re}\right)\\ \mathbf{elif}\;re \le 8.625314473020069 \cdot 10^{-300}:\\ \;\;\;\;\log im\\ \mathbf{elif}\;re \le 3.7928809221081285 \cdot 10^{+114}:\\ \;\;\;\;\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 < -1.6412829992478922e+138

    1. Initial program 57.9

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

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

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

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

    if -1.6412829992478922e+138 < re < -3.377774402336158e-177 or 8.625314473020069e-300 < re < 3.7928809221081285e+114

    1. Initial program 19.4

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

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

    if -3.377774402336158e-177 < re < 8.625314473020069e-300

    1. Initial program 29.0

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

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

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

    if 3.7928809221081285e+114 < re

    1. Initial program 52.9

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \le -1.6412829992478922 \cdot 10^{+138}:\\ \;\;\;\;\log \left(-re\right)\\ \mathbf{elif}\;re \le -3.377774402336158 \cdot 10^{-177}:\\ \;\;\;\;\log \left(\sqrt{im \cdot im + re \cdot re}\right)\\ \mathbf{elif}\;re \le 8.625314473020069 \cdot 10^{-300}:\\ \;\;\;\;\log im\\ \mathbf{elif}\;re \le 3.7928809221081285 \cdot 10^{+114}:\\ \;\;\;\;\log \left(\sqrt{im \cdot im + re \cdot re}\right)\\ \mathbf{else}:\\ \;\;\;\;\log re\\ \end{array}\]

Runtime

Time bar (total: 4.0s)Debug logProfile

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