math.log10 on complex, real part

Percentage Accurate: 52.5% → 99.7%
Time: 11.2s
Alternatives: 11
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10} \end{array} \]
(FPCore (re im)
 :precision binary64
 (/ (log (sqrt (+ (* re re) (* im im)))) (log 10.0)))
double code(double re, double im) {
	return log(sqrt(((re * re) + (im * im)))) / log(10.0);
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = log(sqrt(((re * re) + (im * im)))) / log(10.0d0)
end function
public static double code(double re, double im) {
	return Math.log(Math.sqrt(((re * re) + (im * im)))) / Math.log(10.0);
}
def code(re, im):
	return math.log(math.sqrt(((re * re) + (im * im)))) / math.log(10.0)
function code(re, im)
	return Float64(log(sqrt(Float64(Float64(re * re) + Float64(im * im)))) / log(10.0))
end
function tmp = code(re, im)
	tmp = log(sqrt(((re * re) + (im * im)))) / log(10.0);
end
code[re_, im_] := N[(N[Log[N[Sqrt[N[(N[(re * re), $MachinePrecision] + N[(im * im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] / N[Log[10.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}
\end{array}

Sampling outcomes in binary64 precision:

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 11 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: 52.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10} \end{array} \]
(FPCore (re im)
 :precision binary64
 (/ (log (sqrt (+ (* re re) (* im im)))) (log 10.0)))
double code(double re, double im) {
	return log(sqrt(((re * re) + (im * im)))) / log(10.0);
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = log(sqrt(((re * re) + (im * im)))) / log(10.0d0)
end function
public static double code(double re, double im) {
	return Math.log(Math.sqrt(((re * re) + (im * im)))) / Math.log(10.0);
}
def code(re, im):
	return math.log(math.sqrt(((re * re) + (im * im)))) / math.log(10.0)
function code(re, im)
	return Float64(log(sqrt(Float64(Float64(re * re) + Float64(im * im)))) / log(10.0))
end
function tmp = code(re, im)
	tmp = log(sqrt(((re * re) + (im * im)))) / log(10.0);
end
code[re_, im_] := N[(N[Log[N[Sqrt[N[(N[(re * re), $MachinePrecision] + N[(im * im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] / N[Log[10.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}
\end{array}

Alternative 1: 99.7% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left({\left({\log 10}^{-0.5}\right)}^{2}\right)}\right) \end{array} \]
(FPCore (re im)
 :precision binary64
 (log (pow (hypot re im) (pow (pow (log 10.0) -0.5) 2.0))))
double code(double re, double im) {
	return log(pow(hypot(re, im), pow(pow(log(10.0), -0.5), 2.0)));
}
public static double code(double re, double im) {
	return Math.log(Math.pow(Math.hypot(re, im), Math.pow(Math.pow(Math.log(10.0), -0.5), 2.0)));
}
def code(re, im):
	return math.log(math.pow(math.hypot(re, im), math.pow(math.pow(math.log(10.0), -0.5), 2.0)))
function code(re, im)
	return log((hypot(re, im) ^ ((log(10.0) ^ -0.5) ^ 2.0)))
end
function tmp = code(re, im)
	tmp = log((hypot(re, im) ^ ((log(10.0) ^ -0.5) ^ 2.0)));
end
code[re_, im_] := N[Log[N[Power[N[Sqrt[re ^ 2 + im ^ 2], $MachinePrecision], N[Power[N[Power[N[Log[10.0], $MachinePrecision], -0.5], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left({\left({\log 10}^{-0.5}\right)}^{2}\right)}\right)
\end{array}
Derivation
  1. Initial program 53.9%

    \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10} \]
  2. Step-by-step derivation
    1. hypot-def99.0%

      \[\leadsto \frac{\log \color{blue}{\left(\mathsf{hypot}\left(re, im\right)\right)}}{\log 10} \]
  3. Simplified99.0%

    \[\leadsto \color{blue}{\frac{\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\log 10}} \]
  4. Step-by-step derivation
    1. add-log-exp99.0%

      \[\leadsto \color{blue}{\log \left(e^{\frac{\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\log 10}}\right)} \]
    2. div-inv98.5%

      \[\leadsto \log \left(e^{\color{blue}{\log \left(\mathsf{hypot}\left(re, im\right)\right) \cdot \frac{1}{\log 10}}}\right) \]
    3. exp-to-pow98.5%

      \[\leadsto \log \color{blue}{\left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left(\frac{1}{\log 10}\right)}\right)} \]
    4. frac-2neg98.5%

      \[\leadsto \log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\color{blue}{\left(\frac{-1}{-\log 10}\right)}}\right) \]
    5. metadata-eval98.5%

      \[\leadsto \log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left(\frac{\color{blue}{-1}}{-\log 10}\right)}\right) \]
    6. neg-log99.0%

      \[\leadsto \log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left(\frac{-1}{\color{blue}{\log \left(\frac{1}{10}\right)}}\right)}\right) \]
    7. metadata-eval99.0%

      \[\leadsto \log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left(\frac{-1}{\log \color{blue}{0.1}}\right)}\right) \]
  5. Applied egg-rr99.0%

    \[\leadsto \color{blue}{\log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left(\frac{-1}{\log 0.1}\right)}\right)} \]
  6. Step-by-step derivation
    1. metadata-eval99.0%

      \[\leadsto \log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left(\frac{\color{blue}{-1}}{\log 0.1}\right)}\right) \]
    2. metadata-eval99.0%

      \[\leadsto \log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left(\frac{-1}{\log \color{blue}{\left(\frac{1}{10}\right)}}\right)}\right) \]
    3. neg-log98.5%

      \[\leadsto \log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left(\frac{-1}{\color{blue}{-\log 10}}\right)}\right) \]
    4. frac-2neg98.5%

      \[\leadsto \log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\color{blue}{\left(\frac{1}{\log 10}\right)}}\right) \]
    5. add-sqr-sqrt98.5%

      \[\leadsto \log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left(\frac{1}{\color{blue}{\sqrt{\log 10} \cdot \sqrt{\log 10}}}\right)}\right) \]
    6. metadata-eval98.5%

      \[\leadsto \log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left(\frac{\color{blue}{1 \cdot 1}}{\sqrt{\log 10} \cdot \sqrt{\log 10}}\right)}\right) \]
    7. frac-times99.7%

      \[\leadsto \log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\color{blue}{\left(\frac{1}{\sqrt{\log 10}} \cdot \frac{1}{\sqrt{\log 10}}\right)}}\right) \]
    8. pow299.7%

      \[\leadsto \log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\color{blue}{\left({\left(\frac{1}{\sqrt{\log 10}}\right)}^{2}\right)}}\right) \]
    9. pow1/299.7%

      \[\leadsto \log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left({\left(\frac{1}{\color{blue}{{\log 10}^{0.5}}}\right)}^{2}\right)}\right) \]
    10. pow-flip99.7%

      \[\leadsto \log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left({\color{blue}{\left({\log 10}^{\left(-0.5\right)}\right)}}^{2}\right)}\right) \]
    11. metadata-eval99.7%

      \[\leadsto \log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left({\left({\log 10}^{\color{blue}{-0.5}}\right)}^{2}\right)}\right) \]
  7. Applied egg-rr99.7%

    \[\leadsto \log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\color{blue}{\left({\left({\log 10}^{-0.5}\right)}^{2}\right)}}\right) \]
  8. Final simplification99.7%

    \[\leadsto \log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left({\left({\log 10}^{-0.5}\right)}^{2}\right)}\right) \]

