Hướng dẫn where is complex number used in python? - Số phức được sử dụng ở đâu trong python?

Không chỉ các số thực, Python cũng có thể xử lý các số phức và các chức năng liên quan của nó bằng cách sử dụng tệp CM CMath. Các số phức tạp có cách sử dụng của chúng trong nhiều ứng dụng liên quan đến toán học và Python cung cấp các công cụ hữu ích để xử lý và thao túng chúng.

Chuyển đổi số thực thành số phức

Một số phức được đại diện bởi các x + yi. Python chuyển đổi các số thực x và y thành phức tạp bằng cách sử dụng phức hợp hàm (x, y). Phần thực có thể được truy cập bằng cách sử dụng phần thực () và phần tưởng tượng có thể được biểu diễn bằng hình ảnh (). x + yi “. Python converts the real numbers x and y into complex using the function complex(x,y). The real part can be accessed using the function real() and imaginary part can be represented by imag().

The phase of complex number is : 3.141592653589793
8
The phase of complex number is : 3.141592653589793
9

The modulus and argument of polar complex number is : (1.4142135623730951, 0.7853981633974483)
The rectangular form of complex number is : (1.0000000000000002+1j)
0
The modulus and argument of polar complex number is : (1.4142135623730951, 0.7853981633974483)
The rectangular form of complex number is : (1.0000000000000002+1j)
1
The modulus and argument of polar complex number is : (1.4142135623730951, 0.7853981633974483)
The rectangular form of complex number is : (1.0000000000000002+1j)
2

The modulus and argument of polar complex number is : (1.4142135623730951, 0.7853981633974483)
The rectangular form of complex number is : (1.0000000000000002+1j)
3
The modulus and argument of polar complex number is : (1.4142135623730951, 0.7853981633974483)
The rectangular form of complex number is : (1.0000000000000002+1j)
1
The modulus and argument of polar complex number is : (1.4142135623730951, 0.7853981633974483)
The rectangular form of complex number is : (1.0000000000000002+1j)
5

The modulus and argument of polar complex number is : (1.4142135623730951, 0.7853981633974483)
The rectangular form of complex number is : (1.0000000000000002+1j)
6
The modulus and argument of polar complex number is : (1.4142135623730951, 0.7853981633974483)
The rectangular form of complex number is : (1.0000000000000002+1j)
1
The modulus and argument of polar complex number is : (1.4142135623730951, 0.7853981633974483)
The rectangular form of complex number is : (1.0000000000000002+1j)
8
The modulus and argument of polar complex number is : (1.4142135623730951, 0.7853981633974483)
The rectangular form of complex number is : (1.0000000000000002+1j)
9

complex([real[, imag]])
0
complex([real[, imag]])
1
complex([real[, imag]])
2
complex([real[, imag]])
3
The modulus and argument of polar complex number is : (1.4142135623730951, 0.7853981633974483)
The rectangular form of complex number is : (1.0000000000000002+1j)
1
complex([real[, imag]])
5

complex([real[, imag]])
0
complex([real[, imag]])
7

complex([real[, imag]])
0
complex([real[, imag]])
1
>>> c = 3 +6j
>>> print(type(c))

>>> print(c)
(3+6j)
>>>
>>> c1 = complex(3,6)
>>> print(type(c1))

>>> print(c1)
(3+6j)
0
complex([real[, imag]])
3
The modulus and argument of polar complex number is : (1.4142135623730951, 0.7853981633974483)
The rectangular form of complex number is : (1.0000000000000002+1j)
1
complex([real[, imag]])
5

complex([real[, imag]])
0
>>> c = 3 +6j
>>> print(type(c))

>>> print(c)
(3+6j)
>>>
>>> c1 = complex(3,6)
>>> print(type(c1))

>>> print(c1)
(3+6j)
5

Đầu ra:

The real part of complex number is : 5.0
The imaginary part of complex number is : 3.0

Giai đoạn của số phức

