math.log/2 on complex, imaginary part

Percentage Accurate: 24.8% → 86.6%
Time: 9.6s
Alternatives: 4
Speedup: 2.6×

Specification

?
\[\frac{\tan^{-1}_* \frac{im}{re} \cdot \log base - \log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot 0}{\log base \cdot \log base + 0 \cdot 0} \]
(FPCore (re im base)
  :precision binary64
  (/
 (-
  (* (atan2 im re) (log base))
  (* (log (sqrt (+ (* re re) (* im im)))) 0.0))
 (+ (* (log base) (log base)) (* 0.0 0.0))))
double code(double re, double im, double base) {
	return ((atan2(im, re) * log(base)) - (log(sqrt(((re * re) + (im * im)))) * 0.0)) / ((log(base) * log(base)) + (0.0 * 0.0));
}
real(8) function code(re, im, base)
use fmin_fmax_functions
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8), intent (in) :: base
    code = ((atan2(im, re) * log(base)) - (log(sqrt(((re * re) + (im * im)))) * 0.0d0)) / ((log(base) * log(base)) + (0.0d0 * 0.0d0))
end function
public static double code(double re, double im, double base) {
	return ((Math.atan2(im, re) * Math.log(base)) - (Math.log(Math.sqrt(((re * re) + (im * im)))) * 0.0)) / ((Math.log(base) * Math.log(base)) + (0.0 * 0.0));
}
def code(re, im, base):
	return ((math.atan2(im, re) * math.log(base)) - (math.log(math.sqrt(((re * re) + (im * im)))) * 0.0)) / ((math.log(base) * math.log(base)) + (0.0 * 0.0))
function code(re, im, base)
	return Float64(Float64(Float64(atan(im, re) * log(base)) - Float64(log(sqrt(Float64(Float64(re * re) + Float64(im * im)))) * 0.0)) / Float64(Float64(log(base) * log(base)) + Float64(0.0 * 0.0)))
end
function tmp = code(re, im, base)
	tmp = ((atan2(im, re) * log(base)) - (log(sqrt(((re * re) + (im * im)))) * 0.0)) / ((log(base) * log(base)) + (0.0 * 0.0));
