Average Error: 31.0 → 17.7
Time: 1.1m
Precision: 64
Internal Precision: 384
\[\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 -2.27249649114862 \cdot 10^{+70}:\\ \;\;\;\;\frac{\log \left(-im\right)}{\log base}\\ \mathbf{if}\;im \le -1.3435073056426419 \cdot 10^{-192}:\\ \;\;\;\;1 \cdot \frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\log base}\\ \mathbf{if}\;im \le -4.861880677138458 \cdot 10^{-301}:\\ \;\;\;\;\frac{\log re}{\log base}\\ \mathbf{if}\;im \le 2.4969404815932267 \cdot 10^{+53}:\\ \;\;\;\;1 \cdot \frac{\log \left(\sqrt{im \cdot im + re \cdot re}\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

Derivation

  1. Split input into 4 regimes
  2. if im < -2.27249649114862e+70

    1. Initial program 45.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. Applied simplify45.3

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

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

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

    if -2.27249649114862e+70 < im < -1.3435073056426419e-192 or -4.861880677138458e-301 < im < 2.4969404815932267e+53

    1. Initial program 20.0

      \[\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. Applied simplify20.0

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

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

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

    if -1.3435073056426419e-192 < im < -4.861880677138458e-301

    1. Initial program 30.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. Applied simplify30.9

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

      \[\leadsto \frac{\log base \cdot \log \color{blue}{re}}{\log base \cdot \log base}\]
    4. Applied simplify34.8

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

    if 2.4969404815932267e+53 < im

    1. Initial program 45.0

      \[\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. Applied simplify45.0

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

      \[\leadsto \frac{\log base \cdot \log \color{blue}{im}}{\log base \cdot \log base}\]
    4. Applied simplify11.5

      \[\leadsto \color{blue}{\frac{\log im}{\log base}}\]
  3. Recombined 4 regimes into one program.
  4. Removed slow pow expressions.

Runtime

Time bar (total: 1.1m)Debug logProfile

herbie shell --seed '#(1063282112 2455465480 4141627379 3773598652 1647277307 776739644)' 
(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))))