Average Error: 32.0 → 19.5
Time: 12.1s
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 -3.60442074634633805 \cdot 10^{105}:\\ \;\;\;\;\frac{1}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}} \cdot \frac{\log \left(-1 \cdot re\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}\\ \mathbf{elif}\;re \le -4.59696521868004084 \cdot 10^{-72}:\\ \;\;\;\;\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)}^{3} + {\left(0.0 \cdot 0.0\right)}^{3}} \cdot \left(\left(\log base \cdot \log base\right) \cdot \left(\log base \cdot \log base\right) + \left(\left(0.0 \cdot 0.0\right) \cdot \left(0.0 \cdot 0.0\right) - \left(\log base \cdot \log base\right) \cdot \left(0.0 \cdot 0.0\right)\right)\right)\\ \mathbf{elif}\;re \le -1.37690997977882964 \cdot 10^{-184}:\\ \;\;\;\;\frac{1}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}} \cdot \frac{\log im \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}\\ \mathbf{elif}\;re \le 2.1261068827005115 \cdot 10^{97}:\\ \;\;\;\;\frac{1}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}} \cdot \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log re}{0 + \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 -3.60442074634633805 \cdot 10^{105}:\\
\;\;\;\;\frac{1}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}} \cdot \frac{\log \left(-1 \cdot re\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}\\

\mathbf{elif}\;re \le -4.59696521868004084 \cdot 10^{-72}:\\
\;\;\;\;\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)}^{3} + {\left(0.0 \cdot 0.0\right)}^{3}} \cdot \left(\left(\log base \cdot \log base\right) \cdot \left(\log base \cdot \log base\right) + \left(\left(0.0 \cdot 0.0\right) \cdot \left(0.0 \cdot 0.0\right) - \left(\log base \cdot \log base\right) \cdot \left(0.0 \cdot 0.0\right)\right)\right)\\

\mathbf{elif}\;re \le -1.37690997977882964 \cdot 10^{-184}:\\
\;\;\;\;\frac{1}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}} \cdot \frac{\log im \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}\\

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

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

\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 <= -3.604420746346338e+105)) {
		VAR = ((double) (((double) (1.0 / ((double) sqrt(((double) (((double) (((double) log(base)) * ((double) log(base)))) + ((double) (0.0 * 0.0)))))))) * ((double) (((double) (((double) (((double) log(((double) (-1.0 * re)))) * ((double) log(base)))) + ((double) (((double) atan2(im, re)) * 0.0)))) / ((double) sqrt(((double) (((double) (((double) log(base)) * ((double) log(base)))) + ((double) (0.0 * 0.0))))))))));
	} else {
		double VAR_1;
		if ((re <= -4.596965218680041e-72)) {
			VAR_1 = ((double) (((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) pow(((double) (((double) log(base)) * ((double) log(base)))), 3.0)) + ((double) pow(((double) (0.0 * 0.0)), 3.0)))))) * ((double) (((double) (((double) (((double) log(base)) * ((double) log(base)))) * ((double) (((double) log(base)) * ((double) log(base)))))) + ((double) (((double) (((double) (0.0 * 0.0)) * ((double) (0.0 * 0.0)))) - ((double) (((double) (((double) log(base)) * ((double) log(base)))) * ((double) (0.0 * 0.0))))))))));
		} else {
			double VAR_2;
			if ((re <= -1.3769099797788296e-184)) {
				VAR_2 = ((double) (((double) (1.0 / ((double) sqrt(((double) (((double) (((double) log(base)) * ((double) log(base)))) + ((double) (0.0 * 0.0)))))))) * ((double) (((double) (((double) (((double) log(im)) * ((double) log(base)))) + ((double) (((double) atan2(im, re)) * 0.0)))) / ((double) sqrt(((double) (((double) (((double) log(base)) * ((double) log(base)))) + ((double) (0.0 * 0.0))))))))));
			} else {
				double VAR_3;
				if ((re <= 2.1261068827005115e+97)) {
					VAR_3 = ((double) (((double) (1.0 / ((double) sqrt(((double) (((double) (((double) log(base)) * ((double) log(base)))) + ((double) (0.0 * 0.0)))))))) * ((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) sqrt(((double) (((double) (((double) log(base)) * ((double) log(base)))) + ((double) (0.0 * 0.0))))))))));
				} else {
					VAR_3 = ((double) (((double) log(re)) / ((double) (0.0 + ((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 < -3.60442074634633805e105

    1. Initial program 52.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-sqr-sqrt52.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{\log base \cdot \log base + 0.0 \cdot 0.0} \cdot \sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}}\]
    4. Applied *-un-lft-identity52.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.0\right)}}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0} \cdot \sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}\]
    5. Applied times-frac52.6

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

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

    if -3.60442074634633805e105 < re < -4.59696521868004084e-72

    1. Initial program 16.7

      \[\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 flip3-+16.8

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

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

    if -4.59696521868004084e-72 < re < -1.37690997977882964e-184

    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 add-sqr-sqrt20.3

      \[\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{\log base \cdot \log base + 0.0 \cdot 0.0} \cdot \sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}}\]
    4. Applied *-un-lft-identity20.3

      \[\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.0\right)}}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0} \cdot \sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}\]
    5. Applied times-frac20.3

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

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

    if -1.37690997977882964e-184 < re < 2.1261068827005115e97

    1. Initial program 24.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-sqr-sqrt24.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{\log base \cdot \log base + 0.0 \cdot 0.0} \cdot \sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}}\]
    4. Applied *-un-lft-identity24.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.0\right)}}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0} \cdot \sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}\]
    5. Applied times-frac24.6

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

    if 2.1261068827005115e97 < re

    1. Initial program 50.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 inf 9.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \le -3.60442074634633805 \cdot 10^{105}:\\ \;\;\;\;\frac{1}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}} \cdot \frac{\log \left(-1 \cdot re\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}\\ \mathbf{elif}\;re \le -4.59696521868004084 \cdot 10^{-72}:\\ \;\;\;\;\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)}^{3} + {\left(0.0 \cdot 0.0\right)}^{3}} \cdot \left(\left(\log base \cdot \log base\right) \cdot \left(\log base \cdot \log base\right) + \left(\left(0.0 \cdot 0.0\right) \cdot \left(0.0 \cdot 0.0\right) - \left(\log base \cdot \log base\right) \cdot \left(0.0 \cdot 0.0\right)\right)\right)\\ \mathbf{elif}\;re \le -1.37690997977882964 \cdot 10^{-184}:\\ \;\;\;\;\frac{1}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}} \cdot \frac{\log im \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}\\ \mathbf{elif}\;re \le 2.1261068827005115 \cdot 10^{97}:\\ \;\;\;\;\frac{1}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}} \cdot \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log re}{0 + \log base}\\ \end{array}\]

Reproduce

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