Average Error: 31.2 → 13.6
Time: 1.4m
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 -3.61275636705143 \cdot 10^{+35}:\\ \;\;\;\;\frac{\log \left(-im\right)}{\log base}\\ \mathbf{if}\;im \le 1.8875741619944465 \cdot 10^{+140}:\\ \;\;\;\;\frac{1}{\frac{\log base}{\log \left(\sqrt{im \cdot im + re \cdot re}\right)}}\\ \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 3 regimes
  2. if im < -3.61275636705143e+35

    1. Initial program 44.7

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

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

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

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

    if -3.61275636705143e+35 < im < 1.8875741619944465e+140

    1. Initial program 20.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. Applied simplify20.8

      \[\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 clear-num20.9

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

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

    if 1.8875741619944465e+140 < im

    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. Applied simplify58.8

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

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

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

Runtime

Time bar (total: 1.4m)Debug log

herbie shell --seed '#(1567391828 2030694642 2833800258 828025724 3004380912 3532991858)' +o setup:early-exit
(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))))