Average Error: 32.1 → 17.8
Time: 8.2s
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 -2.0752208244632336 \cdot 10^{60}:\\ \;\;\;\;\frac{\log 1 - \log \left(\frac{-1}{re}\right)}{\log base}\\ \mathbf{elif}\;re \le -2.88208828919163744 \cdot 10^{-308}:\\ \;\;\;\;\frac{\log base \cdot \log \left(\sqrt{re \cdot re + im \cdot im}\right) + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\sqrt[3]{{\left(\log base\right)}^{6}} + 0.0 \cdot 0.0}\\ \mathbf{elif}\;re \le 1.0126300995154855 \cdot 10^{-212}:\\ \;\;\;\;\frac{\log 1 + \log im}{\log base}\\ \mathbf{elif}\;re \le 3.36626267455570162 \cdot 10^{37}:\\ \;\;\;\;\frac{\tan^{-1}_* \frac{im}{re} \cdot 0.0 + \sqrt[3]{{\left(\log base \cdot \log \left(\sqrt{re \cdot re + im \cdot im}\right)\right)}^{3}}}{0.0 \cdot 0.0 + \log base \cdot \log base}\\ \mathbf{else}:\\ \;\;\;\;\frac{\tan^{-1}_* \frac{im}{re} \cdot 0.0 + \log base \cdot \log re}{0.0 \cdot 0.0 + \log base \cdot \log base}\\ \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 -2.0752208244632336 \cdot 10^{60}:\\
\;\;\;\;\frac{\log 1 - \log \left(\frac{-1}{re}\right)}{\log base}\\

\mathbf{elif}\;re \le -2.88208828919163744 \cdot 10^{-308}:\\
\;\;\;\;\frac{\log base \cdot \log \left(\sqrt{re \cdot re + im \cdot im}\right) + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\sqrt[3]{{\left(\log base\right)}^{6}} + 0.0 \cdot 0.0}\\

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

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

\mathbf{else}:\\
\;\;\;\;\frac{\tan^{-1}_* \frac{im}{re} \cdot 0.0 + \log base \cdot \log re}{0.0 \cdot 0.0 + \log base \cdot \log base}\\

\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 <= -2.0752208244632336e+60)) {
		VAR = (((double) (((double) log(1.0)) - ((double) log((-1.0 / re))))) / ((double) log(base)));
	} else {
		double VAR_1;
		if ((re <= -2.8820882891916374e-308)) {
			VAR_1 = (((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) cbrt(((double) pow(((double) log(base)), 6.0)))) + ((double) (0.0 * 0.0)))));
		} else {
			double VAR_2;
			if ((re <= 1.0126300995154855e-212)) {
				VAR_2 = (((double) (((double) log(1.0)) + ((double) log(im)))) / ((double) log(base)));
			} else {
				double VAR_3;
				if ((re <= 3.3662626745557016e+37)) {
					VAR_3 = (((double) (((double) (((double) atan2(im, re)) * 0.0)) + ((double) cbrt(((double) pow(((double) (((double) log(base)) * ((double) log(((double) sqrt(((double) (((double) (re * re)) + ((double) (im * im)))))))))), 3.0)))))) / ((double) (((double) (0.0 * 0.0)) + ((double) (((double) log(base)) * ((double) log(base)))))));
				} else {
					VAR_3 = (((double) (((double) (((double) atan2(im, re)) * 0.0)) + ((double) (((double) log(base)) * ((double) log(re)))))) / ((double) (((double) (0.0 * 0.0)) + ((double) (((double) log(base)) * ((double) log(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 5 regimes
  2. if re < -2.0752208244632336e60

    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. 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. Simplified10.4

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

    if -2.0752208244632336e60 < re < -2.88208828919163744e-308

    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-cbrt-cube22.4

      \[\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}{\sqrt[3]{\left(\log base \cdot \log base\right) \cdot \log base}} + 0.0 \cdot 0.0}\]
    4. Applied add-cbrt-cube22.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[3]{\left(\log base \cdot \log base\right) \cdot \log base}} \cdot \sqrt[3]{\left(\log base \cdot \log base\right) \cdot \log base} + 0.0 \cdot 0.0}\]
    5. Applied cbrt-unprod22.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[3]{\left(\left(\log base \cdot \log base\right) \cdot \log base\right) \cdot \left(\left(\log base \cdot \log base\right) \cdot \log base\right)}} + 0.0 \cdot 0.0}\]
    6. Simplified22.4

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

    if -2.88208828919163744e-308 < re < 1.0126300995154855e-212

    1. Initial program 34.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 0 34.1

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

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

    if 1.0126300995154855e-212 < re < 3.36626267455570162e37

    1. Initial program 19.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-cbrt-cube19.8

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

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

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

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

    if 3.36626267455570162e37 < re

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

      \[\leadsto \frac{\log \color{blue}{re} \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\log base \cdot \log base + 0.0 \cdot 0.0}\]
  3. Recombined 5 regimes into one program.
  4. Final simplification17.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \le -2.0752208244632336 \cdot 10^{60}:\\ \;\;\;\;\frac{\log 1 - \log \left(\frac{-1}{re}\right)}{\log base}\\ \mathbf{elif}\;re \le -2.88208828919163744 \cdot 10^{-308}:\\ \;\;\;\;\frac{\log base \cdot \log \left(\sqrt{re \cdot re + im \cdot im}\right) + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\sqrt[3]{{\left(\log base\right)}^{6}} + 0.0 \cdot 0.0}\\ \mathbf{elif}\;re \le 1.0126300995154855 \cdot 10^{-212}:\\ \;\;\;\;\frac{\log 1 + \log im}{\log base}\\ \mathbf{elif}\;re \le 3.36626267455570162 \cdot 10^{37}:\\ \;\;\;\;\frac{\tan^{-1}_* \frac{im}{re} \cdot 0.0 + \sqrt[3]{{\left(\log base \cdot \log \left(\sqrt{re \cdot re + im \cdot im}\right)\right)}^{3}}}{0.0 \cdot 0.0 + \log base \cdot \log base}\\ \mathbf{else}:\\ \;\;\;\;\frac{\tan^{-1}_* \frac{im}{re} \cdot 0.0 + \log base \cdot \log re}{0.0 \cdot 0.0 + \log base \cdot \log base}\\ \end{array}\]

Reproduce

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