Average Error: 31.9 → 17.5
Time: 6.7s
Precision: binary64
\[\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 \leq -1.4855642221203277 \cdot 10^{+41}:\\ \;\;\;\;\frac{\log 1 - \log \left(\frac{-1}{re}\right)}{\log base}\\ \mathbf{elif}\;re \leq 4.6156350849393567 \cdot 10^{+111}:\\ \;\;\;\;\frac{1}{\sqrt{{\left(\log base\right)}^{2} + 0 \cdot 0}} \cdot \frac{\log base \cdot \log \left(\sqrt{re \cdot re + im \cdot im}\right) + 0 \cdot \tan^{-1}_* \frac{im}{re}}{\sqrt{{\left(\log base\right)}^{2} + 0 \cdot 0}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{\log base}{\log re}}\\ \end{array}\]
\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 \leq -1.4855642221203277 \cdot 10^{+41}:\\
\;\;\;\;\frac{\log 1 - \log \left(\frac{-1}{re}\right)}{\log base}\\

\mathbf{elif}\;re \leq 4.6156350849393567 \cdot 10^{+111}:\\
\;\;\;\;\frac{1}{\sqrt{{\left(\log base\right)}^{2} + 0 \cdot 0}} \cdot \frac{\log base \cdot \log \left(\sqrt{re \cdot re + im \cdot im}\right) + 0 \cdot \tan^{-1}_* \frac{im}{re}}{\sqrt{{\left(\log base\right)}^{2} + 0 \cdot 0}}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\log base}{\log re}}\\

\end{array}
double code(double re, double im, double base) {
	return (((double) (((double) (((double) log(((double) sqrt(((double) (((double) (re * re)) + ((double) (im * im)))))))) * ((double) log(base)))) + ((double) (((double) atan2(im, re)) * 0.0)))) / ((double) (((double) (((double) log(base)) * ((double) log(base)))) + ((double) (0.0 * 0.0)))));
}
double code(double re, double im, double base) {
	double VAR;
	if ((re <= -1.4855642221203277e+41)) {
		VAR = (((double) (((double) log(1.0)) - ((double) log((-1.0 / re))))) / ((double) log(base)));
	} else {
		double VAR_1;
		if ((re <= 4.6156350849393567e+111)) {
			VAR_1 = ((double) ((1.0 / ((double) sqrt(((double) (((double) pow(((double) log(base)), 2.0)) + ((double) (0.0 * 0.0))))))) * (((double) (((double) (((double) log(base)) * ((double) log(((double) sqrt(((double) (((double) (re * re)) + ((double) (im * im)))))))))) + ((double) (0.0 * ((double) atan2(im, re)))))) / ((double) sqrt(((double) (((double) pow(((double) log(base)), 2.0)) + ((double) (0.0 * 0.0)))))))));
		} else {
			VAR_1 = (1.0 / (((double) log(base)) / ((double) log(re))));
		}
		VAR = VAR_1;
	}
	return VAR;
}

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 < -1.48556422212032769e41

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

      \[\leadsto \color{blue}{\frac{\log 1 - \log \left(\frac{-1}{re}\right)}{\log -1 - \log \left(\frac{-1}{base}\right)}}\]
    3. Simplified11.7

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

    if -1.48556422212032769e41 < re < 4.61563508493935666e111

    1. Initial program 22.2

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

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\color{blue}{\sqrt{\log base \cdot \log base + 0 \cdot 0} \cdot \sqrt{\log base \cdot \log base + 0 \cdot 0}}}\]
    4. Applied *-un-lft-identity22.2

      \[\leadsto \frac{\color{blue}{1 \cdot \left(\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0\right)}}{\sqrt{\log base \cdot \log base + 0 \cdot 0} \cdot \sqrt{\log base \cdot \log base + 0 \cdot 0}}\]
    5. Applied times-frac22.2

      \[\leadsto \color{blue}{\frac{1}{\sqrt{\log base \cdot \log base + 0 \cdot 0}} \cdot \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\sqrt{\log base \cdot \log base + 0 \cdot 0}}}\]
    6. Simplified22.2

      \[\leadsto \color{blue}{\frac{1}{\sqrt{{\left(\log base\right)}^{2} + 0 \cdot 0}}} \cdot \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\sqrt{\log base \cdot \log base + 0 \cdot 0}}\]
    7. Simplified22.2

      \[\leadsto \frac{1}{\sqrt{{\left(\log base\right)}^{2} + 0 \cdot 0}} \cdot \color{blue}{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\sqrt{{\left(\log base\right)}^{2} + 0 \cdot 0}}}\]

    if 4.61563508493935666e111 < re

    1. Initial program 53.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. Using strategy rm
    3. Applied clear-num53.1

      \[\leadsto \color{blue}{\frac{1}{\frac{\log base \cdot \log base + 0 \cdot 0}{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}}}\]
    4. Simplified53.1

      \[\leadsto \frac{1}{\color{blue}{\frac{{\left(\log base\right)}^{2} + 0 \cdot 0}{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}}}\]
    5. Taylor expanded around inf 7.9

      \[\leadsto \frac{1}{\color{blue}{\frac{\log 1 - \log \left(\frac{1}{base}\right)}{\log 1 - \log \left(\frac{1}{re}\right)}}}\]
    6. Simplified7.9

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq -1.4855642221203277 \cdot 10^{+41}:\\ \;\;\;\;\frac{\log 1 - \log \left(\frac{-1}{re}\right)}{\log base}\\ \mathbf{elif}\;re \leq 4.6156350849393567 \cdot 10^{+111}:\\ \;\;\;\;\frac{1}{\sqrt{{\left(\log base\right)}^{2} + 0 \cdot 0}} \cdot \frac{\log base \cdot \log \left(\sqrt{re \cdot re + im \cdot im}\right) + 0 \cdot \tan^{-1}_* \frac{im}{re}}{\sqrt{{\left(\log base\right)}^{2} + 0 \cdot 0}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{\log base}{\log re}}\\ \end{array}\]

Reproduce

herbie shell --seed 2020199 
(FPCore (re im base)
  :name "math.log/2 on complex, real part"
  :precision binary64
  (/ (+ (* (log (sqrt (+ (* re re) (* im im)))) (log base)) (* (atan2 im re) 0.0)) (+ (* (log base) (log base)) (* 0.0 0.0))))