Average Error: 32.3 → 18.2
Time: 8.2s
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.105570696718409 \cdot 10^{82}:\\ \;\;\;\;\frac{\frac{\log \left(-1 \cdot re\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.02574445467936043 \cdot 10^{130}:\\ \;\;\;\;\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.105570696718409 \cdot 10^{82}:\\
\;\;\;\;\frac{\frac{\log \left(-1 \cdot re\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.02574445467936043 \cdot 10^{130}:\\
\;\;\;\;\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.1055706967184089e+82)) {
		VAR = ((double) (((double) (((double) (((double) (((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 <= 1.0257444546793604e+130)) {
			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 {
			VAR_1 = ((double) (((double) log(((double) (1.0 / re)))) / ((double) log(((double) (1.0 / base))))));
		}
		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.1055706967184089e+82

    1. Initial program 49.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-sqrt49.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*49.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}}}\]
    5. Taylor expanded around -inf 10.5

      \[\leadsto \frac{\frac{\log \color{blue}{\left(-1 \cdot re\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.1055706967184089e+82 < re < 1.0257444546793604e+130

    1. Initial program 22.3

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

      \[\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*22.2

      \[\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 1.0257444546793604e+130 < re

    1. Initial program 58.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.6

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \le -1.105570696718409 \cdot 10^{82}:\\ \;\;\;\;\frac{\frac{\log \left(-1 \cdot re\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.02574445467936043 \cdot 10^{130}:\\ \;\;\;\;\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 2020126 
(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))))