Average Error: 31.3 → 19.1
Time: 2.8m
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 -2.9216166541368324 \cdot 10^{+122}:\\ \;\;\;\;\frac{\log \left(-re\right)}{\log base}\\ \mathbf{if}\;re \le -1.2064191199655908 \cdot 10^{-248}:\\ \;\;\;\;\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\sqrt[3]{{\left(\log base \cdot \log base\right)}^{3}} + 0 \cdot 0}\\ \mathbf{if}\;re \le 6.587431757463134 \cdot 10^{-222}:\\ \;\;\;\;\frac{\log im}{\log base}\\ \mathbf{if}\;re \le 4.662681224595411 \cdot 10^{-97}:\\ \;\;\;\;\frac{\log \left(-im\right)}{\log base}\\ \mathbf{if}\;re \le 5.8691948597264694 \cdot 10^{+107}:\\ \;\;\;\;\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\sqrt[3]{{\left(\log base \cdot \log base\right)}^{3}} + 0 \cdot 0}\\ \mathbf{else}:\\ \;\;\;\;\frac{-\log re}{-\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 re < -2.9216166541368324e+122

    1. Initial program 52.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 7.9

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

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

    if -2.9216166541368324e+122 < re < -1.2064191199655908e-248 or 4.662681224595411e-97 < re < 5.8691948597264694e+107

    1. Initial program 18.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-cbrt-cube18.8

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

      \[\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[3]{\left(\log base \cdot \log base\right) \cdot \log base}} \cdot \sqrt[3]{\left(\log base \cdot \log base\right) \cdot \log base} + 0 \cdot 0}\]
    5. Applied cbrt-unprod18.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[3]{\left(\left(\log base \cdot \log base\right) \cdot \log base\right) \cdot \left(\left(\log base \cdot \log base\right) \cdot \log base\right)}} + 0 \cdot 0}\]
    6. Applied simplify18.8

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

    if -1.2064191199655908e-248 < re < 6.587431757463134e-222

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

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

    if 6.587431757463134e-222 < re < 4.662681224595411e-97

    1. Initial program 22.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 clear-num22.9

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

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

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

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

    if 5.8691948597264694e+107 < re

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

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

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

Runtime

Time bar (total: 2.8m)Debug logProfile

herbie shell --seed '#(1071821486 549052472 3784827256 1559736200 3548510075 881134285)' 
(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))))