\[\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: 7.5 s
Input Error: 14.8
Output Error: 5.6
Log:
Profile: 🕒
\(\begin{cases} \log \left(-re\right) & \text{when } re \le -0.9544243f0 \\ \log \left(\sqrt{{re}^2 + im \cdot im}\right) & \text{when } re \le 2.5568826f+12 \\ \log re & \text{otherwise} \end{cases}\)

    if re < -0.9544243f0

    1. Started with
      \[\log \left(\sqrt{re \cdot re + im \cdot im}\right)\]
      19.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)}\]
      19.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 -0.9544243f0 < re < 2.5568826f+12

    1. Started with
      \[\log \left(\sqrt{re \cdot re + im \cdot im}\right)\]
      9.7
    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.7

    if 2.5568826f+12 < re

    1. Started with
      \[\log \left(\sqrt{re \cdot re + im \cdot im}\right)\]
      24.9
    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)}\]
      24.9
    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)))))