Average Error: 30.9 → 19.0
Time: 3.6m
Precision: 64
Internal Precision: 384
\[\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}\;-im \le -1.5804974069431365 \cdot 10^{+81}:\\ \;\;\;\;\frac{\log im}{\log base}\\ \mathbf{if}\;-im \le -1.5899367998282125 \cdot 10^{-210}:\\ \;\;\;\;\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}\;-im \le 1.148517948158285 \cdot 10^{-210}:\\ \;\;\;\;\frac{-\log re}{-\log base}\\ \mathbf{if}\;-im \le 8.797961098260114 \cdot 10^{-158}:\\ \;\;\;\;\frac{\log \left(-re\right)}{\log base}\\ \mathbf{if}\;-im \le 1.4042710844831155 \cdot 10^{-102}:\\ \;\;\;\;\frac{-\log re}{-\log base}\\ \mathbf{if}\;-im \le 1.3697690058318732 \cdot 10^{+93}:\\ \;\;\;\;\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}:\\ \;\;\;\;\frac{\log \left(-im\right)}{\log base}\\ \end{array}\]

Error

Bits error versus re

Bits error versus im

Bits error versus base

Derivation

  1. Split input into 5 regimes
  2. if (- im) < -1.5804974069431365e+81

    1. Initial program 46.5

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

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

    if -1.5804974069431365e+81 < (- im) < -1.5899367998282125e-210 or 1.4042710844831155e-102 < (- im) < 1.3697690058318732e+93

    1. Initial program 17.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. Using strategy rm
    3. Applied add-sqr-sqrt17.4

      \[\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-identity17.4

      \[\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-frac17.4

      \[\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 simplify17.4

      \[\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 simplify17.4

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

    if -1.5899367998282125e-210 < (- im) < 1.148517948158285e-210 or 8.797961098260114e-158 < (- im) < 1.4042710844831155e-102

    1. Initial program 27.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 35.4

      \[\leadsto \color{blue}{\frac{\log \left(\frac{1}{re}\right)}{\log \left(\frac{1}{base}\right)}}\]
    3. Applied simplify35.4

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

    if 1.148517948158285e-210 < (- im) < 8.797961098260114e-158

    1. Initial program 28.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 34.1

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

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

    if 1.3697690058318732e+93 < (- im)

    1. Initial program 49.8

      \[\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-sqrt49.8

      \[\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 associate-/r*49.8

      \[\leadsto \color{blue}{\frac{\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}}}{\sqrt{\log base \cdot \log base + 0 \cdot 0}}}\]
    5. Applied simplify49.8

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

      \[\leadsto \frac{\frac{\log base \cdot \log \color{blue}{\left(-1 \cdot im\right)}}{\sqrt{\log base \cdot \log base}}}{\sqrt{\log base \cdot \log base + 0 \cdot 0}}\]
    7. Applied simplify9.4

      \[\leadsto \color{blue}{\frac{\log \left(-im\right)}{\log base}}\]
  3. Recombined 5 regimes into one program.

Runtime

Time bar (total: 3.6m)Debug logProfile

herbie shell --seed '#(1070960995 739739648 2531964651 3069671617 351857262 3877178482)' 
(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))))