{"id":25427,"date":"2021-11-13T14:59:38","date_gmt":"2021-11-13T09:29:38","guid":{"rendered":"https:\/\/python-programs.com\/?p=25427"},"modified":"2021-11-14T15:01:52","modified_gmt":"2021-11-14T09:31:52","slug":"python-cmath-log10-method-with-examples","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-cmath-log10-method-with-examples\/","title":{"rendered":"Python cmath.log10() Method with Examples"},"content":{"rendered":"
cmath.log10() Method in Python:<\/strong><\/p>\n The cmath.log10() method returns the complex number’s base-10 logarithm.<\/p>\n There is one continuous branch cut from 0 to – \u221e along the negative real axis.<\/p>\n Syntax:<\/strong><\/p>\n Parameters<\/strong><\/p>\n x: <\/strong>This is Required. Specifies the value for which the base-10 logarithm will be computed.<\/p>\n Return Value:<\/strong><\/p>\n Returns a complex value that represents a number’s base-10 logarithm.<\/p>\n Examples:<\/strong><\/p>\n Example1:<\/strong><\/p>\n Input:<\/strong><\/p>\n Output:<\/strong><\/p>\n Example2:<\/strong><\/p>\n Input:<\/strong><\/p>\n Output:<\/strong><\/p>\n Note:<\/strong> The above input format is for dynamic input.<\/p>\n Approach:<\/strong><\/p>\n Below is the implementation:<\/strong><\/p>\n Output:<\/strong><\/p>\n Similarly, try for the other examples<\/p>\n Output:<\/strong><\/p>\n Approach:<\/strong><\/p>\n Below is the implementation:<\/strong><\/p>\n Output:<\/strong><\/p>\n cmath.log10() Method in Python: The cmath.log10() method returns the complex number’s base-10 logarithm. There is one continuous branch cut from 0 to – \u221e along the negative real axis. Syntax: cmath.log10(x) Parameters x: This is Required. Specifies the value for which the base-10 logarithm will be computed. If the value is 0 or a negative …<\/p>\ncmath.log10(x)<\/pre>\n
\n
Given Complex Number = 3+4j<\/pre>\n
The given complex number's (3+4j) base-10 logarithm value = \r\n(0.6989700043360187+0.4027191962733731j)<\/pre>\n
Given realpart = 5\r\nGiven imaginary part = 2<\/pre>\n
The given complex number's (5+2j) base-10 logarithm value = \r\n(0.7311989989494779+0.16525181990889787j)<\/pre>\n
cmath.log10() Method with Examples in Python<\/h2>\n
\n
Method #1: Using Built-in Functions (Static Input)<\/h3>\n
\n
# Import cmath module(for complex number operations) using the import keyword.\r\nimport cmath\r\n# Give the complex number as static input and store it in a variable.\r\ncomplexnumb = 3+4j\r\n# Pass the given complex number as an argument to the cmath.log10() method that\r\n# returns the the given complex number's base-10 logarithm value.\r\n# Store it in another variable.\r\nrslt = cmath.log10(complexnumb)\r\n# Print the base-10 logarithm value of the given complex number.\r\nprint(\"The given complex number's\", complexnumb,\r\n \"base-10 logarithm value = \")\r\nprint(rslt)\r\n<\/pre>\n
The given complex number's (3+4j) base-10 logarithm value = \r\n(0.6989700043360187+0.4027191962733731j)<\/pre>\n
import cmath\r\ncomplexnumb = -6-2j\r\nrslt = cmath.log10(complexnumb)\r\nprint(\"The given complex number's\", complexnumb,\r\n \"base-10 logarithm value = \")\r\nprint(rslt)\r\n<\/pre>\n
The given complex number's (-6-2j) base-10 logarithm value = \r\n(0.8010299956639811-1.2246418635180674j)<\/pre>\n
Method #2: Using Built-in Functions (User Input)<\/h3>\n
\n
# Import cmath module(for complex number operations) using the import keyword.\r\nimport cmath\r\n# Give the real part and imaginary part of the complex number as user input\r\n# using map(), int(), split().\r\n# Store it in two variables.\r\nrealnumb, imaginarynumb = map(int, input(\r\n 'Enter real part and complex part of the complex number = ').split())\r\n# Using a complex() function convert those two variables into a complex number.\r\ncomplexnumb = complex(realnumb, imaginarynumb)\r\n\r\n# Pass the given complex number as an argument to the cmath.log10() method that\r\n# returns the the given complex number's base-10 logarithm value.\r\n# Store it in another variable.\r\nrslt = cmath.log10(complexnumb)\r\n# Print the base-10 logarithm value of the given complex number.\r\nprint(\"The given complex number's\", complexnumb,\r\n \"base-10 logarithm value = \")\r\nprint(rslt)\r\n<\/pre>\n
Enter real part and complex part of the complex number = 5 2\r\nThe given complex number's (5+2j) base-10 logarithm value = \r\n(0.7311989989494779+0.16525181990889787j)<\/pre>\n","protected":false},"excerpt":{"rendered":"