Average Error: 31.1 → 17.7
Time: 5.2m
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.2598324738165398 \cdot 10^{+116}:\\ \;\;\;\;\frac{-1}{\log base} \cdot \log \left(\frac{-1}{re}\right)\\ \mathbf{elif}\;re \le -8.120359948335902 \cdot 10^{-181}:\\ \;\;\;\;\frac{\frac{1}{2}}{\frac{\frac{\log base \cdot \log base}{\log base}}{\log \left(im \cdot im + re \cdot re\right)}}\\ \mathbf{elif}\;re \le 2.2744559929173244 \cdot 10^{-276}:\\ \;\;\;\;\frac{\log im}{\log base}\\ \mathbf{elif}\;re \le 9.321905324645453 \cdot 10^{+141}:\\ \;\;\;\;\left(\log base \cdot \log \left(im \cdot im + re \cdot re\right)\right) \cdot \frac{\frac{1}{2}}{\log base \cdot \log base}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{2}}{\frac{\frac{\log base \cdot \log base}{\log base}}{\log re \cdot 2}}\\ \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 5 regimes
  2. if re < -2.2598324738165398e+116

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

      \[\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 associate-/l*52.2

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

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

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

    if -2.2598324738165398e+116 < re < -8.120359948335902e-181

    1. Initial program 17.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 simplification17.6

      \[\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 associate-/l*17.5

      \[\leadsto \color{blue}{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\frac{\log base \cdot \log base}{\log base}}}\]
    5. Using strategy rm
    6. Applied pow1/217.5

      \[\leadsto \frac{\log \color{blue}{\left({\left(re \cdot re + im \cdot im\right)}^{\frac{1}{2}}\right)}}{\frac{\log base \cdot \log base}{\log base}}\]
    7. Applied log-pow17.5

      \[\leadsto \frac{\color{blue}{\frac{1}{2} \cdot \log \left(re \cdot re + im \cdot im\right)}}{\frac{\log base \cdot \log base}{\log base}}\]
    8. Applied associate-/l*17.5

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

    if -8.120359948335902e-181 < re < 2.2744559929173244e-276

    1. Initial program 32.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. Initial simplification32.5

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

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

    if 2.2744559929173244e-276 < re < 9.321905324645453e+141

    1. Initial program 19.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 simplification19.6

      \[\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 associate-/l*19.6

      \[\leadsto \color{blue}{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\frac{\log base \cdot \log base}{\log base}}}\]
    5. Using strategy rm
    6. Applied div-inv19.6

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\color{blue}{\left(\log base \cdot \log base\right) \cdot \frac{1}{\log base}}}\]
    7. Applied pow1/219.6

      \[\leadsto \frac{\log \color{blue}{\left({\left(re \cdot re + im \cdot im\right)}^{\frac{1}{2}}\right)}}{\left(\log base \cdot \log base\right) \cdot \frac{1}{\log base}}\]
    8. Applied log-pow19.6

      \[\leadsto \frac{\color{blue}{\frac{1}{2} \cdot \log \left(re \cdot re + im \cdot im\right)}}{\left(\log base \cdot \log base\right) \cdot \frac{1}{\log base}}\]
    9. Applied times-frac19.7

      \[\leadsto \color{blue}{\frac{\frac{1}{2}}{\log base \cdot \log base} \cdot \frac{\log \left(re \cdot re + im \cdot im\right)}{\frac{1}{\log base}}}\]
    10. Simplified19.6

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

    if 9.321905324645453e+141 < re

    1. Initial program 58.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 simplification58.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 associate-/l*58.8

      \[\leadsto \color{blue}{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\frac{\log base \cdot \log base}{\log base}}}\]
    5. Using strategy rm
    6. Applied pow1/258.8

      \[\leadsto \frac{\log \color{blue}{\left({\left(re \cdot re + im \cdot im\right)}^{\frac{1}{2}}\right)}}{\frac{\log base \cdot \log base}{\log base}}\]
    7. Applied log-pow58.8

      \[\leadsto \frac{\color{blue}{\frac{1}{2} \cdot \log \left(re \cdot re + im \cdot im\right)}}{\frac{\log base \cdot \log base}{\log base}}\]
    8. Applied associate-/l*58.8

      \[\leadsto \color{blue}{\frac{\frac{1}{2}}{\frac{\frac{\log base \cdot \log base}{\log base}}{\log \left(re \cdot re + im \cdot im\right)}}}\]
    9. Taylor expanded around inf 7.4

      \[\leadsto \frac{\frac{1}{2}}{\frac{\frac{\log base \cdot \log base}{\log base}}{\color{blue}{-2 \cdot \log \left(\frac{1}{re}\right)}}}\]
    10. Simplified7.4

      \[\leadsto \frac{\frac{1}{2}}{\frac{\frac{\log base \cdot \log base}{\log base}}{\color{blue}{\log re \cdot 2}}}\]
  3. Recombined 5 regimes into one program.
  4. Final simplification17.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \le -2.2598324738165398 \cdot 10^{+116}:\\ \;\;\;\;\frac{-1}{\log base} \cdot \log \left(\frac{-1}{re}\right)\\ \mathbf{elif}\;re \le -8.120359948335902 \cdot 10^{-181}:\\ \;\;\;\;\frac{\frac{1}{2}}{\frac{\frac{\log base \cdot \log base}{\log base}}{\log \left(im \cdot im + re \cdot re\right)}}\\ \mathbf{elif}\;re \le 2.2744559929173244 \cdot 10^{-276}:\\ \;\;\;\;\frac{\log im}{\log base}\\ \mathbf{elif}\;re \le 9.321905324645453 \cdot 10^{+141}:\\ \;\;\;\;\left(\log base \cdot \log \left(im \cdot im + re \cdot re\right)\right) \cdot \frac{\frac{1}{2}}{\log base \cdot \log base}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{2}}{\frac{\frac{\log base \cdot \log base}{\log base}}{\log re \cdot 2}}\\ \end{array}\]

Runtime

Time bar (total: 5.2m)Debug logProfile

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