Average Error: 31.8 → 17.9
Time: 7.9s
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 -6.2516816374929655 \cdot 10^{43}:\\ \;\;\;\;\frac{\log \left(-1 \cdot re\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\left(\log base \cdot \left(2 \cdot \log \left(\sqrt[3]{base}\right)\right) + \log base \cdot \log \left(\sqrt[3]{base}\right)\right) + 0.0 \cdot 0.0}\\ \mathbf{elif}\;re \le 7.3038892301020221 \cdot 10^{84}:\\ \;\;\;\;\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\left(-{0.0}^{3}\right) \cdot 0.0 + {\left({\left(\log base\right)}^{2}\right)}^{\left(\sqrt{4}\right)}} \cdot \left(\log base \cdot \log base - 0.0 \cdot 0.0\right)\\ \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 -6.2516816374929655 \cdot 10^{43}:\\
\;\;\;\;\frac{\log \left(-1 \cdot re\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\left(\log base \cdot \left(2 \cdot \log \left(\sqrt[3]{base}\right)\right) + \log base \cdot \log \left(\sqrt[3]{base}\right)\right) + 0.0 \cdot 0.0}\\

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

\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 (((log(sqrt(((re * re) + (im * im)))) * log(base)) + (atan2(im, re) * 0.0)) / ((log(base) * log(base)) + (0.0 * 0.0)));
}
double code(double re, double im, double base) {
	double VAR;
	if ((re <= -6.251681637492965e+43)) {
		VAR = (((log((-1.0 * re)) * log(base)) + (atan2(im, re) * 0.0)) / (((log(base) * (2.0 * log(cbrt(base)))) + (log(base) * log(cbrt(base)))) + (0.0 * 0.0)));
	} else {
		double VAR_1;
		if ((re <= 7.303889230102022e+84)) {
			VAR_1 = ((((log(sqrt(((re * re) + (im * im)))) * log(base)) + (atan2(im, re) * 0.0)) / ((-pow(0.0, 3.0) * 0.0) + pow(pow(log(base), 2.0), sqrt(4.0)))) * ((log(base) * log(base)) - (0.0 * 0.0)));
		} else {
			VAR_1 = (log((1.0 / re)) / log((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 < -6.251681637492965e+43

    1. Initial program 45.2

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

      \[\leadsto \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 \color{blue}{\left(\left(\sqrt[3]{base} \cdot \sqrt[3]{base}\right) \cdot \sqrt[3]{base}\right)} + 0.0 \cdot 0.0}\]
    4. Applied log-prod45.2

      \[\leadsto \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 \color{blue}{\left(\log \left(\sqrt[3]{base} \cdot \sqrt[3]{base}\right) + \log \left(\sqrt[3]{base}\right)\right)} + 0.0 \cdot 0.0}\]
    5. Applied distribute-lft-in45.2

      \[\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}{\left(\log base \cdot \log \left(\sqrt[3]{base} \cdot \sqrt[3]{base}\right) + \log base \cdot \log \left(\sqrt[3]{base}\right)\right)} + 0.0 \cdot 0.0}\]
    6. Simplified45.2

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

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

    if -6.251681637492965e+43 < re < 7.303889230102022e+84

    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.0}{\log base \cdot \log base + 0.0 \cdot 0.0}\]
    2. Using strategy rm
    3. Applied flip-+22.2

      \[\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}{\frac{\left(\log base \cdot \log base\right) \cdot \left(\log base \cdot \log base\right) - \left(0.0 \cdot 0.0\right) \cdot \left(0.0 \cdot 0.0\right)}{\log base \cdot \log base - 0.0 \cdot 0.0}}}\]
    4. Applied associate-/r/22.2

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

      \[\leadsto \color{blue}{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\left(-{0.0}^{3}\right) \cdot 0.0 + {\left(\log base\right)}^{4}}} \cdot \left(\log base \cdot \log base - 0.0 \cdot 0.0\right)\]
    6. Using strategy rm
    7. 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}{\left(-{0.0}^{3}\right) \cdot 0.0 + {\left(\log base\right)}^{\color{blue}{\left(\sqrt{4} \cdot \sqrt{4}\right)}}} \cdot \left(\log base \cdot \log base - 0.0 \cdot 0.0\right)\]
    8. Applied pow-unpow22.2

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

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

    if 7.303889230102022e+84 < re

    1. Initial program 49.1

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

      \[\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 simplification17.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \le -6.2516816374929655 \cdot 10^{43}:\\ \;\;\;\;\frac{\log \left(-1 \cdot re\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\left(\log base \cdot \left(2 \cdot \log \left(\sqrt[3]{base}\right)\right) + \log base \cdot \log \left(\sqrt[3]{base}\right)\right) + 0.0 \cdot 0.0}\\ \mathbf{elif}\;re \le 7.3038892301020221 \cdot 10^{84}:\\ \;\;\;\;\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\left(-{0.0}^{3}\right) \cdot 0.0 + {\left({\left(\log base\right)}^{2}\right)}^{\left(\sqrt{4}\right)}} \cdot \left(\log base \cdot \log base - 0.0 \cdot 0.0\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\log \left(\frac{1}{re}\right)}{\log \left(\frac{1}{base}\right)}\\ \end{array}\]

Reproduce

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