Về mặt hình học, pha của một số phức là góc giữa trục thực dương và vectơ đại diện cho số phức. Điều này còn được gọi là đối số của số phức. Pha được trả về bằng pha (), lấy số phức làm đối số. Phạm vi của pha nằm từ -pi đến +pi. tức là từ -3,14 đến +3,14.angle between the positive real axis and the vector representing complex number. This is also known as argument of complex number. Phase is returned using phase(), which takes complex number as argument. The range of phase lies from -pi to +pi. i.e from -3.14 to +3.14.

The phase of complex number is : 3.141592653589793
8
The phase of complex number is : 3.141592653589793
9

The modulus and argument of polar complex number is : (1.4142135623730951, 0.7853981633974483)
The rectangular form of complex number is : (1.0000000000000002+1j)
0
The modulus and argument of polar complex number is : (1.4142135623730951, 0.7853981633974483)
The rectangular form of complex number is : (1.0000000000000002+1j)
1
The modulus and argument of polar complex number is : (1.4142135623730951, 0.7853981633974483)
The rectangular form of complex number is : (1.0000000000000002+1j)
2

The modulus and argument of polar complex number is : (1.4142135623730951, 0.7853981633974483)
The rectangular form of complex number is : (1.0000000000000002+1j)
3
The modulus and argument of polar complex number is : (1.4142135623730951, 0.7853981633974483)
The rectangular form of complex number is : (1.0000000000000002+1j)
1
The modulus and argument of polar complex number is : (1.4142135623730951, 0.7853981633974483)
The rectangular form of complex number is : (1.0000000000000002+1j)
5

The modulus and argument of polar complex number is : (1.4142135623730951, 0.7853981633974483)
The rectangular form of complex number is : (1.0000000000000002+1j)
6
The modulus and argument of polar complex number is : (1.4142135623730951, 0.7853981633974483)
The rectangular form of complex number is : (1.0000000000000002+1j)
1
The modulus and argument of polar complex number is : (1.4142135623730951, 0.7853981633974483)
The rectangular form of complex number is : (1.0000000000000002+1j)
8
The modulus and argument of polar complex number is : (1.4142135623730951, 0.7853981633974483)
The rectangular form of complex number is : (1.0000000000000002+1j)
9

complex([real[, imag]])
0
complex([real[, imag]])
1
complex([real[, imag]])
2
complex([real[, imag]])
3
The modulus and argument of polar complex number is : (1.4142135623730951, 0.7853981633974483)
The rectangular form of complex number is : (1.0000000000000002+1j)
1
complex([real[, imag]])
5

complex([real[, imag]])
0
complex([real[, imag]])
7

Output:

The phase of complex number is : 3.141592653589793

complex([real[, imag]])
0
complex([real[, imag]])
1
>>> c = 3 +6j
>>> print(type(c))

>>> print(c)
(3+6j)
>>>
>>> c1 = complex(3,6)
>>> print(type(c1))

>>> print(c1)
(3+6j)
0
complex([real[, imag]])
3
The modulus and argument of polar complex number is : (1.4142135623730951, 0.7853981633974483)
The rectangular form of complex number is : (1.0000000000000002+1j)
1
complex([real[, imag]])
5

complex([real[, imag]])
0
>>> c = 3 +6j
>>> print(type(c))

>>> print(c)
(3+6j)
>>>
>>> c1 = complex(3,6)
>>> print(type(c1))

>>> print(c1)
(3+6j)
5 polar(), which returns a pair(r,ph) denoting the modulus r and phase angle ph. modulus can be displayed using abs() and phase using phase().
A complex number converts into rectangular coordinates by using rect(r, ph), where r is modulus and ph is phase angle. It returns a value numerically equal to r * (math.cos(ph) + math.sin(ph)*1j)

The phase of complex number is : 3.141592653589793
8
The phase of complex number is : 3.141592653589793
9

The modulus and argument of polar complex number is : (1.4142135623730951, 0.7853981633974483)
The rectangular form of complex number is : (1.0000000000000002+1j)
0
The modulus and argument of polar complex number is : (1.4142135623730951, 0.7853981633974483)
The rectangular form of complex number is : (1.0000000000000002+1j)
1
The modulus and argument of polar complex number is : (1.4142135623730951, 0.7853981633974483)
The rectangular form of complex number is : (1.0000000000000002+1j)
2

