Average Error: 32.3 → 18.0
Time: 7.4s
Precision: binary64
\[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0}\]
\[\begin{array}{l} \mathbf{if}\;re \leq -9.003963061251663 \cdot 10^{+137}:\\ \;\;\;\;\frac{\log \left(-re\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0}\\ \mathbf{elif}\;re \leq -8.602224484858101 \cdot 10^{-234}:\\ \;\;\;\;\frac{1}{\sqrt{0 \cdot 0 + {\left(\log base\right)}^{2}}} \cdot \frac{\tan^{-1}_* \frac{im}{re} \cdot 0 + \log base \cdot \log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\sqrt{0 \cdot 0 + {\left(\log base\right)}^{2}}}\\ \mathbf{elif}\;re \leq 8.19756653341619 \cdot 10^{-297}:\\ \;\;\;\;\frac{\log 1 + \log im}{\log base}\\ \mathbf{elif}\;re \leq 7.632785135818537 \cdot 10^{+48}:\\ \;\;\;\;\frac{1}{\sqrt{0 \cdot 0 + {\left(\log base\right)}^{2}}} \cdot \frac{\tan^{-1}_* \frac{im}{re} \cdot 0 + \log base \cdot \log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\sqrt{0 \cdot 0 + {\left(\log base\right)}^{2}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log re}{\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}{\log base \cdot \log base + 0 \cdot 0}
\begin{array}{l}
\mathbf{if}\;re \leq -9.003963061251663 \cdot 10^{+137}:\\
\;\;\;\;\frac{\log \left(-re\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0}\\

\mathbf{elif}\;re \leq -8.602224484858101 \cdot 10^{-234}:\\
\;\;\;\;\frac{1}{\sqrt{0 \cdot 0 + {\left(\log base\right)}^{2}}} \cdot \frac{\tan^{-1}_* \frac{im}{re} \cdot 0 + \log base \cdot \log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\sqrt{0 \cdot 0 + {\left(\log base\right)}^{2}}}\\

\mathbf{elif}\;re \leq 8.19756653341619 \cdot 10^{-297}:\\
\;\;\;\;\frac{\log 1 + \log im}{\log base}\\

\mathbf{elif}\;re \leq 7.632785135818537 \cdot 10^{+48}:\\
\;\;\;\;\frac{1}{\sqrt{0 \cdot 0 + {\left(\log base\right)}^{2}}} \cdot \frac{\tan^{-1}_* \frac{im}{re} \cdot 0 + \log base \cdot \log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\sqrt{0 \cdot 0 + {\left(\log base\right)}^{2}}}\\

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

\end{array}
(FPCore (re im base)
 :precision binary64
 (/
  (+ (* (log (sqrt (+ (* re re) (* im im)))) (log base)) (* (atan2 im re) 0.0))
  (+ (* (log base) (log base)) (* 0.0 0.0))))
(FPCore (re im base)
 :precision binary64
 (if (<= re -9.003963061251663e+137)
   (/
    (+ (* (log (- re)) (log base)) (* (atan2 im re) 0.0))
    (+ (* (log base) (log base)) (* 0.0 0.0)))
   (if (<= re -8.602224484858101e-234)
     (*
      (/ 1.0 (sqrt (+ (* 0.0 0.0) (pow (log base) 2.0))))
      (/
       (+
        (* (atan2 im re) 0.0)
        (* (log base) (log (sqrt (+ (* re re) (* im im))))))
       (sqrt (+ (* 0.0 0.0) (pow (log base) 2.0)))))
     (if (<= re 8.19756653341619e-297)
       (/ (+ (log 1.0) (log im)) (log base))
       (if (<= re 7.632785135818537e+48)
         (*
          (/ 1.0 (sqrt (+ (* 0.0 0.0) (pow (log base) 2.0))))
          (/
           (+
            (* (atan2 im re) 0.0)
            (* (log base) (log (sqrt (+ (* re re) (* im im))))))
           (sqrt (+ (* 0.0 0.0) (pow (log base) 2.0)))))
         (/ (log re) (log base)))))))
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 <= -9.003963061251663e+137)) {
		VAR = (((double) (((double) (((double) log(((double) -(re)))) * ((double) log(base)))) + ((double) (((double) atan2(im, re)) * 0.0)))) / ((double) (((double) (((double) log(base)) * ((double) log(base)))) + ((double) (0.0 * 0.0)))));
	} else {
		double VAR_1;
		if ((re <= -8.602224484858101e-234)) {
			VAR_1 = ((double) ((1.0 / ((double) sqrt(((double) (((double) (0.0 * 0.0)) + ((double) pow(((double) log(base)), 2.0))))))) * (((double) (((double) (((double) atan2(im, re)) * 0.0)) + ((double) (((double) log(base)) * ((double) log(((double) sqrt(((double) (((double) (re * re)) + ((double) (im * im)))))))))))) / ((double) sqrt(((double) (((double) (0.0 * 0.0)) + ((double) pow(((double) log(base)), 2.0)))))))));
		} else {
			double VAR_2;
			if ((re <= 8.19756653341619e-297)) {
				VAR_2 = (((double) (((double) log(1.0)) + ((double) log(im)))) / ((double) log(base)));
			} else {
				double VAR_3;
				if ((re <= 7.632785135818537e+48)) {
					VAR_3 = ((double) ((1.0 / ((double) sqrt(((double) (((double) (0.0 * 0.0)) + ((double) pow(((double) log(base)), 2.0))))))) * (((double) (((double) (((double) atan2(im, re)) * 0.0)) + ((double) (((double) log(base)) * ((double) log(((double) sqrt(((double) (((double) (re * re)) + ((double) (im * im)))))))))))) / ((double) sqrt(((double) (((double) (0.0 * 0.0)) + ((double) pow(((double) log(base)), 2.0)))))))));
				} else {
					VAR_3 = (((double) log(re)) / ((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 4 regimes
  2. if re < -9.003963061251663e137

    1. Initial program 60.4

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

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

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

    if -9.003963061251663e137 < re < -8.60222448485810144e-234 or 8.19756653341618975e-297 < re < 7.6327851358185368e48

    1. Initial program 20.6

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

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\color{blue}{\sqrt{\log base \cdot \log base + 0 \cdot 0} \cdot \sqrt{\log base \cdot \log base + 0 \cdot 0}}}\]
    4. Applied *-un-lft-identity20.6

      \[\leadsto \frac{\color{blue}{1 \cdot \left(\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0\right)}}{\sqrt{\log base \cdot \log base + 0 \cdot 0} \cdot \sqrt{\log base \cdot \log base + 0 \cdot 0}}\]
    5. Applied times-frac20.6

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

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

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

    if -8.60222448485810144e-234 < re < 8.19756653341618975e-297

    1. Initial program 31.5

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

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

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

    if 7.6327851358185368e48 < re

    1. Initial program 45.6

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq -9.003963061251663 \cdot 10^{+137}:\\ \;\;\;\;\frac{\log \left(-re\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0}\\ \mathbf{elif}\;re \leq -8.602224484858101 \cdot 10^{-234}:\\ \;\;\;\;\frac{1}{\sqrt{0 \cdot 0 + {\left(\log base\right)}^{2}}} \cdot \frac{\tan^{-1}_* \frac{im}{re} \cdot 0 + \log base \cdot \log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\sqrt{0 \cdot 0 + {\left(\log base\right)}^{2}}}\\ \mathbf{elif}\;re \leq 8.19756653341619 \cdot 10^{-297}:\\ \;\;\;\;\frac{\log 1 + \log im}{\log base}\\ \mathbf{elif}\;re \leq 7.632785135818537 \cdot 10^{+48}:\\ \;\;\;\;\frac{1}{\sqrt{0 \cdot 0 + {\left(\log base\right)}^{2}}} \cdot \frac{\tan^{-1}_* \frac{im}{re} \cdot 0 + \log base \cdot \log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\sqrt{0 \cdot 0 + {\left(\log base\right)}^{2}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log re}{\log base}\\ \end{array}\]

Reproduce

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