Average Error: 30.5 → 17.3
Time: 1.5m
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}\;re \le -7.123779293932832 \cdot 10^{+122}:\\ \;\;\;\;\log \left(e^{\frac{-1}{\log base} \cdot \log \left(\frac{-1}{re}\right)}\right)\\ \mathbf{elif}\;re \le -7.135212444301522 \cdot 10^{-170} \lor \neg \left(re \le -3.4047603445478845 \cdot 10^{-240}\right):\\ \;\;\;\;\frac{1}{\frac{\log base \cdot \log base}{\log base \cdot \log \left(\sqrt{im \cdot im + re \cdot re}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log im \cdot \log base}{\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 3 regimes
  2. if re < -7.123779293932832e+122

    1. Initial program 54.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. Initial simplification54.7

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

      \[\leadsto \color{blue}{\frac{-1}{\log base} \cdot \log \left(\frac{-1}{re}\right)}\]
    5. Using strategy rm
    6. Applied add-log-exp8.4

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

    if -7.123779293932832e+122 < re < -7.135212444301522e-170 or -3.4047603445478845e-240 < re

    1. Initial program 18.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 simplification18.1

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

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

    if -7.135212444301522e-170 < re < -3.4047603445478845e-240

    1. Initial program 31.4

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \le -7.123779293932832 \cdot 10^{+122}:\\ \;\;\;\;\log \left(e^{\frac{-1}{\log base} \cdot \log \left(\frac{-1}{re}\right)}\right)\\ \mathbf{elif}\;re \le -7.135212444301522 \cdot 10^{-170} \lor \neg \left(re \le -3.4047603445478845 \cdot 10^{-240}\right):\\ \;\;\;\;\frac{1}{\frac{\log base \cdot \log base}{\log base \cdot \log \left(\sqrt{im \cdot im + re \cdot re}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log im \cdot \log base}{\log base \cdot \log base}\\ \end{array}\]

Runtime

Time bar (total: 1.5m)Debug logProfile

BaselineHerbieOracleSpan%
Regimes28.917.36.922.052.8%
herbie shell --seed 2018352 
(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))))