Average Error: 30.9 → 16.8
Time: 1.6m
Precision: 64
Internal Precision: 128
\[\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 -3.950465317537182 \cdot 10^{+151}:\\ \;\;\;\;\log \left({\left(\frac{-1}{re}\right)}^{\frac{1}{3}}\right) \cdot \frac{-1}{\log base} + \log \left(\sqrt[3]{\frac{-1}{re}} \cdot \sqrt[3]{\frac{-1}{re}}\right) \cdot \frac{-1}{\log base}\\ \mathbf{elif}\;im \le -1.8195771354884505 \cdot 10^{-129}:\\ \;\;\;\;\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log base}\\ \mathbf{elif}\;im \le 7.12313116146826 \cdot 10^{-111}:\\ \;\;\;\;\log \left({\left(\frac{-1}{re}\right)}^{\frac{1}{3}}\right) \cdot \frac{-1}{\log base} + \log \left(\sqrt[3]{\frac{-1}{re}} \cdot \sqrt[3]{\frac{-1}{re}}\right) \cdot \frac{-1}{\log base}\\ \mathbf{elif}\;im \le 1.0672993883914327 \cdot 10^{+108}:\\ \;\;\;\;\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log base}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log im}{\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 im < -3.950465317537182e+151 or -1.8195771354884505e-129 < im < 7.12313116146826e-111

    1. Initial program 36.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. Initial simplification36.6

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\log base \cdot \log base}\]
    3. 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)}}\]
    4. Simplified20.2

      \[\leadsto \color{blue}{\frac{-1}{\log base} \cdot \log \left(\frac{-1}{re}\right)}\]
    5. Using strategy rm
    6. Applied add-cube-cbrt20.2

      \[\leadsto \frac{-1}{\log base} \cdot \log \color{blue}{\left(\left(\sqrt[3]{\frac{-1}{re}} \cdot \sqrt[3]{\frac{-1}{re}}\right) \cdot \sqrt[3]{\frac{-1}{re}}\right)}\]
    7. Applied log-prod20.2

      \[\leadsto \frac{-1}{\log base} \cdot \color{blue}{\left(\log \left(\sqrt[3]{\frac{-1}{re}} \cdot \sqrt[3]{\frac{-1}{re}}\right) + \log \left(\sqrt[3]{\frac{-1}{re}}\right)\right)}\]
    8. Applied distribute-lft-in20.2

      \[\leadsto \color{blue}{\frac{-1}{\log base} \cdot \log \left(\sqrt[3]{\frac{-1}{re}} \cdot \sqrt[3]{\frac{-1}{re}}\right) + \frac{-1}{\log base} \cdot \log \left(\sqrt[3]{\frac{-1}{re}}\right)}\]
    9. Using strategy rm
    10. Applied pow1/320.2

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

    if -3.950465317537182e+151 < im < -1.8195771354884505e-129 or 7.12313116146826e-111 < im < 1.0672993883914327e+108

    1. Initial program 16.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. Initial simplification16.8

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\log base \cdot \log base}\]
    3. Using strategy rm
    4. Applied times-frac16.7

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

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

    if 1.0672993883914327e+108 < im

    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. Initial simplification51.9

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\log base \cdot \log base}\]
    3. Taylor expanded around 0 7.7

      \[\leadsto \color{blue}{\frac{\log im}{\log base}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification16.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \le -3.950465317537182 \cdot 10^{+151}:\\ \;\;\;\;\log \left({\left(\frac{-1}{re}\right)}^{\frac{1}{3}}\right) \cdot \frac{-1}{\log base} + \log \left(\sqrt[3]{\frac{-1}{re}} \cdot \sqrt[3]{\frac{-1}{re}}\right) \cdot \frac{-1}{\log base}\\ \mathbf{elif}\;im \le -1.8195771354884505 \cdot 10^{-129}:\\ \;\;\;\;\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log base}\\ \mathbf{elif}\;im \le 7.12313116146826 \cdot 10^{-111}:\\ \;\;\;\;\log \left({\left(\frac{-1}{re}\right)}^{\frac{1}{3}}\right) \cdot \frac{-1}{\log base} + \log \left(\sqrt[3]{\frac{-1}{re}} \cdot \sqrt[3]{\frac{-1}{re}}\right) \cdot \frac{-1}{\log base}\\ \mathbf{elif}\;im \le 1.0672993883914327 \cdot 10^{+108}:\\ \;\;\;\;\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log base}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log im}{\log base}\\ \end{array}\]

Runtime

Time bar (total: 1.6m)Debug logProfile

BaselineHerbieOracleSpan%
Regimes28.516.86.921.554%
herbie shell --seed 2018351 
(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))))