Average Error: 30.4 → 16.6
Time: 3.4m
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 -6.78761428929356 \cdot 10^{+126}:\\ \;\;\;\;\frac{\log \left(-re\right)}{\log base}\\ \mathbf{if}\;re \le 6.422215144202997 \cdot 10^{+133}:\\ \;\;\;\;\left(\log \left(\sqrt{im \cdot im + re \cdot re}\right) \cdot \frac{\frac{1}{\log base}}{\log base \cdot \log base}\right) \cdot \left(\log base \cdot \log base - 0 \cdot 0\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\log base \cdot \log re}{\log base \cdot \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 < -6.78761428929356e+126

    1. Initial program 55.6

      \[\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. Taylor expanded around -inf 7.8

      \[\leadsto \frac{\log \color{blue}{\left(-1 \cdot re\right)} \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0}\]
    3. Applied simplify7.7

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

    if -6.78761428929356e+126 < re < 6.422215144202997e+133

    1. Initial program 20.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. Using strategy rm
    3. Applied flip-+20.1

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\color{blue}{\frac{\left(\log base \cdot \log base\right) \cdot \left(\log base \cdot \log base\right) - \left(0 \cdot 0\right) \cdot \left(0 \cdot 0\right)}{\log base \cdot \log base - 0 \cdot 0}}}\]
    4. Applied associate-/r/20.1

      \[\leadsto \color{blue}{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\left(\log base \cdot \log base\right) \cdot \left(\log base \cdot \log base\right) - \left(0 \cdot 0\right) \cdot \left(0 \cdot 0\right)} \cdot \left(\log base \cdot \log base - 0 \cdot 0\right)}\]
    5. Applied simplify20.1

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

    if 6.422215144202997e+133 < re

    1. Initial program 57.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. Taylor expanded around inf 7.9

      \[\leadsto \frac{\log \color{blue}{re} \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0}\]
    3. Applied simplify7.9

      \[\leadsto \color{blue}{\frac{\log base \cdot \log re}{\log base \cdot \log base}}\]
  3. Recombined 3 regimes into one program.

Runtime

Time bar (total: 3.4m)Debug logProfile

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