Alternative 2: 99.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{1}{\frac{\log 10}{\log \left(\mathsf{hypot}\left(re, im\right)\right)}} \end{array} \]
(FPCore (re im) :precision binary64 (/ 1.0 (/ (log 10.0) (log (hypot re im)))))
double code(double re, double im) {
	return 1.0 / (log(10.0) / log(hypot(re, im)));
}
public static double code(double re, double im) {
	return 1.0 / (Math.log(10.0) / Math.log(Math.hypot(re, im)));
}
def code(re, im):
	return 1.0 / (math.log(10.0) / math.log(math.hypot(re, im)))
function code(re, im)
	return Float64(1.0 / Float64(log(10.0) / log(hypot(re, im))))
end
function tmp = code(re, im)
	tmp = 1.0 / (log(10.0) / log(hypot(re, im)));
end
code[re_, im_] := N[(1.0 / N[(N[Log[10.0], $MachinePrecision] / N[Log[N[Sqrt[re ^ 2 + im ^ 2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1}{\frac{\log 10}{\log \left(\mathsf{hypot}\left(re, im\right)\right)}}
\end{array}
Derivation
  1. Initial program 53.9%

    \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10} \]
  2. Step-by-step derivation
    1. hypot-def99.0%

      \[\leadsto \frac{\log \color{blue}{\left(\mathsf{hypot}\left(re, im\right)\right)}}{\log 10} \]
  3. Simplified99.0%

    \[\leadsto \color{blue}{\frac{\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\log 10}} \]
  4. Step-by-step derivation
    1. *-un-lft-identity99.0%

      \[\leadsto \frac{\color{blue}{1 \cdot \log \left(\mathsf{hypot}\left(re, im\right)\right)}}{\log 10} \]
    2. add-sqr-sqrt99.0%

      \[\leadsto \frac{1 \cdot \log \left(\mathsf{hypot}\left(re, im\right)\right)}{\color{blue}{\sqrt{\log 10} \cdot \sqrt{\log 10}}} \]
    3. times-frac99.1%

      \[\leadsto \color{blue}{\frac{1}{\sqrt{\log 10}} \cdot \frac{\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\sqrt{\log 10}}} \]
  5. Applied egg-rr99.1%

    \[\leadsto \color{blue}{\frac{1}{\sqrt{\log 10}} \cdot \frac{\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\sqrt{\log 10}}} \]
  6. Step-by-step derivation
    1. frac-times99.0%

      \[\leadsto \color{blue}{\frac{1 \cdot \log \left(\mathsf{hypot}\left(re, im\right)\right)}{\sqrt{\log 10} \cdot \sqrt{\log 10}}} \]
    2. add-sqr-sqrt99.0%

      \[\leadsto \frac{1 \cdot \log \left(\mathsf{hypot}\left(re, im\right)\right)}{\color{blue}{\log 10}} \]
    3. associate-/l*99.1%

      \[\leadsto \color{blue}{\frac{1}{\frac{\log 10}{\log \left(\mathsf{hypot}\left(re, im\right)\right)}}} \]
  7. Applied egg-rr99.1%

    \[\leadsto \color{blue}{\frac{1}{\frac{\log 10}{\log \left(\mathsf{hypot}\left(re, im\right)\right)}}} \]
  8. Final simplification99.1%

    \[\leadsto \frac{1}{\frac{\log 10}{\log \left(\mathsf{hypot}\left(re, im\right)\right)}} \]

Alternative 3: 99.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{-\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\log 0.1} \end{array} \]
(FPCore (re im) :precision binary64 (/ (- (log (hypot re im))) (log 0.1)))
double code(double re, double im) {
	return -log(hypot(re, im)) / log(0.1);
}
public static double code(double re, double im) {
	return -Math.log(Math.hypot(re, im)) / Math.log(0.1);
}
def code(re, im):
	return -math.log(math.hypot(re, im)) / math.log(0.1)
function code(re, im)
	return Float64(Float64(-log(hypot(re, im))) / log(0.1))
end
function tmp = code(re, im)
	tmp = -log(hypot(re, im)) / log(0.1);
end
code[re_, im_] := N[((-N[Log[N[Sqrt[re ^ 2 + im ^ 2], $MachinePrecision]], $MachinePrecision]) / N[Log[0.1], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{-\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\log 0.1}
\end{array}
Derivation
  1. Initial program 53.9%

    \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10} \]
  2. Step-by-step derivation
    1. hypot-def99.0%

      \[\leadsto \frac{\log \color{blue}{\left(\mathsf{hypot}\left(re, im\right)\right)}}{\log 10} \]
  3. Simplified99.0%

    \[\leadsto \color{blue}{\frac{\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\log 10}} \]
  4. Step-by-step derivation
    1. div-inv98.5%

      \[\leadsto \color{blue}{\log \left(\mathsf{hypot}\left(re, im\right)\right) \cdot \frac{1}{\log 10}} \]
    2. frac-2neg98.5%

      \[\leadsto \log \left(\mathsf{hypot}\left(re, im\right)\right) \cdot \color{blue}{\frac{-1}{-\log 10}} \]
    3. metadata-eval98.5%

      \[\leadsto \log \left(\mathsf{hypot}\left(re, im\right)\right) \cdot \frac{\color{blue}{-1}}{-\log 10} \]
    4. neg-log99.0%

      \[\leadsto \log \left(\mathsf{hypot}\left(re, im\right)\right) \cdot \frac{-1}{\color{blue}{\log \left(\frac{1}{10}\right)}} \]
    5. metadata-eval99.0%

      \[\leadsto \log \left(\mathsf{hypot}\left(re, im\right)\right) \cdot \frac{-1}{\log \color{blue}{0.1}} \]
  5. Applied egg-rr99.0%

    \[\leadsto \color{blue}{\log \left(\mathsf{hypot}\left(re, im\right)\right) \cdot \frac{-1}{\log 0.1}} \]
  6. Step-by-step derivation
    1. *-commutative99.0%

      \[\leadsto \color{blue}{\frac{-1}{\log 0.1} \cdot \log \left(\mathsf{hypot}\left(re, im\right)\right)} \]
    2. associate-*l/99.0%

      \[\leadsto \color{blue}{\frac{-1 \cdot \log \left(\mathsf{hypot}\left(re, im\right)\right)}{\log 0.1}} \]
    3. neg-mul-199.0%

      \[\leadsto \frac{\color{blue}{-\log \left(\mathsf{hypot}\left(re, im\right)\right)}}{\log 0.1} \]
  7. Simplified99.0%

    \[\leadsto \color{blue}{\frac{-\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\log 0.1}} \]
  8. Final simplification99.0%

    \[\leadsto \frac{-\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\log 0.1} \]

Alternative 4: 99.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\log 10} \end{array} \]
(FPCore (re im) :precision binary64 (/ (log (hypot re im)) (log 10.0)))
double code(double re, double im) {
	return log(hypot(re, im)) / log(10.0);
}
public static double code(double re, double im) {
	return Math.log(Math.hypot(re, im)) / Math.log(10.0);
}
def code(re, im):
	return math.log(math.hypot(re, im)) / math.log(10.0)
function code(re, im)
	return Float64(log(hypot(re, im)) / log(10.0))
end
function tmp = code(re, im)
	tmp = log(hypot(re, im)) / log(10.0);
end
code[re_, im_] := N[(N[Log[N[Sqrt[re ^ 2 + im ^ 2], $MachinePrecision]], $MachinePrecision] / N[Log[10.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\log 10}
\end{array}
Derivation
  1. Initial program 53.9%

    \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10} \]
  2. Step-by-step derivation
    1. hypot-def99.0%

      \[\leadsto \frac{\log \color{blue}{\left(\mathsf{hypot}\left(re, im\right)\right)}}{\log 10} \]
  3. Simplified99.0%

    \[\leadsto \color{blue}{\frac{\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\log 10}} \]
  4. Final simplification99.0%

    \[\leadsto \frac{\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\log 10} \]

Alternative 5: 44.1% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 4.3 \cdot 10^{-29}:\\ \;\;\;\;\frac{1}{\frac{-\log 10}{\log \left(\frac{-1}{re}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{\log 10}{\log im}}\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 4.3e-29)
   (/ 1.0 (/ (- (log 10.0)) (log (/ -1.0 re))))
   (/ 1.0 (/ (log 10.0) (log im)))))
double code(double re, double im) {
	double tmp;
	if (im <= 4.3e-29) {
		tmp = 1.0 / (-log(10.0) / log((-1.0 / re)));
	} else {
		tmp = 1.0 / (log(10.0) / log(im));
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= 4.3d-29) then
        tmp = 1.0d0 / (-log(10.0d0) / log(((-1.0d0) / re)))
    else
        tmp = 1.0d0 / (log(10.0d0) / log(im))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= 4.3e-29) {
		tmp = 1.0 / (-Math.log(10.0) / Math.log((-1.0 / re)));
	} else {
		tmp = 1.0 / (Math.log(10.0) / Math.log(im));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 4.3e-29:
		tmp = 1.0 / (-math.log(10.0) / math.log((-1.0 / re)))
	else:
		tmp = 1.0 / (math.log(10.0) / math.log(im))
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 4.3e-29)
		tmp = Float64(1.0 / Float64(Float64(-log(10.0)) / log(Float64(-1.0 / re))));
	else
		tmp = Float64(1.0 / Float64(log(10.0) / log(im)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 4.3e-29)
		tmp = 1.0 / (-log(10.0) / log((-1.0 / re)));
	else
		tmp = 1.0 / (log(10.0) / log(im));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 4.3e-29], N[(1.0 / N[((-N[Log[10.0], $MachinePrecision]) / N[Log[N[(-1.0 / re), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[Log[10.0], $MachinePrecision] / N[Log[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq 4.3 \cdot 10^{-29}:\\
\;\;\;\;\frac{1}{\frac{-\log 10}{\log \left(\frac{-1}{re}\right)}}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\log 10}{\log im}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < 4.2999999999999998e-29

    1. Initial program 59.2%

      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10} \]
    2. Step-by-step derivation
      1. hypot-def99.0%

        \[\leadsto \frac{\log \color{blue}{\left(\mathsf{hypot}\left(re, im\right)\right)}}{\log 10} \]
    3. Simplified99.0%

      \[\leadsto \color{blue}{\frac{\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\log 10}} \]
    4. Step-by-step derivation
      1. add-log-exp99.0%

        \[\leadsto \color{blue}{\log \left(e^{\frac{\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\log 10}}\right)} \]
      2. div-inv98.5%

        \[\leadsto \log \left(e^{\color{blue}{\log \left(\mathsf{hypot}\left(re, im\right)\right) \cdot \frac{1}{\log 10}}}\right) \]
      3. exp-to-pow98.5%

        \[\leadsto \log \color{blue}{\left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left(\frac{1}{\log 10}\right)}\right)} \]
      4. frac-2neg98.5%

        \[\leadsto \log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\color{blue}{\left(\frac{-1}{-\log 10}\right)}}\right) \]
      5. metadata-eval98.5%

        \[\leadsto \log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left(\frac{\color{blue}{-1}}{-\log 10}\right)}\right) \]
      6. neg-log99.0%

        \[\leadsto \log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left(\frac{-1}{\color{blue}{\log \left(\frac{1}{10}\right)}}\right)}\right) \]
      7. metadata-eval99.0%

        \[\leadsto \log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left(\frac{-1}{\log \color{blue}{0.1}}\right)}\right) \]
    5. Applied egg-rr99.0%

      \[\leadsto \color{blue}{\log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left(\frac{-1}{\log 0.1}\right)}\right)} \]
    6. Step-by-step derivation
      1. metadata-eval99.0%

        \[\leadsto \log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left(\frac{\color{blue}{-1}}{\log 0.1}\right)}\right) \]
      2. metadata-eval99.0%

        \[\leadsto \log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left(\frac{-1}{\log \color{blue}{\left(\frac{1}{10}\right)}}\right)}\right) \]
      3. neg-log98.5%

        \[\leadsto \log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left(\frac{-1}{\color{blue}{-\log 10}}\right)}\right) \]
      4. frac-2neg98.5%

        \[\leadsto \log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\color{blue}{\left(\frac{1}{\log 10}\right)}}\right) \]
      5. add-sqr-sqrt98.5%

        \[\leadsto \log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left(\frac{1}{\color{blue}{\sqrt{\log 10} \cdot \sqrt{\log 10}}}\right)}\right) \]
      6. metadata-eval98.5%

        \[\leadsto \log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left(\frac{\color{blue}{1 \cdot 1}}{\sqrt{\log 10} \cdot \sqrt{\log 10}}\right)}\right) \]
      7. frac-times99.7%

        \[\leadsto \log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\color{blue}{\left(\frac{1}{\sqrt{\log 10}} \cdot \frac{1}{\sqrt{\log 10}}\right)}}\right) \]
      8. pow299.7%

        \[\leadsto \log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\color{blue}{\left({\left(\frac{1}{\sqrt{\log 10}}\right)}^{2}\right)}}\right) \]
      9. pow1/299.7%

        \[\leadsto \log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left({\left(\frac{1}{\color{blue}{{\log 10}^{0.5}}}\right)}^{2}\right)}\right) \]
      10. pow-flip99.7%

        \[\leadsto \log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left({\color{blue}{\left({\log 10}^{\left(-0.5\right)}\right)}}^{2}\right)}\right) \]
      11. metadata-eval99.7%

        \[\leadsto \log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left({\left({\log 10}^{\color{blue}{-0.5}}\right)}^{2}\right)}\right) \]
    7. Applied egg-rr99.7%

      \[\leadsto \log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\color{blue}{\left({\left({\log 10}^{-0.5}\right)}^{2}\right)}}\right) \]
    8. Step-by-step derivation
      1. log-pow99.6%

        \[\leadsto \color{blue}{{\left({\log 10}^{-0.5}\right)}^{2} \cdot \log \left(\mathsf{hypot}\left(re, im\right)\right)} \]
      2. pow-pow98.5%

        \[\leadsto \color{blue}{{\log 10}^{\left(-0.5 \cdot 2\right)}} \cdot \log \left(\mathsf{hypot}\left(re, im\right)\right) \]
      3. metadata-eval98.5%

        \[\leadsto {\log 10}^{\color{blue}{-1}} \cdot \log \left(\mathsf{hypot}\left(re, im\right)\right) \]
      4. inv-pow98.5%

        \[\leadsto \color{blue}{\frac{1}{\log 10}} \cdot \log \left(\mathsf{hypot}\left(re, im\right)\right) \]
      5. associate-/r/99.0%

        \[\leadsto \color{blue}{\frac{1}{\frac{\log 10}{\log \left(\mathsf{hypot}\left(re, im\right)\right)}}} \]
      6. log1p-expm1-u99.0%

        \[\leadsto \frac{1}{\frac{\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\log 10\right)\right)}}{\log \left(\mathsf{hypot}\left(re, im\right)\right)}} \]
      7. expm1-udef99.0%

        \[\leadsto \frac{1}{\frac{\mathsf{log1p}\left(\color{blue}{e^{\log 10} - 1}\right)}{\log \left(\mathsf{hypot}\left(re, im\right)\right)}} \]
      8. add-exp-log99.0%

        \[\leadsto \frac{1}{\frac{\mathsf{log1p}\left(\color{blue}{10} - 1\right)}{\log \left(\mathsf{hypot}\left(re, im\right)\right)}} \]
      9. metadata-eval99.0%

        \[\leadsto \frac{1}{\frac{\mathsf{log1p}\left(\color{blue}{9}\right)}{\log \left(\mathsf{hypot}\left(re, im\right)\right)}} \]
    9. Applied egg-rr99.0%

      \[\leadsto \color{blue}{\frac{1}{\frac{\mathsf{log1p}\left(9\right)}{\log \left(\mathsf{hypot}\left(re, im\right)\right)}}} \]
    10. Taylor expanded in re around -inf 35.0%

      \[\leadsto \frac{1}{\color{blue}{-1 \cdot \frac{\log 10}{\log \left(\frac{-1}{re}\right)}}} \]
    11. Step-by-step derivation
      1. associate-*r/35.0%

        \[\leadsto \frac{1}{\color{blue}{\frac{-1 \cdot \log 10}{\log \left(\frac{-1}{re}\right)}}} \]
      2. neg-mul-135.0%

        \[\leadsto \frac{1}{\frac{\color{blue}{-\log 10}}{\log \left(\frac{-1}{re}\right)}} \]
    12. Simplified35.0%

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

    if 4.2999999999999998e-29 < im

    1. Initial program 42.3%

      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10} \]
    2. Step-by-step derivation
      1. hypot-def99.0%

        \[\leadsto \frac{\log \color{blue}{\left(\mathsf{hypot}\left(re, im\right)\right)}}{\log 10} \]
    3. Simplified99.0%

      \[\leadsto \color{blue}{\frac{\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\log 10}} \]
    4. Taylor expanded in re around 0 77.1%

      \[\leadsto \color{blue}{\frac{\log im}{\log 10}} \]
    5. Step-by-step derivation
      1. clear-num77.2%

        \[\leadsto \color{blue}{\frac{1}{\frac{\log 10}{\log im}}} \]
      2. inv-pow77.2%

        \[\leadsto \color{blue}{{\left(\frac{\log 10}{\log im}\right)}^{-1}} \]
    6. Applied egg-rr77.2%

      \[\leadsto \color{blue}{{\left(\frac{\log 10}{\log im}\right)}^{-1}} \]
    7. Step-by-step derivation
      1. unpow-177.2%

        \[\leadsto \color{blue}{\frac{1}{\frac{\log 10}{\log im}}} \]
    8. Simplified77.2%

      \[\leadsto \color{blue}{\frac{1}{\frac{\log 10}{\log im}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification48.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 4.3 \cdot 10^{-29}:\\ \;\;\;\;\frac{1}{\frac{-\log 10}{\log \left(\frac{-1}{re}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{\log 10}{\log im}}\\ \end{array} \]

Alternative 6: 44.1% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 4.4 \cdot 10^{-29}:\\ \;\;\;\;\frac{-\log \left(\frac{-1}{re}\right)}{\log 10}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{\log 10}{\log im}}\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 4.4e-29)
   (/ (- (log (/ -1.0 re))) (log 10.0))
   (/ 1.0 (/ (log 10.0) (log im)))))
