\[\log \left(\sqrt{re \cdot re + im \cdot im}\right)\]
Test:
math.log/1 on complex, real part
Bits:
128 bits
Bits error versus re
Bits error versus im
Time: 4.9 s
Input Error: 14.9
Output Error: 5.8
Log:
Profile: 🕒
\(\begin{cases} \log \left(-re\right) & \text{when } re \le -1.04118355f+09 \\ \log \left(\sqrt{{re}^2 + im \cdot im}\right) & \text{when } re \le 1212733.4f0 \\ \log re & \text{otherwise} \end{cases}\)

    if re < -1.04118355f+09

    1. Started with
      \[\log \left(\sqrt{re \cdot re + im \cdot im}\right)\]
      22.8
    2. Applied simplify to get
      \[\color{red}{\log \left(\sqrt{re \cdot re + im \cdot im}\right)} \leadsto \color{blue}{\log \left(\sqrt{{re}^2 + im \cdot im}\right)}\]
      22.8
    3. Applied taylor to get
      \[\log \left(\sqrt{{re}^2 + im \cdot im}\right) \leadsto \log \left(-1 \cdot re\right)\]
      0.0
    4. Taylor expanded around -inf to get
      \[\log \color{red}{\left(-1 \cdot re\right)} \leadsto \log \color{blue}{\left(-1 \cdot re\right)}\]
      0.0
    5. Applied simplify to get
      \[\color{red}{\log \left(-1 \cdot re\right)} \leadsto \color{blue}{\log \left(-re\right)}\]
      0.0

    if -1.04118355f+09 < re < 1212733.4f0

    1. Started with
      \[\log \left(\sqrt{re \cdot re + im \cdot im}\right)\]
      9.8
    2. Applied simplify to get
      \[\color{red}{\log \left(\sqrt{re \cdot re + im \cdot im}\right)} \leadsto \color{blue}{\log \left(\sqrt{{re}^2 + im \cdot im}\right)}\]
      9.8

    if 1212733.4f0 < re

    1. Started with
      \[\log \left(\sqrt{re \cdot re + im \cdot im}\right)\]
      22.2
    2. Applied simplify to get
      \[\color{red}{\log \left(\sqrt{re \cdot re + im \cdot im}\right)} \leadsto \color{blue}{\log \left(\sqrt{{re}^2 + im \cdot im}\right)}\]
      22.2
    3. Applied taylor to get
      \[\log \left(\sqrt{{re}^2 + im \cdot im}\right) \leadsto \log re\]
      0.0
    4. Taylor expanded around inf to get
      \[\log \color{red}{re} \leadsto \log \color{blue}{re}\]
      0.0

  1. Removed slow pow expressions

Original test:


(lambda ((re default) (im default))
  #:name "math.log/1 on complex, real part"
  (log (sqrt (+ (* re re) (* im im)))))