Average Error: 31.1 → 17.2
Time: 1.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 -4.402648364861606 \cdot 10^{+144}:\\ \;\;\;\;\frac{\log re}{\log base}\\ \mathbf{if}\;-re \le -4.025957105797844 \cdot 10^{-252}:\\ \;\;\;\;\frac{1}{\sqrt{\log base \cdot \log base}} \cdot \frac{\log base \cdot \log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\sqrt{\log base \cdot \log base}}\\ \mathbf{if}\;-re \le 9.008777105504111 \cdot 10^{-235}:\\ \;\;\;\;\frac{\log base \cdot \log im}{\log base \cdot \log base}\\ \mathbf{if}\;-re \le 1.8997768895150623 \cdot 10^{+112}:\\ \;\;\;\;\frac{1}{\sqrt{\log base \cdot \log base}} \cdot \frac{\log base \cdot \log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\sqrt{\log base \cdot \log base}}\\ \mathbf{else}:\\ \;\;\;\;\log \left(\frac{-1}{re}\right) \cdot \frac{-1}{\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 4 regimes
  2. if (- re) < -4.402648364861606e+144

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

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

      \[\leadsto \color{blue}{\frac{\log re}{\log base} \cdot 1}\]

    if -4.402648364861606e+144 < (- re) < -4.025957105797844e-252 or 9.008777105504111e-235 < (- re) < 1.8997768895150623e+112

    1. Initial program 18.9

      \[\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 add-sqr-sqrt18.9

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

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

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

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

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

    if -4.025957105797844e-252 < (- re) < 9.008777105504111e-235

    1. Initial program 31.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 0 32.5

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

      \[\leadsto \color{blue}{\frac{\log base \cdot \log im}{\log base \cdot \log base}}\]

    if 1.8997768895150623e+112 < (- re)

    1. Initial program 51.9

      \[\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 62.8

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

      \[\leadsto \color{blue}{\frac{-1}{\log base} \cdot \log \left(\frac{-1}{re}\right)}\]
  3. Recombined 4 regimes into one program.
  4. Applied simplify17.2

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;-re \le -4.402648364861606 \cdot 10^{+144}:\\ \;\;\;\;\frac{\log re}{\log base}\\ \mathbf{if}\;-re \le -4.025957105797844 \cdot 10^{-252}:\\ \;\;\;\;\frac{1}{\sqrt{\log base \cdot \log base}} \cdot \frac{\log base \cdot \log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\sqrt{\log base \cdot \log base}}\\ \mathbf{if}\;-re \le 9.008777105504111 \cdot 10^{-235}:\\ \;\;\;\;\frac{\log base \cdot \log im}{\log base \cdot \log base}\\ \mathbf{if}\;-re \le 1.8997768895150623 \cdot 10^{+112}:\\ \;\;\;\;\frac{1}{\sqrt{\log base \cdot \log base}} \cdot \frac{\log base \cdot \log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\sqrt{\log base \cdot \log base}}\\ \mathbf{else}:\\ \;\;\;\;\log \left(\frac{-1}{re}\right) \cdot \frac{-1}{\log base}\\ \end{array}}\]

Runtime

Time bar (total: 1.4m)Debug logProfile

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