Hi all,

When running the libcxx I got asserts in complex.transcendentals. After a lot of digging I have the following:

-- pow_complex_test.cpp:

#include <complex>

#include <cmath>

#include <cstdio>

int main()

{

const std::complex<long double> a = std::complex<long double>(2, 3);

const std::complex<long double> b = std::complex<long double>(2, 0);

std::complex<long double> x = std::complex<long double>(-5, 12);

std::complex<long double> c = pow(a, b);

printf("c = pow(a,b) = %.20Le + i*%.20Le\n", real(c), imag(c));

printf("x = %.20Le + i*%.20Le\n\n", real(x), imag(x));

printf("err = c - x = %.20Le + i*%.20Le\n\n", real(c-x), imag(c-x));

long double r_a = sqrt(real(a)*real(a) + imag(a)*imag(a));

long double th_a = atan(imag(a)/real(a));

/* bw = b*log(a) = 2*log(r_a) + i*2*th_a */

std::complex<long double> bw = b*log(a);

/* d = exp(x) = exp(xr) * (cos(xi) + i*sin(xi) */

std::complex<long double> d = exp(b*log(a));

std::complex<long double> dx0 = exp(std::complex<long

(bw.real(), bw.imag()));

std::complex<long double> dx1 =

std::complex<long double>(exp(bw.real()) * cos(bw.imag()),

exp(bw.real()) * sin(bw.imag()));

std::complex<long double> dx2 =

(long double)exp(bw.real()) *

std::complex<long double>(cos(bw.imag()), sin(bw.imag()));

printf("d = exp(b*log(a)) = %.20Le + i*%.20Le\n", real(d), imag(d));

printf("dx0 = %.20Le + i*%.20Le\n", real(dx0), imag(dx0));

printf("dx1 = %.20Le + i*%.20Le\n", real(dx1), imag(dx1));

printf("dx2 = %.20Le + i*%.20Le\n\n", real(dx2), imag(dx2));

printf("err = d - x = %.20Le + i*%.20Le\n", real(d-x), imag(d-x));

printf("err = dx0 - x = %.20Le + i*%.20Le\n", real(dx0-x), imag(dx0-x));

printf("err = dx1 - x = %.20Le + i*%.20Le\n", real(dx1-x), imag(dx1-x));

printf("err = dx2 - x = %.20Le + i*%.20Le\n", real(dx2-x), imag(dx2-x));

}