C++ <complex> - log() Function
The C++ <complex> log() function returns natural logarithm (base-e) of a complex number z. It is a function on complex plane, and has a branch cut, from 0 along the negative real axis to -∞, continuous from above.
Syntax
template<class T> complex<T> log (const complex<T>& z);
Parameters
z |
Specify the complex number. |
Return Value
Returns natural logarithm of z.
Example:
The example below shows the usage of log() function.
#include <iostream> #include <complex> using namespace std; int main (){ complex<double> z1 (2, 2); complex<double> z2 (2, 0); complex<double> z3 (0, 2); //calculate natural logarithm of given value cout<<"log(z1): "<<log(z1)<<"\n"; cout<<"log(z2): "<<log(z2)<<"\n"; cout<<"log(z3): "<<log(z3)<<"\n"; return 0; }
The output of the above code will be:
log(z1): (1.03972,0.785398) log(z2): (0.693147,0) log(z3): (0.693147,1.5708)
❮ C++ <complex> Library