math.log10 on complex, imaginary part

?

Percentage Accurate: 98.7% → 99.8%
Time: 5.8s
Precision: binary64
Cost: 45440

?

\[\frac{\tan^{-1}_* \frac{im}{re}}{\log 10} \]
\[\begin{array}{l} t_0 := {\log 10}^{0.25}\\ \frac{\frac{\frac{\tan^{-1}_* \frac{im}{re}}{\sqrt{\log 10}}}{t_0}}{t_0} \end{array} \]
(FPCore (re im) :precision binary64 (/ (atan2 im re) (log 10.0)))
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (pow (log 10.0) 0.25)))
   (/ (/ (/ (atan2 im re) (sqrt (log 10.0))) t_0) t_0)))
double code(double re, double im) {
	return atan2(im, re) / log(10.0);
}
double code(double re, double im) {
	double t_0 = pow(log(10.0), 0.25);
	return ((atan2(im, re) / sqrt(log(10.0))) / t_0) / t_0;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = atan2(im, re) / log(10.0d0)
end function
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    t_0 = log(10.0d0) ** 0.25d0
    code = ((atan2(im, re) / sqrt(log(10.0d0))) / t_0) / t_0
end function
public static double code(double re, double im) {
	return Math.atan2(im, re) / Math.log(10.0);
}
public static double code(double re, double im) {
	double t_0 = Math.pow(Math.log(10.0), 0.25);
	return ((Math.atan2(im, re) / Math.sqrt(Math.log(10.0))) / t_0) / t_0;
}
def code(re, im):
	return math.atan2(im, re) / math.log(10.0)
def code(re, im):
	t_0 = math.pow(math.log(10.0), 0.25)
	return ((math.atan2(im, re) / math.sqrt(math.log(10.0))) / t_0) / t_0
function code(re, im)
	return Float64(atan(im, re) / log(10.0))
end
function code(re, im)
	t_0 = log(10.0) ^ 0.25
	return Float64(Float64(Float64(atan(im, re) / sqrt(log(10.0))) / t_0) / t_0)
end
function tmp = code(re, im)
	tmp = atan2(im, re) / log(10.0);
end
function tmp = code(re, im)
	t_0 = log(10.0) ^ 0.25;
	tmp = ((atan2(im, re) / sqrt(log(10.0))) / t_0) / t_0;
end
code[re_, im_] := N[(N[ArcTan[im / re], $MachinePrecision] / N[Log[10.0], $MachinePrecision]), $MachinePrecision]
code[re_, im_] := Block[{t$95$0 = N[Power[N[Log[10.0], $MachinePrecision], 0.25], $MachinePrecision]}, N[(N[(N[(N[ArcTan[im / re], $MachinePrecision] / N[Sqrt[N[Log[10.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]
\frac{\tan^{-1}_* \frac{im}{re}}{\log 10}
\begin{array}{l}
t_0 := {\log 10}^{0.25}\\
\frac{\frac{\frac{\tan^{-1}_* \frac{im}{re}}{\sqrt{\log 10}}}{t_0}}{t_0}
\end{array}

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.

Herbie found 3 alternatives:

AlternativeAccuracySpeedup

Accuracy vs Speed

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.

Bogosity?

Bogosity

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 98.7%

    \[\frac{\tan^{-1}_* \frac{im}{re}}{\log 10} \]
  2. Applied egg-rr79.1%

    \[\leadsto \color{blue}{\left(1 + \frac{\tan^{-1}_* \frac{im}{re}}{\log 10}\right) - 1} \]
    Step-by-step derivation

    [Start]98.7%

    \[ \frac{\tan^{-1}_* \frac{im}{re}}{\log 10} \]

    expm1-log1p-u [=>]86.8%

    \[ \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\tan^{-1}_* \frac{im}{re}}{\log 10}\right)\right)} \]

    expm1-udef [=>]67.2%

    \[ \color{blue}{e^{\mathsf{log1p}\left(\frac{\tan^{-1}_* \frac{im}{re}}{\log 10}\right)} - 1} \]

    log1p-udef [=>]67.2%

    \[ e^{\color{blue}{\log \left(1 + \frac{\tan^{-1}_* \frac{im}{re}}{\log 10}\right)}} - 1 \]

    add-exp-log [<=]79.1%

    \[ \color{blue}{\left(1 + \frac{\tan^{-1}_* \frac{im}{re}}{\log 10}\right)} - 1 \]
  3. Simplified79.1%

    \[\leadsto \color{blue}{1 + \left(\frac{\tan^{-1}_* \frac{im}{re}}{\log 10} - 1\right)} \]
    Step-by-step derivation

    [Start]79.1%

    \[ \left(1 + \frac{\tan^{-1}_* \frac{im}{re}}{\log 10}\right) - 1 \]

    associate--l+ [=>]79.1%

    \[ \color{blue}{1 + \left(\frac{\tan^{-1}_* \frac{im}{re}}{\log 10} - 1\right)} \]
  4. Applied egg-rr99.8%

    \[\leadsto \color{blue}{\frac{\frac{\frac{\tan^{-1}_* \frac{im}{re}}{\sqrt{\log 10}}}{{\log 10}^{0.25}}}{{\log 10}^{0.25}}} \]
    Step-by-step derivation

    [Start]79.1%

    \[ 1 + \left(\frac{\tan^{-1}_* \frac{im}{re}}{\log 10} - 1\right) \]

    associate-+r- [=>]79.1%

    \[ \color{blue}{\left(1 + \frac{\tan^{-1}_* \frac{im}{re}}{\log 10}\right) - 1} \]

    add-exp-log [=>]67.2%

    \[ \color{blue}{e^{\log \left(1 + \frac{\tan^{-1}_* \frac{im}{re}}{\log 10}\right)}} - 1 \]

    log1p-udef [<=]67.2%

    \[ e^{\color{blue}{\mathsf{log1p}\left(\frac{\tan^{-1}_* \frac{im}{re}}{\log 10}\right)}} - 1 \]

    expm1-udef [<=]86.8%

    \[ \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\tan^{-1}_* \frac{im}{re}}{\log 10}\right)\right)} \]

    expm1-log1p-u [<=]98.7%

    \[ \color{blue}{\frac{\tan^{-1}_* \frac{im}{re}}{\log 10}} \]

    add-sqr-sqrt [=>]98.7%

    \[ \frac{\tan^{-1}_* \frac{im}{re}}{\color{blue}{\sqrt{\log 10} \cdot \sqrt{\log 10}}} \]

    associate-/r* [=>]98.7%

    \[ \color{blue}{\frac{\frac{\tan^{-1}_* \frac{im}{re}}{\sqrt{\log 10}}}{\sqrt{\log 10}}} \]

    add-sqr-sqrt [=>]97.8%

    \[ \frac{\frac{\tan^{-1}_* \frac{im}{re}}{\sqrt{\log 10}}}{\color{blue}{\sqrt{\sqrt{\log 10}} \cdot \sqrt{\sqrt{\log 10}}}} \]

    associate-/r* [=>]97.8%

    \[ \color{blue}{\frac{\frac{\frac{\tan^{-1}_* \frac{im}{re}}{\sqrt{\log 10}}}{\sqrt{\sqrt{\log 10}}}}{\sqrt{\sqrt{\log 10}}}} \]

    pow1/2 [=>]97.8%

    \[ \frac{\frac{\frac{\tan^{-1}_* \frac{im}{re}}{\sqrt{\log 10}}}{\sqrt{\color{blue}{{\log 10}^{0.5}}}}}{\sqrt{\sqrt{\log 10}}} \]

    sqrt-pow1 [=>]98.7%

    \[ \frac{\frac{\frac{\tan^{-1}_* \frac{im}{re}}{\sqrt{\log 10}}}{\color{blue}{{\log 10}^{\left(\frac{0.5}{2}\right)}}}}{\sqrt{\sqrt{\log 10}}} \]

    metadata-eval [=>]98.7%

    \[ \frac{\frac{\frac{\tan^{-1}_* \frac{im}{re}}{\sqrt{\log 10}}}{{\log 10}^{\color{blue}{0.25}}}}{\sqrt{\sqrt{\log 10}}} \]

    pow1/2 [=>]98.7%

    \[ \frac{\frac{\frac{\tan^{-1}_* \frac{im}{re}}{\sqrt{\log 10}}}{{\log 10}^{0.25}}}{\sqrt{\color{blue}{{\log 10}^{0.5}}}} \]

    sqrt-pow1 [=>]99.8%

    \[ \frac{\frac{\frac{\tan^{-1}_* \frac{im}{re}}{\sqrt{\log 10}}}{{\log 10}^{0.25}}}{\color{blue}{{\log 10}^{\left(\frac{0.5}{2}\right)}}} \]

    metadata-eval [=>]99.8%

    \[ \frac{\frac{\frac{\tan^{-1}_* \frac{im}{re}}{\sqrt{\log 10}}}{{\log 10}^{0.25}}}{{\log 10}^{\color{blue}{0.25}}} \]
  5. Final simplification99.8%

    \[\leadsto \frac{\frac{\frac{\tan^{-1}_* \frac{im}{re}}{\sqrt{\log 10}}}{{\log 10}^{0.25}}}{{\log 10}^{0.25}} \]

Alternatives

Alternative 1
Accuracy99.8%
Cost45440
\[\begin{array}{l} t_0 := {\log 10}^{0.25}\\ \frac{\frac{\frac{\tan^{-1}_* \frac{im}{re}}{\sqrt{\log 10}}}{t_0}}{t_0} \end{array} \]
Alternative 2
Accuracy99.8%
Cost13120
\[-\frac{\tan^{-1}_* \frac{im}{re}}{\log 0.1} \]
Alternative 3
Accuracy98.7%
Cost13056
\[\frac{\tan^{-1}_* \frac{im}{re}}{\log 10} \]

Reproduce?

herbie shell --seed 2023178 
(FPCore (re im)
  :name "math.log10 on complex, imaginary part"
  :precision binary64
  (/ (atan2 im re) (log 10.0)))