double code(double re, double im) {
	double tmp;
	if (im <= 4.4e-29) {
		tmp = -log((-1.0 / re)) / log(10.0);
	} else {
		tmp = 1.0 / (log(10.0) / log(im));
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= 4.4d-29) then
        tmp = -log(((-1.0d0) / re)) / log(10.0d0)
    else
        tmp = 1.0d0 / (log(10.0d0) / log(im))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= 4.4e-29) {
		tmp = -Math.log((-1.0 / re)) / Math.log(10.0);
	} else {
		tmp = 1.0 / (Math.log(10.0) / Math.log(im));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 4.4e-29:
		tmp = -math.log((-1.0 / re)) / math.log(10.0)
	else:
		tmp = 1.0 / (math.log(10.0) / math.log(im))
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 4.4e-29)
		tmp = Float64(Float64(-log(Float64(-1.0 / re))) / log(10.0));
	else
		tmp = Float64(1.0 / Float64(log(10.0) / log(im)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 4.4e-29)
		tmp = -log((-1.0 / re)) / log(10.0);
	else
		tmp = 1.0 / (log(10.0) / log(im));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 4.4e-29], N[((-N[Log[N[(-1.0 / re), $MachinePrecision]], $MachinePrecision]) / N[Log[10.0], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[Log[10.0], $MachinePrecision] / N[Log[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq 4.4 \cdot 10^{-29}:\\
\;\;\;\;\frac{-\log \left(\frac{-1}{re}\right)}{\log 10}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\log 10}{\log im}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < 4.39999999999999981e-29

    1. Initial program 59.2%

      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10} \]
    2. Step-by-step derivation
      1. hypot-def99.0%

        \[\leadsto \frac{\log \color{blue}{\left(\mathsf{hypot}\left(re, im\right)\right)}}{\log 10} \]
    3. Simplified99.0%

      \[\leadsto \color{blue}{\frac{\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\log 10}} \]
    4. Taylor expanded in re around -inf 35.0%

      \[\leadsto \color{blue}{-1 \cdot \frac{\log \left(\frac{-1}{re}\right)}{\log 10}} \]
    5. Step-by-step derivation
      1. associate-*r/35.0%

        \[\leadsto \color{blue}{\frac{-1 \cdot \log \left(\frac{-1}{re}\right)}{\log 10}} \]
      2. mul-1-neg35.0%

        \[\leadsto \frac{\color{blue}{-\log \left(\frac{-1}{re}\right)}}{\log 10} \]
    6. Simplified35.0%

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

    if 4.39999999999999981e-29 < im

    1. Initial program 42.3%

      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10} \]
    2. Step-by-step derivation
      1. hypot-def99.0%

        \[\leadsto \frac{\log \color{blue}{\left(\mathsf{hypot}\left(re, im\right)\right)}}{\log 10} \]
    3. Simplified99.0%

      \[\leadsto \color{blue}{\frac{\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\log 10}} \]
    4. Taylor expanded in re around 0 77.1%

      \[\leadsto \color{blue}{\frac{\log im}{\log 10}} \]
    5. Step-by-step derivation
      1. clear-num77.2%

        \[\leadsto \color{blue}{\frac{1}{\frac{\log 10}{\log im}}} \]
      2. inv-pow77.2%

        \[\leadsto \color{blue}{{\left(\frac{\log 10}{\log im}\right)}^{-1}} \]
    6. Applied egg-rr77.2%

      \[\leadsto \color{blue}{{\left(\frac{\log 10}{\log im}\right)}^{-1}} \]
    7. Step-by-step derivation
      1. unpow-177.2%

        \[\leadsto \color{blue}{\frac{1}{\frac{\log 10}{\log im}}} \]
    8. Simplified77.2%

      \[\leadsto \color{blue}{\frac{1}{\frac{\log 10}{\log im}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification48.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 4.4 \cdot 10^{-29}:\\ \;\;\;\;\frac{-\log \left(\frac{-1}{re}\right)}{\log 10}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{\log 10}{\log im}}\\ \end{array} \]

Alternative 7: 44.1% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 4.4 \cdot 10^{-29}:\\ \;\;\;\;\frac{\log \left(\frac{-1}{re}\right)}{\log 0.1}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{\log 10}{\log im}}\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 4.4e-29)
   (/ (log (/ -1.0 re)) (log 0.1))
   (/ 1.0 (/ (log 10.0) (log im)))))
