Average Error: 32.2 → 24.1
Time: 7.5s
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}\;im \leq -1.3444364465238792 \cdot 10^{+154}:\\ \;\;\;\;\frac{1}{\sqrt{{\left(\log base\right)}^{2} + 0 \cdot 0}} \cdot \frac{\log base \cdot \log \left(-re\right) + 0 \cdot \tan^{-1}_* \frac{im}{re}}{\sqrt{{\left(\log base\right)}^{2} + 0 \cdot 0}}\\ \mathbf{elif}\;im \leq -2.3107304361754112 \cdot 10^{-235}:\\ \;\;\;\;\frac{1}{\sqrt{{\left(\log base\right)}^{2} + 0 \cdot 0}} \cdot \frac{0 \cdot \tan^{-1}_* \frac{im}{re} + \log base \cdot \log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\sqrt{{\left(\log base\right)}^{2} + 0 \cdot 0}}\\ \mathbf{elif}\;im \leq -2.7719158935979882 \cdot 10^{-303}:\\ \;\;\;\;\frac{\log base \cdot \log \left(-re\right) + 0 \cdot \tan^{-1}_* \frac{im}{re}}{{\left(\log base\right)}^{4} - {0}^{4}} \cdot \left(\log base \cdot \log base - 0 \cdot 0\right)\\ \mathbf{elif}\;im \leq 8.836668233359011 \cdot 10^{+75}:\\ \;\;\;\;\frac{1}{\sqrt{{\left(\log base\right)}^{2} + 0 \cdot 0}} \cdot \frac{0 \cdot \tan^{-1}_* \frac{im}{re} + \log base \cdot \log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\sqrt{{\left(\log base\right)}^{2} + 0 \cdot 0}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log 1 + \log im}{\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}\;im \leq -1.3444364465238792 \cdot 10^{+154}:\\
\;\;\;\;\frac{1}{\sqrt{{\left(\log base\right)}^{2} + 0 \cdot 0}} \cdot \frac{\log base \cdot \log \left(-re\right) + 0 \cdot \tan^{-1}_* \frac{im}{re}}{\sqrt{{\left(\log base\right)}^{2} + 0 \cdot 0}}\\

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

\mathbf{elif}\;im \leq -2.7719158935979882 \cdot 10^{-303}:\\
\;\;\;\;\frac{\log base \cdot \log \left(-re\right) + 0 \cdot \tan^{-1}_* \frac{im}{re}}{{\left(\log base\right)}^{4} - {0}^{4}} \cdot \left(\log base \cdot \log base - 0 \cdot 0\right)\\

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

\mathbf{else}:\\
\;\;\;\;\frac{\log 1 + \log im}{\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 ((im <= -1.3444364465238792e+154)) {
		VAR = ((double) ((1.0 / ((double) sqrt(((double) (((double) pow(((double) log(base)), 2.0)) + ((double) (0.0 * 0.0))))))) * (((double) (((double) (((double) log(base)) * ((double) log(((double) -(re)))))) + ((double) (0.0 * ((double) atan2(im, re)))))) / ((double) sqrt(((double) (((double) pow(((double) log(base)), 2.0)) + ((double) (0.0 * 0.0)))))))));
	} else {
		double VAR_1;
		if ((im <= -2.3107304361754112e-235)) {
			VAR_1 = ((double) ((1.0 / ((double) sqrt(((double) (((double) pow(((double) log(base)), 2.0)) + ((double) (0.0 * 0.0))))))) * (((double) (((double) (0.0 * ((double) atan2(im, re)))) + ((double) (((double) log(base)) * ((double) log(((double) sqrt(((double) (((double) (re * re)) + ((double) (im * im)))))))))))) / ((double) sqrt(((double) (((double) pow(((double) log(base)), 2.0)) + ((double) (0.0 * 0.0)))))))));
		} else {
			double VAR_2;
			if ((im <= -2.7719158935979882e-303)) {
				VAR_2 = ((double) ((((double) (((double) (((double) log(base)) * ((double) log(((double) -(re)))))) + ((double) (0.0 * ((double) atan2(im, re)))))) / ((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_3;
				if ((im <= 8.836668233359011e+75)) {
					VAR_3 = ((double) ((1.0 / ((double) sqrt(((double) (((double) pow(((double) log(base)), 2.0)) + ((double) (0.0 * 0.0))))))) * (((double) (((double) (0.0 * ((double) atan2(im, re)))) + ((double) (((double) log(base)) * ((double) log(((double) sqrt(((double) (((double) (re * re)) + ((double) (im * im)))))))))))) / ((double) sqrt(((double) (((double) pow(((double) log(base)), 2.0)) + ((double) (0.0 * 0.0)))))))));
				} else {
					VAR_3 = (((double) (((double) log(1.0)) + ((double) log(im)))) / ((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 im < -1.34443644652387919e154

    1. Initial program 64.0

      \[\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-sqrt64.0

      \[\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-identity64.0

      \[\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-frac64.0

      \[\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. Simplified64.0

      \[\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. Simplified64.0

      \[\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}}}\]
    8. Taylor expanded around -inf 57.2

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

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

    if -1.34443644652387919e154 < im < -2.3107304361754112e-235 or -2.77191589359798818e-303 < im < 8.83666823335901099e75

    1. Initial program 20.8

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

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

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

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

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

      \[\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 -2.3107304361754112e-235 < im < -2.77191589359798818e-303

    1. Initial program 30.8

      \[\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 flip-+30.8

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\color{blue}{\frac{\left(\log base \cdot \log base\right) \cdot \left(\log base \cdot \log base\right) - \left(0 \cdot 0\right) \cdot \left(0 \cdot 0\right)}{\log base \cdot \log base - 0 \cdot 0}}}\]
    4. Applied associate-/r/30.9

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

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

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

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

    if 8.83666823335901099e75 < im

    1. Initial program 49.2

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

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

      \[\leadsto \color{blue}{\frac{\log 1 + \log im}{\log base}}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification24.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1.3444364465238792 \cdot 10^{+154}:\\ \;\;\;\;\frac{1}{\sqrt{{\left(\log base\right)}^{2} + 0 \cdot 0}} \cdot \frac{\log base \cdot \log \left(-re\right) + 0 \cdot \tan^{-1}_* \frac{im}{re}}{\sqrt{{\left(\log base\right)}^{2} + 0 \cdot 0}}\\ \mathbf{elif}\;im \leq -2.3107304361754112 \cdot 10^{-235}:\\ \;\;\;\;\frac{1}{\sqrt{{\left(\log base\right)}^{2} + 0 \cdot 0}} \cdot \frac{0 \cdot \tan^{-1}_* \frac{im}{re} + \log base \cdot \log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\sqrt{{\left(\log base\right)}^{2} + 0 \cdot 0}}\\ \mathbf{elif}\;im \leq -2.7719158935979882 \cdot 10^{-303}:\\ \;\;\;\;\frac{\log base \cdot \log \left(-re\right) + 0 \cdot \tan^{-1}_* \frac{im}{re}}{{\left(\log base\right)}^{4} - {0}^{4}} \cdot \left(\log base \cdot \log base - 0 \cdot 0\right)\\ \mathbf{elif}\;im \leq 8.836668233359011 \cdot 10^{+75}:\\ \;\;\;\;\frac{1}{\sqrt{{\left(\log base\right)}^{2} + 0 \cdot 0}} \cdot \frac{0 \cdot \tan^{-1}_* \frac{im}{re} + \log base \cdot \log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\sqrt{{\left(\log base\right)}^{2} + 0 \cdot 0}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log 1 + \log im}{\log base}\\ \end{array}\]

Reproduce

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