\[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\]
Test:
math.log10 on complex, real part
Bits:
128 bits
Bits error versus re
Bits error versus im
Time: 8.2 s
Input Error: 31.8
Output Error: 12.8
Log:
Profile: 🕒
\(\begin{cases} \frac{\log \left(-re\right)}{\log 10} & \text{when } re \le -5.001969231040948 \cdot 10^{+151} \\ \frac{1}{\frac{\log 10}{\log \left(\sqrt{{re}^2 + im \cdot im}\right)}} & \text{when } re \le 6.526828139904173 \cdot 10^{-268} \\ \frac{\log im}{\log 10} & \text{when } re \le 3.51720187277729 \cdot 10^{-183} \\ \frac{1}{\frac{\log 10}{\log \left(\sqrt{{re}^2 + im \cdot im}\right)}} & \text{when } re \le 3.0634872044683813 \cdot 10^{+39} \\ \frac{\log re}{\log 10} & \text{otherwise} \end{cases}\)

    if re < -5.001969231040948e+151

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

    if -5.001969231040948e+151 < re < 6.526828139904173e-268 or 3.51720187277729e-183 < re < 3.0634872044683813e+39

    1. Started with
      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\]
      20.8
    2. Applied simplify to get
      \[\color{red}{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}} \leadsto \color{blue}{\frac{\log \left(\sqrt{{re}^2 + im \cdot im}\right)}{\log 10}}\]
      20.8
    3. Using strategy rm
      20.8
    4. Applied clear-num to get
      \[\color{red}{\frac{\log \left(\sqrt{{re}^2 + im \cdot im}\right)}{\log 10}} \leadsto \color{blue}{\frac{1}{\frac{\log 10}{\log \left(\sqrt{{re}^2 + im \cdot im}\right)}}}\]
      20.8

    if 6.526828139904173e-268 < re < 3.51720187277729e-183

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

    if 3.0634872044683813e+39 < re

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

  1. Removed slow pow expressions

Original test:


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