Average Error: 31.3 → 17.0
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 -1.3378009695161851 \cdot 10^{+154}:\\ \;\;\;\;\frac{\log \left(\frac{-1}{re}\right) \cdot \left(-\log base\right)}{\log base \cdot \log base}\\ \mathbf{elif}\;im \le -3.7368973661738945 \cdot 10^{-101}:\\ \;\;\;\;\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log base}\\ \mathbf{elif}\;im \le 1.9349690822092957 \cdot 10^{-164}:\\ \;\;\;\;\frac{\log \left(\frac{-1}{re}\right) \cdot \left(-\log base\right)}{\log base \cdot \log base}\\ \mathbf{elif}\;im \le 5.238375664691967 \cdot 10^{+86}:\\ \;\;\;\;\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 < -1.3378009695161851e+154 or -3.7368973661738945e-101 < im < 1.9349690822092957e-164

    1. Initial program 39.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. Initial simplification39.1

      \[\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 \frac{\color{blue}{-1 \cdot \left(\log \left(\frac{-1}{re}\right) \cdot \left(\log -1 - \log \left(\frac{-1}{base}\right)\right)\right)}}{\log base \cdot \log base}\]
    4. Simplified21.2

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

    if -1.3378009695161851e+154 < im < -3.7368973661738945e-101 or 1.9349690822092957e-164 < im < 5.238375664691967e+86

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

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

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

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

    if 5.238375664691967e+86 < im

    1. Initial program 47.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 simplification47.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 0 9.8

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \le -1.3378009695161851 \cdot 10^{+154}:\\ \;\;\;\;\frac{\log \left(\frac{-1}{re}\right) \cdot \left(-\log base\right)}{\log base \cdot \log base}\\ \mathbf{elif}\;im \le -3.7368973661738945 \cdot 10^{-101}:\\ \;\;\;\;\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log base}\\ \mathbf{elif}\;im \le 1.9349690822092957 \cdot 10^{-164}:\\ \;\;\;\;\frac{\log \left(\frac{-1}{re}\right) \cdot \left(-\log base\right)}{\log base \cdot \log base}\\ \mathbf{elif}\;im \le 5.238375664691967 \cdot 10^{+86}:\\ \;\;\;\;\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%
Regimes29.017.07.321.755%
herbie shell --seed 2018354 
(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))))