\[\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: 6.2 s
Input Error: 14.5
Output Error: 6.6
Log:
Profile: 🕒
\(\begin{cases} \log \left(-re\right) & \text{when } re \le -3.924884f+16 \\ \log \left(\sqrt{e^{\log \left({re}^2 + im \cdot im\right)}}\right) & \text{when } re \le 1.6052693f+16 \\ \log re & \text{otherwise} \end{cases}\)

    if re < -3.924884f+16

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

    1. Started with
      \[\log \left(\sqrt{re \cdot re + im \cdot im}\right)\]
      9.3
    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.3
    3. Using strategy rm
      9.3
    4. Applied add-exp-log to get
      \[\log \left(\sqrt{\color{red}{{re}^2 + im \cdot im}}\right) \leadsto \log \left(\sqrt{\color{blue}{e^{\log \left({re}^2 + im \cdot im\right)}}}\right)\]
      9.3

    if 1.6052693f+16 < re

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