double code(double re, double im) {
	double tmp;
	if (im <= 4.4e-29) {
		tmp = log((-1.0 / re)) / log(0.1);
	} else {
		tmp = 1.0 / (log(10.0) / log(im));
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= 4.4d-29) then
        tmp = log(((-1.0d0) / re)) / log(0.1d0)
    else
        tmp = 1.0d0 / (log(10.0d0) / log(im))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= 4.4e-29) {
		tmp = Math.log((-1.0 / re)) / Math.log(0.1);
	} else {
		tmp = 1.0 / (Math.log(10.0) / Math.log(im));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 4.4e-29:
		tmp = math.log((-1.0 / re)) / math.log(0.1)
	else:
		tmp = 1.0 / (math.log(10.0) / math.log(im))
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 4.4e-29)
		tmp = Float64(log(Float64(-1.0 / re)) / log(0.1));
	else
		tmp = Float64(1.0 / Float64(log(10.0) / log(im)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 4.4e-29)
		tmp = log((-1.0 / re)) / log(0.1);
	else
		tmp = 1.0 / (log(10.0) / log(im));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 4.4e-29], N[(N[Log[N[(-1.0 / re), $MachinePrecision]], $MachinePrecision] / N[Log[0.1], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[Log[10.0], $MachinePrecision] / N[Log[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq 4.4 \cdot 10^{-29}:\\
\;\;\;\;\frac{\log \left(\frac{-1}{re}\right)}{\log 0.1}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\log 10}{\log im}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < 4.39999999999999981e-29

    1. Initial program 59.2%

      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10} \]
    2. Step-by-step derivation
      1. hypot-def99.0%

        \[\leadsto \frac{\log \color{blue}{\left(\mathsf{hypot}\left(re, im\right)\right)}}{\log 10} \]
    3. Simplified99.0%

      \[\leadsto \color{blue}{\frac{\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\log 10}} \]
    4. Step-by-step derivation
      1. add-log-exp99.0%

        \[\leadsto \color{blue}{\log \left(e^{\frac{\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\log 10}}\right)} \]
      2. div-inv98.5%

        \[\leadsto \log \left(e^{\color{blue}{\log \left(\mathsf{hypot}\left(re, im\right)\right) \cdot \frac{1}{\log 10}}}\right) \]
      3. exp-to-pow98.5%

        \[\leadsto \log \color{blue}{\left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left(\frac{1}{\log 10}\right)}\right)} \]
      4. frac-2neg98.5%

        \[\leadsto \log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\color{blue}{\left(\frac{-1}{-\log 10}\right)}}\right) \]
      5. metadata-eval98.5%

        \[\leadsto \log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left(\frac{\color{blue}{-1}}{-\log 10}\right)}\right) \]
      6. neg-log99.0%

        \[\leadsto \log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left(\frac{-1}{\color{blue}{\log \left(\frac{1}{10}\right)}}\right)}\right) \]
      7. metadata-eval99.0%

        \[\leadsto \log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left(\frac{-1}{\log \color{blue}{0.1}}\right)}\right) \]
    5. Applied egg-rr99.0%

      \[\leadsto \color{blue}{\log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left(\frac{-1}{\log 0.1}\right)}\right)} \]
    6. Taylor expanded in re around -inf 35.0%

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

    if 4.39999999999999981e-29 < im

    1. Initial program 42.3%

      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10} \]
    2. Step-by-step derivation
      1. hypot-def99.0%

        \[\leadsto \frac{\log \color{blue}{\left(\mathsf{hypot}\left(re, im\right)\right)}}{\log 10} \]
    3. Simplified99.0%

      \[\leadsto \color{blue}{\frac{\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\log 10}} \]
    4. Taylor expanded in re around 0 77.1%

      \[\leadsto \color{blue}{\frac{\log im}{\log 10}} \]
    5. Step-by-step derivation
      1. clear-num77.2%

        \[\leadsto \color{blue}{\frac{1}{\frac{\log 10}{\log im}}} \]
      2. inv-pow77.2%

        \[\leadsto \color{blue}{{\left(\frac{\log 10}{\log im}\right)}^{-1}} \]
    6. Applied egg-rr77.2%

      \[\leadsto \color{blue}{{\left(\frac{\log 10}{\log im}\right)}^{-1}} \]
    7. Step-by-step derivation
      1. unpow-177.2%

        \[\leadsto \color{blue}{\frac{1}{\frac{\log 10}{\log im}}} \]
    8. Simplified77.2%

      \[\leadsto \color{blue}{\frac{1}{\frac{\log 10}{\log im}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification48.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 4.4 \cdot 10^{-29}:\\ \;\;\;\;\frac{\log \left(\frac{-1}{re}\right)}{\log 0.1}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{\log 10}{\log im}}\\ \end{array} \]

Alternative 8: 27.6% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \frac{1}{\frac{\log 10}{\log im}} \end{array} \]
(FPCore (re im) :precision binary64 (/ 1.0 (/ (log 10.0) (log im))))
double code(double re, double im) {
	return 1.0 / (log(10.0) / log(im));
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = 1.0d0 / (log(10.0d0) / log(im))
end function
public static double code(double re, double im) {
	return 1.0 / (Math.log(10.0) / Math.log(im));
}
def code(re, im):
	return 1.0 / (math.log(10.0) / math.log(im))
function code(re, im)
	return Float64(1.0 / Float64(log(10.0) / log(im)))
end
function tmp = code(re, im)
	tmp = 1.0 / (log(10.0) / log(im));
end
code[re_, im_] := N[(1.0 / N[(N[Log[10.0], $MachinePrecision] / N[Log[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1}{\frac{\log 10}{\log im}}
\end{array}
Derivation
  1. Initial program 53.9%

    \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10} \]
  2. Step-by-step derivation
    1. hypot-def99.0%

      \[\leadsto \frac{\log \color{blue}{\left(\mathsf{hypot}\left(re, im\right)\right)}}{\log 10} \]
  3. Simplified99.0%

    \[\leadsto \color{blue}{\frac{\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\log 10}} \]
  4. Taylor expanded in re around 0 28.8%

    \[\leadsto \color{blue}{\frac{\log im}{\log 10}} \]
  5. Step-by-step derivation
    1. clear-num28.8%

      \[\leadsto \color{blue}{\frac{1}{\frac{\log 10}{\log im}}} \]
    2. inv-pow28.8%

      \[\leadsto \color{blue}{{\left(\frac{\log 10}{\log im}\right)}^{-1}} \]
  6. Applied egg-rr28.8%

    \[\leadsto \color{blue}{{\left(\frac{\log 10}{\log im}\right)}^{-1}} \]
  7. Step-by-step derivation
    1. unpow-128.8%

      \[\leadsto \color{blue}{\frac{1}{\frac{\log 10}{\log im}}} \]
  8. Simplified28.8%

    \[\leadsto \color{blue}{\frac{1}{\frac{\log 10}{\log im}}} \]
  9. Final simplification28.8%

    \[\leadsto \frac{1}{\frac{\log 10}{\log im}} \]

Alternative 9: 27.6% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \frac{-\log im}{\log 0.1} \end{array} \]
(FPCore (re im) :precision binary64 (/ (- (log im)) (log 0.1)))
double code(double re, double im) {
	return -log(im) / log(0.1);
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = -log(im) / log(0.1d0)
end function
public static double code(double re, double im) {
	return -Math.log(im) / Math.log(0.1);
}
def code(re, im):
	return -math.log(im) / math.log(0.1)
function code(re, im)
	return Float64(Float64(-log(im)) / log(0.1))
end
function tmp = code(re, im)
	tmp = -log(im) / log(0.1);
end
code[re_, im_] := N[((-N[Log[im], $MachinePrecision]) / N[Log[0.1], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{-\log im}{\log 0.1}
\end{array}
Derivation
  1. Initial program 53.9%

    \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10} \]
  2. Step-by-step derivation
    1. hypot-def99.0%

      \[\leadsto \frac{\log \color{blue}{\left(\mathsf{hypot}\left(re, im\right)\right)}}{\log 10} \]
  3. Simplified99.0%

    \[\leadsto \color{blue}{\frac{\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\log 10}} \]
  4. Step-by-step derivation
    1. add-log-exp99.0%

      \[\leadsto \color{blue}{\log \left(e^{\frac{\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\log 10}}\right)} \]
    2. div-inv98.5%

      \[\leadsto \log \left(e^{\color{blue}{\log \left(\mathsf{hypot}\left(re, im\right)\right) \cdot \frac{1}{\log 10}}}\right) \]
    3. exp-to-pow98.5%

      \[\leadsto \log \color{blue}{\left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left(\frac{1}{\log 10}\right)}\right)} \]
    4. frac-2neg98.5%

      \[\leadsto \log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\color{blue}{\left(\frac{-1}{-\log 10}\right)}}\right) \]
    5. metadata-eval98.5%

      \[\leadsto \log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left(\frac{\color{blue}{-1}}{-\log 10}\right)}\right) \]
    6. neg-log99.0%

      \[\leadsto \log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left(\frac{-1}{\color{blue}{\log \left(\frac{1}{10}\right)}}\right)}\right) \]
    7. metadata-eval99.0%

      \[\leadsto \log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left(\frac{-1}{\log \color{blue}{0.1}}\right)}\right) \]
  5. Applied egg-rr99.0%

    \[\leadsto \color{blue}{\log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left(\frac{-1}{\log 0.1}\right)}\right)} \]
  6. Taylor expanded in re around 0 28.8%

    \[\leadsto \color{blue}{-1 \cdot \frac{\log im}{\log 0.1}} \]
  7. Step-by-step derivation
    1. neg-mul-128.8%

      \[\leadsto \color{blue}{-\frac{\log im}{\log 0.1}} \]
    2. distribute-neg-frac28.8%

      \[\leadsto \color{blue}{\frac{-\log im}{\log 0.1}} \]
  8. Simplified28.8%

    \[\leadsto \color{blue}{\frac{-\log im}{\log 0.1}} \]
  9. Final simplification28.8%

    \[\leadsto \frac{-\log im}{\log 0.1} \]