The modulus and argument of polar complex number is : (1.4142135623730951, 0.7853981633974483)
The rectangular form of complex number is : (1.0000000000000002+1j)
3
The modulus and argument of polar complex number is : (1.4142135623730951, 0.7853981633974483)
The rectangular form of complex number is : (1.0000000000000002+1j)
1
The modulus and argument of polar complex number is : (1.4142135623730951, 0.7853981633974483)
The rectangular form of complex number is : (1.0000000000000002+1j)
5

The modulus and argument of polar complex number is : (1.4142135623730951, 0.7853981633974483)
The rectangular form of complex number is : (1.0000000000000002+1j)
6
The modulus and argument of polar complex number is : (1.4142135623730951, 0.7853981633974483)
The rectangular form of complex number is : (1.0000000000000002+1j)
1
The modulus and argument of polar complex number is : (1.4142135623730951, 0.7853981633974483)
The rectangular form of complex number is : (1.0000000000000002+1j)
8
The modulus and argument of polar complex number is : (1.4142135623730951, 0.7853981633974483)
The rectangular form of complex number is : (1.0000000000000002+1j)
9

The modulus and argument of polar complex number is : (1.4142135623730951, 0.7853981633974483)
The rectangular form of complex number is : (1.0000000000000002+1j)
6
The modulus and argument of polar complex number is : (1.4142135623730951, 0.7853981633974483)
The rectangular form of complex number is : (1.0000000000000002+1j)
1
The modulus and argument of polar complex number is : (1.4142135623730951, 0.7853981633974483)
The rectangular form of complex number is : (1.0000000000000002+1j)
8
The modulus and argument of polar complex number is : (1.4142135623730951, 0.7853981633974483)
The rectangular form of complex number is : (1.0000000000000002+1j)
9

complex([real[, imag]])
0
complex([real[, imag]])
1
complex([real[, imag]])
2
complex([real[, imag]])
3
The modulus and argument of polar complex number is : (1.4142135623730951, 0.7853981633974483)
The rectangular form of complex number is : (1.0000000000000002+1j)
1
complex([real[, imag]])
5

complex([real[, imag]])
0
complex([real[, imag]])
7

complex([real[, imag]])
0
complex([real[, imag]])
1
>>> c = 3 +6j
>>> print(type(c))

>>> print(c)
(3+6j)
>>>
>>> c1 = complex(3,6)
>>> print(type(c1))

>>> print(c1)
(3+6j)
0
complex([real[, imag]])
3
The modulus and argument of polar complex number is : (1.4142135623730951, 0.7853981633974483)
The rectangular form of complex number is : (1.0000000000000002+1j)
1
complex([real[, imag]])
5

complex([real[, imag]])
0
>>> c = 3 +6j
>>> print(type(c))

>>> print(c)
(3+6j)
>>>
>>> c1 = complex(3,6)
>>> print(type(c1))

>>> print(c1)
(3+6j)
5

Đầu ra:

complex([real[, imag]])
0
complex([real[, imag]])
1
>>> c = 3 +6j
>>> print(type(c))

>>> print(c)
(3+6j)
>>>
>>> c1 = complex(3,6)
>>> print(type(c1))

>>> print(c1)
(3+6j)
0
complex([real[, imag]])
3
The modulus and argument of polar complex number is : (1.4142135623730951, 0.7853981633974483)
The rectangular form of complex number is : (1.0000000000000002+1j)
1
complex([real[, imag]])
5

Output:

The modulus and argument of polar complex number is : (1.4142135623730951, 0.7853981633974483)
The rectangular form of complex number is : (1.0000000000000002+1j)

complex([real[, imag]])
0
>>> c = 3 +6j
>>> print(type(c))

>>> print(c)
(3+6j)
>>>
>>> c1 = complex(3,6)
>>> print(type(c1))

