Average Error: 32.4 → 18.0
Time: 7.3s
Precision: binary64
\[\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 -184.045576900692964:\\ \;\;\;\;\frac{\log 1 - \log \left(\frac{-1}{re}\right)}{\log base}\\ \mathbf{elif}\;re \le -5.4176857200810718 \cdot 10^{-297}:\\ \;\;\;\;\frac{\log base \cdot \log \left(\sqrt{re \cdot re + im \cdot im}\right) + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{{\left(\log base\right)}^{4} - {0.0}^{4}} \cdot \left(\log base \cdot \log base - 0.0 \cdot 0.0\right)\\ \mathbf{elif}\;re \le 4.03283230768147503 \cdot 10^{-263}:\\ \;\;\;\;\frac{\log 1 + \log im}{\log base}\\ \mathbf{elif}\;re \le 2.9972928323585169 \cdot 10^{140}:\\ \;\;\;\;\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \left(\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot {\left(\log base\right)}^{2}\right) - \tan^{-1}_* \frac{im}{re} \cdot \left(\tan^{-1}_* \frac{im}{re} \cdot \left(0.0 \cdot 0.0\right)\right)}{\left(0.0 \cdot 0.0 + {\left(\log base\right)}^{2}\right) \cdot \left(\log base \cdot \log \left(\sqrt{re \cdot re + im \cdot im}\right) - \tan^{-1}_* \frac{im}{re} \cdot 0.0\right)}\\ \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.0}{\log base \cdot \log base + 0.0 \cdot 0.0}
\begin{array}{l}
\mathbf{if}\;re \le -184.045576900692964:\\
\;\;\;\;\frac{\log 1 - \log \left(\frac{-1}{re}\right)}{\log base}\\

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

\mathbf{elif}\;re \le 4.03283230768147503 \cdot 10^{-263}:\\
\;\;\;\;\frac{\log 1 + \log im}{\log base}\\

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

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

\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 <= -184.04557690069296)) {
		VAR = ((double) (((double) (((double) log(1.0)) - ((double) log(((double) (-1.0 / re)))))) / ((double) log(base))));
	} else {
		double VAR_1;
		if ((re <= -5.417685720081072e-297)) {
			VAR_1 = ((double) (((double) (((double) (((double) (((double) log(base)) * ((double) log(((double) sqrt(((double) (((double) (re * re)) + ((double) (im * im)))))))))) + ((double) (((double) atan2(im, re)) * 0.0)))) / ((double) (((double) pow(((double) log(base)), 4.0)) - ((double) pow(0.0, 4.0)))))) * ((double) (((double) (((double) log(base)) * ((double) log(base)))) - ((double) (0.0 * 0.0))))));
		} else {
			double VAR_2;
			if ((re <= 4.032832307681475e-263)) {
				VAR_2 = ((double) (((double) (((double) log(1.0)) + ((double) log(im)))) / ((double) log(base))));
			} else {
				double VAR_3;
				if ((re <= 2.997292832358517e+140)) {
					VAR_3 = ((double) (((double) (((double) (((double) log(((double) sqrt(((double) (((double) (re * re)) + ((double) (im * im)))))))) * ((double) (((double) log(((double) sqrt(((double) (((double) (re * re)) + ((double) (im * im)))))))) * ((double) pow(((double) log(base)), 2.0)))))) - ((double) (((double) atan2(im, re)) * ((double) (((double) atan2(im, re)) * ((double) (0.0 * 0.0)))))))) / ((double) (((double) (((double) (0.0 * 0.0)) + ((double) pow(((double) log(base)), 2.0)))) * ((double) (((double) (((double) log(base)) * ((double) log(((double) sqrt(((double) (((double) (re * re)) + ((double) (im * im)))))))))) - ((double) (((double) atan2(im, re)) * 0.0))))))));
				} else {
					VAR_3 = ((double) (1.0 / ((double) (((double) log(base)) / ((double) log(re))))));
				}
				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 5 regimes
  2. if re < -184.045576900692964

    1. Initial program 40.8

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

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

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

    if -184.045576900692964 < re < -5.4176857200810718e-297

    1. Initial program 22.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 flip-+22.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}{\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.4

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

      \[\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\right)}^{4} - {0.0}^{4}}} \cdot \left(\log base \cdot \log base - 0.0 \cdot 0.0\right)\]

    if -5.4176857200810718e-297 < re < 4.03283230768147503e-263

    1. Initial program 34.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. Taylor expanded around 0 32.4

      \[\leadsto \color{blue}{\frac{\log 1 + \log im}{\log 1 + \log base}}\]
    3. Simplified32.4

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

    if 4.03283230768147503e-263 < re < 2.9972928323585169e140

    1. Initial program 20.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 div-inv20.3

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

      \[\leadsto \left(\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0\right) \cdot \color{blue}{\frac{1}{{\left(\log base\right)}^{2} + 0.0 \cdot 0.0}}\]
    5. Using strategy rm
    6. Applied flip-+20.3

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

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

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

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

    if 2.9972928323585169e140 < re

    1. Initial program 61.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 clear-num61.4

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \le -184.045576900692964:\\ \;\;\;\;\frac{\log 1 - \log \left(\frac{-1}{re}\right)}{\log base}\\ \mathbf{elif}\;re \le -5.4176857200810718 \cdot 10^{-297}:\\ \;\;\;\;\frac{\log base \cdot \log \left(\sqrt{re \cdot re + im \cdot im}\right) + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{{\left(\log base\right)}^{4} - {0.0}^{4}} \cdot \left(\log base \cdot \log base - 0.0 \cdot 0.0\right)\\ \mathbf{elif}\;re \le 4.03283230768147503 \cdot 10^{-263}:\\ \;\;\;\;\frac{\log 1 + \log im}{\log base}\\ \mathbf{elif}\;re \le 2.9972928323585169 \cdot 10^{140}:\\ \;\;\;\;\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \left(\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot {\left(\log base\right)}^{2}\right) - \tan^{-1}_* \frac{im}{re} \cdot \left(\tan^{-1}_* \frac{im}{re} \cdot \left(0.0 \cdot 0.0\right)\right)}{\left(0.0 \cdot 0.0 + {\left(\log base\right)}^{2}\right) \cdot \left(\log base \cdot \log \left(\sqrt{re \cdot re + im \cdot im}\right) - \tan^{-1}_* \frac{im}{re} \cdot 0.0\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{\log base}{\log re}}\\ \end{array}\]

Reproduce

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