C++ Standard Library C++ STL Library

C++ <complex> - log10() Function

The C++ <complex> log10() function returns base-10 logarithm 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.


template<class T> 
  complex<T> log10 (const complex<T>& z);


z Specify the complex number.

Return Value

Returns base-10 logarithm of z.


The example below shows the usage of log10() 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 base-10 logarithm of given value
  cout<<"log10(z1): "<<log10(z1)<<"\n";
  cout<<"log10(z2): "<<log10(z2)<<"\n";
  cout<<"log10(z3): "<<log10(z3)<<"\n";

  return 0;

The output of the above code will be:

log10(z1): (0.451545,0.341094)
log10(z2): (0.30103,0)
log10(z3): (0.30103,0.682188)

❮ C++ <complex> Library