math.log10 on complex, real part

Percentage Accurate: 52.4% → 99.5%
Time: 8.6s
Alternatives: 5
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 5 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.4% 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.5% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \log \left(\mathsf{hypot}\left(re, im\right)\right) \cdot \sqrt[3]{{\log 10}^{-3}} \end{array} \]
(FPCore (re im)
 :precision binary64
 (* (log (hypot re im)) (cbrt (pow (log 10.0) -3.0))))
double code(double re, double im) {
	return log(hypot(re, im)) * cbrt(pow(log(10.0), -3.0));
}
public static double code(double re, double im) {
	return Math.log(Math.hypot(re, im)) * Math.cbrt(Math.pow(Math.log(10.0), -3.0));
}
function code(re, im)
	return Float64(log(hypot(re, im)) * cbrt((log(10.0) ^ -3.0)))
end
code[re_, im_] := N[(N[Log[N[Sqrt[re ^ 2 + im ^ 2], $MachinePrecision]], $MachinePrecision] * N[Power[N[Power[N[Log[10.0], $MachinePrecision], -3.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\log \left(\mathsf{hypot}\left(re, im\right)\right) \cdot \sqrt[3]{{\log 10}^{-3}}
\end{array}
Derivation
  1. Initial program 51.8%

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

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

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

      \[\leadsto \color{blue}{e^{\log \left(\frac{\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\log 10}\right)}} \]
  5. Applied egg-rr73.4%

    \[\leadsto \color{blue}{e^{\log \left(\frac{\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\log 10}\right)}} \]
  6. Step-by-step derivation
    1. rem-cbrt-cube73.3%

      \[\leadsto e^{\log \left(\frac{\color{blue}{\sqrt[3]{{\log \left(\mathsf{hypot}\left(re, im\right)\right)}^{3}}}}{\log 10}\right)} \]
    2. rem-cbrt-cube73.1%

      \[\leadsto e^{\log \left(\frac{\sqrt[3]{{\log \left(\mathsf{hypot}\left(re, im\right)\right)}^{3}}}{\color{blue}{\sqrt[3]{{\log 10}^{3}}}}\right)} \]
    3. cbrt-div73.3%

      \[\leadsto e^{\log \color{blue}{\left(\sqrt[3]{\frac{{\log \left(\mathsf{hypot}\left(re, im\right)\right)}^{3}}{{\log 10}^{3}}}\right)}} \]
    4. add-exp-log98.9%

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

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

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

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

      \[\leadsto \log \left(\mathsf{hypot}\left(re, im\right)\right) \cdot \sqrt[3]{\color{blue}{{\log 10}^{\left(-3\right)}}} \]
    9. metadata-eval99.6%

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

    \[\leadsto \color{blue}{\log \left(\mathsf{hypot}\left(re, im\right)\right) \cdot \sqrt[3]{{\log 10}^{-3}}} \]
  8. Final simplification99.6%

    \[\leadsto \log \left(\mathsf{hypot}\left(re, im\right)\right) \cdot \sqrt[3]{{\log 10}^{-3}} \]

Alternative 2: 99.1% accurate, 1.0× speedup?

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

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

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

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

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

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\log 10}\right)} - 1} \]
    3. log1p-udef73.7%

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

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

    \[\leadsto \color{blue}{\left(1 + \frac{\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\log 10}\right) - 1} \]
  6. Step-by-step derivation
    1. associate--l+99.1%

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

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

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

Alternative 3: 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 51.8%

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

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

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

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

Alternative 4: 27.0% 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 51.8%

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

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

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

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

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

Alternative 5: 3.9% accurate, 2.9× speedup?

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

\\
\left(re \cdot \frac{re}{\log 10}\right) \cdot 0.5
\end{array}
Derivation
  1. Initial program 51.8%

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

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

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

    \[\leadsto \color{blue}{\frac{\log im}{\log 10} + 0.5 \cdot \frac{{re}^{2}}{\log 10 \cdot {im}^{2}}} \]
  5. Step-by-step derivation
    1. unpow226.0%

      \[\leadsto \frac{\log im}{\log 10} + 0.5 \cdot \frac{\color{blue}{re \cdot re}}{\log 10 \cdot {im}^{2}} \]
    2. unpow226.0%

      \[\leadsto \frac{\log im}{\log 10} + 0.5 \cdot \frac{re \cdot re}{\log 10 \cdot \color{blue}{\left(im \cdot im\right)}} \]
  6. Simplified26.0%

    \[\leadsto \color{blue}{\frac{\log im}{\log 10} + 0.5 \cdot \frac{re \cdot re}{\log 10 \cdot \left(im \cdot im\right)}} \]
  7. Taylor expanded in im around 0 2.7%

    \[\leadsto \color{blue}{0.5 \cdot \frac{{re}^{2}}{\log 10 \cdot {im}^{2}}} \]
  8. Step-by-step derivation
    1. *-commutative2.7%

      \[\leadsto \color{blue}{\frac{{re}^{2}}{\log 10 \cdot {im}^{2}} \cdot 0.5} \]
    2. unpow22.7%

      \[\leadsto \frac{\color{blue}{re \cdot re}}{\log 10 \cdot {im}^{2}} \cdot 0.5 \]
    3. *-commutative2.7%

      \[\leadsto \frac{re \cdot re}{\color{blue}{{im}^{2} \cdot \log 10}} \cdot 0.5 \]
    4. unpow22.7%

      \[\leadsto \frac{re \cdot re}{\color{blue}{\left(im \cdot im\right)} \cdot \log 10} \cdot 0.5 \]
    5. associate-*r*2.7%

      \[\leadsto \frac{re \cdot re}{\color{blue}{im \cdot \left(im \cdot \log 10\right)}} \cdot 0.5 \]
  9. Simplified2.7%

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

      \[\leadsto \color{blue}{\frac{re}{\frac{im \cdot \left(im \cdot \log 10\right)}{re}}} \cdot 0.5 \]
    2. div-inv3.0%

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

      \[\leadsto \left(re \cdot \frac{1}{\color{blue}{\frac{im}{\frac{re}{im \cdot \log 10}}}}\right) \cdot 0.5 \]
    4. associate-/r*3.4%

      \[\leadsto \left(re \cdot \frac{1}{\frac{im}{\color{blue}{\frac{\frac{re}{im}}{\log 10}}}}\right) \cdot 0.5 \]
    5. div-inv3.4%

      \[\leadsto \left(re \cdot \frac{1}{\frac{im}{\frac{\color{blue}{re \cdot \frac{1}{im}}}{\log 10}}}\right) \cdot 0.5 \]
    6. add-exp-log1.7%

      \[\leadsto \left(re \cdot \frac{1}{\frac{im}{\frac{re \cdot \color{blue}{e^{\log \left(\frac{1}{im}\right)}}}{\log 10}}}\right) \cdot 0.5 \]
    7. neg-log1.7%

      \[\leadsto \left(re \cdot \frac{1}{\frac{im}{\frac{re \cdot e^{\color{blue}{-\log im}}}{\log 10}}}\right) \cdot 0.5 \]
    8. add-sqr-sqrt0.6%

      \[\leadsto \left(re \cdot \frac{1}{\frac{im}{\frac{re \cdot e^{\color{blue}{\sqrt{-\log im} \cdot \sqrt{-\log im}}}}{\log 10}}}\right) \cdot 0.5 \]
    9. sqrt-unprod1.8%

      \[\leadsto \left(re \cdot \frac{1}{\frac{im}{\frac{re \cdot e^{\color{blue}{\sqrt{\left(-\log im\right) \cdot \left(-\log im\right)}}}}{\log 10}}}\right) \cdot 0.5 \]
    10. sqr-neg1.8%

      \[\leadsto \left(re \cdot \frac{1}{\frac{im}{\frac{re \cdot e^{\sqrt{\color{blue}{\log im \cdot \log im}}}}{\log 10}}}\right) \cdot 0.5 \]
    11. sqrt-unprod1.2%

      \[\leadsto \left(re \cdot \frac{1}{\frac{im}{\frac{re \cdot e^{\color{blue}{\sqrt{\log im} \cdot \sqrt{\log im}}}}{\log 10}}}\right) \cdot 0.5 \]
    12. add-sqr-sqrt2.1%

      \[\leadsto \left(re \cdot \frac{1}{\frac{im}{\frac{re \cdot e^{\color{blue}{\log im}}}{\log 10}}}\right) \cdot 0.5 \]
    13. add-exp-log3.9%

      \[\leadsto \left(re \cdot \frac{1}{\frac{im}{\frac{re \cdot \color{blue}{im}}{\log 10}}}\right) \cdot 0.5 \]
  11. Applied egg-rr3.9%

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

      \[\leadsto \color{blue}{\frac{re \cdot 1}{\frac{im}{\frac{re \cdot im}{\log 10}}}} \cdot 0.5 \]
    2. *-rgt-identity3.9%

      \[\leadsto \frac{\color{blue}{re}}{\frac{im}{\frac{re \cdot im}{\log 10}}} \cdot 0.5 \]
    3. associate-/r/3.8%

      \[\leadsto \color{blue}{\left(\frac{re}{im} \cdot \frac{re \cdot im}{\log 10}\right)} \cdot 0.5 \]
    4. times-frac3.8%

      \[\leadsto \color{blue}{\frac{re \cdot \left(re \cdot im\right)}{im \cdot \log 10}} \cdot 0.5 \]
    5. associate-*l*3.8%

      \[\leadsto \frac{\color{blue}{\left(re \cdot re\right) \cdot im}}{im \cdot \log 10} \cdot 0.5 \]
    6. *-commutative3.8%

      \[\leadsto \frac{\color{blue}{im \cdot \left(re \cdot re\right)}}{im \cdot \log 10} \cdot 0.5 \]
    7. *-commutative3.8%

      \[\leadsto \frac{im \cdot \left(re \cdot re\right)}{\color{blue}{\log 10 \cdot im}} \cdot 0.5 \]
    8. associate-*r/3.7%

      \[\leadsto \color{blue}{\left(im \cdot \frac{re \cdot re}{\log 10 \cdot im}\right)} \cdot 0.5 \]
    9. times-frac3.7%

      \[\leadsto \left(im \cdot \color{blue}{\left(\frac{re}{\log 10} \cdot \frac{re}{im}\right)}\right) \cdot 0.5 \]
  13. Simplified3.7%

    \[\leadsto \color{blue}{\left(im \cdot \left(\frac{re}{\log 10} \cdot \frac{re}{im}\right)\right)} \cdot 0.5 \]
  14. Taylor expanded in im around 0 3.9%

    \[\leadsto \color{blue}{\frac{{re}^{2}}{\log 10}} \cdot 0.5 \]
  15. Step-by-step derivation
    1. unpow23.9%

      \[\leadsto \frac{\color{blue}{re \cdot re}}{\log 10} \cdot 0.5 \]
    2. associate-*r/3.9%

      \[\leadsto \color{blue}{\left(re \cdot \frac{re}{\log 10}\right)} \cdot 0.5 \]
  16. Simplified3.9%

    \[\leadsto \color{blue}{\left(re \cdot \frac{re}{\log 10}\right)} \cdot 0.5 \]
  17. Final simplification3.9%

    \[\leadsto \left(re \cdot \frac{re}{\log 10}\right) \cdot 0.5 \]

Reproduce

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