Average Error: 31.8 → 18.2
Time: 7.6s
Precision: 64
\[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\log base \cdot \log base + 0.0 \cdot 0.0}\]
\[\begin{array}{l} \mathbf{if}\;re \le -1.4185974229156341 \cdot 10^{116}:\\ \;\;\;\;\frac{\frac{\left(-1 \cdot \log \left(\frac{-1}{re}\right)\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}\\ \mathbf{elif}\;re \le -2.60707670884589029 \cdot 10^{-120}:\\ \;\;\;\;\frac{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}\\ \mathbf{elif}\;re \le -1.0096510313516879 \cdot 10^{-179}:\\ \;\;\;\;\frac{\log im}{\log base}\\ \mathbf{elif}\;re \le 7.916959787142804 \cdot 10^{93}:\\ \;\;\;\;\frac{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log \left(\frac{1}{re}\right)}{\log \left(\frac{1}{base}\right)}\\ \end{array}\]
\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\log base \cdot \log base + 0.0 \cdot 0.0}
\begin{array}{l}
\mathbf{if}\;re \le -1.4185974229156341 \cdot 10^{116}:\\
\;\;\;\;\frac{\frac{\left(-1 \cdot \log \left(\frac{-1}{re}\right)\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}\\

\mathbf{elif}\;re \le -2.60707670884589029 \cdot 10^{-120}:\\
\;\;\;\;\frac{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}\\

\mathbf{elif}\;re \le -1.0096510313516879 \cdot 10^{-179}:\\
\;\;\;\;\frac{\log im}{\log base}\\

\mathbf{elif}\;re \le 7.916959787142804 \cdot 10^{93}:\\
\;\;\;\;\frac{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\log \left(\frac{1}{re}\right)}{\log \left(\frac{1}{base}\right)}\\

\end{array}
double code(double re, double im, double base) {
	return ((double) (((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.4185974229156341e+116)) {
		VAR = ((double) (((double) (((double) (((double) (((double) (-1.0 * ((double) log(((double) (-1.0 / re)))))) * ((double) log(base)))) + ((double) (((double) atan2(im, re)) * 0.0)))) / ((double) sqrt(((double) (((double) (((double) log(base)) * ((double) log(base)))) + ((double) (0.0 * 0.0)))))))) / ((double) sqrt(((double) (((double) (((double) log(base)) * ((double) log(base)))) + ((double) (0.0 * 0.0))))))));
	} else {
		double VAR_1;
		if ((re <= -2.6070767088458903e-120)) {
			VAR_1 = ((double) (((double) (((double) (((double) (((double) log(((double) sqrt(((double) (((double) (re * re)) + ((double) (im * im)))))))) * ((double) log(base)))) + ((double) (((double) atan2(im, re)) * 0.0)))) / ((double) sqrt(((double) (((double) (((double) log(base)) * ((double) log(base)))) + ((double) (0.0 * 0.0)))))))) / ((double) sqrt(((double) (((double) (((double) log(base)) * ((double) log(base)))) + ((double) (0.0 * 0.0))))))));
		} else {
			double VAR_2;
			if ((re <= -1.0096510313516879e-179)) {
				VAR_2 = ((double) (((double) log(im)) / ((double) log(base))));
			} else {
				double VAR_3;
				if ((re <= 7.916959787142804e+93)) {
					VAR_3 = ((double) (((double) (((double) (((double) (((double) log(((double) sqrt(((double) (((double) (re * re)) + ((double) (im * im)))))))) * ((double) log(base)))) + ((double) (((double) atan2(im, re)) * 0.0)))) / ((double) sqrt(((double) (((double) (((double) log(base)) * ((double) log(base)))) + ((double) (0.0 * 0.0)))))))) / ((double) sqrt(((double) (((double) (((double) log(base)) * ((double) log(base)))) + ((double) (0.0 * 0.0))))))));
				} else {
					VAR_3 = ((double) (((double) log(((double) (1.0 / re)))) / ((double) log(((double) (1.0 / base))))));
				}
				VAR_2 = VAR_3;
			}
			VAR_1 = VAR_2;
		}
		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 4 regimes
  2. if re < -1.4185974229156341e+116

    1. Initial program 54.4

      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\log base \cdot \log base + 0.0 \cdot 0.0}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt54.4

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\color{blue}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0} \cdot \sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}}\]
    4. Applied associate-/r*54.4

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

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

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

    if -1.4185974229156341e+116 < re < -2.6070767088458903e-120 or -1.0096510313516879e-179 < re < 7.916959787142804e+93

    1. Initial program 21.6

      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\log base \cdot \log base + 0.0 \cdot 0.0}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt21.6

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\color{blue}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0} \cdot \sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}}\]
    4. Applied associate-/r*21.6

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

    if -2.6070767088458903e-120 < re < -1.0096510313516879e-179

    1. Initial program 21.5

      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\log base \cdot \log base + 0.0 \cdot 0.0}\]
    2. Taylor expanded around 0 40.6

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

    if 7.916959787142804e+93 < re

    1. Initial program 50.0

      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\log base \cdot \log base + 0.0 \cdot 0.0}\]
    2. Taylor expanded around inf 8.2

      \[\leadsto \color{blue}{\frac{\log \left(\frac{1}{re}\right)}{\log \left(\frac{1}{base}\right)}}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification18.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \le -1.4185974229156341 \cdot 10^{116}:\\ \;\;\;\;\frac{\frac{\left(-1 \cdot \log \left(\frac{-1}{re}\right)\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}\\ \mathbf{elif}\;re \le -2.60707670884589029 \cdot 10^{-120}:\\ \;\;\;\;\frac{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}\\ \mathbf{elif}\;re \le -1.0096510313516879 \cdot 10^{-179}:\\ \;\;\;\;\frac{\log im}{\log base}\\ \mathbf{elif}\;re \le 7.916959787142804 \cdot 10^{93}:\\ \;\;\;\;\frac{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log \left(\frac{1}{re}\right)}{\log \left(\frac{1}{base}\right)}\\ \end{array}\]

Reproduce

herbie shell --seed 2020113 
(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))))