Average Error: 30.4 → 16.9
Time: 49.2s
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}\;-re \le -1.3556794003074475 \cdot 10^{+95}:\\ \;\;\;\;\frac{\log re}{\log base}\\ \mathbf{if}\;-re \le 8.262394647296831 \cdot 10^{+142}:\\ \;\;\;\;\frac{\log \left(\sqrt{\sqrt{re \cdot re + im \cdot im}} \cdot \sqrt{\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}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log \left(-re\right)}{\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 (- re) < -1.3556794003074475e+95

    1. Initial program 48.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 8.9

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

    if -1.3556794003074475e+95 < (- re) < 8.262394647296831e+142

    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. Using strategy rm
    3. Applied add-sqr-sqrt20.8

      \[\leadsto \frac{\log \left(\sqrt{\color{blue}{\sqrt{re \cdot re + im \cdot im} \cdot \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 sqrt-prod20.8

      \[\leadsto \frac{\log \color{blue}{\left(\sqrt{\sqrt{re \cdot re + im \cdot im}} \cdot \sqrt{\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}\]

    if 8.262394647296831e+142 < (- re)

    1. Initial program 59.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. Taylor expanded around -inf 6.5

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

      \[\leadsto \color{blue}{\frac{\log \left(-re\right)}{\log base}}\]
  3. Recombined 3 regimes into one program.

Runtime

Time bar (total: 49.2s)Debug logProfile

herbie shell --seed '#(1064173506 2580572819 2847706409 4129882574 1125180799 1845288547)' 
(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))))