Average Error: 31.7 → 17.6
Time: 32.5s
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 -7.166994147449691 \cdot 10^{+117}:\\ \;\;\;\;\frac{-1}{\log base} \cdot \log \left(\frac{-1}{re}\right)\\ \mathbf{elif}\;re \le 6.064674052305725 \cdot 10^{+103}:\\ \;\;\;\;\frac{\log base \cdot \log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\sqrt{\log base \cdot \log base}} \cdot \frac{1}{\sqrt{\log base \cdot \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 < -7.166994147449691e+117

    1. Initial program 53.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. 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. Simplified8.5

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

    if -7.166994147449691e+117 < re < 6.064674052305725e+103

    1. Initial program 21.7

      \[\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-sqrt21.7

      \[\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-identity21.7

      \[\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-frac21.7

      \[\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. Simplified21.7

      \[\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. Simplified21.7

      \[\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 6.064674052305725e+103 < re

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

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

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

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

Runtime

Time bar (total: 32.5s)Debug logProfile

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