Average Error: 30.5 → 16.8
Time: 51.4s
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 -1.2664790619393736 \cdot 10^{+120}:\\ \;\;\;\;\frac{-1}{\log base} \cdot \log \left(\frac{-1}{re}\right)\\ \mathbf{elif}\;re \le 3.4201672440346235 \cdot 10^{+103}:\\ \;\;\;\;\frac{1}{\log base \cdot \left(\log base \cdot \frac{1}{\log base \cdot \log \left(\sqrt{im \cdot im + re \cdot re}\right)}\right)}\\ \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 < -1.2664790619393736e+120

    1. Initial program 54.0

      \[\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 simplification54.0

      \[\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 div-inv54.0

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

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

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

    if -1.2664790619393736e+120 < re < 3.4201672440346235e+103

    1. Initial program 20.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 simplification20.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 clear-num20.2

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

      \[\leadsto \frac{1}{\color{blue}{\left(\log base \cdot \log base\right) \cdot \frac{1}{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}}}\]
    7. Using strategy rm
    8. Applied associate-*l*20.2

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

    if 3.4201672440346235e+103 < re

    1. Initial program 51.2

      \[\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 simplification51.2

      \[\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 div-inv51.2

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \le -1.2664790619393736 \cdot 10^{+120}:\\ \;\;\;\;\frac{-1}{\log base} \cdot \log \left(\frac{-1}{re}\right)\\ \mathbf{elif}\;re \le 3.4201672440346235 \cdot 10^{+103}:\\ \;\;\;\;\frac{1}{\log base \cdot \left(\log base \cdot \frac{1}{\log base \cdot \log \left(\sqrt{im \cdot im + re \cdot re}\right)}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{-\log re}{-\log base}\\ \end{array}\]

Runtime

Time bar (total: 51.4s)Debug logProfile

herbie shell --seed 2018252 
(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))))