>>> print(c1)
(3+6j)
5
 

Đầu ra:Manjeet Singh. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to . See your article appearing on the GeeksforGeeks main page and help other Geeks.

Giai đoạn của số phức



Một số phức được tạo từ các số thực. Số phức Python có thể được tạo bằng cách sử dụng câu lệnh gán trực tiếp hoặc bằng cách sử dụng hàm phức tạp ().

Các số phức tạp hầu hết được sử dụng ở nơi chúng tôi đang sử dụng hai số thực. Ví dụ, một mạch điện được xác định bởi điện áp (V) và dòng điện (C) được sử dụng trong hình học, tính toán khoa học và tính toán.

Cú pháp

complex([real[, imag]])

Tạo một số phức tạp đơn giản trong Python

>>> c = 3 +6j
>>> print(type(c))

>>> print(c)
(3+6j)
>>>
>>> c1 = complex(3,6)
>>> print(type(c1))

>>> print(c1)
(3+6j)

Từ kết quả trên, chúng ta có thể thấy các số phức Python có loại phức tạp. Mỗi số phức tạp bao gồm một phần thực và một phần tưởng tượng.

Các số phức tạp Python- Thuộc tính và Chức năng

>>> #Complex Number:
>>> c = (3 + 6j)
>>>
>>> #Real Part of complex number
>>> print('Complex Number: Real Part is = ', c. real)
Complex Number: Real Part is = 3.0
>>>
>>> #Imaginary Part of complex number
>>> print('Complex Number: Imaginary Part is = ', c. imag)
Complex Number: Imaginary Part is = 6.0
>>>
>>> #Conjugate of complex number
>>> print('Complex Number: conjugate Part = ', c. conjugate())
Complex Number: conjugate Part = (3-6j)

Tính toán toán học trên các số phức tạp

Chúng ta có thể thực hiện các tính toán toán học đơn giản trên các số phức:

>>> #first complex number
>>> c1 = 3 + 6j
>>> #Second complex number
>>> c2 = 6 + 15j
>>>
>>> #Addition
>>> print("Addition of two complex number =", c1 + c2)
Addition of two complex number = (9+21j)
>>>
>>> #Subtraction
>>> print("Subtraction of two complex number =", c1 - c2)
Subtraction of two complex number = (-3-9j)
>>>
>>> #Multiplication
>>> print("Multiplication of two complex number =", c1 * c2)
Multiplication of two complex number = (-72+81j)
>>>
>>> #Division
>>> print("Division of two complex number =", c1 / c2)
Division of two complex number = (0.4137931034482759-0.03448275862068964j)

Tuy nhiên, các số phức tạp don lồng hỗ trợ các nhà khai thác so sánh như và nó sẽ thông qua thông báo typeerror:

>>> c2 <= c2
Traceback (most recent call last):
File "", line 1, in 
c2 <= c2
TypeError: '<=' not supported between instances of 'complex' and 'complex'

Mô -đun Python CMATH

Mô -đun Python CMATH cung cấp quyền truy cập vào các hàm toán học cho các số phức. Hãy cùng xem xét một số tính năng quan trọng của các số phức tạp sử dụng hàm mô -đun toán học.

Giai đoạn của số phức

Pha của một số phức là góc giữa trục thực và vectơ đại diện cho phần tưởng tượng.

Pha được trả về bởi các mô -đun toán học và cmath nằm trong radian và chúng tôi sử dụng hàm numpy.degrees () để chuyển đổi nó thành độ.

import cmath, math, numpy
c = 4+ 4j
# phase
phase = cmath.phase(c)
print('4+ 4j Phase =', phase)
print('Phase in Degrees =', numpy.degrees(phase))
print('-4-4j Phase =', cmath.phase(-4-4j), 'radians. Degrees =', numpy.degrees(cmath.phase(-4-4j)))
# we can get phase using math.atan2() function too
print('Complex number phase using math.atan2() =', math.atan2(2, 1))

Kết quả