Alternative 10: 3.0% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \frac{\log im}{\log 0.1} \end{array} \]
(FPCore (re im) :precision binary64 (/ (log im) (log 0.1)))
double code(double re, double im) {
	return log(im) / log(0.1);
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = log(im) / log(0.1d0)
end function
public static double code(double re, double im) {
	return Math.log(im) / Math.log(0.1);
}
def code(re, im):
	return math.log(im) / math.log(0.1)
function code(re, im)
	return Float64(log(im) / log(0.1))
end
function tmp = code(re, im)
	tmp = log(im) / log(0.1);
end
code[re_, im_] := N[(N[Log[im], $MachinePrecision] / N[Log[0.1], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\log im}{\log 0.1}
\end{array}
Derivation
  1. Initial program 53.9%

    \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10} \]
  2. Step-by-step derivation
    1. hypot-def99.0%

      \[\leadsto \frac{\log \color{blue}{\left(\mathsf{hypot}\left(re, im\right)\right)}}{\log 10} \]
  3. Simplified99.0%

    \[\leadsto \color{blue}{\frac{\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\log 10}} \]
  4. Step-by-step derivation
    1. add-log-exp99.0%

      \[\leadsto \color{blue}{\log \left(e^{\frac{\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\log 10}}\right)} \]
    2. div-inv98.5%

      \[\leadsto \log \left(e^{\color{blue}{\log \left(\mathsf{hypot}\left(re, im\right)\right) \cdot \frac{1}{\log 10}}}\right) \]
    3. exp-to-pow98.5%

      \[\leadsto \log \color{blue}{\left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left(\frac{1}{\log 10}\right)}\right)} \]
    4. frac-2neg98.5%

      \[\leadsto \log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\color{blue}{\left(\frac{-1}{-\log 10}\right)}}\right) \]
    5. metadata-eval98.5%

      \[\leadsto \log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left(\frac{\color{blue}{-1}}{-\log 10}\right)}\right) \]
    6. neg-log99.0%

      \[\leadsto \log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left(\frac{-1}{\color{blue}{\log \left(\frac{1}{10}\right)}}\right)}\right) \]
    7. metadata-eval99.0%

      \[\leadsto \log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left(\frac{-1}{\log \color{blue}{0.1}}\right)}\right) \]
  5. Applied egg-rr99.0%

    \[\leadsto \color{blue}{\log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left(\frac{-1}{\log 0.1}\right)}\right)} \]
  6. Taylor expanded in re around 0 28.8%

    \[\leadsto \color{blue}{-1 \cdot \frac{\log im}{\log 0.1}} \]
  7. Step-by-step derivation
    1. neg-mul-128.8%

      \[\leadsto \color{blue}{-\frac{\log im}{\log 0.1}} \]
    2. distribute-neg-frac28.8%

      \[\leadsto \color{blue}{\frac{-\log im}{\log 0.1}} \]
  8. Simplified28.8%

    \[\leadsto \color{blue}{\frac{-\log im}{\log 0.1}} \]
  9. Step-by-step derivation
    1. add-sqr-sqrt5.9%

      \[\leadsto \frac{\color{blue}{\sqrt{-\log im} \cdot \sqrt{-\log im}}}{\log 0.1} \]
    2. sqrt-unprod6.4%

      \[\leadsto \frac{\color{blue}{\sqrt{\left(-\log im\right) \cdot \left(-\log im\right)}}}{\log 0.1} \]
    3. sqr-neg6.4%

      \[\leadsto \frac{\sqrt{\color{blue}{\log im \cdot \log im}}}{\log 0.1} \]
    4. sqrt-unprod0.5%

      \[\leadsto \frac{\color{blue}{\sqrt{\log im} \cdot \sqrt{\log im}}}{\log 0.1} \]
    5. add-sqr-sqrt3.4%

      \[\leadsto \frac{\color{blue}{\log im}}{\log 0.1} \]
    6. add-cube-cbrt3.4%

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{\log im} \cdot \sqrt[3]{\log im}\right) \cdot \sqrt[3]{\log im}}}{\log 0.1} \]
    7. *-un-lft-identity3.4%

      \[\leadsto \frac{\left(\sqrt[3]{\log im} \cdot \sqrt[3]{\log im}\right) \cdot \sqrt[3]{\log im}}{\color{blue}{1 \cdot \log 0.1}} \]
    8. times-frac3.4%

      \[\leadsto \color{blue}{\frac{\sqrt[3]{\log im} \cdot \sqrt[3]{\log im}}{1} \cdot \frac{\sqrt[3]{\log im}}{\log 0.1}} \]
    9. pow23.4%

      \[\leadsto \frac{\color{blue}{{\left(\sqrt[3]{\log im}\right)}^{2}}}{1} \cdot \frac{\sqrt[3]{\log im}}{\log 0.1} \]
  10. Applied egg-rr3.4%

    \[\leadsto \color{blue}{\frac{{\left(\sqrt[3]{\log im}\right)}^{2}}{1} \cdot \frac{\sqrt[3]{\log im}}{\log 0.1}} \]
  11. Step-by-step derivation
    1. /-rgt-identity3.4%

      \[\leadsto \color{blue}{{\left(\sqrt[3]{\log im}\right)}^{2}} \cdot \frac{\sqrt[3]{\log im}}{\log 0.1} \]
    2. associate-*r/3.4%

      \[\leadsto \color{blue}{\frac{{\left(\sqrt[3]{\log im}\right)}^{2} \cdot \sqrt[3]{\log im}}{\log 0.1}} \]
    3. unpow23.4%

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{\log im} \cdot \sqrt[3]{\log im}\right)} \cdot \sqrt[3]{\log im}}{\log 0.1} \]
    4. rem-3cbrt-lft3.4%

      \[\leadsto \frac{\color{blue}{\log im}}{\log 0.1} \]
  12. Simplified3.4%

    \[\leadsto \color{blue}{\frac{\log im}{\log 0.1}} \]
  13. Final simplification3.4%

    \[\leadsto \frac{\log im}{\log 0.1} \]

