Is this correct: $\ln({(-1)}^{2x-1})=(2x-1)\ln(-1)$?

77 Views Asked by At

I would expect the answer to be positive, but it appears otherwise for some values of $x \geq 1$.

Here is a simple C++ code that I have used in order to test this:

#include <complex>
#include <iostream>

void test(double x)
{
    complex<double> i(0,1);
    complex<double> res1 = (2*x-1)*log(i*i);
    complex<double> res2 = log(pow(i*i,2*x-1));
    cout<<res1<<endl;
    cout<<res2<<endl;
}