complex - STL C++

log()

Declaration

complex<X> log(const complex<X>& kqrZ);

Description

This is the friend function log() for complex numbers. It returns the logarithm of the complex number kqrZ, where the branch cuts along the negative real axis. The formula for the logarithm of a complex number z is

Log(z) = ln(abs(z)) + iArg(z).

Header Include

#include <complex>

Example

#include <complex>
#include <iostream>

int main()
{
	using namespace std;

	// Create a complex number and calculate its logarithm
	complex<double> qZ(2.0, 4.0);
	cout << "Complex Number : "<< qZ << endl;
	cout << "The logarithm is "<< log(qZ) << endl;

	// Keep the window open
	cin.get();
	return 0;
}

Output

log() Output
 

© 2007–2024 XoaX.net LLC. All rights reserved.