Alternative 11: 27.6% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \frac{\log im}{\log 10} \end{array} \]
(FPCore (re im) :precision binary64 (/ (log im) (log 10.0)))
double code(double re, double im) {
	return log(im) / log(10.0);
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = log(im) / log(10.0d0)
end function
public static double code(double re, double im) {
	return Math.log(im) / Math.log(10.0);
}
def code(re, im):
	return math.log(im) / math.log(10.0)
function code(re, im)
	return Float64(log(im) / log(10.0))
end
function tmp = code(re, im)
	tmp = log(im) / log(10.0);
end
code[re_, im_] := N[(N[Log[im], $MachinePrecision] / N[Log[10.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\log im}{\log 10}
\end{array}
Derivation
  1. Initial program 53.9%

    \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10} \]
  2. Step-by-step derivation
    1. hypot-def99.0%

      \[\leadsto \frac{\log \color{blue}{\left(\mathsf{hypot}\left(re, im\right)\right)}}{\log 10} \]
  3. Simplified99.0%

    \[\leadsto \color{blue}{\frac{\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\log 10}} \]
  4. Taylor expanded in re around 0 28.8%

    \[\leadsto \color{blue}{\frac{\log im}{\log 10}} \]
  5. Final simplification28.8%

    \[\leadsto \frac{\log im}{\log 10} \]

Reproduce

?
herbie shell --seed 2023189 
(FPCore (re im)
  :name "math.log10 on complex, real part"
  :precision binary64
  (/ (log (sqrt (+ (* re re) (* im im)))) (log 10.0)))