\[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0}\]
Test:
math.log/2 on complex, real part
Bits:
128 bits
Bits error versus re
Bits error versus im
Bits error versus base
Time: 14.4 s
Input Error: 31.4
Output Error: 9.5
Log:
Profile: 🕒
\(\begin{cases} \frac{\log \left(-im\right)}{\log base} & \text{when } im \le -5.051947517249776 \cdot 10^{+32} \\ \frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right) \cdot \log base}{\log base \cdot \log base} & \text{when } im \le -1.0784901626853544 \cdot 10^{-218} \\ \frac{\log \left(-re\right)}{\log base} & \text{when } im \le 8.51308327519678 \cdot 10^{-216} \\ \frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right) \cdot \log base}{\log base \cdot \log base} & \text{when } im \le 1.5868349258537704 \cdot 10^{+124} \\ \frac{\log im}{\log base} & \text{otherwise} \end{cases}\)

    if im < -5.051947517249776e+32

    1. Started with
      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0}\]
      44.4
    2. Applied simplify to get
      \[\color{red}{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0}} \leadsto \color{blue}{\frac{\log base \cdot \log \left(\sqrt{{re}^2 + im \cdot im}\right) + 0}{\log base \cdot \log base}}\]
      44.4
    3. Applied taylor to get
      \[\frac{\log base \cdot \log \left(\sqrt{{re}^2 + im \cdot im}\right) + 0}{\log base \cdot \log base} \leadsto \frac{\log base \cdot \log \left(\sqrt{{re}^2 + im \cdot im}\right) + 0}{{\left(\log base\right)}^2}\]
      44.4
    4. Taylor expanded around 0 to get
      \[\frac{\log base \cdot \log \left(\sqrt{{re}^2 + im \cdot im}\right) + 0}{\color{red}{{\left(\log base\right)}^2}} \leadsto \frac{\log base \cdot \log \left(\sqrt{{re}^2 + im \cdot im}\right) + 0}{\color{blue}{{\left(\log base\right)}^2}}\]
      44.4
    5. Applied simplify to get
      \[\color{red}{\frac{\log base \cdot \log \left(\sqrt{{re}^2 + im \cdot im}\right) + 0}{{\left(\log base\right)}^2}} \leadsto \color{blue}{\frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\log base}}\]
      44.4
    6. Applied taylor to get
      \[\frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\log base} \leadsto \frac{\log \left(-1 \cdot im\right)}{\log base}\]
      0.4
    7. Taylor expanded around -inf to get
      \[\frac{\log \color{red}{\left(-1 \cdot im\right)}}{\log base} \leadsto \frac{\log \color{blue}{\left(-1 \cdot im\right)}}{\log base}\]
      0.4
    8. Applied simplify to get
      \[\color{red}{\frac{\log \left(-1 \cdot im\right)}{\log base}} \leadsto \color{blue}{\frac{\log \left(-im\right)}{\log base}}\]
      0.4

    if -5.051947517249776e+32 < im < -1.0784901626853544e-218 or 8.51308327519678e-216 < im < 1.5868349258537704e+124

    1. Started with
      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0}\]
      18.1
    2. Applied simplify to get
      \[\color{red}{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0}} \leadsto \color{blue}{\frac{\log base \cdot \log \left(\sqrt{{re}^2 + im \cdot im}\right) + 0}{\log base \cdot \log base}}\]
      18.1
    3. Applied simplify to get
      \[\frac{\color{red}{\log base \cdot \log \left(\sqrt{{re}^2 + im \cdot im}\right) + 0}}{\log base \cdot \log base} \leadsto \frac{\color{blue}{\log \left(\sqrt{im \cdot im + re \cdot re}\right) \cdot \log base}}{\log base \cdot \log base}\]
      18.1

    if -1.0784901626853544e-218 < im < 8.51308327519678e-216

    1. Started with
      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0}\]
      31.9
    2. Applied simplify to get
      \[\color{red}{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0}} \leadsto \color{blue}{\frac{\log base \cdot \log \left(\sqrt{{re}^2 + im \cdot im}\right) + 0}{\log base \cdot \log base}}\]
      31.9
    3. Applied taylor to get
      \[\frac{\log base \cdot \log \left(\sqrt{{re}^2 + im \cdot im}\right) + 0}{\log base \cdot \log base} \leadsto \frac{\log base \cdot \log \left(-1 \cdot re\right) + 0}{\log base \cdot \log base}\]
      0.5
    4. Taylor expanded around -inf to get
      \[\frac{\log base \cdot \log \color{red}{\left(-1 \cdot re\right)} + 0}{\log base \cdot \log base} \leadsto \frac{\log base \cdot \log \color{blue}{\left(-1 \cdot re\right)} + 0}{\log base \cdot \log base}\]
      0.5
    5. Applied simplify to get
      \[\color{red}{\frac{\log base \cdot \log \left(-1 \cdot re\right) + 0}{\log base \cdot \log base}} \leadsto \color{blue}{\frac{\log \left(-re\right)}{\log base}}\]
      0.4

    if 1.5868349258537704e+124 < im

    1. Started with
      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0}\]
      54.3
    2. Applied simplify to get
      \[\color{red}{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0}} \leadsto \color{blue}{\frac{\log base \cdot \log \left(\sqrt{{re}^2 + im \cdot im}\right) + 0}{\log base \cdot \log base}}\]
      54.3
    3. Applied taylor to get
      \[\frac{\log base \cdot \log \left(\sqrt{{re}^2 + im \cdot im}\right) + 0}{\log base \cdot \log base} \leadsto \frac{\log base \cdot \log im + 0}{\log base \cdot \log base}\]
      0.5
    4. Taylor expanded around 0 to get
      \[\frac{\log base \cdot \log \color{red}{im} + 0}{\log base \cdot \log base} \leadsto \frac{\log base \cdot \log \color{blue}{im} + 0}{\log base \cdot \log base}\]
      0.5
    5. Applied simplify to get
      \[\color{red}{\frac{\log base \cdot \log im + 0}{\log base \cdot \log base}} \leadsto \color{blue}{\frac{\log im}{\log base}}\]
      0.4

  1. Removed slow pow expressions

Original test:


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