Skip to main content

Python cmath Module

 

Python cmath Module


Python cmath Module

Python has a built-in module that you can use for mathematical tasks for complex numbers.

The methods in this module accepts intfloat, and complex numbers. It even accepts Python objects that has a __complex__() or __float__() method.

The methods in this module almost always return a complex number. If the return value can be expressed as a real number, the return value has an imaginary part of 0.

The cmath module has a set of methods and constants.


cMath Methods

MethodDescription
cmath.acos(x)Returns the arc cosine value of x
cmath.acosh(x)Returns the hyperbolic arc cosine of x
cmath.asin(x)Returns the arc sine of x
cmath.asinh(x)Returns the hyperbolic arc sine of x
cmath.atan(x)Returns the arc tangent value of x
cmath.atanh(x)Returns the hyperbolic arctangent value of x
cmath.cos(x)Returns the cosine of x
cmath.cosh(x)Returns the hyperbolic cosine of x
cmath.exp(x)Returns the value of Ex, where E is Euler's number (approximately 2.718281...), and x is the number passed to it
cmath.isclose()Checks whether two values are close, or not
cmath.isfinite(x)Checks whether x is a finite number
cmath.isinf(x)Check whether x is a positive or negative infinty
cmath.isnan(x)Checks whether x is NaN (not a number)
cmath.log(x[, base])Returns the logarithm of x to the base
cmath.log10(x)Returns the base-10 logarithm of x
cmath.phase()Return the phase of a complex number
cmath.polar()Convert a complex number to polar coordinates
cmath.rect()Convert polar coordinates to rectangular form
cmath.sin(x)Returns the sine of x
cmath.sinh(x)Returns the hyperbolic sine of x
cmath.sqrt(x)Returns the square root of x
cmath.tan(x)Returns the tangent of x
cmath.tanh(x)Returns the hyperbolic tangent of x

cMath Constants

ConstantDescription
cmath.eReturns Euler's number (2.7182...)
cmath.infReturns a floating-point positive infinity value
cmath.infjReturns a complex infinity value
cmath.nanReturns floating-point NaN (Not a Number) value
cmath.nanjReturns coplext NaN (Not a Number) value
cmath.piReturns PI (3.1415...)
cmath.tauReturns tau (6.2831...)

Comments

Popular posts from this blog

Python Introduction

  Python  Introduction What is Python? Python is a popular programming language. It was created by Guido van Rossum, and released in 1991. It is used for: web development (server-side), software development, mathematics, system scripting. What can Python do? Python can be used on a server to create web applications. Python can be used alongside software to create workflows. Python can connect to database systems. It can also read and modify files. Python can be used to handle big data and perform complex mathematics. Python can be used for rapid prototyping, or for production-ready software development. Why Python? Python works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc). Python has a simple syntax similar to the English language. Python has syntax that allows developers to write programs with fewer lines than some other programming languages. Python runs on an interpreter system, meaning that code can be executed as soon as it is written. This means that p...

LIST OF TOPICS YOU WILL BE LEARN THIS WHOLE SERIES

Python  Introduction    Python  Getting Started Python  Variables Python  Comments Python Try Except Python Data Types Python Casting Python Strings Python Operators Python Lists Python Tuples Python Sets Python Dictionaries Python Arrays Python PIP Python Booleans Python If  Else Python Loops Python Functions Python Lambda Function Python Modules Python Random Module Python cmath Module Python Math Module Python Classes and Objects Python Inheritance PYTHON FILE I/O                Video Contain 1. Telusko 2. CodeWithHarry For Certification Course 01. Udemy1 02. Udemy2                                                                                                     ...

Python Lists

  Python  Lists mylist = [ "apple" ,  "banana" ,  "cherry" ] List Lists are used to store multiple items in a single variable. Lists are one of 4 built-in data types in Python used to store collections of data, the other 3 are  Tuple ,  Set , and  Dictionary , all with different qualities and usage. Lists are created using square brackets: Example Create a List: thislist = [ "apple" ,  "banana" ,  "cherry" ] print (thislist) List Items List items are ordered, changeable, and allow duplicate values. List items are indexed, the first item has index  [0] , the second item has index  [1]  etc. Ordered When we say that lists are ordered, it means that the items have a defined order, and that order will not change. If you add new items to a list, the new items will be placed at the end of the list. Changeable The list is changeable, meaning that we can change, add, and remove items in a list after it has been created. Allow Duplicat...