Average Error: 31.0 → 17.0
Time: 3.7m
Precision: 64
Internal Precision: 576
\[\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}\]
\[\begin{array}{l} \mathbf{if}\;re \le -5.9574811165202225 \cdot 10^{+125}:\\ \;\;\;\;\frac{\log \left(-re\right)}{\frac{\log base \cdot \log base}{\log base}}\\ \mathbf{elif}\;re \le 1.6372007532725882 \cdot 10^{+96}:\\ \;\;\;\;\frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\frac{\log base \cdot \log base}{\log base}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-\log re}{-\log base}\\ \end{array}\]

Error

Bits error versus re

Bits error versus im

Bits error versus base

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if re < -5.9574811165202225e+125

    1. Initial program 55.1

      \[\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}\]
    2. Initial simplification55.1

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\log base \cdot \log base}\]
    3. Using strategy rm
    4. Applied associate-/l*55.1

      \[\leadsto \color{blue}{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\frac{\log base \cdot \log base}{\log base}}}\]
    5. Taylor expanded around -inf 7.9

      \[\leadsto \frac{\log \color{blue}{\left(-1 \cdot re\right)}}{\frac{\log base \cdot \log base}{\log base}}\]
    6. Simplified7.9

      \[\leadsto \frac{\log \color{blue}{\left(-re\right)}}{\frac{\log base \cdot \log base}{\log base}}\]

    if -5.9574811165202225e+125 < re < 1.6372007532725882e+96

    1. Initial program 21.1

      \[\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}\]
    2. Initial simplification21.1

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\log base \cdot \log base}\]
    3. Using strategy rm
    4. Applied associate-/l*21.1

      \[\leadsto \color{blue}{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\frac{\log base \cdot \log base}{\log base}}}\]

    if 1.6372007532725882e+96 < re

    1. Initial program 48.4

      \[\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}\]
    2. Initial simplification48.4

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\log base \cdot \log base}\]
    3. Using strategy rm
    4. Applied associate-/l*48.4

      \[\leadsto \color{blue}{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\frac{\log base \cdot \log base}{\log base}}}\]
    5. Using strategy rm
    6. Applied div-inv48.4

      \[\leadsto \color{blue}{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \frac{1}{\frac{\log base \cdot \log base}{\log base}}}\]
    7. Taylor expanded around inf 9.5

      \[\leadsto \color{blue}{\frac{\log \left(\frac{1}{re}\right)}{\log \left(\frac{1}{base}\right)}}\]
    8. Simplified9.5

      \[\leadsto \color{blue}{\frac{-\log re}{-\log base}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification17.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \le -5.9574811165202225 \cdot 10^{+125}:\\ \;\;\;\;\frac{\log \left(-re\right)}{\frac{\log base \cdot \log base}{\log base}}\\ \mathbf{elif}\;re \le 1.6372007532725882 \cdot 10^{+96}:\\ \;\;\;\;\frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\frac{\log base \cdot \log base}{\log base}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-\log re}{-\log base}\\ \end{array}\]

Runtime

Time bar (total: 3.7m)Debug logProfile

herbie shell --seed 2018248 
(FPCore (re im base)
  :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))))