Average Error: 31.2 → 18.1
Time: 3.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 -1.3505082134524001 \cdot 10^{+32}:\\ \;\;\;\;\frac{\log \left(-re\right)}{\log base}\\ \mathbf{if}\;re \le -2.1809202669233877 \cdot 10^{-170}:\\ \;\;\;\;\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{if}\;re \le -3.7032766182290336 \cdot 10^{-250}:\\ \;\;\;\;\frac{-1}{\log base \cdot \log base} \cdot \left(\log \left(\frac{-1}{im}\right) \cdot \log base\right)\\ \mathbf{if}\;re \le 1.5998665519233234 \cdot 10^{-303}:\\ \;\;\;\;\frac{\log im}{\log base}\\ \mathbf{if}\;re \le 6.160578325280785 \cdot 10^{-218}:\\ \;\;\;\;\frac{\log \left(-im\right)}{\log base}\\ \mathbf{if}\;re \le 1.2572170467906488 \cdot 10^{-205} \lor \neg \left(re \le 3.0378643623074555 \cdot 10^{+54}\right):\\ \;\;\;\;\frac{-\log re}{-\log base}\\ \mathbf{else}:\\ \;\;\;\;\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}}\\ \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 6 regimes
  2. if re < -1.3505082134524001e+32

    1. Initial program 41.3

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

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

    if -1.3505082134524001e+32 < re < -2.1809202669233877e-170 or 1.2572170467906488e-205 < re < 3.0378643623074555e+54

    1. Initial program 17.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-sqrt17.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 *-un-lft-identity17.8

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

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

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

      \[\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 -2.1809202669233877e-170 < re < -3.7032766182290336e-250

    1. Initial program 30.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-sqrt30.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 *-un-lft-identity30.8

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

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

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

      \[\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}}}\]
    8. Taylor expanded around -inf 62.8

      \[\leadsto \frac{1}{\sqrt{\log base \cdot \log base}} \cdot \frac{\color{blue}{-1 \cdot \left(\left(\log -1 - \log \left(\frac{-1}{base}\right)\right) \cdot \log \left(\frac{-1}{im}\right)\right)}}{\sqrt{\log base \cdot \log base}}\]
    9. Applied simplify36.0

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

    if -3.7032766182290336e-250 < re < 1.5998665519233234e-303

    1. Initial program 34.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 33.0

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

    if 1.5998665519233234e-303 < re < 6.160578325280785e-218

    1. Initial program 31.3

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

      \[\leadsto \color{blue}{\sqrt[3]{\left(\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} \cdot \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}\right) \cdot \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}}}\]
    4. Applied simplify31.4

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

      \[\leadsto \sqrt[3]{{\left(\frac{\log \color{blue}{\left(-1 \cdot im\right)}}{\frac{\log base}{1}}\right)}^{3}}\]
    6. Applied simplify33.7

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

    if 6.160578325280785e-218 < re < 1.2572170467906488e-205 or 3.0378643623074555e+54 < re

    1. Initial program 44.1

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

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

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

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;re \le -1.3505082134524001 \cdot 10^{+32}:\\ \;\;\;\;\frac{\log \left(-re\right)}{\log base}\\ \mathbf{if}\;re \le -2.1809202669233877 \cdot 10^{-170}:\\ \;\;\;\;\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{if}\;re \le -3.7032766182290336 \cdot 10^{-250}:\\ \;\;\;\;\frac{-1}{\log base \cdot \log base} \cdot \left(\log \left(\frac{-1}{im}\right) \cdot \log base\right)\\ \mathbf{if}\;re \le 1.5998665519233234 \cdot 10^{-303}:\\ \;\;\;\;\frac{\log im}{\log base}\\ \mathbf{if}\;re \le 6.160578325280785 \cdot 10^{-218}:\\ \;\;\;\;\frac{\log \left(-im\right)}{\log base}\\ \mathbf{if}\;re \le 1.2572170467906488 \cdot 10^{-205} \lor \neg \left(re \le 3.0378643623074555 \cdot 10^{+54}\right):\\ \;\;\;\;\frac{-\log re}{-\log base}\\ \mathbf{else}:\\ \;\;\;\;\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}}\\ \end{array}}\]

Runtime

Time bar (total: 3.8m)Debug logProfile

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