end
code[re_, im_, base_] := N[(N[(N[(N[ArcTan[im / re], $MachinePrecision] * N[Log[base], $MachinePrecision]), $MachinePrecision] - N[(N[Log[N[Sqrt[N[(N[(re * re), $MachinePrecision] + N[(im * im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * 0.0), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Log[base], $MachinePrecision] * N[Log[base], $MachinePrecision]), $MachinePrecision] + N[(0.0 * 0.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{\tan^{-1}_* \frac{im}{re} \cdot \log base - \log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot 0}{\log base \cdot \log base + 0 \cdot 0}

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 4 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 24.8% accurate, 1.0× speedup?

\[\frac{\tan^{-1}_* \frac{im}{re} \cdot \log base - \log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot 0}{\log base \cdot \log base + 0 \cdot 0} \]
(FPCore (re im base)
  :precision binary64
  (/
 (-
  (* (atan2 im re) (log base))
  (* (log (sqrt (+ (* re re) (* im im)))) 0.0))
 (+ (* (log base) (log base)) (* 0.0 0.0))))
double code(double re, double im, double base) {
	return ((atan2(im, re) * log(base)) - (log(sqrt(((re * re) + (im * im)))) * 0.0)) / ((log(base) * log(base)) + (0.0 * 0.0));
}
real(8) function code(re, im, base)
use fmin_fmax_functions
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8), intent (in) :: base
    code = ((atan2(im, re) * log(base)) - (log(sqrt(((re * re) + (im * im)))) * 0.0d0)) / ((log(base) * log(base)) + (0.0d0 * 0.0d0))
end function
public static double code(double re, double im, double base) {
	return ((Math.atan2(im, re) * Math.log(base)) - (Math.log(Math.sqrt(((re * re) + (im * im)))) * 0.0)) / ((Math.log(base) * Math.log(base)) + (0.0 * 0.0));
}
def code(re, im, base):
	return ((math.atan2(im, re) * math.log(base)) - (math.log(math.sqrt(((re * re) + (im * im)))) * 0.0)) / ((math.log(base) * math.log(base)) + (0.0 * 0.0))
function code(re, im, base)
	return Float64(Float64(Float64(atan(im, re) * log(base)) - Float64(log(sqrt(Float64(Float64(re * re) + Float64(im * im)))) * 0.0)) / Float64(Float64(log(base) * log(base)) + Float64(0.0 * 0.0)))
end
function tmp = code(re, im, base)
	tmp = ((atan2(im, re) * log(base)) - (log(sqrt(((re * re) + (im * im)))) * 0.0)) / ((log(base) * log(base)) + (0.0 * 0.0));
end
code[re_, im_, base_] := N[(N[(N[(N[ArcTan[im / re], $MachinePrecision] * N[Log[base], $MachinePrecision]), $MachinePrecision] - N[(N[Log[N[Sqrt[N[(N[(re * re), $MachinePrecision] + N[(im * im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * 0.0), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Log[base], $MachinePrecision] * N[Log[base], $MachinePrecision]), $MachinePrecision] + N[(0.0 * 0.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{\tan^{-1}_* \frac{im}{re} \cdot \log base - \log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot 0}{\log base \cdot \log base + 0 \cdot 0}

Alternative 1: 86.6% accurate, 1.7× speedup?

\[\begin{array}{l} t_0 := \frac{\tan^{-1}_* \frac{im}{re}}{\log \left(\sqrt{base \cdot base}\right)}\\ \mathbf{if}\;base \leq -7.6 \cdot 10^{+146}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;base \leq -1.56 \cdot 10^{-162}:\\ \;\;\;\;\frac{\tan^{-1}_* \frac{0}{re}}{\log \left(\left|base\right|\right)}\\ \mathbf{elif}\;base \leq 1.6 \cdot 10^{-299}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{\tan^{-1}_* \frac{im}{re}}{\log base}\\ \end{array} \]
(FPCore (re im base)
  :precision binary64
  (let* ((t_0 (/ (atan2 im re) (log (sqrt (* base base))))))
  (if (<= base -7.6e+146)
    t_0
    (if (<= base -1.56e-162)
      (/ (atan2 0.0 re) (log (fabs base)))
      (if (<= base 1.6e-299) t_0 (/ (atan2 im re) (log base)))))))
double code(double re, double im, double base) {
	double t_0 = atan2(im, re) / log(sqrt((base * base)));
	double tmp;
	if (base <= -7.6e+146) {
		tmp = t_0;
	} else if (base <= -1.56e-162) {
		tmp = atan2(0.0, re) / log(fabs(base));
	} else if (base <= 1.6e-299) {
		tmp = t_0;
	} else {
		tmp = atan2(im, re) / log(base);
	}
	return tmp;
}
real(8) function code(re, im, base)
use fmin_fmax_functions
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8), intent (in) :: base
    real(8) :: t_0
    real(8) :: tmp
    t_0 = atan2(im, re) / log(sqrt((base * base)))
    if (base <= (-7.6d+146)) then
        tmp = t_0
    else if (base <= (-1.56d-162)) then
        tmp = atan2(0.0d0, re) / log(abs(base))
    else if (base <= 1.6d-299) then
        tmp = t_0
    else
        tmp = atan2(im, re) / log(base)
    end if
    code = tmp
end function
public static double code(double re, double im, double base) {
	double t_0 = Math.atan2(im, re) / Math.log(Math.sqrt((base * base)));
	double tmp;
	if (base <= -7.6e+146) {
		tmp = t_0;
	} else if (base <= -1.56e-162) {
		tmp = Math.atan2(0.0, re) / Math.log(Math.abs(base));
	} else if (base <= 1.6e-299) {
		tmp = t_0;
	} else {
		tmp = Math.atan2(im, re) / Math.log(base);
	}
	return tmp;
}
def code(re, im, base):
	t_0 = math.atan2(im, re) / math.log(math.sqrt((base * base)))
	tmp = 0
	if base <= -7.6e+146:
		tmp = t_0
	elif base <= -1.56e-162:
		tmp = math.atan2(0.0, re) / math.log(math.fabs(base))
	elif base <= 1.6e-299:
		tmp = t_0
	else:
		tmp = math.atan2(im, re) / math.log(base)
	return tmp
function code(re, im, base)
	t_0 = Float64(atan(im, re) / log(sqrt(Float64(base * base))))
	tmp = 0.0
	if (base <= -7.6e+146)
		tmp = t_0;
	elseif (base <= -1.56e-162)
		tmp = Float64(atan(0.0, re) / log(abs(base)));
	elseif (base <= 1.6e-299)
		tmp = t_0;
	else
		tmp = Float64(atan(im, re) / log(base));
	end
	return tmp
end
function tmp_2 = code(re, im, base)
	t_0 = atan2(im, re) / log(sqrt((base * base)));
	tmp = 0.0;
	if (base <= -7.6e+146)
		tmp = t_0;
	elseif (base <= -1.56e-162)
		tmp = atan2(0.0, re) / log(abs(base));
	elseif (base <= 1.6e-299)
		tmp = t_0;
	else
		tmp = atan2(im, re) / log(base);
	end
	tmp_2 = tmp;
end
code[re_, im_, base_] := Block[{t$95$0 = N[(N[ArcTan[im / re], $MachinePrecision] / N[Log[N[Sqrt[N[(base * base), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[base, -7.6e+146], t$95$0, If[LessEqual[base, -1.56e-162], N[(N[ArcTan[0.0 / re], $MachinePrecision] / N[Log[N[Abs[base], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[base, 1.6e-299], t$95$0, N[(N[ArcTan[im / re], $MachinePrecision] / N[Log[base], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \frac{\tan^{-1}_* \frac{im}{re}}{\log \left(\sqrt{base \cdot base}\right)}\\
\mathbf{if}\;base \leq -7.6 \cdot 10^{+146}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;base \leq -1.56 \cdot 10^{-162}:\\
\;\;\;\;\frac{\tan^{-1}_* \frac{0}{re}}{\log \left(\left|base\right|\right)}\\

\mathbf{elif}\;base \leq 1.6 \cdot 10^{-299}:\\
\;\;\;\;t\_0\\

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


\end{array}
Derivation
  1. Split input into 3 regimes
  2. if base < -7.5999999999999996e146 or -1.5600000000000001e-162 < base < 1.6e-299

    1. Initial program 24.8%

      \[\frac{\tan^{-1}_* \frac{im}{re} \cdot \log base - \log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot 0}{\log base \cdot \log base + 0 \cdot 0} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1}{\log base \cdot \log base + 0 \cdot 0} \cdot \left(\tan^{-1}_* \frac{im}{re} \cdot \log base\right)} \]
      9. lower-/.f6449.8%

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{\log base \cdot \log base}} \cdot \left(\tan^{-1}_* \frac{im}{re} \cdot \log base\right) \]
      14. lift-*.f64N/A

        \[\leadsto \frac{1}{\log base \cdot \log base} \cdot \color{blue}{\left(\tan^{-1}_* \frac{im}{re} \cdot \log base\right)} \]
      15. *-commutativeN/A

        \[\leadsto \frac{1}{\log base \cdot \log base} \cdot \color{blue}{\left(\log base \cdot \tan^{-1}_* \frac{im}{re}\right)} \]
    3. Applied rewrites49.8%

      \[\leadsto \color{blue}{\frac{1}{\log base \cdot \log base} \cdot \left(\log base \cdot \tan^{-1}_* \frac{im}{re}\right)} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\frac{1}{\log base \cdot \log base} \cdot \left(\log base \cdot \tan^{-1}_* \frac{im}{re}\right)} \]
      2. *-commutativeN/A

        \[\leadsto \color{blue}{\left(\log base \cdot \tan^{-1}_* \frac{im}{re}\right) \cdot \frac{1}{\log base \cdot \log base}} \]
      3. lift-*.f64N/A

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

        \[\leadsto \color{blue}{\left(\tan^{-1}_* \frac{im}{re} \cdot \log base\right)} \cdot \frac{1}{\log base \cdot \log base} \]
      5. associate-*l*N/A

        \[\leadsto \color{blue}{\tan^{-1}_* \frac{im}{re} \cdot \left(\log base \cdot \frac{1}{\log base \cdot \log base}\right)} \]
      6. *-commutativeN/A

        \[\leadsto \tan^{-1}_* \frac{im}{re} \cdot \color{blue}{\left(\frac{1}{\log base \cdot \log base} \cdot \log base\right)} \]
      7. lift-/.f64N/A

        \[\leadsto \tan^{-1}_* \frac{im}{re} \cdot \left(\color{blue}{\frac{1}{\log base \cdot \log base}} \cdot \log base\right) \]
      8. lift-*.f64N/A

        \[\leadsto \tan^{-1}_* \frac{im}{re} \cdot \left(\frac{1}{\color{blue}{\log base \cdot \log base}} \cdot \log base\right) \]
      9. pow2N/A

        \[\leadsto \tan^{-1}_* \frac{im}{re} \cdot \left(\frac{1}{\color{blue}{{\log base}^{2}}} \cdot \log base\right) \]
      10. pow-flipN/A

        \[\leadsto \tan^{-1}_* \frac{im}{re} \cdot \left(\color{blue}{{\log base}^{\left(\mathsf{neg}\left(2\right)\right)}} \cdot \log base\right) \]
      11. pow-plusN/A

        \[\leadsto \tan^{-1}_* \frac{im}{re} \cdot \color{blue}{{\log base}^{\left(\left(\mathsf{neg}\left(2\right)\right) + 1\right)}} \]
      12. metadata-evalN/A

        \[\leadsto \tan^{-1}_* \frac{im}{re} \cdot {\log base}^{\left(\color{blue}{-2} + 1\right)} \]
      13. metadata-evalN/A

        \[\leadsto \tan^{-1}_* \frac{im}{re} \cdot {\log base}^{\color{blue}{-1}} \]
      14. inv-powN/A

        \[\leadsto \tan^{-1}_* \frac{im}{re} \cdot \color{blue}{\frac{1}{\log base}} \]
      15. lower-*.f64N/A

        \[\leadsto \color{blue}{\tan^{-1}_* \frac{im}{re} \cdot \frac{1}{\log base}} \]
      16. lower-/.f6449.9%

        \[\leadsto \tan^{-1}_* \frac{im}{re} \cdot \color{blue}{\frac{1}{\log base}} \]
    5. Applied rewrites49.9%

      \[\leadsto \color{blue}{\tan^{-1}_* \frac{im}{re} \cdot \frac{1}{\log base}} \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\tan^{-1}_* \frac{im}{re} \cdot \frac{1}{\log base}} \]
      2. lift-/.f64N/A

        \[\leadsto \tan^{-1}_* \frac{im}{re} \cdot \color{blue}{\frac{1}{\log base}} \]
      3. associate-*r/N/A

        \[\leadsto \color{blue}{\frac{\tan^{-1}_* \frac{im}{re} \cdot 1}{\log base}} \]
      4. rgt-mult-inverseN/A

        \[\leadsto \frac{\tan^{-1}_* \frac{im}{re} \cdot \color{blue}{\left(\log base \cdot \frac{1}{\log base}\right)}}{\log base} \]
      5. mult-flip-revN/A

        \[\leadsto \frac{\tan^{-1}_* \frac{im}{re} \cdot \color{blue}{\frac{\log base}{\log base}}}{\log base} \]
      6. associate-/l*N/A

        \[\leadsto \frac{\color{blue}{\frac{\tan^{-1}_* \frac{im}{re} \cdot \log base}{\log base}}}{\log base} \]
      7. *-commutativeN/A

        \[\leadsto \frac{\frac{\color{blue}{\log base \cdot \tan^{-1}_* \frac{im}{re}}}{\log base}}{\log base} \]
      8. lift-*.f64N/A

        \[\leadsto \frac{\frac{\color{blue}{\log base \cdot \tan^{-1}_* \frac{im}{re}}}{\log base}}{\log base} \]
      9. associate-/l/N/A

        \[\leadsto \color{blue}{\frac{\log base \cdot \tan^{-1}_* \frac{im}{re}}{\log base \cdot \log base}} \]
      10. lift-*.f64N/A

        \[\leadsto \frac{\log base \cdot \tan^{-1}_* \frac{im}{re}}{\color{blue}{\log base \cdot \log base}} \]
      11. lift-*.f64N/A

        \[\leadsto \frac{\log base \cdot \tan^{-1}_* \frac{im}{re}}{\color{blue}{\log base \cdot \log base}} \]
      12. lift-log.f64N/A

        \[\leadsto \frac{\log base \cdot \tan^{-1}_* \frac{im}{re}}{\log base \cdot \color{blue}{\log base}} \]
      13. log-pow-revN/A

        \[\leadsto \frac{\log base \cdot \tan^{-1}_* \frac{im}{re}}{\color{blue}{\log \left({base}^{\log base}\right)}} \]
      14. log-powN/A

        \[\leadsto \frac{\log base \cdot \tan^{-1}_* \frac{im}{re}}{\color{blue}{\log base \cdot \log \left(\left|base\right|\right)}} \]
      15. associate-/r*N/A

        \[\leadsto \color{blue}{\frac{\frac{\log base \cdot \tan^{-1}_* \frac{im}{re}}{\log base}}{\log \left(\left|base\right|\right)}} \]
    7. Applied rewrites54.7%

      \[\leadsto \color{blue}{\frac{\tan^{-1}_* \frac{im}{re}}{\log \left(\left|base\right|\right)}} \]
    8. Step-by-step derivation
      1. lift-fabs.f64N/A

        \[\leadsto \frac{\tan^{-1}_* \frac{im}{re}}{\log \color{blue}{\left(\left|base\right|\right)}} \]
      2. rem-sqrt-square-revN/A

        \[\leadsto \frac{\tan^{-1}_* \frac{im}{re}}{\log \color{blue}{\left(\sqrt{base \cdot base}\right)}} \]
      3. lower-sqrt.f64N/A

        \[\leadsto \frac{\tan^{-1}_* \frac{im}{re}}{\log \color{blue}{\left(\sqrt{base \cdot base}\right)}} \]
      4. lower-*.f6455.5%

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

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

    if -7.5999999999999996e146 < base < -1.5600000000000001e-162

    1. Initial program 24.8%

      \[\frac{\tan^{-1}_* \frac{im}{re} \cdot \log base - \log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot 0}{\log base \cdot \log base + 0 \cdot 0} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1}{\log base \cdot \log base + 0 \cdot 0} \cdot \left(\tan^{-1}_* \frac{im}{re} \cdot \log base\right)} \]
      9. lower-/.f6449.8%

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{\log base \cdot \log base}} \cdot \left(\tan^{-1}_* \frac{im}{re} \cdot \log base\right) \]
      14. lift-*.f64N/A

        \[\leadsto \frac{1}{\log base \cdot \log base} \cdot \color{blue}{\left(\tan^{-1}_* \frac{im}{re} \cdot \log base\right)} \]
      15. *-commutativeN/A

        \[\leadsto \frac{1}{\log base \cdot \log base} \cdot \color{blue}{\left(\log base \cdot \tan^{-1}_* \frac{im}{re}\right)} \]
    3. Applied rewrites49.8%

      \[\leadsto \color{blue}{\frac{1}{\log base \cdot \log base} \cdot \left(\log base \cdot \tan^{-1}_* \frac{im}{re}\right)} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\frac{1}{\log base \cdot \log base} \cdot \left(\log base \cdot \tan^{-1}_* \frac{im}{re}\right)} \]
      2. *-commutativeN/A

        \[\leadsto \color{blue}{\left(\log base \cdot \tan^{-1}_* \frac{im}{re}\right) \cdot \frac{1}{\log base \cdot \log base}} \]
      3. lift-*.f64N/A

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

        \[\leadsto \color{blue}{\left(\tan^{-1}_* \frac{im}{re} \cdot \log base\right)} \cdot \frac{1}{\log base \cdot \log base} \]
      5. associate-*l*N/A

        \[\leadsto \color{blue}{\tan^{-1}_* \frac{im}{re} \cdot \left(\log base \cdot \frac{1}{\log base \cdot \log base}\right)} \]
      6. *-commutativeN/A

        \[\leadsto \tan^{-1}_* \frac{im}{re} \cdot \color{blue}{\left(\frac{1}{\log base \cdot \log base} \cdot \log base\right)} \]
      7. lift-/.f64N/A

        \[\leadsto \tan^{-1}_* \frac{im}{re} \cdot \left(\color{blue}{\frac{1}{\log base \cdot \log base}} \cdot \log base\right) \]
      8. lift-*.f64N/A

        \[\leadsto \tan^{-1}_* \frac{im}{re} \cdot \left(\frac{1}{\color{blue}{\log base \cdot \log base}} \cdot \log base\right) \]
      9. pow2N/A

        \[\leadsto \tan^{-1}_* \frac{im}{re} \cdot \left(\frac{1}{\color{blue}{{\log base}^{2}}} \cdot \log base\right) \]
      10. pow-flipN/A

        \[\leadsto \tan^{-1}_* \frac{im}{re} \cdot \left(\color{blue}{{\log base}^{\left(\mathsf{neg}\left(2\right)\right)}} \cdot \log base\right) \]
      11. pow-plusN/A

        \[\leadsto \tan^{-1}_* \frac{im}{re} \cdot \color{blue}{{\log base}^{\left(\left(\mathsf{neg}\left(2\right)\right) + 1\right)}} \]
      12. metadata-evalN/A

        \[\leadsto \tan^{-1}_* \frac{im}{re} \cdot {\log base}^{\left(\color{blue}{-2} + 1\right)} \]
      13. metadata-evalN/A

        \[\leadsto \tan^{-1}_* \frac{im}{re} \cdot {\log base}^{\color{blue}{-1}} \]
      14. inv-powN/A

        \[\leadsto \tan^{-1}_* \frac{im}{re} \cdot \color{blue}{\frac{1}{\log base}} \]
      15. lower-*.f64N/A

        \[\leadsto \color{blue}{\tan^{-1}_* \frac{im}{re} \cdot \frac{1}{\log base}} \]
      16. lower-/.f6449.9%

        \[\leadsto \tan^{-1}_* \frac{im}{re} \cdot \color{blue}{\frac{1}{\log base}} \]
    5. Applied rewrites49.9%

      \[\leadsto \color{blue}{\tan^{-1}_* \frac{im}{re} \cdot \frac{1}{\log base}} \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\tan^{-1}_* \frac{im}{re} \cdot \frac{1}{\log base}} \]
      2. lift-/.f64N/A

        \[\leadsto \tan^{-1}_* \frac{im}{re} \cdot \color{blue}{\frac{1}{\log base}} \]
      3. associate-*r/N/A

        \[\leadsto \color{blue}{\frac{\tan^{-1}_* \frac{im}{re} \cdot 1}{\log base}} \]
      4. rgt-mult-inverseN/A

        \[\leadsto \frac{\tan^{-1}_* \frac{im}{re} \cdot \color{blue}{\left(\log base \cdot \frac{1}{\log base}\right)}}{\log base} \]
      5. mult-flip-revN/A

        \[\leadsto \frac{\tan^{-1}_* \frac{im}{re} \cdot \color{blue}{\frac{\log base}{\log base}}}{\log base} \]
      6. associate-/l*N/A

        \[\leadsto \frac{\color{blue}{\frac{\tan^{-1}_* \frac{im}{re} \cdot \log base}{\log base}}}{\log base} \]
      7. *-commutativeN/A

        \[\leadsto \frac{\frac{\color{blue}{\log base \cdot \tan^{-1}_* \frac{im}{re}}}{\log base}}{\log base} \]
      8. lift-*.f64N/A

        \[\leadsto \frac{\frac{\color{blue}{\log base \cdot \tan^{-1}_* \frac{im}{re}}}{\log base}}{\log base} \]
      9. associate-/l/N/A

        \[\leadsto \color{blue}{\frac{\log base \cdot \tan^{-1}_* \frac{im}{re}}{\log base \cdot \log base}} \]
      10. lift-*.f64N/A

        \[\leadsto \frac{\log base \cdot \tan^{-1}_* \frac{im}{re}}{\color{blue}{\log base \cdot \log base}} \]
      11. lift-*.f64N/A

        \[\leadsto \frac{\log base \cdot \tan^{-1}_* \frac{im}{re}}{\color{blue}{\log base \cdot \log base}} \]
      12. lift-log.f64N/A

        \[\leadsto \frac{\log base \cdot \tan^{-1}_* \frac{im}{re}}{\log base \cdot \color{blue}{\log base}} \]
      13. log-pow-revN/A

        \[\leadsto \frac{\log base \cdot \tan^{-1}_* \frac{im}{re}}{\color{blue}{\log \left({base}^{\log base}\right)}} \]
      14. log-powN/A

        \[\leadsto \frac{\log base \cdot \tan^{-1}_* \frac{im}{re}}{\color{blue}{\log base \cdot \log \left(\left|base\right|\right)}} \]
      15. associate-/r*N/A

        \[\leadsto \color{blue}{\frac{\frac{\log base \cdot \tan^{-1}_* \frac{im}{re}}{\log base}}{\log \left(\left|base\right|\right)}} \]
    7. Applied rewrites54.7%

      \[\leadsto \color{blue}{\frac{\tan^{-1}_* \frac{im}{re}}{\log \left(\left|base\right|\right)}} \]
    8. Taylor expanded in undef-var around zero

      \[\leadsto \frac{\tan^{-1}_* \frac{\color{blue}{0}}{re}}{\log \left(\left|base\right|\right)} \]
    9. Step-by-step derivation
      1. Applied rewrites37.2%

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

      if 1.6e-299 < base

      1. Initial program 24.8%

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

        \[\leadsto \color{blue}{\frac{\tan^{-1}_* \frac{im}{re}}{\log base}} \]
      3. Step-by-step derivation
        1. lower-/.f64N/A

          \[\leadsto \frac{\tan^{-1}_* \frac{im}{re}}{\color{blue}{\log base}} \]
        2. lower-atan2.f64N/A

          \[\leadsto \frac{\tan^{-1}_* \frac{im}{re}}{\log \color{blue}{base}} \]
        3. lower-log.f6450.0%

          \[\leadsto \frac{\tan^{-1}_* \frac{im}{re}}{\log base} \]
      4. Applied rewrites50.0%

        \[\leadsto \color{blue}{\frac{\tan^{-1}_* \frac{im}{re}}{\log base}} \]
    10. Recombined 3 regimes into one program.
    11. Add Preprocessing

    Alternative 2: 75.4% accurate, 2.3× speedup?

    \[\begin{array}{l} \mathbf{if}\;base \leq 10^{-300}:\\ \;\;\;\;\frac{\tan^{-1}_* \frac{0}{re}}{\log \left(\left|base\right|\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\tan^{-1}_* \frac{im}{re}}{\log base}\\ \end{array} \]
    (FPCore (re im base)
      :precision binary64
      (if (<= base 1e-300)
      (/ (atan2 0.0 re) (log (fabs base)))
      (/ (atan2 im re) (log base))))
    double code(double re, double im, double base) {
    	double tmp;
    	if (base <= 1e-300) {
    		tmp = atan2(0.0, re) / log(fabs(base));
    	} else {
    		tmp = atan2(im, re) / log(base);
    	}
    	return tmp;
    }
    
    real(8) function code(re, im, base)
    use fmin_fmax_functions
        real(8), intent (in) :: re
        real(8), intent (in) :: im
        real(8), intent (in) :: base
        real(8) :: tmp
        if (base <= 1d-300) then
            tmp = atan2(0.0d0, re) / log(abs(base))
        else
            tmp = atan2(im, re) / log(base)
        end if
        code = tmp
    end function
    
    public static double code(double re, double im, double base) {
    	double tmp;
    	if (base <= 1e-300) {
    		tmp = Math.atan2(0.0, re) / Math.log(Math.abs(base));
    	} else {
    		tmp = Math.atan2(im, re) / Math.log(base);
    	}
    	return tmp;
    }
    
    def code(re, im, base):
    	tmp = 0
    	if base <= 1e-300:
    		tmp = math.atan2(0.0, re) / math.log(math.fabs(base))
    	else:
    		tmp = math.atan2(im, re) / math.log(base)
    	return tmp
    
    function code(re, im, base)
    	tmp = 0.0
    	if (base <= 1e-300)
    		tmp = Float64(atan(0.0, re) / log(abs(base)));
    	else
    		tmp = Float64(atan(im, re) / log(base));
    	end
    	return tmp
    end
    
    function tmp_2 = code(re, im, base)
    	tmp = 0.0;
    	if (base <= 1e-300)
    		tmp = atan2(0.0, re) / log(abs(base));
    	else
    		tmp = atan2(im, re) / log(base);
    	end
    	tmp_2 = tmp;
    end
    
    code[re_, im_, base_] := If[LessEqual[base, 1e-300], N[(N[ArcTan[0.0 / re], $MachinePrecision] / N[Log[N[Abs[base], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[ArcTan[im / re], $MachinePrecision] / N[Log[base], $MachinePrecision]), $MachinePrecision]]
    
    \begin{array}{l}
    \mathbf{if}\;base \leq 10^{-300}:\\
    \;\;\;\;\frac{\tan^{-1}_* \frac{0}{re}}{\log \left(\left|base\right|\right)}\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{\tan^{-1}_* \frac{im}{re}}{\log base}\\
    
    
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if base < 1e-300

      1. Initial program 24.8%

        \[\frac{\tan^{-1}_* \frac{im}{re} \cdot \log base - \log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot 0}{\log base \cdot \log base + 0 \cdot 0} \]
      2. Step-by-step derivation
        1. lift-/.f64N/A

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{\frac{1}{\log base \cdot \log base + 0 \cdot 0} \cdot \left(\tan^{-1}_* \frac{im}{re} \cdot \log base\right)} \]
        9. lower-/.f6449.8%

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

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

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

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

          \[\leadsto \frac{1}{\color{blue}{\log base \cdot \log base}} \cdot \left(\tan^{-1}_* \frac{im}{re} \cdot \log base\right) \]
        14. lift-*.f64N/A

          \[\leadsto \frac{1}{\log base \cdot \log base} \cdot \color{blue}{\left(\tan^{-1}_* \frac{im}{re} \cdot \log base\right)} \]
        15. *-commutativeN/A

          \[\leadsto \frac{1}{\log base \cdot \log base} \cdot \color{blue}{\left(\log base \cdot \tan^{-1}_* \frac{im}{re}\right)} \]
      3. Applied rewrites49.8%

        \[\leadsto \color{blue}{\frac{1}{\log base \cdot \log base} \cdot \left(\log base \cdot \tan^{-1}_* \frac{im}{re}\right)} \]
      4. Step-by-step derivation
        1. lift-*.f64N/A

          \[\leadsto \color{blue}{\frac{1}{\log base \cdot \log base} \cdot \left(\log base \cdot \tan^{-1}_* \frac{im}{re}\right)} \]
        2. *-commutativeN/A

          \[\leadsto \color{blue}{\left(\log base \cdot \tan^{-1}_* \frac{im}{re}\right) \cdot \frac{1}{\log base \cdot \log base}} \]
        3. lift-*.f64N/A

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

          \[\leadsto \color{blue}{\left(\tan^{-1}_* \frac{im}{re} \cdot \log base\right)} \cdot \frac{1}{\log base \cdot \log base} \]
        5. associate-*l*N/A

          \[\leadsto \color{blue}{\tan^{-1}_* \frac{im}{re} \cdot \left(\log base \cdot \frac{1}{\log base \cdot \log base}\right)} \]
        6. *-commutativeN/A

          \[\leadsto \tan^{-1}_* \frac{im}{re} \cdot \color{blue}{\left(\frac{1}{\log base \cdot \log base} \cdot \log base\right)} \]
        7. lift-/.f64N/A

          \[\leadsto \tan^{-1}_* \frac{im}{re} \cdot \left(\color{blue}{\frac{1}{\log base \cdot \log base}} \cdot \log base\right) \]
        8. lift-*.f64N/A

          \[\leadsto \tan^{-1}_* \frac{im}{re} \cdot \left(\frac{1}{\color{blue}{\log base \cdot \log base}} \cdot \log base\right) \]
        9. pow2N/A

          \[\leadsto \tan^{-1}_* \frac{im}{re} \cdot \left(\frac{1}{\color{blue}{{\log base}^{2}}} \cdot \log base\right) \]
        10. pow-flipN/A

          \[\leadsto \tan^{-1}_* \frac{im}{re} \cdot \left(\color{blue}{{\log base}^{\left(\mathsf{neg}\left(2\right)\right)}} \cdot \log base\right) \]
        11. pow-plusN/A

          \[\leadsto \tan^{-1}_* \frac{im}{re} \cdot \color{blue}{{\log base}^{\left(\left(\mathsf{neg}\left(2\right)\right) + 1\right)}} \]
        12. metadata-evalN/A

          \[\leadsto \tan^{-1}_* \frac{im}{re} \cdot {\log base}^{\left(\color{blue}{-2} + 1\right)} \]
        13. metadata-evalN/A

          \[\leadsto \tan^{-1}_* \frac{im}{re} \cdot {\log base}^{\color{blue}{-1}} \]
        14. inv-powN/A

          \[\leadsto \tan^{-1}_* \frac{im}{re} \cdot \color{blue}{\frac{1}{\log base}} \]
        15. lower-*.f64N/A

          \[\leadsto \color{blue}{\tan^{-1}_* \frac{im}{re} \cdot \frac{1}{\log base}} \]
        16. lower-/.f6449.9%

          \[\leadsto \tan^{-1}_* \frac{im}{re} \cdot \color{blue}{\frac{1}{\log base}} \]
      5. Applied rewrites49.9%

        \[\leadsto \color{blue}{\tan^{-1}_* \frac{im}{re} \cdot \frac{1}{\log base}} \]
      6. Step-by-step derivation
        1. lift-*.f64N/A

          \[\leadsto \color{blue}{\tan^{-1}_* \frac{im}{re} \cdot \frac{1}{\log base}} \]
        2. lift-/.f64N/A

          \[\leadsto \tan^{-1}_* \frac{im}{re} \cdot \color{blue}{\frac{1}{\log base}} \]
        3. associate-*r/N/A

          \[\leadsto \color{blue}{\frac{\tan^{-1}_* \frac{im}{re} \cdot 1}{\log base}} \]
        4. rgt-mult-inverseN/A

          \[\leadsto \frac{\tan^{-1}_* \frac{im}{re} \cdot \color{blue}{\left(\log base \cdot \frac{1}{\log base}\right)}}{\log base} \]
        5. mult-flip-revN/A

          \[\leadsto \frac{\tan^{-1}_* \frac{im}{re} \cdot \color{blue}{\frac{\log base}{\log base}}}{\log base} \]
        6. associate-/l*N/A

          \[\leadsto \frac{\color{blue}{\frac{\tan^{-1}_* \frac{im}{re} \cdot \log base}{\log base}}}{\log base} \]
        7. *-commutativeN/A

          \[\leadsto \frac{\frac{\color{blue}{\log base \cdot \tan^{-1}_* \frac{im}{re}}}{\log base}}{\log base} \]
        8. lift-*.f64N/A

          \[\leadsto \frac{\frac{\color{blue}{\log base \cdot \tan^{-1}_* \frac{im}{re}}}{\log base}}{\log base} \]
        9. associate-/l/N/A

          \[\leadsto \color{blue}{\frac{\log base \cdot \tan^{-1}_* \frac{im}{re}}{\log base \cdot \log base}} \]
        10. lift-*.f64N/A

          \[\leadsto \frac{\log base \cdot \tan^{-1}_* \frac{im}{re}}{\color{blue}{\log base \cdot \log base}} \]
        11. lift-*.f64N/A

          \[\leadsto \frac{\log base \cdot \tan^{-1}_* \frac{im}{re}}{\color{blue}{\log base \cdot \log base}} \]
        12. lift-log.f64N/A

          \[\leadsto \frac{\log base \cdot \tan^{-1}_* \frac{im}{re}}{\log base \cdot \color{blue}{\log base}} \]
        13. log-pow-revN/A

          \[\leadsto \frac{\log base \cdot \tan^{-1}_* \frac{im}{re}}{\color{blue}{\log \left({base}^{\log base}\right)}} \]
        14. log-powN/A

          \[\leadsto \frac{\log base \cdot \tan^{-1}_* \frac{im}{re}}{\color{blue}{\log base \cdot \log \left(\left|base\right|\right)}} \]
        15. associate-/r*N/A

          \[\leadsto \color{blue}{\frac{\frac{\log base \cdot \tan^{-1}_* \frac{im}{re}}{\log base}}{\log \left(\left|base\right|\right)}} \]
      7. Applied rewrites54.7%

        \[\leadsto \color{blue}{\frac{\tan^{-1}_* \frac{im}{re}}{\log \left(\left|base\right|\right)}} \]
      8. Taylor expanded in undef-var around zero

        \[\leadsto \frac{\tan^{-1}_* \frac{\color{blue}{0}}{re}}{\log \left(\left|base\right|\right)} \]
      9. Step-by-step derivation
        1. Applied rewrites37.2%

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

        if 1e-300 < base

        1. Initial program 24.8%

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

          \[\leadsto \color{blue}{\frac{\tan^{-1}_* \frac{im}{re}}{\log base}} \]
        3. Step-by-step derivation
          1. lower-/.f64N/A

            \[\leadsto \frac{\tan^{-1}_* \frac{im}{re}}{\color{blue}{\log base}} \]
          2. lower-atan2.f64N/A

            \[\leadsto \frac{\tan^{-1}_* \frac{im}{re}}{\log \color{blue}{base}} \]
          3. lower-log.f6450.0%

            \[\leadsto \frac{\tan^{-1}_* \frac{im}{re}}{\log base} \]
        4. Applied rewrites50.0%

          \[\leadsto \color{blue}{\frac{\tan^{-1}_* \frac{im}{re}}{\log base}} \]
      10. Recombined 2 regimes into one program.
      11. Add Preprocessing

      Alternative 3: 54.7% accurate, 2.6× speedup?

      \[\frac{\tan^{-1}_* \frac{im}{re}}{\log \left(\left|base\right|\right)} \]
      (FPCore (re im base)
        :precision binary64
        (/ (atan2 im re) (log (fabs base))))
      double code(double re, double im, double base) {
      	return atan2(im, re) / log(fabs(base));
      }
      
      real(8) function code(re, im, base)
      use fmin_fmax_functions
          real(8), intent (in) :: re
          real(8), intent (in) :: im
          real(8), intent (in) :: base
          code = atan2(im, re) / log(abs(base))
      end function
      
      public static double code(double re, double im, double base) {
      	return Math.atan2(im, re) / Math.log(Math.abs(base));
      }
      
      def code(re, im, base):
      	return math.atan2(im, re) / math.log(math.fabs(base))
      
      function code(re, im, base)
      	return Float64(atan(im, re) / log(abs(base)))
      end
      
      function tmp = code(re, im, base)
      	tmp = atan2(im, re) / log(abs(base));
      end
      
      code[re_, im_, base_] := N[(N[ArcTan[im / re], $MachinePrecision] / N[Log[N[Abs[base], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
      
      \frac{\tan^{-1}_* \frac{im}{re}}{\log \left(\left|base\right|\right)}
      
      Derivation
      1. Initial program 24.8%

        \[\frac{\tan^{-1}_* \frac{im}{re} \cdot \log base - \log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot 0}{\log base \cdot \log base + 0 \cdot 0} \]
      2. Step-by-step derivation
        1. lift-/.f64N/A

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{\frac{1}{\log base \cdot \log base + 0 \cdot 0} \cdot \left(\tan^{-1}_* \frac{im}{re} \cdot \log base\right)} \]
        9. lower-/.f6449.8%

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

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

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

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

          \[\leadsto \frac{1}{\color{blue}{\log base \cdot \log base}} \cdot \left(\tan^{-1}_* \frac{im}{re} \cdot \log base\right) \]
        14. lift-*.f64N/A

          \[\leadsto \frac{1}{\log base \cdot \log base} \cdot \color{blue}{\left(\tan^{-1}_* \frac{im}{re} \cdot \log base\right)} \]
        15. *-commutativeN/A

          \[\leadsto \frac{1}{\log base \cdot \log base} \cdot \color{blue}{\left(\log base \cdot \tan^{-1}_* \frac{im}{re}\right)} \]
      3. Applied rewrites49.8%

        \[\leadsto \color{blue}{\frac{1}{\log base \cdot \log base} \cdot \left(\log base \cdot \tan^{-1}_* \frac{im}{re}\right)} \]
      4. Step-by-step derivation
        1. lift-*.f64N/A

          \[\leadsto \color{blue}{\frac{1}{\log base \cdot \log base} \cdot \left(\log base \cdot \tan^{-1}_* \frac{im}{re}\right)} \]
        2. *-commutativeN/A

          \[\leadsto \color{blue}{\left(\log base \cdot \tan^{-1}_* \frac{im}{re}\right) \cdot \frac{1}{\log base \cdot \log base}} \]
        3. lift-*.f64N/A

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

          \[\leadsto \color{blue}{\left(\tan^{-1}_* \frac{im}{re} \cdot \log base\right)} \cdot \frac{1}{\log base \cdot \log base} \]
        5. associate-*l*N/A

          \[\leadsto \color{blue}{\tan^{-1}_* \frac{im}{re} \cdot \left(\log base \cdot \frac{1}{\log base \cdot \log base}\right)} \]
        6. *-commutativeN/A

          \[\leadsto \tan^{-1}_* \frac{im}{re} \cdot \color{blue}{\left(\frac{1}{\log base \cdot \log base} \cdot \log base\right)} \]
        7. lift-/.f64N/A

          \[\leadsto \tan^{-1}_* \frac{im}{re} \cdot \left(\color{blue}{\frac{1}{\log base \cdot \log base}} \cdot \log base\right) \]
        8. lift-*.f64N/A

          \[\leadsto \tan^{-1}_* \frac{im}{re} \cdot \left(\frac{1}{\color{blue}{\log base \cdot \log base}} \cdot \log base\right) \]
        9. pow2N/A

          \[\leadsto \tan^{-1}_* \frac{im}{re} \cdot \left(\frac{1}{\color{blue}{{\log base}^{2}}} \cdot \log base\right) \]
        10. pow-flipN/A

          \[\leadsto \tan^{-1}_* \frac{im}{re} \cdot \left(\color{blue}{{\log base}^{\left(\mathsf{neg}\left(2\right)\right)}} \cdot \log base\right) \]
        11. pow-plusN/A

          \[\leadsto \tan^{-1}_* \frac{im}{re} \cdot \color{blue}{{\log base}^{\left(\left(\mathsf{neg}\left(2\right)\right) + 1\right)}} \]
        12. metadata-evalN/A

          \[\leadsto \tan^{-1}_* \frac{im}{re} \cdot {\log base}^{\left(\color{blue}{-2} + 1\right)} \]
        13. metadata-evalN/A

          \[\leadsto \tan^{-1}_* \frac{im}{re} \cdot {\log base}^{\color{blue}{-1}} \]
        14. inv-powN/A

          \[\leadsto \tan^{-1}_* \frac{im}{re} \cdot \color{blue}{\frac{1}{\log base}} \]
        15. lower-*.f64N/A

          \[\leadsto \color{blue}{\tan^{-1}_* \frac{im}{re} \cdot \frac{1}{\log base}} \]
        16. lower-/.f6449.9%

          \[\leadsto \tan^{-1}_* \frac{im}{re} \cdot \color{blue}{\frac{1}{\log base}} \]
      5. Applied rewrites49.9%

        \[\leadsto \color{blue}{\tan^{-1}_* \frac{im}{re} \cdot \frac{1}{\log base}} \]
      6. Step-by-step derivation
        1. lift-*.f64N/A

          \[\leadsto \color{blue}{\tan^{-1}_* \frac{im}{re} \cdot \frac{1}{\log base}} \]
        2. lift-/.f64N/A

          \[\leadsto \tan^{-1}_* \frac{im}{re} \cdot \color{blue}{\frac{1}{\log base}} \]
        3. associate-*r/N/A

          \[\leadsto \color{blue}{\frac{\tan^{-1}_* \frac{im}{re} \cdot 1}{\log base}} \]
        4. rgt-mult-inverseN/A

          \[\leadsto \frac{\tan^{-1}_* \frac{im}{re} \cdot \color{blue}{\left(\log base \cdot \frac{1}{\log base}\right)}}{\log base} \]
        5. mult-flip-revN/A

          \[\leadsto \frac{\tan^{-1}_* \frac{im}{re} \cdot \color{blue}{\frac{\log base}{\log base}}}{\log base} \]
        6. associate-/l*N/A

          \[\leadsto \frac{\color{blue}{\frac{\tan^{-1}_* \frac{im}{re} \cdot \log base}{\log base}}}{\log base} \]
        7. *-commutativeN/A

          \[\leadsto \frac{\frac{\color{blue}{\log base \cdot \tan^{-1}_* \frac{im}{re}}}{\log base}}{\log base} \]
        8. lift-*.f64N/A

          \[\leadsto \frac{\frac{\color{blue}{\log base \cdot \tan^{-1}_* \frac{im}{re}}}{\log base}}{\log base} \]
        9. associate-/l/N/A

          \[\leadsto \color{blue}{\frac{\log base \cdot \tan^{-1}_* \frac{im}{re}}{\log base \cdot \log base}} \]
        10. lift-*.f64N/A

          \[\leadsto \frac{\log base \cdot \tan^{-1}_* \frac{im}{re}}{\color{blue}{\log base \cdot \log base}} \]
        11. lift-*.f64N/A

          \[\leadsto \frac{\log base \cdot \tan^{-1}_* \frac{im}{re}}{\color{blue}{\log base \cdot \log base}} \]
        12. lift-log.f64N/A

          \[\leadsto \frac{\log base \cdot \tan^{-1}_* \frac{im}{re}}{\log base \cdot \color{blue}{\log base}} \]
        13. log-pow-revN/A

          \[\leadsto \frac{\log base \cdot \tan^{-1}_* \frac{im}{re}}{\color{blue}{\log \left({base}^{\log base}\right)}} \]
        14. log-powN/A

          \[\leadsto \frac{\log base \cdot \tan^{-1}_* \frac{im}{re}}{\color{blue}{\log base \cdot \log \left(\left|base\right|\right)}} \]
        15. associate-/r*N/A

          \[\leadsto \color{blue}{\frac{\frac{\log base \cdot \tan^{-1}_* \frac{im}{re}}{\log base}}{\log \left(\left|base\right|\right)}} \]
      7. Applied rewrites54.7%

        \[\leadsto \color{blue}{\frac{\tan^{-1}_* \frac{im}{re}}{\log \left(\left|base\right|\right)}} \]
      8. Add Preprocessing

      Alternative 4: 50.0% accurate, 2.6× speedup?

      \[\frac{\tan^{-1}_* \frac{im}{re}}{\log base} \]
      (FPCore (re im base)
        :precision binary64
        (/ (atan2 im re) (log base)))
      double code(double re, double im, double base) {
      	return atan2(im, re) / log(base);
      }
      
      real(8) function code(re, im, base)
      use fmin_fmax_functions
          real(8), intent (in) :: re
          real(8), intent (in) :: im
          real(8), intent (in) :: base
          code = atan2(im, re) / log(base)
      end function
      
      public static double code(double re, double im, double base) {
      	return Math.atan2(im, re) / Math.log(base);
      }
      
      def code(re, im, base):
      	return math.atan2(im, re) / math.log(base)
      
      function code(re, im, base)
      	return Float64(atan(im, re) / log(base))
      end
      
      function tmp = code(re, im, base)
      	tmp = atan2(im, re) / log(base);
      end
      
      code[re_, im_, base_] := N[(N[ArcTan[im / re], $MachinePrecision] / N[Log[base], $MachinePrecision]), $MachinePrecision]
      
      \frac{\tan^{-1}_* \frac{im}{re}}{\log base}
      
      Derivation
      1. Initial program 24.8%

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

        \[\leadsto \color{blue}{\frac{\tan^{-1}_* \frac{im}{re}}{\log base}} \]
      3. Step-by-step derivation
        1. lower-/.f64N/A

          \[\leadsto \frac{\tan^{-1}_* \frac{im}{re}}{\color{blue}{\log base}} \]
        2. lower-atan2.f64N/A

          \[\leadsto \frac{\tan^{-1}_* \frac{im}{re}}{\log \color{blue}{base}} \]
        3. lower-log.f6450.0%

          \[\leadsto \frac{\tan^{-1}_* \frac{im}{re}}{\log base} \]
      4. Applied rewrites50.0%

        \[\leadsto \color{blue}{\frac{\tan^{-1}_* \frac{im}{re}}{\log base}} \]
      5. Add Preprocessing

      Reproduce

      ?
      herbie shell --seed 2025313 -o setup:search
      (FPCore (re im base)
        :name "math.log/2 on complex, imaginary part"
        :precision binary64
        (/ (- (* (atan2 im re) (log base)) (* (log (sqrt (+ (* re re) (* im im)))) 0.0)) (+ (* (log base) (log base)) (* 0.0 0.0))))