4+ 4j Phase = 0.7853981633974483
Phase in Degrees = 45.0
-4-4j Phase = -2.356194490192345 radians. Degrees = -135.0
Complex number phase using math.atan2() = 1.1071487177940904

Hằng số mô -đun CMATH

Có một vài constans có sẵn trong mô -đun CMATH được sử dụng trong các tính toán số phức:

The phase of complex number is : 3.141592653589793
0

Kết quả

The phase of complex number is : 3.141592653589793
1

Hằng số mô -đun CMATH

Có một vài constans có sẵn trong mô -đun CMATH được sử dụng trong các tính toán số phức:

The phase of complex number is : 3.141592653589793
2

Kết quả

The phase of complex number is : 3.141592653589793
3

Hằng số mô -đun CMATH

The phase of complex number is : 3.141592653589793
4

Kết quả

The phase of complex number is : 3.141592653589793
5

Hằng số mô -đun CMATH

The phase of complex number is : 3.141592653589793
6

Kết quả

The phase of complex number is : 3.141592653589793
7

Hướng dẫn where is complex number used in python? - Số phức được sử dụng ở đâu trong python?

Hằng số mô -đun CMATH

  • Có một vài constans có sẵn trong mô -đun CMATH được sử dụng trong các tính toán số phức:
  • Chức năng nguồn và nhật ký
  • Mô -đun CMATH () cung cấp một số hàm hữu ích cho các hoạt động logarit và năng lượng:
  • Hàm lượng giác
  • Chức năng hyperbolic
  • Cập nhật vào ngày 30 tháng 3 năm 2019 22:30:26
  • Câu hỏi và câu trả lời liên quan
  • Chương trình Python cho các số phức tạp
  • Làm thế nào để vẽ các số phức tạp trong Python?
  • Số phức trong C#
  • Các số phức trong C ++
  • Những con số phức tạp trong Java
  • Làm thế nào chúng ta có thể sử dụng các số phức tạp trong Python?
  • Các số phức trong lập trình C ++
  • Các hoạt động số phức tạp trong Arduino
  • Làm thế nào để mô đun hoạt động với các số phức tạp trong Python?

Nơi nào chúng ta sử dụng các số phức tạp trong Python?

Các số phức tạp có cách sử dụng của chúng trong nhiều ứng dụng liên quan đến toán học và Python cung cấp các công cụ hữu ích để xử lý và thao túng chúng ...
Chuyển đổi số thực thành số phức ..
Giai đoạn của số phức ..
Chuyển đổi từ dạng cực sang dạng hình chữ nhật và ngược lại ..

Điều gì phức tạp trong Python được sử dụng để làm?

Hàm python Complex () Hàm () Hàm trả về một số phức bằng cách chỉ định một số thực và một số tưởng tượng.returns a complex number by specifying a real number and an imaginary number.

Những con số phức tạp được sử dụng trong cuộc sống thực?

Số lượng phức tạp trong số lượng thực tế Số lượng phức tạp được sử dụng trong điện từ.Số phức được sử dụng để đơn giản hóa các gốc chưa biết nếu rễ không có thật cho các phương trình bậc hai.Số lượng phức tạp được sử dụng trong kỹ thuật khoa học máy tính.Số lượng phức tạp được sử dụng trong kỹ thuật cơ khí và dân dụng.in Electromagnetism. Complex number is used to simplify the unknown roots if roots are not real for quadratic equations. Complex numbers are used in computer science engineering. Complex number is used in mechanical and civil engineering.

Làm thế nào để bạn sử dụng các số tưởng tượng trong Python?

Trong Python, biểu tượng J được sử dụng để biểu thị đơn vị tưởng tượng.Hơn nữa, một hệ số trước khi J là cần thiết.Để chỉ định một số phức, người ta cũng có thể sử dụng phức chất xây dựng.Python cung cấp gói toán tích hợp để xử lý cơ bản các số phức.the symbol j is used to denote the imaginary unit. Furthermore, a coefficient before j is needed. To specify a complex number, one can also use the constructor complex . Python offers the built-in math package for basic processing of complex numbers.